1 #ifndef _ASM_GENERIC_ATOMIC_H
2 #define _ASM_GENERIC_ATOMIC_H
4 * Copyright (C) 2005 Silicon Graphics, Inc.
5 * Christoph Lameter <clameter@sgi.com>
7 * Allows to provide arch independent atomic definitions without the need to
8 * edit all arch specific atomic.h files.
11 #include <asm/types.h>
14 * Suppport for atomic_long_t
16 * Casts for parameters are avoided for existing atomic functions in order to
17 * avoid issues with cast-as-lval under gcc 4.x and other limitations that the
18 * macros of a platform may have.
21 #if BITS_PER_LONG == 64
23 typedef atomic64_t atomic_long_t;
25 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
27 static inline long atomic_long_read(atomic_long_t *l)
29 atomic64_t *v = (atomic64_t *)l;
31 return (long)atomic64_read(v);
34 static inline void atomic_long_set(atomic_long_t *l, long i)
36 atomic64_t *v = (atomic64_t *)l;
41 static inline void atomic_long_inc(atomic_long_t *l)
43 atomic64_t *v = (atomic64_t *)l;
48 static inline void atomic_long_dec(atomic_long_t *l)
50 atomic64_t *v = (atomic64_t *)l;
55 static inline void atomic_long_add(long i, atomic_long_t *l)
57 atomic64_t *v = (atomic64_t *)l;
62 static inline void atomic_long_sub(long i, atomic_long_t *l)
64 atomic64_t *v = (atomic64_t *)l;
69 #else /* BITS_PER_LONG == 64 */
71 typedef atomic_t atomic_long_t;
73 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
74 static inline long atomic_long_read(atomic_long_t *l)
76 atomic_t *v = (atomic_t *)l;
78 return (long)atomic_read(v);
81 static inline void atomic_long_set(atomic_long_t *l, long i)
83 atomic_t *v = (atomic_t *)l;
88 static inline void atomic_long_inc(atomic_long_t *l)
90 atomic_t *v = (atomic_t *)l;
95 static inline void atomic_long_dec(atomic_long_t *l)
97 atomic_t *v = (atomic_t *)l;
102 static inline void atomic_long_add(long i, atomic_long_t *l)
104 atomic_t *v = (atomic_t *)l;
109 static inline void atomic_long_sub(long i, atomic_long_t *l)
111 atomic_t *v = (atomic_t *)l;
116 #endif /* BITS_PER_LONG == 64 */
118 #endif /* _ASM_GENERIC_ATOMIC_H */