Detect if 8-bit atomics are available.
In some rare cases (older compiler, e.g. gcc 4.2 w/ MIPS), 8-bit atomics might be unavailable. Detect such cases so that we can workaround.
This commit is contained in:
parent
14d3686c9f
commit
06f0850427
25
configure.ac
25
configure.ac
@ -1896,6 +1896,19 @@ JE_COMPILABLE([GCC __atomic atomics], [
|
|||||||
], [je_cv_gcc_atomic_atomics])
|
], [je_cv_gcc_atomic_atomics])
|
||||||
if test "x${je_cv_gcc_atomic_atomics}" = "xyes" ; then
|
if test "x${je_cv_gcc_atomic_atomics}" = "xyes" ; then
|
||||||
AC_DEFINE([JEMALLOC_GCC_ATOMIC_ATOMICS])
|
AC_DEFINE([JEMALLOC_GCC_ATOMIC_ATOMICS])
|
||||||
|
|
||||||
|
dnl check for 8-bit atomic support
|
||||||
|
JE_COMPILABLE([GCC 8-bit __atomic atomics], [
|
||||||
|
], [
|
||||||
|
unsigned char x = 0;
|
||||||
|
int val = 1;
|
||||||
|
int y = __atomic_fetch_add(&x, val, __ATOMIC_RELAXED);
|
||||||
|
int after_add = (int)x;
|
||||||
|
return after_add == 1;
|
||||||
|
], [je_cv_gcc_u8_atomic_atomics])
|
||||||
|
if test "x${je_cv_gcc_u8_atomic_atomics}" = "xyes" ; then
|
||||||
|
AC_DEFINE([JEMALLOC_GCC_U8_ATOMIC_ATOMICS])
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dnl ============================================================================
|
dnl ============================================================================
|
||||||
@ -1910,6 +1923,18 @@ JE_COMPILABLE([GCC __sync atomics], [
|
|||||||
], [je_cv_gcc_sync_atomics])
|
], [je_cv_gcc_sync_atomics])
|
||||||
if test "x${je_cv_gcc_sync_atomics}" = "xyes" ; then
|
if test "x${je_cv_gcc_sync_atomics}" = "xyes" ; then
|
||||||
AC_DEFINE([JEMALLOC_GCC_SYNC_ATOMICS])
|
AC_DEFINE([JEMALLOC_GCC_SYNC_ATOMICS])
|
||||||
|
|
||||||
|
dnl check for 8-bit atomic support
|
||||||
|
JE_COMPILABLE([GCC 8-bit __sync atomics], [
|
||||||
|
], [
|
||||||
|
unsigned char x = 0;
|
||||||
|
int before_add = __sync_fetch_and_add(&x, 1);
|
||||||
|
int after_add = (int)x;
|
||||||
|
return (before_add == 0) && (after_add == 1);
|
||||||
|
], [je_cv_gcc_u8_sync_atomics])
|
||||||
|
if test "x${je_cv_gcc_u8_sync_atomics}" = "xyes" ; then
|
||||||
|
AC_DEFINE([JEMALLOC_GCC_U8_SYNC_ATOMICS])
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dnl ============================================================================
|
dnl ============================================================================
|
||||||
|
@ -3,10 +3,17 @@
|
|||||||
|
|
||||||
#define ATOMIC_INLINE JEMALLOC_ALWAYS_INLINE
|
#define ATOMIC_INLINE JEMALLOC_ALWAYS_INLINE
|
||||||
|
|
||||||
|
#define JEMALLOC_U8_ATOMICS
|
||||||
#if defined(JEMALLOC_GCC_ATOMIC_ATOMICS)
|
#if defined(JEMALLOC_GCC_ATOMIC_ATOMICS)
|
||||||
# include "jemalloc/internal/atomic_gcc_atomic.h"
|
# include "jemalloc/internal/atomic_gcc_atomic.h"
|
||||||
|
# if !defined(JEMALLOC_GCC_U8_ATOMIC_ATOMICS)
|
||||||
|
# undef JEMALLOC_U8_ATOMICS
|
||||||
|
# endif
|
||||||
#elif defined(JEMALLOC_GCC_SYNC_ATOMICS)
|
#elif defined(JEMALLOC_GCC_SYNC_ATOMICS)
|
||||||
# include "jemalloc/internal/atomic_gcc_sync.h"
|
# include "jemalloc/internal/atomic_gcc_sync.h"
|
||||||
|
# if !defined(JEMALLOC_GCC_U8_SYNC_ATOMICS)
|
||||||
|
# undef JEMALLOC_U8_ATOMICS
|
||||||
|
# endif
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
# include "jemalloc/internal/atomic_msvc.h"
|
# include "jemalloc/internal/atomic_msvc.h"
|
||||||
#elif defined(JEMALLOC_C11_ATOMICS)
|
#elif defined(JEMALLOC_C11_ATOMICS)
|
||||||
|
@ -48,9 +48,16 @@
|
|||||||
|
|
||||||
/* Defined if GCC __atomic atomics are available. */
|
/* Defined if GCC __atomic atomics are available. */
|
||||||
#undef JEMALLOC_GCC_ATOMIC_ATOMICS
|
#undef JEMALLOC_GCC_ATOMIC_ATOMICS
|
||||||
|
/* and the 8-bit variant support. */
|
||||||
|
#undef JEMALLOC_GCC_U8_ATOMIC_ATOMICS
|
||||||
|
|
||||||
/* Defined if GCC __sync atomics are available. */
|
/* Defined if GCC __sync atomics are available. */
|
||||||
#undef JEMALLOC_GCC_SYNC_ATOMICS
|
#undef JEMALLOC_GCC_SYNC_ATOMICS
|
||||||
|
/* and the 8-bit variant support. */
|
||||||
|
#undef JEMALLOC_GCC_U8_SYNC_ATOMICS
|
||||||
|
|
||||||
|
/* Defined if 8-bit atomics are supported. */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Defined if __builtin_clz() and __builtin_clzl() are available.
|
* Defined if __builtin_clz() and __builtin_clzl() are available.
|
||||||
|
Loading…
Reference in New Issue
Block a user