summaryrefslogtreecommitdiff
path: root/m4/ffsl.m4
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 /m4/ffsl.m4
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.
Diffstat (limited to 'm4/ffsl.m4')
-rw-r--r--m4/ffsl.m424
1 files changed, 21 insertions, 3 deletions
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
])