MMgr v2.3.0
Zero-heap memory manager in C11. One borrowed buffer, carved by asserted offset.
Loading...
Searching...
No Matches
clz — leading zero count

Data Structures

struct  ClzCfg
 Argument for both clz calls: the value to count zeros in. More...
struct  ClzNs
 Type of the clz dispatch table. More...

Functions

EMBED_HOST_DEVICE embed_iword mmgr_clz_lead (const ClzCfg *args)
 Counts the zero bits above the highest set bit of args->val.
EMBED_HOST_DEVICE embed_iword mmgr_clz_trail (const ClzCfg *args)
 Counts the zero bits below the lowest set bit of args->val.

Variables

static const ClzNs clz
 Dispatch table instance named clz, with each member set to its mmgr_clz_ function.

Detailed Description

Function Documentation

◆ mmgr_clz_lead()

EMBED_HOST_DEVICE embed_iword mmgr_clz_lead ( const ClzCfg * args)

Counts the zero bits above the highest set bit of args->val.

Parameters
[in]argsValue to measure [BORROWS].
Returns
Leading zero count, 0 through 63.
Note
Runs in a fixed number of steps, none of which branches on the value.
Warning
An args->val of 0 returns 63, the same answer as an args->val of 1.

References mmgr_clz_lead().

Referenced by mmgr_clz_lead().

◆ mmgr_clz_trail()

EMBED_HOST_DEVICE embed_iword mmgr_clz_trail ( const ClzCfg * args)

Counts the zero bits below the lowest set bit of args->val.

Parameters
[in]argsValue to measure [BORROWS].
Returns
Trailing zero count, 0 through 63.
Note
Runs in a fixed number of steps, none of which branches on the value.
Warning
An args->val of 0 returns 63, the same answer as an args->val of 2^63.

References mmgr_clz_trail().

Referenced by mmgr_clz_trail().

Variable Documentation

◆ clz

const ClzNs clz
static

Dispatch table instance named clz, with each member set to its mmgr_clz_ function.

Definition at line 76 of file clz.h.