2 * use wrappers around libatomic-ops for folks that don't have GCC
3 * or a new enough version of GCC
5 #ifndef HAVE_GCC_ATOMIC_BUILTINS
6 #include <atomic_ops.h>
8 static inline unsigned long
9 __sync_add_and_fetch(unsigned long *dst
, unsigned long incr
)
11 AO_t tmp
= AO_fetch_and_add((AO_t
*)dst
, (AO_t
)incr
);
13 return (unsigned long)tmp
+ incr
;
16 static inline unsigned long
17 __sync_sub_and_fetch(unsigned long *dst
, unsigned long incr
)
19 AO_t tmp
= AO_fetch_and_add((AO_t
*)dst
, (AO_t
)(-(long)incr
));
21 return (unsigned long)tmp
- incr
;
23 #endif /* HAVE_GCC_ATOMIC_BUILTINS */