Rev 2195 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2195 | Rev 2313 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup arm32 |
29 | /** @addtogroup libcarm32 |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | /** @file |
32 | /** @file |
33 | */ |
33 | */ |
34 | 34 | ||
35 | #ifndef KERN_arm32_ATOMIC_H_ |
35 | #ifndef KERN_arm32_ATOMIC_H_ |
36 | #define KERN_arm32_ATOMIC_H_ |
36 | #define KERN_arm32_ATOMIC_H_ |
37 | 37 | ||
38 | #define atomic_inc(x) ((void) atomic_add(x, 1)) |
- | |
39 | #define atomic_dec(x) ((void) atomic_add(x, -1)) |
- | |
40 | - | ||
41 | #define atomic_postinc(x) (atomic_add(x, 1) - 1) |
- | |
42 | #define atomic_postdec(x) (atomic_add(x, -1) + 1) |
- | |
43 | - | ||
44 | #define atomic_preinc(x) atomic_add(x, 1) |
- | |
45 | #define atomic_predec(x) atomic_add(x, -1) |
- | |
46 | - | ||
47 | /* Atomic addition of immediate value. |
38 | /** Atomic addition. |
48 | * |
39 | * |
49 | * @param val Memory location to which will be the immediate value added. |
40 | * @param val "Atomic variable". |
50 | * @param i Signed immediate that will be added to *val. |
41 | * @param i Value to add. |
51 | * |
42 | * |
52 | * @return Value after addition. |
43 | * @return Value after addition. |
53 | */ |
44 | */ |
54 | static inline long atomic_add(atomic_t *val, int i) |
45 | static inline long atomic_add(atomic_t *val, int i) |
55 | { |
46 | { |
Line 69... | Line 60... | ||
69 | : "r" (mem), "r" (i) |
60 | : "r" (mem), "r" (i) |
70 | : "r3", "r2" |
61 | : "r3", "r2" |
71 | ); |
62 | ); |
72 | 63 | ||
73 | return ret; |
64 | return ret; |
74 | } |
65 | } |
- | 66 | ||
- | 67 | static inline void atomic_inc(atomic_t *val) { atomic_add(val, 1); } |
|
- | 68 | static inline void atomic_dec(atomic_t *val) { atomic_add(val, -1); } |
|
- | 69 | ||
- | 70 | static inline long atomic_preinc(atomic_t *val) { return atomic_add(val, 1); } |
|
- | 71 | static inline long atomic_predec(atomic_t *val) { return atomic_add(val, -1); } |
|
- | 72 | ||
- | 73 | static inline long atomic_postinc(atomic_t *val) { return atomic_add(val, 1) - 1; } |
|
- | 74 | static inline long atomic_postdec(atomic_t *val) { return atomic_add(val, -1) + 1; } |
|
75 | 75 | ||
76 | #endif |
76 | #endif |
77 | 77 | ||
78 | /** @} |
78 | /** @} |
79 | */ |
79 | */ |