Debian Codegraph @

upstream/debian-unstable/man3/ffs.3

raw
1 '\" t
2 .\" Copyright 1993, David Metcalfe <[email protected]>
3 .\" Copyright, the authors of the Linux man-pages project
4 .\"
5 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\"
7 .TH ffs 3 2026-02-08 "Linux man-pages 6.18"
8 .SH NAME
9 ffs, ffsl, ffsll \- find first bit set in a word
10 .SH LIBRARY
11 Standard C library
12 .RI ( libc ,\~ \-lc )
13 .SH SYNOPSIS
14 .nf
15 .B #include <strings.h>
16 .P
17 .BI "int ffs(int " i );
18 .BI "int ffsl(long " i );
19 .BI "int ffsll(long long " i );
20 .fi
21 .P
22 .RS -4
23 Feature Test Macro Requirements for glibc (see
24 .BR feature_test_macros (7)):
25 .RE
26 .P
27 .BR ffs ():
28 .nf
29 Since glibc 2.12:
30 _XOPEN_SOURCE >= 700
31 || ! (_POSIX_C_SOURCE >= 200809L)
32 || /* glibc >= 2.19: */ _DEFAULT_SOURCE
33 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
34 Before glibc 2.12:
35 none
36 .fi
37 .P
38 .BR ffsl (),
39 .BR ffsll ():
40 .nf
41 Since glibc 2.27:
42 .\" glibc commit 68fe16dd327c895c08b9ee443b234c49c13b36e9
43 _DEFAULT_SOURCE
44 Before glibc 2.27:
45 _GNU_SOURCE
46 .fi
47 .SH DESCRIPTION
48 The
49 .BR ffs ()
50 function returns the position of the first
51 (least significant) bit set in the word
52 .IR i .
53 The least significant bit is position 1 and the
54 most significant position is, for example, 32 or 64.
55 The functions
56 .BR ffsll ()
57 and
58 .BR ffsl ()
59 do the same but take
60 arguments of possibly different size.
61 .SH RETURN VALUE
62 These functions return the position of the first bit set,
63 or 0 if no bits are set in
64 .IR i .
65 .SH ATTRIBUTES
66 For an explanation of the terms used in this section, see
67 .BR attributes (7).
68 .TS
69 allbox;
70 lbx lb lb
71 l l l.
72 Interface Attribute Value
73 T{
74 .na
75 .nh
76 .BR ffs (),
77 .BR ffsl (),
78 .BR ffsll ()
79 T} Thread safety MT-Safe
80 .TE
81 .SH STANDARDS
82 .TP
83 .BR ffs ()
84 POSIX.1-2001, POSIX.1-2008, 4.3BSD.
85 .TP
86 .BR ffsl ()
87 .TQ
88 .BR ffsll ()
89 GNU.
90 .SH SEE ALSO
91 .BR memchr (3)