+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.
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:
/* 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
-# 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,
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
])
# 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.
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])
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])
-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' \