BSON-XS
view release on metacpan or search on metacpan
bson/bson-atomic.h view on Meta::CPAN
BSON_BEGIN_DECLS
#if defined(__sun) && defined(__SVR4)
/* Solaris */
# include <atomic.h>
# define bson_atomic_int_add(p,v) atomic_add_32_nv((volatile uint32_t *)p, (v))
# define bson_atomic_int64_add(p,v) atomic_add_64_nv((volatile uint64_t *)p, (v))
#elif defined(_WIN32)
/* MSVC/MinGW */
# define bson_atomic_int_add(p, v) (InterlockedExchangeAdd((volatile LONG *)(p), (LONG)(v)) + (LONG)(v))
# define bson_atomic_int64_add(p, v) (InterlockedExchangeAdd64((volatile LONGLONG *)(p), (LONGLONG)(v)) + (LONGLONG)(v))
#else
# ifdef BSON_HAVE_ATOMIC_32_ADD_AND_FETCH
# define bson_atomic_int_add(p,v) __sync_add_and_fetch((p), (v))
# else
# define __BSON_NEED_ATOMIC_32
# endif
# ifdef BSON_HAVE_ATOMIC_64_ADD_AND_FETCH
# if BSON_GNUC_IS_VERSION(4, 1)
/*
* GCC 4.1 on i386 can generate buggy 64-bit atomic increment.
( run in 0.256 second using v1.01-cache-2.11-cpan-a5abf4f5562 )