tests api: remove atomics
[urcu.git] / tests / api_gcc.h
index 2db1ef2d2c1c4c6de330d3820e3ca31b9223ca56..93b72442cab1f37dd7f7dd4b69560ed2e86a77ed 100644 (file)
 
 /* #define CAA_CACHE_LINE_SIZE 64 */
 #define ____cacheline_internodealigned_in_smp \
-       __attribute__((__aligned__(1 << 6)))
-
-#define LOCK_PREFIX "lock ; "
-
-#if 0 /* duplicate with arch_atomic.h */
-/*
- * Atomic data structure, initialization, and access.
- */
-
-typedef struct { volatile int counter; } atomic_t;
-
-#define ATOMIC_INIT(i)  { (i) }
-
-#define atomic_read(v)         ((v)->counter)
-#define atomic_set(v, i)       (((v)->counter) = (i))
-
-/*
- * Atomic operations.
- */
-
-/**
- * atomic_add - add integer to atomic variable
- * @i: integer value to add
- * @v: pointer of type atomic_t
- * 
- * Atomically adds @i to @v.
- */
-
-static __inline__ void atomic_add(int i, atomic_t *v)
-{
-       (void)__sync_fetch_and_add(&v->counter, i);
-}
-
-/**
- * atomic_sub - subtract the atomic variable
- * @i: integer value to subtract
- * @v: pointer of type atomic_t
- * 
- * Atomically subtracts @i from @v.
- */
-static __inline__ void atomic_sub(int i, atomic_t *v)
-{
-       (void)__sync_fetch_and_add(&v->counter, -i);
-}
-
-/**
- * atomic_sub_and_test - subtract value from variable and test result
- * @i: integer value to subtract
- * @v: pointer of type atomic_t
- * 
- * Atomically subtracts @i from @v and returns
- * true if the result is zero, or false for all
- * other cases.
- */
-static __inline__ int atomic_sub_and_test(int i, atomic_t *v)
-{
-       return __sync_add_and_fetch(&v->counter, -i) == 0;
-}
-
-/**
- * atomic_inc - increment atomic variable
- * @v: pointer of type atomic_t
- * 
- * Atomically increments @v by 1.
- */ 
-static __inline__ void atomic_inc(atomic_t *v)
-{
-       (void)__sync_fetch_and_add(&v->counter, 1);
-}
-
-/**
- * atomic_dec - decrement atomic variable
- * @v: pointer of type atomic_t
- * 
- * Atomically decrements @v by 1.
- */ 
-static __inline__ void atomic_dec(atomic_t *v)
-{
-       (void)__sync_fetch_and_add(&v->counter, -1);
-}
-
-/**
- * atomic_dec_and_test - decrement and test
- * @v: pointer of type atomic_t
- * 
- * Atomically decrements @v by 1 and
- * returns true if the result is 0, or false for all other
- * cases.
- */ 
-static __inline__ int atomic_dec_and_test(atomic_t *v)
-{
-       return __sync_add_and_fetch(&v->counter, -1) == 0;
-}
-
-/**
- * atomic_inc_and_test - increment and test 
- * @v: pointer of type atomic_t
- * 
- * Atomically increments @v by 1
- * and returns true if the result is zero, or false for all
- * other cases.
- */ 
-static __inline__ int atomic_inc_and_test(atomic_t *v)
-{
-       return __sync_add_and_fetch(&v->counter, 1) == 0;
-}
-
-/**
- * atomic_add_negative - add and test if negative
- * @v: pointer of type atomic_t
- * @i: integer value to add
- * 
- * Atomically adds @i to @v and returns true
- * if the result is negative, or false when
- * result is greater than or equal to zero.
- */ 
-static __inline__ int atomic_add_negative(int i, atomic_t *v)
-{
-       return __sync_add_and_fetch(&v->counter, i) < 0;
-}
-
-/**
- * atomic_add_return - add and return
- * @v: pointer of type atomic_t
- * @i: integer value to add
- *
- * Atomically adds @i to @v and returns @i + @v
- */
-static __inline__ int atomic_add_return(int i, atomic_t *v)
-{
-       return __sync_add_and_fetch(&v->counter, i);
-}
-
-static __inline__ int atomic_sub_return(int i, atomic_t *v)
-{
-       return atomic_add_return(-i,v);
-}
-
-static inline unsigned int
-cmpxchg(volatile long *ptr, long oldval, long newval)
-{
-       return __sync_val_compare_and_swap(ptr, oldval, newval);
-}
-
-#define atomic_cmpxchg(v, old, new) ((int)cmpxchg(&((v)->counter), old, new))
-#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
-
-/**
- * atomic_add_unless - add unless the number is a given value
- * @v: pointer of type atomic_t
- * @a: the amount to add to v...
- * @u: ...unless v is equal to u.
- *
- * Atomically adds @a to @v, so long as it was not @u.
- * Returns non-zero if @v was not @u, and zero otherwise.
- */
-#define atomic_add_unless(v, a, u)                             \
-({                                                             \
-       int c, old;                                             \
-       c = atomic_read(v);                                     \
-       for (;;) {                                              \
-               if (unlikely(c == (u)))                         \
-                       break;                                  \
-               old = atomic_cmpxchg((v), c, c + (a));          \
-               if (likely(old == c))                           \
-                       break;                                  \
-               c = old;                                        \
-       }                                                       \
-       c != (u);                                               \
-})
-#define atomic_inc_not_zero(v) atomic_add_unless((v), 1, 0)
-
-#define atomic_inc_return(v)  (atomic_add_return(1,v))
-#define atomic_dec_return(v)  (atomic_sub_return(1,v))
-
-/* Atomic operations are already serializing on x86 */
-#define smp_mb__before_atomic_dec()    cmm_barrier()
-#define smp_mb__after_atomic_dec()     cmm_barrier()
-#define smp_mb__before_atomic_inc()    cmm_barrier()
-#define smp_mb__after_atomic_inc()     cmm_barrier()
-
-#endif //0 /* duplicate with arch_atomic.h */
+       __attribute__((__aligned__(CAA_CACHE_LINE_SIZE)))
 
 /*
  * api_pthreads.h: API mapping to pthreads environment.
This page took 0.024873 seconds and 4 git commands to generate.