#if defined(__has_builtin)
#if __has_builtin(__sync_synchronize)
#define HAS_SYNC_SYNCHRONIZE 1
#endif
#endif

#if ! defined(HAS_SYNC_SYNCHRONIZE)
#if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1))
#define HAS_SYNC_SYNCHRONIZE 1
#endif
#endif

#if defined(HAS_SYNC_SYNCHRONIZE)
#define D_MEM_BARRIER __sync_synchronize()
#else
#define D_MEM_BARRIER __asm__ __volatile__("" ::: "memory");
#endif
