Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions dist/aclocal/mutex.m4
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,8 @@ AH_TEMPLATE(HAVE_ATOMIC_SOLARIS,
[Define to 1 to use Solaris library routes for atomic operations.])
AH_TEMPLATE(HAVE_ATOMIC_BUILTINS,
[Define to 1 to use GCC __atomic_* builtins for atomic operations.])
AH_TEMPLATE(HAVE_ATOMIC_GCC_BUILTIN,
[Define to 1 when the GCC/Clang __atomic_* builtin tier is selected.])
AH_TEMPLATE(HAVE_SYNC_BUILTINS,
[Define to 1 to use GCC __sync_* builtins for atomic operations.])
AH_TEMPLATE(HAVE_ATOMIC_AARCH64,
Expand All @@ -1029,12 +1031,25 @@ if test "$db_cv_mingw" = yes; then
db_cv_atomic=mingw
fi

if test "$db_cv_atomic" = no; then
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdint.h>]], [[
uint32_t val32 = 1;
uint32_t exp32 = 1;
intptr_t valp = 1;
intptr_t expp = 1;
__atomic_add_fetch(&val32, 1, __ATOMIC_SEQ_CST);
__atomic_compare_exchange_n(&val32, &exp32, 2, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
__atomic_compare_exchange_n(&valp, &expp, 2, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
]])], [db_cv_atomic="gcc/__atomic"])
fi

if test "$db_cv_atomic" = no; then
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[
#if ((defined(i386) || defined(__i386__)) && defined(__GNUC__))
exit(0);
(void)0;
#elif ((defined(x86_64) || defined(__x86_64__)) && defined(__GNUC__))
exit(0);
(void)0;
#else
FAIL TO COMPILE/LINK
#endif
Expand All @@ -1053,6 +1068,12 @@ fi
])

case "$db_cv_atomic" in
gcc/__atomic)
AC_DEFINE(HAVE_ATOMIC_SUPPORT)
AC_DEFINE(HAVE_ATOMIC_BUILTINS)
AC_DEFINE(HAVE_ATOMIC_GCC_BUILTIN)
;;

x86/gcc-assembly)
AC_DEFINE(HAVE_ATOMIC_SUPPORT)
AC_DEFINE(HAVE_ATOMIC_X86_GCC_ASSEMBLY)
Expand Down Expand Up @@ -1085,6 +1106,16 @@ fi
AC_CACHE_CHECK([for 64-bit atomic operations], db_cv_atomic_64bit, [
db_cv_atomic_64bit=no
case "$db_cv_atomic" in
gcc/__atomic)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdint.h>]], [[
int64_t val = 1;
int64_t exp = 1;
__atomic_add_fetch(&val, 1, __ATOMIC_SEQ_CST);
__atomic_sub_fetch(&val, 1, __ATOMIC_SEQ_CST);
__atomic_compare_exchange_n(&val, &exp, 2, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
]])], [db_cv_atomic_64bit=yes])
;;
x86/gcc-assembly)
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdint.h>]], [[
Expand Down
3 changes: 3 additions & 0 deletions dist/config.hin
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
/* Define to 1 to use GCC __atomic_* builtins for atomic operations. */
#undef HAVE_ATOMIC_BUILTINS

/* Define to 1 when the GCC/Clang __atomic_* builtin tier is selected. */
#undef HAVE_ATOMIC_GCC_BUILTIN

/* Define to 1 to use Solaris library routes for atomic operations. */
#undef HAVE_ATOMIC_SOLARIS

Expand Down
69 changes: 67 additions & 2 deletions dist/configure
Original file line number Diff line number Diff line change
Expand Up @@ -25809,6 +25809,7 @@ esac




{ printf '%s\n' "$as_me:${as_lineno-$LINENO}: checking for atomic operations" >&5
printf %s "checking for atomic operations... " >&6; }
if test ${db_cv_atomic+y}
Expand All @@ -25827,6 +25828,35 @@ if test "$db_cv_mingw" = yes; then
db_cv_atomic=mingw
fi

if test "$db_cv_atomic" = no; then
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

#include <stdint.h>
int
main (void)
{

uint32_t val32 = 1;
uint32_t exp32 = 1;
intptr_t valp = 1;
intptr_t expp = 1;
__atomic_add_fetch(&val32, 1, __ATOMIC_SEQ_CST);
__atomic_compare_exchange_n(&val32, &exp32, 2, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
__atomic_compare_exchange_n(&valp, &expp, 2, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);

;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
db_cv_atomic="gcc/__atomic"
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
fi

if test "$db_cv_atomic" = no; then
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand All @@ -25836,9 +25866,9 @@ main (void)
{

#if ((defined(i386) || defined(__i386__)) && defined(__GNUC__))
exit(0);
(void)0;
#elif ((defined(x86_64) || defined(__x86_64__)) && defined(__GNUC__))
exit(0);
(void)0;
#else
FAIL TO COMPILE/LINK
#endif
Expand Down Expand Up @@ -25886,6 +25916,15 @@ fi
printf '%s\n' "$db_cv_atomic" >&6; }

case "$db_cv_atomic" in
gcc/__atomic)
printf '%s\n' "#define HAVE_ATOMIC_SUPPORT 1" >>confdefs.h

printf '%s\n' "#define HAVE_ATOMIC_BUILTINS 1" >>confdefs.h

printf '%s\n' "#define HAVE_ATOMIC_GCC_BUILTIN 1" >>confdefs.h

;;

x86/gcc-assembly)
printf '%s\n' "#define HAVE_ATOMIC_SUPPORT 1" >>confdefs.h

Expand Down Expand Up @@ -25958,6 +25997,32 @@ else case e in #(
e)
db_cv_atomic_64bit=no
case "$db_cv_atomic" in
gcc/__atomic)
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

#include <stdint.h>
int
main (void)
{

int64_t val = 1;
int64_t exp = 1;
__atomic_add_fetch(&val, 1, __ATOMIC_SEQ_CST);
__atomic_sub_fetch(&val, 1, __ATOMIC_SEQ_CST);
__atomic_compare_exchange_n(&val, &exp, 2, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);

;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
db_cv_atomic_64bit=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam \
conftest$ac_exeext conftest.$ac_ext
;;
x86/gcc-assembly)
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
Expand Down
Loading