Rev 2313 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2313 | Rev 2350 | ||
---|---|---|---|
Line 28... | Line 28... | ||
28 | 28 | ||
29 | /** @addtogroup libcarm32 |
29 | /** @addtogroup libcarm32 |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
- | 33 | * @brief Atomic operations. |
|
33 | */ |
34 | */ |
34 | 35 | ||
35 | #ifndef LIBC_arm32_ATOMIC_H_ |
36 | #ifndef LIBC_arm32_ATOMIC_H_ |
36 | #define LIBC_arm32_ATOMIC_H_ |
37 | #define LIBC_arm32_ATOMIC_H_ |
37 | 38 | ||
38 | /** Atomic addition. |
39 | /** Atomic addition. |
39 | * |
40 | * |
40 | * @param val "Atomic variable". |
41 | * @param val Where to add. |
41 | * @param i Value to add. |
42 | * @param i Value to be added. |
42 | * |
43 | * |
43 | * @return Value after addition. |
44 | * @return Value after addition. |
44 | */ |
45 | */ |
45 | static inline long atomic_add(atomic_t *val, int i) |
46 | static inline long atomic_add(atomic_t *val, int i) |
46 | { |
47 | { |
Line 62... | Line 63... | ||
62 | ); |
63 | ); |
63 | 64 | ||
64 | return ret; |
65 | return ret; |
65 | } |
66 | } |
66 | 67 | ||
- | 68 | ||
- | 69 | /** Atomic increment. |
|
- | 70 | * |
|
- | 71 | * @param val Variable to be incremented. |
|
- | 72 | */ |
|
67 | static inline void atomic_inc(atomic_t *val) { atomic_add(val, 1); } |
73 | static inline void atomic_inc(atomic_t *val) { atomic_add(val, 1); } |
- | 74 | ||
- | 75 | /** Atomic decrement. |
|
- | 76 | * |
|
- | 77 | * @param val Variable to be decremented. |
|
- | 78 | */ |
|
68 | static inline void atomic_dec(atomic_t *val) { atomic_add(val, -1); } |
79 | static inline void atomic_dec(atomic_t *val) { atomic_add(val, -1); } |
69 | 80 | ||
- | 81 | /** Atomic pre-increment. |
|
- | 82 | * |
|
- | 83 | * @param val Variable to be incremented. |
|
- | 84 | * @return Value after incrementation. |
|
- | 85 | */ |
|
70 | static inline long atomic_preinc(atomic_t *val) { return atomic_add(val, 1); } |
86 | static inline long atomic_preinc(atomic_t *val) { return atomic_add(val, 1); } |
- | 87 | ||
- | 88 | /** Atomic pre-decrement. |
|
- | 89 | * |
|
- | 90 | * @param val Variable to be decremented. |
|
- | 91 | * @return Value after decrementation. |
|
- | 92 | */ |
|
71 | static inline long atomic_predec(atomic_t *val) { return atomic_add(val, -1); } |
93 | static inline long atomic_predec(atomic_t *val) { return atomic_add(val, -1); } |
72 | 94 | ||
- | 95 | /** Atomic post-increment. |
|
- | 96 | * |
|
- | 97 | * @param val Variable to be incremented. |
|
- | 98 | * @return Value before incrementation. |
|
- | 99 | */ |
|
73 | static inline long atomic_postinc(atomic_t *val) { return atomic_add(val, 1) - 1; } |
100 | static inline long atomic_postinc(atomic_t *val) { return atomic_add(val, 1) - 1; } |
- | 101 | ||
- | 102 | /** Atomic post-decrement. |
|
- | 103 | * |
|
- | 104 | * @param val Variable to be decremented. |
|
- | 105 | * @return Value before decrementation. |
|
- | 106 | */ |
|
74 | static inline long atomic_postdec(atomic_t *val) { return atomic_add(val, -1) + 1; } |
107 | static inline long atomic_postdec(atomic_t *val) { return atomic_add(val, -1) + 1; } |
75 | 108 | ||
- | 109 | ||
76 | #endif |
110 | #endif |
77 | 111 | ||
78 | /** @} |
112 | /** @} |
79 | */ |
113 | */ |