Memory-aligned list management functions. More...
#include "common.h"
Go to the source code of this file.
Data Structures | |
struct | qsc_list_state |
Contains the list context state. More... | |
Macros | |
#define | QSC_LIST_ALIGNMENT 64ULL |
The internal memory alignment constant. | |
#define | QSC_LIST_MAX_DEPTH 102400ULL |
The maximum list depth. | |
Functions | |
QSC_EXPORT_API void | qsc_list_add (qsc_list_state *ctx, void *item) |
Add an item to the list. | |
QSC_EXPORT_API void | qsc_list_copy (const qsc_list_state *ctx, size_t index, void *item) |
Copy an item from the list. | |
QSC_EXPORT_API size_t | qsc_list_count (const qsc_list_state *ctx) |
Get the number of items in the list. | |
QSC_EXPORT_API void | qsc_list_deserialize (qsc_list_state *ctx, const uint8_t *input) |
Convert a serialized list into a list context. | |
QSC_EXPORT_API void | qsc_list_dispose (qsc_list_state *ctx) |
Dispose of the list state. | |
QSC_EXPORT_API void | qsc_list_initialize (qsc_list_state *ctx, size_t width) |
Initialize the list state. | |
QSC_EXPORT_API bool | qsc_list_empty (const qsc_list_state *ctx) |
Check if the list is empty. | |
QSC_EXPORT_API bool | qsc_list_full (const qsc_list_state *ctx) |
Check if the list is full. | |
QSC_EXPORT_API void | qsc_list_item (const qsc_list_state *ctx, uint8_t *item, size_t index) |
Retrieve a pointer to a list item. | |
QSC_EXPORT_API void | qsc_list_rshuffle (qsc_list_state *ctx) |
Randomly shuffle the items in the list. | |
QSC_EXPORT_API void | qsc_list_remove (qsc_list_state *ctx, size_t index) |
Remove an item from the list. | |
QSC_EXPORT_API size_t | qsc_list_serialize (uint8_t *output, const qsc_list_state *ctx) |
Serialize the list into a byte array. | |
QSC_EXPORT_API size_t | qsc_list_size (const qsc_list_state *ctx) |
Get the serialized size of the list. | |
QSC_EXPORT_API void | qsc_list_sort (qsc_list_state *ctx) |
Sort the items in the list. | |
Memory-aligned list management functions.
This header defines the public API for managing a memory-aligned list data structure. The list is designed to store items in a contiguous memory block with a specified width (in bytes), ensuring proper alignment for performance-critical operations and compatibility with SIMD instructions.
The module provides functions to:
This design is ideal for cryptographic and high-performance applications where data alignment is crucial for optimal hardware utilization.
Intel 64 and IA-32 Architectures Software Developer's Manual GCC Data Alignment Documentation
QSC_EXPORT_API void qsc_list_add | ( | qsc_list_state * | ctx, |
void * | item ) |
Add an item to the list.
ctx | [qsc_list_state*] Pointer to the list state structure. |
item | [void*] Pointer to the item to be added. |
QSC_EXPORT_API void qsc_list_copy | ( | const qsc_list_state * | ctx, |
size_t | index, | ||
void * | item ) |
Copy an item from the list.
ctx | [const qsc_list_state*] Pointer to the list state structure. |
index | [size_t] The index number of the list item. |
item | [void*] Pointer to the memory that receives the copy. |
QSC_EXPORT_API size_t qsc_list_count | ( | const qsc_list_state * | ctx | ) |
Get the number of items in the list.
ctx | [const qsc_list_state*] Pointer to the list state structure. |
QSC_EXPORT_API void qsc_list_deserialize | ( | qsc_list_state * | ctx, |
const uint8_t * | input ) |
Convert a serialized list into a list context.
ctx | [qsc_list_state*] Pointer to the list state structure. |
input | [const uint8_t*] Pointer to the serialized list. |
QSC_EXPORT_API void qsc_list_dispose | ( | qsc_list_state * | ctx | ) |
Dispose of the list state.
ctx | [qsc_list_state*] Pointer to the list state structure. |
QSC_EXPORT_API bool qsc_list_empty | ( | const qsc_list_state * | ctx | ) |
Check if the list is empty.
ctx | [const qsc_list_state*] Pointer to the list state structure. |
QSC_EXPORT_API bool qsc_list_full | ( | const qsc_list_state * | ctx | ) |
Check if the list is full.
ctx | [const qsc_list_state*] Pointer to the list state structure. |
QSC_EXPORT_API void qsc_list_initialize | ( | qsc_list_state * | ctx, |
size_t | width ) |
Initialize the list state.
ctx | [qsc_list_state*] Pointer to the list state structure. |
width | [size_t] The maximum size of each list item in bytes. |
QSC_EXPORT_API void qsc_list_item | ( | const qsc_list_state * | ctx, |
uint8_t * | item, | ||
size_t | index ) |
Retrieve a pointer to a list item.
ctx | [const qsc_list_state*] Pointer to the list state structure. |
item | [uint8_t*] Pointer to the buffer that receives the item. |
index | [size_t] The index of the list item. |
QSC_EXPORT_API void qsc_list_remove | ( | qsc_list_state * | ctx, |
size_t | index ) |
Remove an item from the list.
ctx | [qsc_list_state*] Pointer to the list state structure. |
index | [size_t] The index number of the item to remove. |
QSC_EXPORT_API void qsc_list_rshuffle | ( | qsc_list_state * | ctx | ) |
Randomly shuffle the items in the list.
ctx | [qsc_list_state*] Pointer to the list state structure. |
QSC_EXPORT_API size_t qsc_list_serialize | ( | uint8_t * | output, |
const qsc_list_state * | ctx ) |
Serialize the list into a byte array.
output | [uint8_t*] Pointer to the output serialized array. |
ctx | [const qsc_list_state*] Pointer to the list state structure. |
QSC_EXPORT_API size_t qsc_list_size | ( | const qsc_list_state * | ctx | ) |
Get the serialized size of the list.
ctx | [const qsc_list_state*] Pointer to the list state structure. |
QSC_EXPORT_API void qsc_list_sort | ( | qsc_list_state * | ctx | ) |
Sort the items in the list.
ctx | [qsc_list_state*] Pointer to the list state structure. |