freebsd-dev/atomic.h
David Chisnall 8e59c7f592 Import b9db3a010143160624f123763025ab544b69bd9a of libcxxrt. This brings in
three fixes:

- Don't treat pointers to members as pointers in catch blocks (they're usually
  fat pointers).

- Correctly catch foreign exceptions in catchalls.

- Ensure that a happens-before relationship is established when setting
  terminate handlers in one thread and calling them in another.
2013-01-11 15:00:43 +00:00

30 lines
665 B
C

#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
#ifndef __has_feature
#define __has_feature(x) 0
#endif
/**
* Swap macro that enforces a happens-before relationship with a corresponding
* ATOMIC_LOAD.
*/
#if __has_feature(cxx_atomic)
#define ATOMIC_SWAP(addr, val)\
__atomic_exchange(addr, val, __ATOMIC_ACQ_REL)
#elif __has_builtin(__sync_swap)
#define ATOMIC_SWAP(addr, val)\
__sync_swap(addr, val)
#else
#define ATOMIC_SWAP(addr, val)\
__sync_lock_test_and_set(addr, val)
#endif
#if __has_feature(cxx_atomic)
#define ATOMIC_LOAD(addr)\
__atomic_load(addr, __ATOMIC_ACQUIRE)
#else
#define ATOMIC_LOAD(addr)\
(__sync_synchronize(), *addr)
#endif