]> Savannah Git Hosting - gnulib.git/commitdiff
ffsl, ffsll: Fix compilation error on Android.
authorBruno Haible <bruno@clisp.org>
Tue, 3 Jan 2023 20:33:32 +0000 (21:33 +0100)
committerBruno Haible <bruno@clisp.org>
Tue, 3 Jan 2023 20:33:32 +0000 (21:33 +0100)
* 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.

ChangeLog
doc/glibc-functions/ffsl.texi
doc/glibc-functions/ffsll.texi
lib/string.in.h
m4/ffsl.m4
m4/ffsll.m4

index fc20f7ebe48d34a52ff0397d60ba5ffd64426173..59a916a13a4b39401c844cad3a027131ed474412 100644 (file)
--- 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.
index 441383cc381be6ee54e8b826abdbef2ebf07c838..fa80a5cb288b386806decd03a83107a70a0130e3 100644 (file)
@@ -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
index 41e701e87efd19ed960708b72e4eb0714b0096b1..7912d451fcf0f937a093c44f043cbd722f97c484 100644 (file)
@@ -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
index e993b2fb6fc64b348993caf2c870f8ac55d8e422..b2683b6e4c0e277181426c6bc914f28086158903 100644 (file)
 # 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
index 1d840e5b8049d4c62e45d1e22e79dee43da4032d..568e47cdaf18d2f258671c8df9549e5f65db64f9 100644 (file)
@@ -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
 ])
index 8414272c6ee8a7f4bb842a0eb99eb590792d0f44..d2bffe6e81c09257e6c15da914d0069ee8b46302 100644 (file)
@@ -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],