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