stdbit3
Bit and byte utilities
Usage
Standard C Library (libc, -lc)
#include <stdbit.h>
#define __STDC_ENDIAN_LITTLE__
#define __STDC_ENDIAN_BIG__
#define __STDC_ENDIAN_NATIVE__
unsigned int
stdc_count_leading_zeros(value);
unsigned int
stdc_count_leading_ones(value);
unsigned int
stdc_count_trailing_zeros(value);
unsigned int
stdc_count_trailing_ones(value);
unsigned int
stdc_first_leading_zero(value);
unsigned int
stdc_first_leading_one(value);
unsigned int
stdc_first_trailing_zero(value);
unsigned int
stdc_first_trailing_one(value);
unsigned int
stdc_count_zeros(value);
unsigned int
stdc_count_ones(value);
bool
stdc_has_single_bit(value);
unsigned int
stdc_bit_width(value);
typeof Ns Pq Em value
stdc_bit_floor(value);
typeof Ns Pq Em value
stdc_bit_ceil(value);
Overview
The __STDC_ENDIAN_NATIVE__ macro describes the byte order or endianness of the machine for which the program is built. If the machine has big-endian byte order, this macro is equal to __STDC_ENDIAN_BIG__. If the machine has little-endian byte order, this macro is equal to __STDC_ENDIAN_LITTLE__. Otherwise, the macro has a value that is equal to neither.
The bit and byte utility functions analyze the bits within a datum. Each function func is provided in five variants stdc_func_type(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. Additionally, for each func, a type-generic macro stdc_func(value) that picks the appropriate function stdc_func_type(value) based on the type of value is provided.
Releases
2 releases since FreeBSD 15.1-RELEASE; the text changed 1 time.