diff --git a/linux/linux.c b/linux/linux.c index 736fd7f7d7f..9d622a800c0 100644 --- a/linux/linux.c +++ b/linux/linux.c @@ -281,3 +281,14 @@ toku_os_get_processor_frequency(uint64_t *hzret) { r = toku_get_processor_frequency_cpuinfo(hzret); return r; } + +#if __GNUC__ && __i386__ + +// workaround for a gcc 4.1.2 bug on 32 bit platforms. +uint64_t toku_sync_fetch_and_add_uint64(volatile uint64_t *a, uint64_t b) __attribute__((noinline)); + +uint64_t toku_sync_fetch_and_add_uint64(volatile uint64_t *a, uint64_t b) { + return __sync_fetch_and_add(a, b); +} + +#endif diff --git a/toku_include/toku_atomic.h b/toku_include/toku_atomic.h index 52ec3acaf2e..3acbdfb04a7 100644 --- a/toku_include/toku_atomic.h +++ b/toku_include/toku_atomic.h @@ -41,24 +41,26 @@ toku_sync_fetch_and_add_uint64(volatile ULONGLONG *a, uint64_t b) { #endif #else -//Linux -#define TOKU_INLINE32 inline -static TOKU_INLINE32 int32_t toku_sync_fetch_and_add_int32(volatile int32_t *a, int32_t b) { +//Linux + +static inline int32_t toku_sync_fetch_and_add_int32(volatile int32_t *a, int32_t b) { return __sync_fetch_and_add(a, b); } #if __GNUC__ && __i386__ -#define TOKU_INLINE64 -// workaround for a gcc 4.1.2 bug on 32 bit platforms. -static uint64_t toku_sync_fetch_and_add_uint64(volatile uint64_t *a, uint64_t b) __attribute__((noinline)); -#else -#define TOKU_INLINE64 inline -#endif -static TOKU_INLINE64 uint64_t toku_sync_fetch_and_add_uint64(volatile uint64_t *a, uint64_t b) { +// workaround for a gcc 4.1.2 bug on 32 bit platforms. +uint64_t toku_sync_fetch_and_add_uint64(volatile uint64_t *a, uint64_t b) __attribute__((noinline)); + +#else + +static inline uint64_t toku_sync_fetch_and_add_uint64(volatile uint64_t *a, uint64_t b) { return __sync_fetch_and_add(a, b); } + +#endif + #endif #endif