OSDN Git Service

37413fd6fb5cc1ebc3a20a3cec381adb272dc79c
[linuxjm/LDP_man-pages.git] / original / man3 / ffs.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\" Modified Sat Jul 24 19:39:35 1993 by Rik Faith (faith@cs.unc.edu)
30 .\"
31 .\" Modified 2003 Walter Harms (walter.harms@informatik.uni-oldenburg.de)
32 .\"
33 .TH FFS 3 2014-04-14 "GNU" "Linux Programmer's Manual"
34 .SH NAME
35 ffs, ffsl, ffsll \- find first bit set in a word
36 .SH SYNOPSIS
37 .nf
38 .B #include <strings.h>
39 .sp
40 .BI "int ffs(int " i );
41 .sp
42 .B #include <string.h>
43 .sp
44 .BI "int ffsl(long int " i );
45 .sp
46 .BI "int ffsll(long long int " i );
47 .fi
48 .sp
49 .in -4n
50 Feature Test Macro Requirements for glibc (see
51 .BR feature_test_macros (7)):
52 .in
53 .PD 0
54 .ad l
55 .sp
56 .BR ffs ():
57 .RS 4
58 .TP 4
59 Since glibc 2.12:
60 _SVID_SOURCE || _BSD_SOURCE ||
61 _POSIX_C_SOURCE\ >=\ 200809L || _XOPEN_SOURCE\ >=\ 700 ||
62 .TP
63 Before glibc 2.12:
64 none
65 .RE
66 .PP
67 .BR ffsl (),
68 .BR ffsll ():
69 .RS 4
70 _GNU_SOURCE
71 .RE
72 .ad
73 .PD
74 .SH DESCRIPTION
75 The
76 .BR ffs ()
77 function returns the position of the first
78 (least significant) bit set in the word \fIi\fP.
79 The least significant bit is position 1 and the
80 most significant position is, for example, 32 or 64.
81 The functions
82 .BR ffsll ()
83 and
84 .BR ffsl ()
85 do the same but take
86 arguments of possibly different size.
87 .SH RETURN VALUE
88 These functions return the position of the first bit set,
89 or 0 if no bits are set in
90 .IR i .
91 .SH ATTRIBUTES
92 .SS Multithreading (see pthreads(7))
93 The
94 .BR ffs (),
95 .BR ffsl (),
96 and
97 .BR ffsll ()
98 functions are thread-safe.
99 .SH CONFORMING TO
100 .BR ffs ():
101 4.3BSD, POSIX.1-2001.
102
103 The
104 .BR ffsl ()
105 and
106 .BR ffsll ()
107 functions are glibc extensions.
108 .SH NOTES
109 BSD systems have a prototype in
110 .IR <string.h> .
111 .SH SEE ALSO
112 .BR memchr (3)
113 .SH COLOPHON
114 This page is part of release 3.67 of the Linux
115 .I man-pages
116 project.
117 A description of the project,
118 information about reporting bugs,
119 and the latest version of this page,
120 can be found at
121 \%http://www.kernel.org/doc/man\-pages/.