STDBIT.H(3HEAD) Headers STDBIT.H(3HEAD)

stdbit.hbit and byte utilities

#include <stdbit.h>

The <stdbit.h> header provides support for C23 bit and byte utilities.

The <stdbit.h> header provides the ability to determine the endian mode of the system through a series of preprocessor macros at compilation time. For more information and examples of how the endian ordering impacts data layout, see endian(7).

This macro is an integer that represents a little-endian byte order.
This macro is an integer that represents a big-endian byte order.
This macro will be defined to indicate the byte order of the system and generally be defined to either __STDC_ENDIAN_LITTLE__ or __STDC_ENDIAN_BIG__. While uncommon and not supported by illumos, if the system is neither little- or big-endian, then __STDC_ENDIAN_NATIVE__ will be defined to a different, platform-defined value.

This functionality is analogous to that found in endian.h(3HEAD), but unlike endian.h(3HEAD), this header is standardized and a part of C23.

The <stdbit.h> header makes available a number of different families of functions which operate on both fixed size integers and have generic forms. The generic forms require support for at least C23 to be requested, while the non-generic forms are always made available. These families are:

stdc_bit_ceil(3C)
Finds the smallest power of two that is equal to or larger than a given value.
stdc_bit_floor(3C)
Finds the largest power of two that is equal to or less than a given value.
stdc_bit_width(3C)
Determines the minimum number of bits required to store a given value.
stdc_count_ones(3C)
Counts the number of one bits in a value. This is sometimes called a population count.
stdc_count_zeros(3C)
Counts the number of zero bits in a value.
stdc_first_leading_one(3C)
Finds the first one bit starting from the most significant bit.
stdc_first_leading_zero(3C)
Finds the first zero bit starting from the most significant bit.
stdc_first_trailing_one(3C)
Finds the first one bit starting from the least significant bit. This is sometimes called find first set.
stdc_first_trailing_zero(3C)
Finds the first one zero starting from the least significant bit.
stdc_has_single_bit(3C)
Determines whether or not a value only has a single bit set.
stdc_leading_ones(3C)
Counts the number of consecutive one bits starting from the most significant bit.
stdc_leading_zeros(3C)
Counts the number of consecutive zero bits starting from the most significant bit.
stdc_trailing_ones(3C)
Counts the number of consecutive one bits starting from the least significant bit.
stdc_trailing_zeros(3C)
Counts the number of consecutive zero bits starting from the least significant bit.

This same functionality is made available to device drivers through <sys/stdbit.h>.

stdc_bit_ceil(3C), stdc_bit_floor(3C), stdc_bit_width(3C), stdc_count_ones(3C), stdc_count_zeros(3C), stdc_first_leading_one(3C), stdc_first_leading_zero(3C), stdc_first_trailing_one(3C), stdc_first_trailing_zero(3C), stdc_has_single_bit(3C), stdc_leading_ones(3C), stdc_leading_zeros(3C), stdc_trailing_ones(3C), stdc_trailing_zeros(3C), endian.h(3HEAD), endian(7)

October 17, 2024 OmniOS