Rev 1024 | Rev 1107 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1024 | Rev 1104 | ||
---|---|---|---|
Line 28... | Line 28... | ||
28 | 28 | ||
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 | - | ||
34 | typedef struct { volatile __u32 count; } atomic_t; |
33 | #include <typedefs.h> |
35 | 34 | ||
36 | static inline void atomic_inc(atomic_t *val) |
35 | static inline void atomic_inc(atomic_t *val) |
37 | { |
36 | { |
38 | __u32 tmp; |
37 | __u32 tmp; |
39 | 38 | ||
Line 61... | Line 60... | ||
61 | : "=&r" (tmp), "=m" (val->count) |
60 | : "=&r" (tmp), "=m" (val->count) |
62 | : "r" (&val->count), "m" (val->count) |
61 | : "r" (&val->count), "m" (val->count) |
63 | : "cc"); |
62 | : "cc"); |
64 | } |
63 | } |
65 | 64 | ||
66 | static inline __u32 atomic_postinc(atomic_t *val) |
65 | static inline long atomic_postinc(atomic_t *val) |
67 | { |
66 | { |
68 | atomic_inc(val); |
67 | atomic_inc(val); |
69 | return val->count - 1; |
68 | return val->count - 1; |
70 | } |
69 | } |
71 | 70 | ||
72 | static inline __u32 atomic_postdec(atomic_t *val) |
71 | static inline long atomic_postdec(atomic_t *val) |
73 | { |
72 | { |
74 | atomic_dec(val); |
73 | atomic_dec(val); |
75 | return val->count + 1; |
74 | return val->count + 1; |
76 | } |
75 | } |
77 | 76 | ||
78 | static inline __u32 atomic_preinc(atomic_t *val) |
77 | static inline long atomic_preinc(atomic_t *val) |
79 | { |
78 | { |
80 | atomic_inc(val); |
79 | atomic_inc(val); |
81 | return val->count; |
80 | return val->count; |
82 | } |
81 | } |
83 | 82 | ||
84 | static inline __u32 atomic_predec(atomic_t *val) |
83 | static inline long atomic_predec(atomic_t *val) |
85 | { |
84 | { |
86 | atomic_dec(val); |
85 | atomic_dec(val); |
87 | return val->count; |
86 | return val->count; |
88 | } |
87 | } |
89 | 88 | ||
90 | static inline void atomic_set(atomic_t *val, __u32 i) |
- | |
91 | { |
- | |
92 | val->count = i; |
- | |
93 | } |
- | |
94 | - | ||
95 | static inline __u32 atomic_get(atomic_t *val) |
- | |
96 | { |
- | |
97 | return val->count; |
- | |
98 | } |
- | |
99 | - | ||
100 | #endif |
89 | #endif |