ASF Bugzilla – Attachment 38327 Details for
Bug 63566
atomic builtins detection not quite correct
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Separate HAVE_ATOMIC_BUILTINS and HAVE_ATOMIC_BUILTINS64 detection/usage (1.7.0)
apr-1.7.0-USE_ATOMICS_BUILTINS64.diff (text/plain), 4.50 KB, created by
Yann Ylavic
on 2022-06-26 23:15:24 UTC
(
hide
)
Description:
Separate HAVE_ATOMIC_BUILTINS and HAVE_ATOMIC_BUILTINS64 detection/usage (1.7.0)
Filename:
MIME Type:
Creator:
Yann Ylavic
Created:
2022-06-26 23:15:24 UTC
Size:
4.50 KB
patch
obsolete
>Index: configure.in >=================================================================== >--- configure.in (revision 1902266) >+++ configure.in (working copy) >@@ -457,17 +457,23 @@ case "$host:$CC" in > ;; > esac > >-AC_CACHE_CHECK([whether the compiler provides atomic builtins], [ap_cv_atomic_builtins], >+AC_CACHE_CHECK([whether the compiler provides 32bit atomic builtins], [ap_cv_atomic_builtins], > [AC_TRY_RUN([ >-int main() >+#if HAVE_STDINT_H >+#include <stdint.h> >+#endif >+int main(int argc, const char *const *argv) > { >- unsigned long val = 1010, tmp, *mem = &val; >+#if HAVE_STDINT_H >+ uint32_t val = 1010, tmp, *mem = &val; >+#else >+ unsigned int val = 1010, tmp, *mem = &val; >+#endif > > if (__sync_fetch_and_add(&val, 1010) != 1010 || val != 2020) > return 1; > > tmp = val; >- > if (__sync_fetch_and_sub(mem, 1010) != tmp || val != 1010) > return 1; > >@@ -475,28 +481,59 @@ esac > return 1; > > tmp = 3030; >- > if (__sync_val_compare_and_swap(mem, 0, tmp) != 0 || val != tmp) > return 1; > >+ __sync_synchronize(); > if (__sync_lock_test_and_set(&val, 4040) != 3030) > return 1; > >- mem = &tmp; >+ if (__sync_val_compare_and_swap(&mem, &val, &tmp) != &val || mem != &tmp) >+ return 1; > >- if (__sync_val_compare_and_swap(&mem, &tmp, &val) != &tmp) >+ return 0; >+}], [ap_cv_atomic_builtins=yes], [ap_cv_atomic_builtins=no], [ap_cv_atomic_builtins=no])]) >+ >+if test "$ap_cv_atomic_builtins" = "yes"; then >+ AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1, [Define if compiler provides 32bit atomic builtins]) >+fi >+ >+AC_CACHE_CHECK([whether the compiler provides 64bit atomic builtins], [ap_cv_atomic_builtins64], >+[AC_TRY_RUN([ >+#if HAVE_STDINT_H >+#include <stdint.h> >+#endif >+int main(int argc, const char *const *argv) >+{ >+#if HAVE_STDINT_H >+ uint64_t val = 1010, tmp, *mem = &val; >+#else >+ unsigned long long val = 1010, tmp, *mem = &val; >+#endif >+ >+ if (__sync_fetch_and_add(&val, 1010) != 1010 || val != 2020) > return 1; > >- __sync_synchronize(); >+ tmp = val; >+ if (__sync_fetch_and_sub(mem, 1010) != tmp || val != 1010) >+ return 1; > >- if (mem != &val) >+ if (__sync_sub_and_fetch(&val, 1010) != 0 || val != 0) > return 1; > >+ tmp = 3030; >+ if (__sync_val_compare_and_swap(mem, 0, tmp) != 0 || val != tmp) >+ return 1; >+ >+ __sync_synchronize(); >+ if (__sync_lock_test_and_set(&val, 4040) != 3030) >+ return 1; >+ > return 0; >-}], [ap_cv_atomic_builtins=yes], [ap_cv_atomic_builtins=no], [ap_cv_atomic_builtins=no])]) >+}], [ap_cv_atomic_builtins64=yes], [ap_cv_atomic_builtins64=no], [ap_cv_atomic_builtins64=no])]) > >-if test "$ap_cv_atomic_builtins" = "yes"; then >- AC_DEFINE(HAVE_ATOMIC_BUILTINS, 1, [Define if compiler provides atomic builtins]) >+if test "$ap_cv_atomic_builtins64" = "yes"; then >+ AC_DEFINE(HAVE_ATOMIC_BUILTINS64, 1, [Define if compiler provides 64bit atomic builtins]) > fi > > case $host in >Index: include/arch/unix/apr_arch_atomic.h >=================================================================== >--- include/arch/unix/apr_arch_atomic.h (revision 1902266) >+++ include/arch/unix/apr_arch_atomic.h (working copy) >@@ -26,6 +26,11 @@ > /* noop */ > #elif HAVE_ATOMIC_BUILTINS > # define USE_ATOMICS_BUILTINS >+# if HAVE_ATOMIC_BUILTINS64 >+# define USE_ATOMICS_BUILTINS64 >+# else >+# define NEED_ATOMICS_GENERIC64 >+# endif > #elif defined(SOLARIS2) && SOLARIS2 >= 10 > # define USE_ATOMICS_SOLARIS > # define NEED_ATOMICS_GENERIC64 >@@ -36,7 +41,9 @@ > #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) > # define USE_ATOMICS_IA32 > # define NEED_ATOMICS_GENERIC64 >-#elif defined(__GNUC__) && (defined(__PPC__) || defined(__ppc__)) >+#elif defined(__GNUC__) && (defined(__powerpc__) \ >+ || defined(__PPC__) \ >+ || defined(__ppc__)) > # define USE_ATOMICS_PPC > # define NEED_ATOMICS_GENERIC64 > #elif defined(__GNUC__) && (defined(__s390__) || defined(__s390x__)) >Index: atomic/unix/builtins64.c >=================================================================== >--- atomic/unix/builtins64.c (revision 1902266) >+++ atomic/unix/builtins64.c (working copy) >@@ -16,7 +16,7 @@ > > #include "apr_arch_atomic.h" > >-#ifdef USE_ATOMICS_BUILTINS >+#ifdef USE_ATOMICS_BUILTINS64 > > APR_DECLARE(apr_uint64_t) apr_atomic_read64(volatile apr_uint64_t *mem) > { >@@ -61,4 +61,4 @@ APR_DECLARE(apr_uint64_t) apr_atomic_xchg64(volati > return __sync_lock_test_and_set(mem, val); > } > >-#endif /* USE_ATOMICS_BUILTINS */ >+#endif /* USE_ATOMICS_BUILTINS64 */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 63566
: 38327