CLZ/CTZ C implementation.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | clz(x) compiler_demux_size(sizeof(x), clz, (x)) |
Count leading zeros in unsigned integer. More... | |
#define | ctz(x) compiler_demux_size(sizeof(x), ctz, (x)) |
Count trailing zeros in unsigned integer. More... | |
Functions | |
static __always_inline uint8_t | clz16 (uint16_t x) |
Count leading zeros in unsigned, 16-bit integer. More... | |
static __always_inline uint8_t | clz32 (uint32_t x) |
Count leading zeros in unsigned, 32-bit integer. More... | |
static __always_inline uint8_t | clz8 (uint8_t x) |
Count leading zeros in unsigned, 8-bit integer. More... | |
static __always_inline uint8_t | ctz16 (uint16_t x) |
Count trailing zeros in unsigned, 16-bit integer. More... | |
static __always_inline uint8_t | ctz32 (uint32_t x) |
Count trailing zeros in unsigned, 32-bit integer. More... | |
static __always_inline uint8_t | ctz8 (uint8_t x) |
Count trailing zeros in unsigned, 8-bit integer. More... | |
#define clz | ( | x | ) | compiler_demux_size(sizeof(x), clz, (x)) |
Count leading zeros in unsigned integer.
This macro takes unsigned integers of any size, and evaluates to a call to the clz-function for its size. These functions count the number of zeros, starting with the MSB, before a one occurs in the integer.
x | Unsigned integer to count the leading zeros in. |
Referenced by ilog2().
#define ctz | ( | x | ) | compiler_demux_size(sizeof(x), ctz, (x)) |
Count trailing zeros in unsigned integer.
This macro takes unsigned integers of any size, and evaluates to a call to the ctz-function for its size. These functions count the number of zeros, starting with the LSB, before a one occurs in the integer.
x | Unsigned integer to count the trailing zeros in. |
|
static |
|
static |
Count leading zeros in unsigned, 32-bit integer.
x | Unsigned double word to count the leading zeros in. |
References clz16().
|
static |
Count leading zeros in unsigned, 8-bit integer.
x | Unsigned byte to count the leading zeros in. |
Referenced by clz16().
|
static |
|
static |
Count trailing zeros in unsigned, 32-bit integer.
x | Unsigned double word to count the trailing zeros in. |
References ctz16().
|
static |
Count trailing zeros in unsigned, 8-bit integer.
x | Unsigned byte to count the trailing zeros in. |
Referenced by ctz16().