1FFS(3)                     Linux Programmer's Manual                    FFS(3)
2
3
4

NAME

6       ffs, ffsl, ffsll - find first bit set in a word
7

SYNOPSIS

9       #include <strings.h>
10
11       int ffs(int i);
12
13       #include <string.h>
14
15       int ffsl(long i);
16       int ffsll(long long i);
17
18   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20       ffs():
21           Since glibc 2.12:
22               _XOPEN_SOURCE >= 700
23                   || ! (_POSIX_C_SOURCE >= 200809L)
24                   || /* Glibc since 2.19: */ _DEFAULT_SOURCE
25                   || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
26           Before glibc 2.12:
27               none
28
29       ffsl(), ffsll():
30           Since glibc 2.27:
31               _DEFAULT_SOURCE
32           Before glibc 2.27:
33               _GNU_SOURCE
34

DESCRIPTION

36       The  ffs()  function  returns the position of the first (least signifi‐
37       cant) bit set in the word i.  The least significant bit is  position  1
38       and the most significant position is, for example, 32 or 64.  The func‐
39       tions ffsll() and ffsl() do the same but  take  arguments  of  possibly
40       different size.
41

RETURN VALUE

43       These  functions  return  the position of the first bit set, or 0 if no
44       bits are set in i.
45

ATTRIBUTES

47       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
48       tributes(7).
49
50       ┌────────────────────────────────────────────┬───────────────┬─────────┐
51Interface                                   Attribute     Value   
52       ├────────────────────────────────────────────┼───────────────┼─────────┤
53ffs(), ffsl(), ffsll()                      │ Thread safety │ MT-Safe │
54       └────────────────────────────────────────────┴───────────────┴─────────┘
55

CONFORMING TO

57       ffs(): POSIX.1-2001, POSIX.1-2008, 4.3BSD.
58
59       The ffsl() and ffsll() functions are glibc extensions.
60

NOTES

62       BSD systems have a prototype in <string.h>.
63

SEE ALSO

65       memchr(3)
66

COLOPHON

68       This  page  is  part of release 5.13 of the Linux man-pages project.  A
69       description of the project, information about reporting bugs,  and  the
70       latest     version     of     this    page,    can    be    found    at
71       https://www.kernel.org/doc/man-pages/.
72
73
74
75GNU                               2021-03-22                            FFS(3)
Impressum