Rev 534 | Rev 990 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 534 | Rev 625 | ||
|---|---|---|---|
| Line 29... | Line 29... | ||
| 29 | #ifndef __ppc32_ATOMIC_H__ |
29 | #ifndef __ppc32_ATOMIC_H__ |
| 30 | #define __ppc32_ATOMIC_H__ |
30 | #define __ppc32_ATOMIC_H__ |
| 31 | 31 | ||
| 32 | #include <arch/types.h> |
32 | #include <arch/types.h> |
| 33 | 33 | ||
| 34 | typedef volatile __u32 atomic_t; |
34 | typedef struct { volatile __u32 count; } atomic_t; |
| 35 | 35 | ||
| 36 | /* |
36 | /* |
| 37 | * TODO: these are just placeholders for real implementations of atomic_inc and atomic_dec. |
37 | * TODO: these are just placeholders for real implementations of atomic_inc and atomic_dec. |
| 38 | * WARNING: the following functions cause the code to be preemption-unsafe !!! |
38 | * WARNING: the following functions cause the code to be preemption-unsafe !!! |
| 39 | */ |
39 | */ |
| 40 | 40 | ||
| 41 | static inline void atomic_inc(atomic_t *val) { |
41 | static inline void atomic_inc(atomic_t *val) { |
| 42 | *val++; |
42 | val->count++; |
| 43 | } |
43 | } |
| 44 | 44 | ||
| 45 | static inline void atomic_dec(atomic_t *val) { |
45 | static inline void atomic_dec(atomic_t *val) { |
| 46 | *val--; |
46 | val->count--; |
| - | 47 | } |
|
| - | 48 | ||
| - | 49 | static inline void atomic_set(atomic_t *val, __u32 i) |
|
| - | 50 | { |
|
| - | 51 | val->count = i; |
|
| - | 52 | } |
|
| - | 53 | ||
| - | 54 | static inline __u32 atomic_get(atomic_t *val) |
|
| - | 55 | { |
|
| - | 56 | return val->count; |
|
| 47 | } |
57 | } |
| 48 | 58 | ||
| 49 | #endif |
59 | #endif |