checkasm 1.0.1
Assembly testing and benchmarking framework
Loading...
Searching...
No Matches
Memory Initialization

Functions for filling buffers with various patterns of data. More...

Macros

#define CLEAR_BUF(buf)
 Clear a fixed size buffer (convenience macro).
#define RANDOMIZE_BUF(buf)
 Fill a fixed size buffer wth random data (convenience macro).
#define INITIALIZE_BUF(buf)
 Fill a fixed size buffer with pathological test data (convenience macro).

Functions

CHECKASM_API void checkasm_randomize (void *buf, size_t bytes)
 Fill a buffer with uniformly chosen random bytes.
CHECKASM_API void checkasm_randomize_mask8 (uint8_t *buf, int width, uint8_t mask)
 Fill a uint8_t buffer with random values chosen uniformly within a mask.
CHECKASM_API void checkasm_randomize_mask16 (uint16_t *buf, int width, uint16_t mask)
 Fill a uint16_t buffer with random values chosen uniformly within a mask.
CHECKASM_API void checkasm_randomize_range (double *buf, int width, double range)
 Fill a double buffer with random values chosen uniformly below a limit.
CHECKASM_API void checkasm_randomize_rangef (float *buf, int width, float range)
 Fill a float buffer with random values chosen uniformly below a limit.
CHECKASM_API void checkasm_randomize_dist (double *buf, int width, CheckasmDist dist)
 Fill a double buffer with normally distributed random values.
CHECKASM_API void checkasm_randomize_distf (float *buf, int width, CheckasmDist dist)
 Fill a float buffer with normally distributed random values.
CHECKASM_API void checkasm_randomize_norm (double *buf, int width)
 Fill a double buffer with values from a standard normal distribution.
CHECKASM_API void checkasm_randomize_normf (float *buf, int width)
 Fill a float buffer with values from a standard normal distribution.
CHECKASM_API void checkasm_clear (void *buf, size_t bytes)
 Clear a buffer to a pre-determined pattern (currently 0xAA).
CHECKASM_API void checkasm_clear8 (uint8_t *buf, int width, uint8_t val)
 Fill a uint8_t buffer with a constant value.
CHECKASM_API void checkasm_clear16 (uint16_t *buf, int width, uint16_t val)
 Fill a uint16_t buffer with a constant value.
CHECKASM_API void checkasm_init (void *buf, size_t bytes)
 Initialize a buffer with pathological test patterns.
CHECKASM_API void checkasm_init_mask8 (uint8_t *buf, int width, uint8_t mask)
 Initialize a uint8_t buffer with pathological values within a mask.
CHECKASM_API void checkasm_init_mask16 (uint16_t *buf, int width, uint16_t mask)
 Initialize a uint16_t buffer with pathological values within a mask.

Detailed Description

Functions for filling buffers with various patterns of data.

A collection of functions to initialize memory buffers with random data, constant values, or pathological test patterns. These are useful for setting up input/output data buffers for checkasm tests.

Macro Definition Documentation

◆ CLEAR_BUF

#define CLEAR_BUF ( buf)
Value:
checkasm_clear(buf, sizeof(buf))
CHECKASM_API void checkasm_clear(void *buf, size_t bytes)
Clear a buffer to a pre-determined pattern (currently 0xAA).

Clear a fixed size buffer (convenience macro).

Parameters
bufFixed-size buffer array to clear

◆ INITIALIZE_BUF

#define INITIALIZE_BUF ( buf)
Value:
checkasm_init(buf, sizeof(buf))
CHECKASM_API void checkasm_init(void *buf, size_t bytes)
Initialize a buffer with pathological test patterns.

Fill a fixed size buffer with pathological test data (convenience macro).

Parameters
bufFixed-size buffer array to initialize
See also
checkasm_init()

◆ RANDOMIZE_BUF

#define RANDOMIZE_BUF ( buf)
Value:
checkasm_randomize(buf, sizeof(buf))
CHECKASM_API void checkasm_randomize(void *buf, size_t bytes)
Fill a buffer with uniformly chosen random bytes.

Fill a fixed size buffer wth random data (convenience macro).

Parameters
bufFixed-size buffer array to randomize

Function Documentation

◆ checkasm_clear()

CHECKASM_API void checkasm_clear ( void * buf,
size_t bytes )

Clear a buffer to a pre-determined pattern (currently 0xAA).

Parameters
[out]bufBuffer to clear
[in]bytesNumber of bytes to clear

◆ checkasm_clear16()

CHECKASM_API void checkasm_clear16 ( uint16_t * buf,
int width,
uint16_t val )

Fill a uint16_t buffer with a constant value.

Parameters
[out]bufBuffer to fill
[in]widthNumber of elements to set
[in]valValue to write to each element

◆ checkasm_clear8()

CHECKASM_API void checkasm_clear8 ( uint8_t * buf,
int width,
uint8_t val )

Fill a uint8_t buffer with a constant value.

Parameters
[out]bufBuffer to fill
[in]widthNumber of elements to set
[in]valValue to write to each element
Note
This is functionally equivalent to memset(), and merely provided for consistency.

◆ checkasm_init()

CHECKASM_API void checkasm_init ( void * buf,
size_t bytes )

Initialize a buffer with pathological test patterns.

Fills a buffer with a random mixture of edge cases, test patterns, and random data designed to trigger potential bugs. The exact pattern depends on the random seed and may include a mix of low values, high values, alternating bits, random bytes, and so on.

Parameters
[out]bufBuffer to initialize
[in]bytesNumber of bytes to initialize

◆ checkasm_init_mask16()

CHECKASM_API void checkasm_init_mask16 ( uint16_t * buf,
int width,
uint16_t mask )

Initialize a uint16_t buffer with pathological values within a mask.

Parameters
[out]bufBuffer to initialize
[in]widthNumber of elements to initialize
[in]maskBit mask to apply to values
See also
checkasm_init()

◆ checkasm_init_mask8()

CHECKASM_API void checkasm_init_mask8 ( uint8_t * buf,
int width,
uint8_t mask )

Initialize a uint8_t buffer with pathological values within a mask.

Parameters
[out]bufBuffer to initialize
[in]widthNumber of elements to initialize
[in]maskBit mask to apply to values
See also
checkasm_init()

◆ checkasm_randomize()

CHECKASM_API void checkasm_randomize ( void * buf,
size_t bytes )

Fill a buffer with uniformly chosen random bytes.

Parameters
[out]bufBuffer to fill
[in]bytesNumber of bytes to randomize

◆ checkasm_randomize_dist()

CHECKASM_API void checkasm_randomize_dist ( double * buf,
int width,
CheckasmDist dist )

Fill a double buffer with normally distributed random values.

Parameters
[out]bufBuffer to fill
[in]widthNumber of elements to randomize
[in]distDistribution parameters (mean and standard deviation)

◆ checkasm_randomize_distf()

CHECKASM_API void checkasm_randomize_distf ( float * buf,
int width,
CheckasmDist dist )

Fill a float buffer with normally distributed random values.

Parameters
[out]bufBuffer to fill
[in]widthNumber of elements to randomize
[in]distDistribution parameters (mean and standard deviation)

◆ checkasm_randomize_mask16()

CHECKASM_API void checkasm_randomize_mask16 ( uint16_t * buf,
int width,
uint16_t mask )

Fill a uint16_t buffer with random values chosen uniformly within a mask.

Parameters
[out]bufBuffer to fill
[in]widthNumber of elements to randomize
[in]maskBit mask to apply to each random value

◆ checkasm_randomize_mask8()

CHECKASM_API void checkasm_randomize_mask8 ( uint8_t * buf,
int width,
uint8_t mask )

Fill a uint8_t buffer with random values chosen uniformly within a mask.

Parameters
[out]bufBuffer to fill
[in]widthNumber of elements to randomize
[in]maskBit mask to apply to each random value

◆ checkasm_randomize_norm()

CHECKASM_API void checkasm_randomize_norm ( double * buf,
int width )

Fill a double buffer with values from a standard normal distribution.

Parameters
[out]bufBuffer to fill
[in]widthNumber of elements to randomize

◆ checkasm_randomize_normf()

CHECKASM_API void checkasm_randomize_normf ( float * buf,
int width )

Fill a float buffer with values from a standard normal distribution.

Parameters
[out]bufBuffer to fill
[in]widthNumber of elements to randomize

◆ checkasm_randomize_range()

CHECKASM_API void checkasm_randomize_range ( double * buf,
int width,
double range )

Fill a double buffer with random values chosen uniformly below a limit.

Parameters
[out]bufBuffer to fill
[in]widthNumber of elements to randomize
[in]rangeExclusive upper bound on value (range is [0, range))

◆ checkasm_randomize_rangef()

CHECKASM_API void checkasm_randomize_rangef ( float * buf,
int width,
float range )

Fill a float buffer with random values chosen uniformly below a limit.

Parameters
[out]bufBuffer to fill
[in]widthNumber of elements to randomize
[in]rangeExclusive upper bound on value (range is [0, range))