1ffs(3) Library Functions Manual ffs(3)
2
3
4
6 ffs, ffsl, ffsll - find first bit set in a word
7
9 Standard C library (libc, -lc)
10
12 #include <strings.h>
13
14 int ffs(int i);
15
16 #include <string.h>
17
18 int ffsl(long i);
19 int ffsll(long long i);
20
21 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
22
23 ffs():
24 Since glibc 2.12:
25 _XOPEN_SOURCE >= 700
26 || ! (_POSIX_C_SOURCE >= 200809L)
27 || /* glibc >= 2.19: */ _DEFAULT_SOURCE
28 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
29 Before glibc 2.12:
30 none
31
32 ffsl(), ffsll():
33 Since glibc 2.27:
34 _DEFAULT_SOURCE
35 Before glibc 2.27:
36 _GNU_SOURCE
37
39 The ffs() function returns the position of the first (least signifi‐
40 cant) bit set in the word i. The least significant bit is position 1
41 and the most significant position is, for example, 32 or 64. The func‐
42 tions ffsll() and ffsl() do the same but take arguments of possibly
43 different size.
44
46 These functions return the position of the first bit set, or 0 if no
47 bits are set in i.
48
50 For an explanation of the terms used in this section, see at‐
51 tributes(7).
52
53 ┌────────────────────────────────────────────┬───────────────┬─────────┐
54 │Interface │ Attribute │ Value │
55 ├────────────────────────────────────────────┼───────────────┼─────────┤
56 │ffs(), ffsl(), ffsll() │ Thread safety │ MT-Safe │
57 └────────────────────────────────────────────┴───────────────┴─────────┘
58
60 BSD systems have a prototype in <string.h>.
61
63 ffs() POSIX.1-2001, POSIX.1-2008, 4.3BSD.
64
65 ffsl()
66 ffsll()
67 GNU.
68
70 memchr(3)
71
72
73
74Linux man-pages 6.05 2023-07-20 ffs(3)