BSON-XS

 view release on metacpan or  search on metacpan

bson/bson-atomic.h  view on Meta::CPAN

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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.254 second using v1.01-cache-2.11-cpan-94b05bcf43c )