STDC_HAS_SINGLE_BIT(9F) Kernel Functions for Drivers STDC_HAS_SINGLE_BIT(9F)

NAME


stdc_has_single_bit, stdc_has_single_bit_uc, stdc_has_single_bit_us,
stdc_has_single_bit_ui, stdc_has_single_bit_ul, stdc_has_single_bit_ull -
determine if only one bit is set

SYNOPSIS


#include <sys/stdbit.h>

bool
stdc_has_single_bit(generic_value_type value);

bool
stdc_has_single_bit_uc(unsigned char value);

bool
stdc_has_single_bit_us(unsigned short value);

bool
stdc_has_single_bit_ui(unsigned int value);

bool
stdc_has_single_bit_ul(unsigned long value);

bool
stdc_has_single_bit_ull(unsigned long long value);

DESCRIPTION


The stdc_has_single_bit() family of functions determines whether the value
has only a single bit set. value. The function returns true if there is
exactly one bit whose value is set to one in value.

The stdc_has_single_bit() function is generic and will operate on all 8,
16, 32, and 64-bit unsigned integers; however, it is only available in C23.
The other functions all operate on a specific integer type, but otherwise
behave the same and are available regardless of the C language version.

CONTEXT


These functions may be called from user, kernel, or interrupt context.

RETURN VALUES


The functions in the stdc_has_single_bit() family return true if exactly
one bit is set in value. Otherwise, false is returned. These functions
cannot fail.

INTERFACE STABILITY


Committed

SEE ALSO


stdc_has_single_bit(3C), stdc_bit_ceil(9F), stdc_bit_floor(9F),
stdc_bit_width(9F), stdc_count_ones(9F), stdc_count_zeros(9F),
stdc_first_leading_one(9F), stdc_first_leading_zero(9F),
stdc_first_trailing_one(9F), stdc_first_trailing_zero(9F),
stdc_leading_ones(9F), stdc_leading_zeros(9F), stdc_trailing_ones(9F),
stdc_trailing_zeros(9F)

illumos October 27, 2024 illumos