stdc_first_trailing_one3
Find the first trailing one in an integer
Usage
Standard C Library (libc, -lc)
#include <stdbit.h>
unsigned int
stdc_first_trailing_one_uc(unsigned char value);
unsigned int
stdc_first_trailing_one_us(unsigned short value);
unsigned int
stdc_first_trailing_one_ui(unsigned int value);
unsigned int
stdc_first_trailing_one_ul(unsigned long value);
unsigned int
stdc_first_trailing_one_ull(unsigned long long value);
unsigned int
stdc_first_trailing_one(value);
Overview
The stdc_first_trailing_one_type() family of functions returns the index of the least significant set bit in value, where value is of type unsigned char, unsigned short, unsigned int, unsigned long, or unsigned long long for type being uc, us, ui, ul, or ull respectively. The stdc_first_trailing_one(value) type-generic macro picks the appropriate stdc_first_trailing_one_type() function based on the type of value.
Functions stdc_first_trailing_one_ui(), stdc_first_trailing_one_ul(), and stdc_first_trailing_one_ull() are identical to 4.3BSD functions ffs(3), ffsl(3), and ffsll(3) respectively, except for operating on unsigned instead of signed values.
Return values
Returns the index of the least significant set bit in value. The bits are numbered such that the least significant bit has number 1, and the most significant bit has number w where w is the number of bits in the type of value. If no bits are set in value (i.e. value is zero), one is returned.
Releases
2 releases since FreeBSD 15.1-RELEASE; the text changed 1 time.