summaryrefslogtreecommitdiff
path: root/lib/libc/stdbit/stdc_first_trailing_zero.3
blob: bc4f7982d7650034a9d17cd5139fe12eaa519e81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
.\"
.\" Copyright (c) 2025 Robert Clausecker <fuz@FreeBSD.org>
.\"
.\" SPDX-License-Identifier: BSD-2-Clause
.\"
.Dd November 9, 2025
.Dt STDC_FIRST_TRAILING_ZERO 3
.Os
.Sh NAME
.Nm stdc_first_trailing_zero
.Nd find the first trailing zero in an integer
.Sh SYNOPSIS
.Lb libc
.In stdbit.h
.Ft unsigned int
.Fn stdc_first_trailing_zero_uc "unsigned char value"
.Ft unsigned int
.Fn stdc_first_trailing_zero_us "unsigned short value"
.Ft unsigned int
.Fn stdc_first_trailing_zero_ui "unsigned int value"
.Ft unsigned int
.Fn stdc_first_trailing_zero_ul "unsigned long value"
.Ft unsigned int
.Fn stdc_first_trailing_zero_ull "unsigned long long value"
.Ft unsigned int
.Fn stdc_first_trailing_zero "value"
.Sh DESCRIPTION
The
.Nm stdc_first_trailing_zero_ Ns Em type Ns ()
family of functions returns the index of the least significant clear bit in
.Fa value ,
where 
.Fa value
is of type
.Va unsigned char ,
.Va unsigned short ,
.Va unsigned int ,
.Va unsigned long ,
or
.Va unsigned long long
for
.Em type
being
.Sy uc ,
.Sy us ,
.Sy ui ,
.Sy ul ,
or
.Sy ull
respectively.
The
.Fn stdc_first_trailing_zero "value"
type-generic macro picks the appropriate
.Nm stdc_first_trailing_zero_ Ns Em type Ns ()
function based on the type of
.Fa value .
.Sh RETURN VALUES
Returns the index of the least significant clear bit in
.Fa value .
The bits are numbered such that the least significant bit has number\~1,
and the most significant bit has number
.Ms w
where
.Ms w
is the number of bits in the type of
.Fa value .
If no bits are clear in
.Fa value
(i.\^e.\&
.Fa value
is the bitwise complement of zero), zero is returned.
.Sh SEE ALSO
.Xr bit_ffc 3 ,
.Xr stdbit 3 ,
.Xr stdc_trailing_ones 3 ,
.Xr stdc_first_trailing_ones 3 ,
.Xr stdc_first_leading_zero 3
.Sh STANDARDS
The
.Nm stdc_first_trailing_zero_ Ns Em type Ns ()
family of functions and the
.Fn stdc_first_trailing_zero
type-generic macro conform to
.St -isoC-2023 .
.Sh HISTORY
The
.Nm stdc_first_trailing_zero_ Ns Em type Ns ()
family of functions and the
.Fn stdc_first_trailing_zero
type-generic macro were added in
.Fx 15.1.
.Sh AUTHOR
.An Robert Clausecker Aq Mt fuz@FreeBSD.org