summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2023-01-03 21:33:32 +0100
committerBruno Haible <bruno@clisp.org>2023-01-03 21:33:32 +0100
commit7c4ee88821d4ee0adc6511a0f6ead0e5ed6518b2 (patch)
tree4ed68439b20eeda3a6ab633da07781f51815ae43
parent0ff4d2d5894ec53eb8bc8930266e3e8e93f5b51b (diff)
downloadgnulib-7c4ee88821d4ee0adc6511a0f6ead0e5ed6518b2.tar.gz
ffsl, ffsll: Fix compilation error on Android.
* lib/string.in.h: On Android as well, include <strings.h>. * m4/ffsl.m4 (gl_FUNC_FFSL): Use a specific link test instead of AC_CHECK_FUNCS_ONCE. * m4/ffsll.m4 (gl_FUNC_FFSLL): Likewise. * doc/glibc-functions/ffsl.texi: Mention Android problems. * doc/glibc-functions/ffsll.texi: Likewise.
-rw-r--r--ChangeLog8
-rw-r--r--doc/glibc-functions/ffsl.texi5
-rw-r--r--doc/glibc-functions/ffsll.texi5
-rw-r--r--lib/string.in.h5
-rw-r--r--m4/ffsl.m424
-rw-r--r--m4/ffsll.m424
6 files changed, 61 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index fc20f7ebe4..59a916a13a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2023-01-03 Bruno Haible <bruno@clisp.org>
+ ffsl, ffsll: Fix compilation error on Android.
+ * lib/string.in.h: On Android as well, include <strings.h>.
+ * m4/ffsl.m4 (gl_FUNC_FFSL): Use a specific link test instead of
+ AC_CHECK_FUNCS_ONCE.
+ * m4/ffsll.m4 (gl_FUNC_FFSLL): Likewise.
+ * doc/glibc-functions/ffsl.texi: Mention Android problems.
+ * doc/glibc-functions/ffsll.texi: Likewise.
+
ffs: Document Android problem.
* doc/posix-functions/ffs.texi: Mention Android problem.
* m4/ffs.m4: Update comment.
diff --git a/doc/glibc-functions/ffsl.texi b/doc/glibc-functions/ffsl.texi
index 441383cc38..fa80a5cb28 100644
--- a/doc/glibc-functions/ffsl.texi
+++ b/doc/glibc-functions/ffsl.texi
@@ -14,9 +14,12 @@ FreeBSD 5.2.1, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5
@item
This function is declared in @code{<strings.h>} instead of @code{<string.h>}
on some platforms:
-AIX 7.2.
+AIX 7.2, Android 13.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
+@item
+This function is only defined as an inline function on some platforms:
+Android 13.
@end itemize
diff --git a/doc/glibc-functions/ffsll.texi b/doc/glibc-functions/ffsll.texi
index 41e701e87e..7912d451fc 100644
--- a/doc/glibc-functions/ffsll.texi
+++ b/doc/glibc-functions/ffsll.texi
@@ -14,7 +14,7 @@ Mac OS X 10.5, FreeBSD 6.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.1.8, AIX 5.1, HP-UX
@item
This function is declared in @code{<strings.h>} instead of @code{<string.h>}
on some platforms:
-AIX 7.2.
+AIX 7.2, Android 13.
@item
This function returns completely wrong values on some platforms:
AIX 7.2 in 32-bit mode.
@@ -22,4 +22,7 @@ AIX 7.2 in 32-bit mode.
Portability problems not fixed by Gnulib:
@itemize
+@item
+This function is only defined as an inline function on some platforms:
+Android 13.
@end itemize
diff --git a/lib/string.in.h b/lib/string.in.h
index e993b2fb6f..b2683b6e4c 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -59,10 +59,11 @@
# include <unistd.h>
#endif
-/* AIX 7.2 declares ffsl and ffsll in <strings.h>, not in <string.h>. */
+/* AIX 7.2 and Android 13 declare ffsl and ffsll in <strings.h>, not in
+ <string.h>. */
/* But in any case avoid namespace pollution on glibc systems. */
#if ((@GNULIB_FFSL@ || @GNULIB_FFSLL@ || defined GNULIB_POSIXCHECK) \
- && defined _AIX) \
+ && (defined _AIX || defined __ANDROID__)) \
&& ! defined __GLIBC__
# include <strings.h>
#endif
diff --git a/m4/ffsl.m4 b/m4/ffsl.m4
index 1d840e5b80..568e47cdaf 100644
--- a/m4/ffsl.m4
+++ b/m4/ffsl.m4
@@ -1,4 +1,4 @@
-# ffsl.m4 serial 2
+# ffsl.m4 serial 3
dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -11,8 +11,26 @@ AC_DEFUN([gl_FUNC_FFSL],
dnl Persuade glibc <string.h> to declare ffsl().
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
- AC_CHECK_FUNCS_ONCE([ffsl])
- if test $ac_cv_func_ffsl = no; then
+ dnl We can't use AC_CHECK_FUNC here, because ffsl() is defined as a
+ dnl static inline function when compiling for Android 13 or older.
+ dnl But require that ffsl() is declared; otherwise we may be using
+ dnl the GCC built-in function, which leads to warnings
+ dnl "warning: implicit declaration of function 'ffsl'".
+ AC_CACHE_CHECK([for ffsl], [gl_cv_func_ffsl],
+ [AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <string.h>
+ #include <strings.h>
+ long x;
+ ]],
+ [[int (*func) (long) = ffsl;
+ return func (x);
+ ]])
+ ],
+ [gl_cv_func_ffsl=yes],
+ [gl_cv_func_ffsl=no])
+ ])
+ if test $gl_cv_func_ffsl = no; then
HAVE_FFSL=0
fi
])
diff --git a/m4/ffsll.m4 b/m4/ffsll.m4
index 8414272c6e..d2bffe6e81 100644
--- a/m4/ffsll.m4
+++ b/m4/ffsll.m4
@@ -1,4 +1,4 @@
-# ffsll.m4 serial 3
+# ffsll.m4 serial 4
dnl Copyright (C) 2011-2023 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -12,8 +12,26 @@ AC_DEFUN([gl_FUNC_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 = yes; then
+ dnl We can't use AC_CHECK_FUNC here, because ffsll() is defined as a
+ dnl static inline function when compiling for Android 13 or older.
+ dnl But require that ffsll() is declared; otherwise we may be using
+ dnl the GCC built-in function, which leads to warnings
+ dnl "warning: implicit declaration of function 'ffsll'".
+ AC_CACHE_CHECK([for ffsll], [gl_cv_func_ffsll],
+ [AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <string.h>
+ #include <strings.h>
+ long long x;
+ ]],
+ [[int (*func) (long long) = ffsll;
+ return func (x);
+ ]])
+ ],
+ [gl_cv_func_ffsll=yes],
+ [gl_cv_func_ffsll=no])
+ ])
+ if test $gl_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],