xstrtol: Strengthen sanity check.
[gnulib.git] / m4 / ffs.m4
blob6392c82c90eb6a671e163b47ce6386d4ea284a3d
1 # ffs.m4
2 # serial 6
3 dnl Copyright (C) 2011-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 AC_DEFUN([gl_FUNC_FFS],
10   AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
12   dnl We can't use AC_CHECK_FUNC here, because ffs() is defined as a
13   dnl static inline function when compiling for Android 13 or older.
14   dnl But require that ffs() is declared; otherwise we may be using
15   dnl the GCC built-in function, which leads to warnings
16   dnl "warning: implicit declaration of function 'ffs'".
17   AC_CACHE_CHECK([for ffs], [gl_cv_func_ffs],
18     [AC_LINK_IFELSE(
19        [AC_LANG_PROGRAM(
20           [[#include <strings.h>
21             int x;
22           ]],
23           [[int (*func) (int) = ffs;
24             return func (x);
25           ]])
26        ],
27        [gl_cv_func_ffs=yes],
28        [gl_cv_func_ffs=no])
29     ])
30   if test $gl_cv_func_ffs = no; then
31     HAVE_FFS=0
32   fi