diff options
author | Corey Farrell <git@cfware.com> | 2018-01-22 14:50:37 -0500 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2018-01-29 14:17:58 -0500 |
commit | dc3b313e91b573f393d8717c1c9e8c11a51f7ab1 (patch) | |
tree | c7fd3b20f2edc53df1a3e94a03785cf6d1823ae8 /configure.ac | |
parent | 9e5af7c3b77f81a7d1720073dca600e51fe9962d (diff) | |
download | jansson-dc3b313e91b573f393d8717c1c9e8c11a51f7ab1.zip jansson-dc3b313e91b573f393d8717c1c9e8c11a51f7ab1.tar.gz jansson-dc3b313e91b573f393d8717c1c9e8c11a51f7ab1.tar.bz2 |
Use thread-safe reference counting if supported by the compiler.
This makes use of __atomic or __sync builtin compiler functions to make
json_decref and json_incref thread-safe.
Issue #387
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index d1c4faf..fa0f005 100644 --- a/configure.ac +++ b/configure.ac @@ -38,25 +38,33 @@ AC_CHECK_FUNCS([close getpid gettimeofday localeconv open read sched_yield strto AC_MSG_CHECKING([for gcc __sync builtins]) have_sync_builtins=no AC_TRY_LINK( - [], [unsigned long val; __sync_bool_compare_and_swap(&val, 0, 1);], + [], [unsigned long val; __sync_bool_compare_and_swap(&val, 0, 1); __sync_add_and_fetch(&val, 1); __sync_sub_and_fetch(&val, 1);], [have_sync_builtins=yes], ) if test "x$have_sync_builtins" = "xyes"; then AC_DEFINE([HAVE_SYNC_BUILTINS], [1], [Define to 1 if gcc's __sync builtins are available]) + json_have_sync_builtins=1 +else + json_have_sync_builtins=0 fi +AC_SUBST([json_have_sync_builtins]) AC_MSG_RESULT([$have_sync_builtins]) AC_MSG_CHECKING([for gcc __atomic builtins]) have_atomic_builtins=no AC_TRY_LINK( - [], [char l; unsigned long v; __atomic_test_and_set(&l, __ATOMIC_RELAXED); __atomic_store_n(&v, 1, __ATOMIC_RELEASE); __atomic_load_n(&v, __ATOMIC_ACQUIRE);], + [], [char l; unsigned long v; __atomic_test_and_set(&l, __ATOMIC_RELAXED); __atomic_store_n(&v, 1, __ATOMIC_RELEASE); __atomic_load_n(&v, __ATOMIC_ACQUIRE); __atomic_add_fetch(&v, 1, __ATOMIC_ACQUIRE); __atomic_sub_fetch(&v, 1, __ATOMIC_RELEASE);], [have_atomic_builtins=yes], ) if test "x$have_atomic_builtins" = "xyes"; then AC_DEFINE([HAVE_ATOMIC_BUILTINS], [1], [Define to 1 if gcc's __atomic builtins are available]) + json_have_atomic_builtins=1 +else + json_have_atomic_builtins=0 fi +AC_SUBST([json_have_atomic_builtins]) AC_MSG_RESULT([$have_atomic_builtins]) case "$ac_cv_type_long_long_int$ac_cv_func_strtoll" in |