если под mingw сабж
ошибки вот такие , если использовать из класического mingw
(.text+0x104): undefined reference to `__sync_add_and_fetch_4'
#if defined (__GNUC__)
#define atomic_cas_uint32(p, o, n) __sync_val_compare_and_swap((uint32_t*)(p), (uint32_t)(o), (uint32_t)(n))
#define atomic_store_uint32(p, v) __sync_val_compare_and_swap((uint32_t*)(p), (uint32_t)(*p), (uint32_t)(v))
#define atomic_inc_uint32(p) __sync_add_and_fetch((uint32_t*)(p), 1)
#define atomic_dec_uint32(p) __sync_sub_and_fetch((uint32_t*)(p), 1)
#define atomic_inc_uint64(p) __sync_add_and_fetch((uint64_t*)(p), 1)
#define atomic_dec_uint64(p) __sync_sub_and_fetch((uint64_t*)(p), 1)
#endif // defined (__GNUC__)