|
ZXC 0.15.0
High-performance asymmetric lossless compression library
|
Single point of override for the C-library dependencies of libzxc. More...
#include <assert.h>#include <limits.h>#include <stdint.h>#include <stdlib.h>#include <string.h>Go to the source code of this file.
Macros | |
Heap Allocator Abstraction | |
Macros around the libc allocators so non-libc targets (Linux kernel, embedded freestanding builds, custom arenas) can override them via
| |
| #define | ZXC_MALLOC(size) malloc(size) |
| Heap allocator. | |
| #define | ZXC_CALLOC(nmemb, size) calloc(nmemb, size) |
| Zero-initialised heap allocator. | |
| #define | ZXC_REALLOC(ptr, size) realloc(ptr, size) |
| In-place / move heap reallocator. | |
| #define | ZXC_FREE(ptr) free(ptr) |
| Heap deallocator. | |
Aligned Allocator Abstraction | |
Macros around the cache-line-aligned allocator used for compression workspace and per-context scratch buffers. The default is the pair defined below, wrapping Kernel builds align by hand over the slab allocator (see contrib/linux-kernel): | |
| #define | ZXC_ALIGNED_MALLOC(size, alignment) zxc_aligned_malloc(size, alignment) |
| Cache-line-aligned allocator. | |
| #define | ZXC_ALIGNED_FREE(ptr) zxc_aligned_free(ptr) |
| Counterpart deallocator for ZXC_ALIGNED_MALLOC. | |
| static void * | zxc_aligned_malloc (const size_t size, const size_t alignment) |
| Default cache-line-aligned allocator; release with zxc_aligned_free. | |
| static void | zxc_aligned_free (void *ptr) |
| Counterpart of zxc_aligned_malloc; NULL is a no-op. | |
Population Count | |
Default: the builtins, libgcc calls without a hardware count; a kernel maps them onto | |
| #define | ZXC_POPCOUNT32(v) zxc_popcount32(v) |
| #define | ZXC_POPCOUNT64(v) zxc_popcount64(v) |
| static int | zxc_popcount32 (const uint32_t v) |
| Portable SWAR popcount (MSVC). | |
| static int | zxc_popcount64 (const uint64_t v) |
Single point of override for the C-library dependencies of libzxc.
The core compression/decompression code only ever reaches the standard library through the macros and headers declared here. Freestanding consumers vendor the source tree and replace this file with an environment-specific version that maps the same macros onto their own allocator, sort, and basic header set.
<assert.h>, <limits.h>, <stdint.h>, <stdlib.h>, <string.h> and expands the macros to their libc equivalents.Per-symbol -D overrides are also accepted (each macro is guarded by an ifndef, the aligned pair as one), so vendoring is optional for ad-hoc consumers.
Definition in file zxc_deps.h.