* 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.
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.
@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
@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.
Portability problems not fixed by Gnulib:
@itemize
+@item
+This function is only defined as an inline function on some platforms:
+Android 13.
@end itemize
# 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
-# 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,
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
])
-# 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,
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],