You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by yl...@apache.org on 2023/05/19 10:32:02 UTC

svn commit: r1909930 - in /apr/apr/branches/1.7.x: ./ atomic/netware/ atomic/os390/ atomic/unix/ atomic/win32/ include/arch/unix/

Author: ylavic
Date: Fri May 19 10:32:01 2023
New Revision: 1909930

URL: http://svn.apache.org/viewvc?rev=1909930&view=rev
Log:
Call apr__atomic_generic64_init() if needed

Otherwise we get a segfault.  Seen on Debian on powerpc with

/* Define if compiler provides 32bit atomic builtins */
#define HAVE_ATOMIC_BUILTINS 1
/* Define if compiler provides 64bit atomic builtins */
/* #undef HAVE_ATOMIC_BUILTINS64 */
/* Define if compiler provides 32bit __atomic builtins */
#define HAVE__ATOMIC_BUILTINS 1
/* Define if compiler provides 64bit __atomic builtins */
/* #undef HAVE__ATOMIC_BUILTINS64 */
/* Define if use of generic atomics is requested */
/* #undef USE_ATOMICS_GENERIC */


configure: atomic builtins might be implemented for i586 and i686.


atomics: Disentangle 32bit and 64bit atomics configuration.

Regardless of --enable-nonportable-atomics setting, 64bit atomic builtins are
disabled for 32bit CPUs/systems (using the generic/mutex implementation), until
we figure out how to properly align apr_uint64_t (at least i[56]86 CPUs which
could work with 64bit builtins actually don't if the data is not 64bit aligned,
assuming the same for other 32bit CPUs is safer).

One can --enable-nonportable-atomics=upto32bit to explicitely enable 32 bit
builtins only (if available in the first place).

Using --enable-nonportable-atomics=no still disables both 64bit and 32bit
builtins, while =yes enables the ones known to exist AND work only (i.e. both,
32bit or none).

Rename NEED_ATOMICS_GENERIC64 to USE_ATOMICS_GENERIC64 for consitency with
32bit atomics.


atomics: Follow up to r1909321: remaining NEED_ATOMICS_GENERIC64.


atomics: Follow up to r1909321: Windows does not use 64bit generic atomics.


Merges r1909929 1.8.x.
Merges r1907442, r1907988, r1909321, r1909323, r1909324 from trunk
Submitted by: sf, ylavic, ylavic, ylavic, ylavic

Modified:
    apr/apr/branches/1.7.x/   (props changed)
    apr/apr/branches/1.7.x/atomic/netware/apr_atomic.c
    apr/apr/branches/1.7.x/atomic/os390/atomic.c
    apr/apr/branches/1.7.x/atomic/unix/builtins.c
    apr/apr/branches/1.7.x/atomic/unix/ia32.c
    apr/apr/branches/1.7.x/atomic/unix/mutex64.c
    apr/apr/branches/1.7.x/atomic/unix/ppc.c
    apr/apr/branches/1.7.x/atomic/unix/s390.c
    apr/apr/branches/1.7.x/atomic/unix/solaris.c
    apr/apr/branches/1.7.x/atomic/win32/apr_atomic.c
    apr/apr/branches/1.7.x/configure.in
    apr/apr/branches/1.7.x/include/arch/unix/apr_arch_atomic.h

Propchange: apr/apr/branches/1.7.x/
------------------------------------------------------------------------------
  Merged /apr/apr/branches/1.8.x:r1909929
  Merged /apr/apr/trunk:r1907442,1907988,1909321,1909323-1909324

Modified: apr/apr/branches/1.7.x/atomic/netware/apr_atomic.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/atomic/netware/apr_atomic.c?rev=1909930&r1=1909929&r2=1909930&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/atomic/netware/apr_atomic.c (original)
+++ apr/apr/branches/1.7.x/atomic/netware/apr_atomic.c Fri May 19 10:32:01 2023
@@ -20,7 +20,7 @@
 
 APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *pool)
 {
-#if defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
     return apr__atomic_generic64_init(p);
 #else
     return APR_SUCCESS;

Modified: apr/apr/branches/1.7.x/atomic/os390/atomic.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/atomic/os390/atomic.c?rev=1909930&r1=1909929&r2=1909930&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/atomic/os390/atomic.c (original)
+++ apr/apr/branches/1.7.x/atomic/os390/atomic.c Fri May 19 10:32:01 2023
@@ -20,7 +20,7 @@
 
 apr_status_t apr_atomic_init(apr_pool_t *p)
 {
-#if defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
     return apr__atomic_generic64_init(p);
 #else
     return APR_SUCCESS;

Modified: apr/apr/branches/1.7.x/atomic/unix/builtins.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/atomic/unix/builtins.c?rev=1909930&r1=1909929&r2=1909930&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/atomic/unix/builtins.c (original)
+++ apr/apr/branches/1.7.x/atomic/unix/builtins.c Fri May 19 10:32:01 2023
@@ -27,7 +27,11 @@
 
 APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
 {
+#if defined (USE_ATOMICS_GENERIC64)
+    return apr__atomic_generic64_init(p);
+#else
     return APR_SUCCESS;
+#endif
 }
 
 APR_DECLARE(apr_uint32_t) apr_atomic_read32(volatile apr_uint32_t *mem)

Modified: apr/apr/branches/1.7.x/atomic/unix/ia32.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/atomic/unix/ia32.c?rev=1909930&r1=1909929&r2=1909930&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/atomic/unix/ia32.c (original)
+++ apr/apr/branches/1.7.x/atomic/unix/ia32.c Fri May 19 10:32:01 2023
@@ -20,7 +20,7 @@
 
 APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
 {
-#if defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
     return apr__atomic_generic64_init(p);
 #else
     return APR_SUCCESS;

Modified: apr/apr/branches/1.7.x/atomic/unix/mutex64.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/atomic/unix/mutex64.c?rev=1909930&r1=1909929&r2=1909930&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/atomic/unix/mutex64.c (original)
+++ apr/apr/branches/1.7.x/atomic/unix/mutex64.c Fri May 19 10:32:01 2023
@@ -17,7 +17,7 @@
 #include "apr_arch_atomic.h"
 #include "apr_thread_mutex.h"
 
-#if defined(USE_ATOMICS_GENERIC) || defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
 
 #include <stdlib.h>
 

Modified: apr/apr/branches/1.7.x/atomic/unix/ppc.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/atomic/unix/ppc.c?rev=1909930&r1=1909929&r2=1909930&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/atomic/unix/ppc.c (original)
+++ apr/apr/branches/1.7.x/atomic/unix/ppc.c Fri May 19 10:32:01 2023
@@ -26,7 +26,7 @@
 
 APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
 {
-#if defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
     return apr__atomic_generic64_init(p);
 #else
     return APR_SUCCESS;

Modified: apr/apr/branches/1.7.x/atomic/unix/s390.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/atomic/unix/s390.c?rev=1909930&r1=1909929&r2=1909930&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/atomic/unix/s390.c (original)
+++ apr/apr/branches/1.7.x/atomic/unix/s390.c Fri May 19 10:32:01 2023
@@ -20,7 +20,7 @@
 
 APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
 {
-#if defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
     return apr__atomic_generic64_init(p);
 #else
     return APR_SUCCESS;

Modified: apr/apr/branches/1.7.x/atomic/unix/solaris.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/atomic/unix/solaris.c?rev=1909930&r1=1909929&r2=1909930&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/atomic/unix/solaris.c (original)
+++ apr/apr/branches/1.7.x/atomic/unix/solaris.c Fri May 19 10:32:01 2023
@@ -22,7 +22,7 @@
 
 APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
 {
-#if defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
     return apr__atomic_generic64_init(p);
 #else
     return APR_SUCCESS;

Modified: apr/apr/branches/1.7.x/atomic/win32/apr_atomic.c
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/atomic/win32/apr_atomic.c?rev=1909930&r1=1909929&r2=1909930&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/atomic/win32/apr_atomic.c (original)
+++ apr/apr/branches/1.7.x/atomic/win32/apr_atomic.c Fri May 19 10:32:01 2023
@@ -18,11 +18,7 @@
 
 APR_DECLARE(apr_status_t) apr_atomic_init(apr_pool_t *p)
 {
-#if defined (NEED_ATOMICS_GENERIC64)
-    return apr__atomic_generic64_init(p);
-#else
     return APR_SUCCESS;
-#endif
 }
 
 APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t val)

Modified: apr/apr/branches/1.7.x/configure.in
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/configure.in?rev=1909930&r1=1909929&r2=1909930&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/configure.in (original)
+++ apr/apr/branches/1.7.x/configure.in Fri May 19 10:32:01 2023
@@ -558,6 +558,9 @@ if test "$ap_cv_atomic_builtins" = "yes"
     if test "$ap_cv__atomic_builtins" = "yes"; then
         AC_DEFINE(HAVE__ATOMIC_BUILTINS, 1, [Define if compiler provides 32bit __atomic builtins])
     fi
+    has_atomic_builtins=yes
+else
+    has_atomic_builtins=no
 fi
 
 AC_CACHE_CHECK([whether the compiler provides 64bit atomic builtins], [ap_cv_atomic_builtins64],
@@ -802,18 +805,30 @@ void main(void)
    fi
 fi
 
+force_generic_atomics=no
+force_generic_atomics64=no
+AC_CHECK_SIZEOF(void*, 4)
+if test "x$ac_cv_sizeof_voidp" = "x"; then
+    force_generic_atomics64=yes
+elif test $ac_cv_sizeof_voidp -lt 8; then
+    force_generic_atomics64=yes
+fi
 AC_ARG_ENABLE(nonportable-atomics,
 [  --enable-nonportable-atomics  Use optimized atomic code which may produce nonportable binaries],
-[if test $enableval = yes; then
-   force_generic_atomics=no
- else
+[if test "$enableval" = "upto32bit"; then
+   force_generic_atomics64=yes
+ elif test "$enableval" != "yes"; then
    force_generic_atomics=yes
  fi
 ],
 [case $host_cpu in
-   i[[456]]86) force_generic_atomics=yes ;;
-   *) force_generic_atomics=no
-      case $host in
+   i[[34]]86)
+      force_generic_atomics=yes
+      ;;
+   i[[56]]86)
+      force_generic_atomics64=yes
+      ;;
+   *) case $host in
          *solaris2.10*)
             AC_TRY_COMPILE(
                 [#include <atomic.h>],
@@ -828,11 +843,14 @@ AC_ARG_ENABLE(nonportable-atomics,
       ;;
 esac
 ])
-
 if test $force_generic_atomics = yes; then
    AC_DEFINE([USE_ATOMICS_GENERIC], 1,
              [Define if use of generic atomics is requested])
 fi
+if test $force_generic_atomics = yes -o $force_generic_atomics64 = yes; then
+   AC_DEFINE([USE_ATOMICS_GENERIC64], 1,
+             [Define if use of 64bit generic atomics is requested])
+fi
 
 AC_SUBST(proc_mutex_is_global)
 AC_SUBST(eolstr)

Modified: apr/apr/branches/1.7.x/include/arch/unix/apr_arch_atomic.h
URL: http://svn.apache.org/viewvc/apr/apr/branches/1.7.x/include/arch/unix/apr_arch_atomic.h?rev=1909930&r1=1909929&r2=1909930&view=diff
==============================================================================
--- apr/apr/branches/1.7.x/include/arch/unix/apr_arch_atomic.h (original)
+++ apr/apr/branches/1.7.x/include/arch/unix/apr_arch_atomic.h Fri May 19 10:32:01 2023
@@ -23,37 +23,35 @@
 #include "apr_atomic.h"
 
 #if defined(USE_ATOMICS_GENERIC)
-/* noop */
+    /* 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
 #elif defined(__GNUC__) && defined(__STRICT_ANSI__)
 /* force use of generic atomics if building e.g. with -std=c89, which
  * doesn't allow inline asm */
 #   define USE_ATOMICS_GENERIC
 #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
 #   define USE_ATOMICS_IA32
-#   define NEED_ATOMICS_GENERIC64
 #elif defined(__GNUC__) && (defined(__powerpc__) \
                             || defined(__PPC__) \
                             || defined(__ppc__))
 #   define USE_ATOMICS_PPC
-#   define NEED_ATOMICS_GENERIC64
 #elif defined(__GNUC__) && (defined(__s390__) || defined(__s390x__))
 #   define USE_ATOMICS_S390
-#   define NEED_ATOMICS_GENERIC64
 #else
 #   define USE_ATOMICS_GENERIC
 #endif
 
-#if defined(USE_ATOMICS_GENERIC) || defined (NEED_ATOMICS_GENERIC64)
+#if defined(USE_ATOMICS_GENERIC64)
+    /* noop */
+#elif HAVE_ATOMIC_BUILTINS64
+#   define USE_ATOMICS_BUILTINS64
+#else
+#   define USE_ATOMICS_GENERIC64
+#endif
+#if defined(USE_ATOMICS_GENERIC64)
 apr_status_t apr__atomic_generic64_init(apr_pool_t *p);
 #endif