]> Savannah Git Hosting - gnulib.git/commitdiff
ffsll: Override completely broken implementation on AIX in 32-bit mode.
authorBruno Haible <bruno@clisp.org>
Tue, 5 Jan 2021 06:15:09 +0000 (07:15 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 5 Jan 2021 06:15:09 +0000 (07:15 +0100)
* m4/ffsll.m4 (gl_FUNC_FFSLL): Test whether ffsll minimally works. If
not, set REPLACE_FFSLL.
* lib/string.in.h (ffsll): Consider REPLACE_FFSLL.
* m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Initialize
REPLACE_FFSLL.
* modules/string (Makefile.am): Substitute REPLACE_FFSLL.
* modules/ffsll (Depends-on, configure.ac): Consider REPLACE_FFSLL.
* doc/glibc-functions/ffsll.texi: Mention the AIX 7.2 bug.

ChangeLog
doc/glibc-functions/ffsll.texi
lib/string.in.h
m4/ffsll.m4
m4/string_h.m4
modules/ffsll
modules/string

index 2663445a73022c282c66d519f080ffe126a48c59..19f9046edebd4f39a8c9f6406657acd49dd0acdf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2021-01-05  Bruno Haible  <bruno@clisp.org>
+
+       ffsll: Override completely broken implementation on AIX in 32-bit mode.
+       * m4/ffsll.m4 (gl_FUNC_FFSLL): Test whether ffsll minimally works. If
+       not, set REPLACE_FFSLL.
+       * lib/string.in.h (ffsll): Consider REPLACE_FFSLL.
+       * m4/string_h.m4 (gl_HEADER_STRING_H_DEFAULTS): Initialize
+       REPLACE_FFSLL.
+       * modules/string (Makefile.am): Substitute REPLACE_FFSLL.
+       * modules/ffsll (Depends-on, configure.ac): Consider REPLACE_FFSLL.
+       * doc/glibc-functions/ffsll.texi: Mention the AIX 7.2 bug.
+
 2021-01-04  Bruno Haible  <bruno@clisp.org>
 
        symlinkat: Fix trailing slash handling.
index 718ccfcafeded7d279fa1e85557f1824517c294f..41e701e87efd19ed960708b72e4eb0714b0096b1 100644 (file)
@@ -15,6 +15,9 @@ Mac OS X 10.5, FreeBSD 6.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 5.1, HP-UX
 This function is declared in @code{<strings.h>} instead of @code{<string.h>}
 on some platforms:
 AIX 7.2.
+@item
+This function returns completely wrong values on some platforms:
+AIX 7.2 in 32-bit mode.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index 2f2e07bd774f08056593830ba4723d3046eb802f..bac515dce2f3a1dbad427c80cf0c1ddd0e8d289d 100644 (file)
@@ -118,10 +118,18 @@ _GL_WARN_ON_USE (ffsl, "ffsl is not portable - use the ffsl module");
 
 /* Find the index of the least-significant set bit.  */
 #if @GNULIB_FFSLL@
-# if !@HAVE_FFSLL@
+# if @REPLACE_FFSLL@
+#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#   define ffsll rpl_ffsll
+#  endif
+_GL_FUNCDECL_RPL (ffsll, int, (long long int i));
+_GL_CXXALIAS_RPL (ffsll, int, (long long int i));
+# else
+#  if !@HAVE_FFSLL@
 _GL_FUNCDECL_SYS (ffsll, int, (long long int i));
-# endif
+#  endif
 _GL_CXXALIAS_SYS (ffsll, int, (long long int i));
+# endif
 _GL_CXXALIASWARN (ffsll);
 #elif defined GNULIB_POSIXCHECK
 # undef ffsll
index f99ea9c74e60619102f180d148f85b950d0cacd8..97491eb2e632ce03faf664a2e37192d29d995a1c 100644 (file)
@@ -1,4 +1,4 @@
-# ffsll.m4 serial 1
+# ffsll.m4 serial 2
 dnl Copyright (C) 2011-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,12 +7,50 @@ dnl with or without modifications, as long as this notice is preserved.
 AC_DEFUN([gl_FUNC_FFSLL],
 [
   AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
+  AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
 
-  dnl Persuade glibc <string.h> to declare ffsll().
+  dnl Persuade glibc <string.h> and AIX <strings.h> to declare ffsll().
   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
 
   AC_CHECK_FUNCS_ONCE([ffsll])
-  if test $ac_cv_func_ffsll = no; then
+  if test $ac_cv_func_ffsll = yes; then
+    dnl Test whether ffsll works.
+    dnl On AIX 7.2 in 32-bit mode it is completely broken.
+    AC_CACHE_CHECK([whether ffsll works],
+      [gl_cv_func_ffsll_works],
+      [AC_RUN_IFELSE(
+         [AC_LANG_SOURCE([[
+            #include <string.h>
+            #include <strings.h>
+            int dummy (long long x) { return 42; }
+            int main (int argc, char *argv[])
+            {
+              int (* volatile my_ffsll) (long long) = argc ? ffsll : dummy;
+              long long int x = -128LL;
+              return my_ffsll (x) != 8;
+            }
+          ]])],
+         [gl_cv_func_ffsll_works=yes],
+         [gl_cv_func_ffsll_works=no],
+         [case "$host_os" in
+                           # Guess yes on glibc systems.
+            *-gnu* | gnu*) gl_cv_func_ffsll_works="guessing yes" ;;
+                           # Guess yes on musl systems.
+            *-musl*)       gl_cv_func_ffsll_works="guessing yes" ;;
+                           # Guess yes on native Windows.
+            mingw*)        gl_cv_func_ffsll_works="guessing yes" ;;
+                           # Guess no on AIX.
+            aix*)          gl_cv_func_ffsll_works="guessing no" ;;
+                           # If we don't know, obey --enable-cross-guesses.
+            *)             gl_cv_func_ffsll_works="$gl_cross_guess_normal" ;;
+          esac
+         ])
+      ])
+    case "$gl_cv_func_ffsll_works" in
+      *yes) ;;
+      *) REPLACE_FFSLL=1 ;;
+    esac
+  else
     HAVE_FFSLL=0
   fi
 ])
index 3e65355735c681329a64b638a6c54c758deaae4a..a4cc5b4378337b4d7a04fa0ac3926ac9e4444c9b 100644 (file)
@@ -5,7 +5,7 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 28
+# serial 29
 
 # Written by Paul Eggert.
 
@@ -113,6 +113,7 @@ AC_DEFUN([gl_HEADER_STRING_H_DEFAULTS],
   HAVE_SIGDESCR_NP=1;           AC_SUBST([HAVE_SIGDESCR_NP])
   HAVE_DECL_STRSIGNAL=1;        AC_SUBST([HAVE_DECL_STRSIGNAL])
   HAVE_STRVERSCMP=1;            AC_SUBST([HAVE_STRVERSCMP])
+  REPLACE_FFSLL=0;              AC_SUBST([REPLACE_FFSLL])
   REPLACE_MEMCHR=0;             AC_SUBST([REPLACE_MEMCHR])
   REPLACE_MEMMEM=0;             AC_SUBST([REPLACE_MEMMEM])
   REPLACE_STPNCPY=0;            AC_SUBST([REPLACE_STPNCPY])
index d1f78fb8ba7e75ef5dd62f7a47cf77c6d10d8aa1..dea0d97e800fd8fa945ad552fa8fd3045f641ab3 100644 (file)
@@ -9,11 +9,11 @@ m4/ffsll.m4
 Depends-on:
 extensions
 string
-ffs             [test $HAVE_FFSLL = 0]
+ffs             [test $HAVE_FFSLL = 0 || test $REPLACE_FFSLL = 1]
 
 configure.ac:
 gl_FUNC_FFSLL
-if test $HAVE_FFSLL = 0; then
+if test $HAVE_FFSLL = 0 || test $REPLACE_FFSLL = 1; then
   AC_LIBOBJ([ffsll])
 fi
 gl_STRING_MODULE_INDICATOR([ffsll])
index 8ce11d24ac43f97fff3fc9846999d44bf40a5798..6c87229e4c051a481ca8c1e9378d8e4a04748a48 100644 (file)
@@ -98,6 +98,7 @@ string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
              -e 's|@''HAVE_SIGDESCR_NP''@|$(HAVE_SIGDESCR_NP)|g' \
              -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \
              -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \
+             -e 's|@''REPLACE_FFSLL''@|$(REPLACE_FFSLL)|g' \
              -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \
              -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \
              -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \