1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2025-08-08 17:22:05 +03:00

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.
This commit is contained in:
Bruno Haible
2021-01-05 07:15:09 +01:00
parent 3d1894d8dd
commit e182feb2ce
7 changed files with 71 additions and 8 deletions

View File

@@ -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.

View 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:

View 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

View 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
])

View 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])

View 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])

View 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' \