xref: /netbsd-src/external/gpl3/gdb/dist/gnulib/import/m4/ffs.m4 (revision 4b169a6ba595ae283ca507b26b15fdff40495b1c)
1# ffs.m4 serial 5
2dnl Copyright (C) 2011-2022 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7AC_DEFUN([gl_FUNC_FFS],
8[
9  AC_REQUIRE([gl_STRINGS_H_DEFAULTS])
10
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
32])
33