bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 4/4] posix_memalign: port better to OpenBSD 6.2+ cross


From: Paul Eggert
Subject: [PATCH 4/4] posix_memalign: port better to OpenBSD 6.2+ cross
Date: Sat, 26 Oct 2024 23:10:44 -0700

* m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN):
Don’t assume sizeof (void *) <= 32 (!).
The bug is fixed in OpenBSD 6.2+.
---
 ChangeLog            |  5 +++++
 m4/posix_memalign.m4 | 18 +++++++++++-------
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6b65268fa2..a03100eacb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2024-10-26  Paul Eggert  <eggert@cs.ucla.edu>
 
+       posix_memalign: port better to OpenBSD 6.2+ cross
+       * m4/posix_memalign.m4 (gl_FUNC_POSIX_MEMALIGN):
+       Don’t assume sizeof (void *) <= 32 (!).
+       The bug is fixed in OpenBSD 6.2+.
+
        posix_memalign-tests: fix message typo
        * tests/test-posix_memalign.c (main): Fix diagnostic typo.
 
diff --git a/m4/posix_memalign.m4 b/m4/posix_memalign.m4
index 0e1d3e5541..e814ec1560 100644
--- a/m4/posix_memalign.m4
+++ b/m4/posix_memalign.m4
@@ -1,5 +1,5 @@
 # posix_memalign.m4
-# serial 3
+# serial 4
 dnl Copyright (C) 2020-2024 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -16,7 +16,7 @@ AC_DEFUN([gl_FUNC_POSIX_MEMALIGN],
 
   gl_CHECK_FUNCS_ANDROID([posix_memalign], [[#include <stdlib.h>]])
   if test $ac_cv_func_posix_memalign = yes; then
-    dnl On OpenBSD 6.1, posix_memalign (&p, 32, 2406) returns a pointer
+    dnl On OpenBSD 6.1, posix_memalign (&p, 32, 2406) stores a pointer
     dnl that is not a multiple of 32.
     AC_CACHE_CHECK([whether posix_memalign works for large alignments],
       [gl_cv_func_posix_memalign_works],
@@ -25,19 +25,23 @@ AC_DEFUN([gl_FUNC_POSIX_MEMALIGN],
             [[#include <stdlib.h>
             ]],
             [[void *p;
-              if (posix_memalign (&p, 32, 2406) == 0)
-                if (((unsigned long)p % 32) != 0)
-                  return 1;
+              if (32 % sizeof (void *) == 0
+                  && posix_memalign (&p, 32, 2406) == 0
+                  && (unsigned long) p % 32 != 0)
+                return 1;
               return 0;
             ]])
          ],
          [gl_cv_func_posix_memalign_works=yes],
          [gl_cv_func_posix_memalign_works=no],
          [case "$host_os" in
-                      # Guess no on OpenBSD.
-            openbsd*) gl_cv_func_posix_memalign_works="guessing no" ;;
+changequote(,)dnl
+                      # Guess no on OpenBSD through 6.1.
+            openbsd[1-5].* | openbsd6.[01] | openbsd6.[01].*)
+                      gl_cv_func_posix_memalign_works="guessing no" ;;
                       # If we don't know, obey --enable-cross-guesses.
             *)        gl_cv_func_posix_memalign_works="$gl_cross_guess_normal" 
;;
+changequote([,])dnl
           esac
          ])
       ])
-- 
2.43.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]