1FFS(3) Linux Programmer's Manual FFS(3)
2
3
4
6 ffs, ffsl, ffsll - find first bit set in a word
7
9 #include <strings.h>
10
11 int ffs(int i);
12
13 #include <string.h>
14
15 int ffsl(long int i);
16
17 int ffsll(long long int i);
18
19 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
20
21 ffs():
22 Since glibc 2.12:
23 _XOPEN_SOURCE >= 700
24 || ! (_POSIX_C_SOURCE >= 200809L)
25 || /* Glibc since 2.19: */ _DEFAULT_SOURCE
26 || /* Glibc versions <= 2.19: */ _BSD_SOURCE ||
27 _SVID_SOURCE
28 Before glibc 2.12:
29 none
30 ffsl(), ffsll():
31 Since glibc 2.27:
32 _DEFAULT_SOURCE
33 Before glibc 2.27:
34 _GNU_SOURCE
35
37 The ffs() function returns the position of the first (least signifi‐
38 cant) bit set in the word i. The least significant bit is position 1
39 and the most significant position is, for example, 32 or 64. The func‐
40 tions ffsll() and ffsl() do the same but take arguments of possibly
41 different size.
42
44 These functions return the position of the first bit set, or 0 if no
45 bits are set in i.
46
48 For an explanation of the terms used in this section, see
49 attributes(7).
50
51 ┌───────────────────────┬───────────────┬─────────┐
52 │Interface │ Attribute │ Value │
53 ├───────────────────────┼───────────────┼─────────┤
54 │ffs(), ffsl(), ffsll() │ Thread safety │ MT-Safe │
55 └───────────────────────┴───────────────┴─────────┘
57 ffs(): POSIX.1-2001, POSIX.1-2008, 4.3BSD.
58
59 The ffsl() and ffsll() functions are glibc extensions.
60
62 BSD systems have a prototype in <string.h>.
63
65 memchr(3)
66
68 This page is part of release 4.16 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 2017-09-15 FFS(3)