ZXC 1.0.3
High-performance asymmetric lossless compression library
Loading...
Searching...
No Matches
zxc_dispatch.c File Reference

Runtime CPU feature detection and SIMD dispatch layer. More...

Go to the source code of this file.

Macros

#define ZXC_GLUE_IMPL(a, b)
#define ZXC_GLUE(a, b)
#define ZXC_DEC_SFX(sfx)
 Suffix of a role in the set of tier sfx.
#define ZXC_ENC_SFX(sfx)
#define ZXC_VARIANT_DICT(sfx)
#define ZXC_VARIANT_HUF(sfx)
#define ZXC_VARIANT_SET(sfx)
 Defines the constant variant set of tier sfx.
#define ZXC_STATIC_CCTX_HDR_SIZE   ZXC_ALIGN_CL(sizeof(struct zxc_cctx_s))
#define ZXC_STATIC_DCTX_HDR_SIZE   ZXC_ALIGN_CL(sizeof(struct zxc_dctx_s))

Typedefs

typedef int(* zxc_decompress_func_t) (const zxc_cctx_t *, const uint8_t *, const size_t, uint8_t *, const size_t, const uint64_t)
 Function pointer type for the chunk decompressor.
typedef int(* zxc_compress_func_t) (zxc_cctx_t *, const uint8_t *, const size_t, uint8_t *, const size_t, const uint64_t)
 Function pointer type for the chunk compressor.

Enumerations

enum  zxc_cpu_feature_t {
  ZXC_CPU_GENERIC = 0 , ZXC_CPU_AVX2 = 1 , ZXC_CPU_AVX512 = 2 , ZXC_CPU_NEON = 3 ,
  ZXC_CPU_SSE2 = 4
}
 Detected CPU SIMD capability level. More...

Functions

int zxc_decompress_chunk_wrapper_default (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index)
int zxc_decompress_chunk_wrapper_dict_default (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index)
int zxc_decompress_chunk_wrapper_safe_default (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index)
int zxc_compress_chunk_wrapper_default (zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index)
int zxc_huf_build_code_lengths_default (const uint32_t *freq, uint8_t *code_len, void *scratch, int max_code_len)
size_t zxc_huf_calc_size_default (const uint32_t *freq, const uint8_t *code_len, int with_header)
int zxc_huf_encode_section_default (const uint8_t *literals, size_t n_literals, const uint32_t *freq, const uint8_t *code_len, uint8_t *dst, size_t dst_cap)
int zxc_huf_decode_section_default (const uint8_t *payload, size_t payload_size, uint8_t *dst, size_t n, uint8_t *scratch)
int zxc_huf_encode_section_dict_default (const uint8_t *literals, size_t n_literals, const uint32_t *freq, const uint8_t *code_len, const zxc_pivco_tree_t *tree, const uint32_t *codes, uint8_t *dst, size_t dst_cap)
int zxc_huf_decode_section_dict_default (const uint8_t *payload, size_t payload_size, uint8_t *dst, size_t n, const zxc_pivco_tree_t *tree, uint8_t *scratch)
size_t zxc_huf_calc_size_dict_default (const uint32_t *freq, const uint8_t *code_len, const zxc_pivco_tree_t *tree)
void zxc_huf_pack_lengths_default (const uint8_t *code_len, uint8_t *out)
int zxc_huf_unpack_lengths_default (const uint8_t *in, uint8_t *code_len)
static zxc_cpu_feature_t zxc_detect_cpu_features (void)
 Probes the running CPU for SIMD support.
static const zxc_variant_set_t * zxc_select_variants (void)
 Detects the CPU tier and returns the matching variant set.
static const zxc_variant_set_t * zxc_variants_resolve (void)
 First call: selects and publishes.
static const zxc_variant_set_t * zxc_variants (void)
 The variant set in use, selected on the first call.
static zxc_decompress_func_t zxc_decompress_safe_resolve (void)
 First call: the _safe decoder of the selected set, published.
static zxc_decompress_func_t zxc_decompress_safe_variant (void)
 The _safe decoder in use, selected on the first call.
int zxc_decompress_chunk_wrapper (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index)
 Public decompression dispatcher.
static int zxc_decompress_chunk_wrapper_safe_public (const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index)
 Internal safe-decompression dispatcher (strict dst_capacity == uncompressed_size).
int zxc_compress_chunk_wrapper (zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index)
 Public compression dispatcher.
int zxc_huf_build_code_lengths (const uint32_t *freq, uint8_t *code_len, void *scratch, const int max_code_len)
 Build length-limited per-symbol Huffman code lengths from frequencies.
size_t zxc_huf_calc_size (const uint32_t *freq, const uint8_t *code_len, const int with_header)
 Un-suffixed forwarders for the PivCo section codec (tests, tools).
int zxc_huf_encode_section (const uint8_t *literals, const size_t n_literals, const uint32_t *freq, const uint8_t *code_len, uint8_t *dst, const size_t dst_cap)
 Encode a PivCo literal section (128-byte lengths header + payload).
int zxc_huf_decode_section (const uint8_t *payload, const size_t payload_size, uint8_t *dst, const size_t n, uint8_t *scratch)
 Decode a PivCo literal section into dst (exactly n bytes).
int zxc_huf_encode_section_dict (const uint8_t *literals, const size_t n_literals, const uint32_t *freq, const uint8_t *code_len, const zxc_pivco_tree_t *tree, const uint32_t *codes, uint8_t *dst, const size_t dst_cap)
 Encode a PivCo section against a prebuilt dict tree/codes (no header).
int zxc_huf_decode_section_dict (const uint8_t *payload, const size_t payload_size, uint8_t *dst, const size_t n, const zxc_pivco_tree_t *tree, uint8_t *scratch)
 Decode a PivCo dict section against a prebuilt dict tree.
size_t zxc_huf_calc_size_dict (const uint32_t *freq, const uint8_t *code_len, const zxc_pivco_tree_t *tree)
 zxc_huf_calc_size for a dict section: prebuilt tree, no header.
void zxc_huf_pack_lengths (const uint8_t *code_len, uint8_t *out)
 Pack per-symbol code lengths into the 128-byte nibble header.
int zxc_huf_unpack_lengths (const uint8_t *in, uint8_t *code_len)
 Unpack and validate a 128-byte packed lengths header.
static int64_t zxc_write_empty_frame (uint8_t *dst, const size_t dst_capacity, const size_t block_size, const int checksum_enabled, const int has_dict, const uint32_t did, const int seekable)
 Writes the whole archive an empty source produces: file header, EOF block, the empty seek table when seekable, then the footer.
static int64_t zxc_write_seek_table_from_blocks (uint8_t *dst, const size_t dst_capacity, const uint8_t *blocks, const uint8_t *const blocks_end, const uint64_t num_blocks, const int checksum_enabled)
 Writes the seek table of the num_blocks blocks in [blocks, blocks_end), sizes read back from their headers.
static int64_t zxc_decompress_oneshot (const uint8_t *src, size_t src_size, uint8_t *dst, size_t dst_capacity, const zxc_dparams_t *opts)
static int64_t zxc_dctx_decode_frame (zxc_dctx *dctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity, const zxc_dparams_t *opts, const int inplace, size_t *frame_end)
 The frame walk behind every buffer decode: zxc_decompress(), its no-destination probe, zxc_decompress_dctx() and both in-place entry points.
static int64_t zxc_dctx_decode_container (zxc_dctx *dctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity, const zxc_dparams_t *opts)
 The container walk behind zxc_decompress() and zxc_decompress_dctx().
static int zxc_buffer_frame_info (const uint8_t *src, const size_t src_size, zxc_frame_info_t *info, size_t *footer_len)
 Validates a frame without decoding it: the check of zxc_read_frame_info() on a whole buffer, header first.
static int64_t zxc_probe_without_dst (const uint8_t *src, const size_t src_size, const zxc_dparams_t *opts, const zxc_container_info_t *scanned)
 Answers a decode request that carries no destination.
static uint64_t zxc_inplace_margin (const uint64_t dsize, const size_t chunk_size, const int has_cs, const int has_seek, const size_t footer_len)
 Bytes an in-place decode needs on top of the decompressed size.
static int zxc_inplace_probe (const uint8_t *comp, const size_t comp_size, uint64_t *dsize, uint64_t *margin, uint64_t *floor)
 Shared archive probe for the in-place entry points: validates the magic + file header, then reads the footer's decompressed size and derives the in-place margin.
size_t zxc_decompress_inplace_bound (const void *src, const size_t src_size)
 Minimum single-buffer size for a safe in-place decode of src.
static int zxc_inplace_prepare (const void *buffer, const size_t buffer_capacity, const size_t comp_size, const uint8_t **comp)
 Argument and buffer checks shared by the in-place entry points.
uint64_t zxc_get_decompressed_size (const void *src, const size_t src_size)
 Reads the decompressed size from a ZXC-compressed buffer.
uint32_t zxc_get_dict_id (const void *src, const size_t src_size)
 Reads the dictionary id from a compressed archive's file header.
int zxc_requires_dict (const void *src, const size_t src_size)
 Tells whether an archive requires a dictionary, from its header.
int zxc_get_frame_info (const void *src, const size_t src_size, zxc_frame_info_t *info, const size_t info_size)
 Reads a frame's header and footer, without decoding.
int zxc_get_last_frame_info (const void *src, const size_t src_size, zxc_frame_info_t *info, const size_t info_size)
 Reads the frame that ends src, without decoding.
static int zxc_dict_copy_set (zxc_dict_copy_t *c, const void *dict, const size_t dict_size, const void *dict_huf)
 Replaces the copy with dict; a NULL or empty dict detaches.
static int zxc_ctx_sync_dict_huf (zxc_cctx_t *inner, uint8_t *cache, int *cached, const uint8_t *dict_huf)
 Attaches the shared literal table to inner; NULL detaches.
static zxc_cctx_opts_t zxc_cparams_resolve (const zxc_cparams_t *p)
 Per-call options of a context; its level and block size are always resolved and in range (setters, defaults, static init).
static zxc_cparams_t zxc_cparams_defaults (void)
 The parameters every public context starts from.
zxc_cctx * zxc_create_cctx (void)
 Creates a reusable compression context, every parameter at its default.
const zxc_cparams_t * zxc_cctx_params (const zxc_cctx *cctx)
 Parameters a public context carries, for the FILE* and push paths.
int zxc_cparam_bounds (const zxc_cparam_t param, int64_t *min, int64_t *max)
 Reports the accepted range of a compression parameter.
int zxc_cctx_set_param (zxc_cctx *cctx, const zxc_cparam_t param, const int64_t value)
 Sets one compression parameter.
int zxc_cctx_get_param (const zxc_cctx *cctx, const zxc_cparam_t param, int64_t *value)
 Reads one parameter of cctx.
int zxc_cctx_set_dict (zxc_cctx *cctx, const void *dict, const size_t dict_size, const void *dict_huf)
 Attaches a pre-trained dictionary to cctx; a NULL dict detaches.
int zxc_cctx_set_progress (zxc_cctx *cctx, const zxc_progress_callback_t cb, void *user_data)
 Sets the progress callback; NULL cb disables it.
int zxc_cctx_reset (zxc_cctx *cctx)
 Restores every parameter to its default, detaches the dictionary and the callback.
void zxc_free_cctx (zxc_cctx *cctx)
 Releases a reusable compression context.
static int64_t zxc_compress_cctx_resolved (zxc_cctx *cctx, const void *src, const size_t src_size, void *dst, const size_t dst_capacity, const zxc_cctx_opts_t o, const zxc_cparams_t *opts)
 Frame compression with resolved options o; opts supplies the dictionary only.
int64_t zxc_compress_cctx (zxc_cctx *cctx, const void *src, const size_t src_size, void *dst, const size_t dst_capacity)
 Compresses data using a reusable context.
zxc_dctx * zxc_create_dctx (void)
 Creates a reusable decompression context.
const zxc_dparams_t * zxc_dctx_params (const zxc_dctx *dctx)
int zxc_dparam_bounds (const zxc_dparam_t param, int64_t *min, int64_t *max)
 Reports the accepted range of a decompression parameter.
int zxc_dctx_set_param (zxc_dctx *dctx, const zxc_dparam_t param, const int64_t value)
 Sets one parameter on dctx; 0 restores its default.
int zxc_dctx_get_param (const zxc_dctx *dctx, const zxc_dparam_t param, int64_t *value)
 Reads one parameter of dctx.
int zxc_dctx_set_dict (zxc_dctx *dctx, const void *dict, const size_t dict_size, const void *dict_huf)
 Attaches the dictionary the archives were compressed with; NULL detaches.
int zxc_dctx_set_progress (zxc_dctx *dctx, const zxc_progress_callback_t cb, void *user_data)
 Sets the progress callback; NULL cb disables it.
int zxc_dctx_reset (zxc_dctx *dctx)
 Restores every parameter to its default, detaches the dictionary and the callback.
void zxc_free_dctx (zxc_dctx *dctx)
 Releases a reusable decompression context.
static int64_t zxc_dctx_probe (const zxc_dctx *dctx, const uint8_t *src, const size_t src_size, const zxc_dparams_t *opts)
 Answers a no-destination decode on a reusable context.
int64_t zxc_decompress_dctx (zxc_dctx *dctx, const void *src, const size_t src_size, void *dst, const size_t dst_capacity)
 Decompresses a framed archive into dst, reusing dctx.
int64_t zxc_decompress_inplace_dctx (zxc_dctx *dctx, void *buffer, const size_t buffer_capacity, const size_t comp_size)
 Decompresses in place inside one caller buffer, reusing dctx.
static int zxc_dctx_carve (zxc_dctx *dctx, const size_t chunk_size, const size_t dict_size, const int checksum, const uint8_t *dict_huf)
 Readies dctx for a frame: re-carves the inner buffers when the block or dictionary size changed (the block API shares this context), then syncs the checksum flag and the shared literal table.
static int64_t zxc_compress_block_resolved (zxc_cctx *cctx, const void *src, const size_t src_size, void *dst, const size_t dst_capacity, const zxc_cctx_opts_t o, const zxc_cparams_t *opts, const uint64_t block_index)
 Block compression with resolved options o; opts supplies the dictionary only.
int64_t zxc_compress_block (zxc_cctx *cctx, const void *src, const size_t src_size, void *dst, const size_t dst_capacity)
 Compresses a single block (no file framing), reusing cctx.
int64_t zxc_compress_block_at (zxc_cctx *cctx, const void *src, const size_t src_size, void *dst, const size_t dst_capacity, const zxc_cparams_t *opts, const uint64_t block_index)
 zxc_compress_block, its checksum seeded with block_index (public entry: 0).
static int64_t zxc_decode_bounce (zxc_cctx_t *ctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity, const size_t carved)
 Block decode through work_buf, for a dst too tight for the speculative writes, then copied out.
static int64_t zxc_static_decompress_block (zxc_dctx *dctx, const uint8_t *src, const size_t src_size, uint8_t *dst, const size_t dst_capacity, const int checksum_enabled, const int strict)
 Block decode on a static dctx: the carved block is the effective capacity.
static int zxc_dctx_prepare (zxc_dctx *dctx, const size_t block_size, const size_t dict_size, const int checksum_enabled)
 Recarves a heap dctx when block_size or dict_size changed; otherwise only refreshes the checksum flag.
int64_t zxc_decompress_block (zxc_dctx *dctx, const void *src, const size_t src_size, void *dst, const size_t dst_capacity)
 Decompresses a single block (no file framing), reusing dctx.
int64_t zxc_decompress_block_safe (zxc_dctx *dctx, const void *src, const size_t src_size, void *dst, const size_t dst_capacity)
 Safe-variant block decompressor: accepts dst_capacity == uncompressed_size.
size_t zxc_static_cctx_workspace_size (const size_t block_size, const int level)
 Workspace size needed for a static compression context.
zxc_cctx * zxc_init_static_cctx (void *workspace, const size_t workspace_size, const size_t block_size, const int level)
 Initialises a compression context inside a caller-supplied workspace.
size_t zxc_static_dctx_workspace_size (const size_t block_size)
 Workspace size needed for a static decompression context.
zxc_dctx * zxc_init_static_dctx (void *workspace, const size_t workspace_size, const size_t block_size)
 Initialises a decompression context inside a caller-supplied workspace.
int64_t zxc_compress (const void *src, const size_t src_size, void *dst, const size_t dst_capacity, const int level)
 Compresses at level with every other parameter at its default.
int64_t zxc_decompress (const void *src, const size_t src_size, void *dst, const size_t dst_capacity)
 Decompresses with no checksum verification and no dictionary.
int64_t zxc_decompress_inplace (void *buffer, const size_t buffer_capacity, const size_t comp_size)
 In-place decode with no checksum verification and no dictionary.

Variables

static const zxc_variant_set_t zxc_variants_default = { .decompress = zxc_decompress_chunk_wrapper_default , .compress = zxc_compress_chunk_wrapper_default , .decompress_dict = zxc_decompress_chunk_wrapper_dict_default , }
static const zxc_variant_set_t *_Atomic zxc_variants_ptr = NULL
 The selection, NULL until the first call.
static _Atomic zxc_decompress_func_t zxc_decompress_safe_ptr = (zxc_decompress_func_t)0
 The _safe decoder in use, NULL until the first call.

Detailed Description

Runtime CPU feature detection and SIMD dispatch layer.

Detects AVX2/AVX512 (x86-64) and NEON (32-bit ARM) at runtime and routes compress/decompress calls to the best available implementation via lazy-initialised function pointers. SSE2 on x86-64 and NEON on AArch64 are baseline ISA guarantees, so the _default variant already covers those tiers. Also contains the public one-shot buffer API (zxc_compress, zxc_decompress, zxc_get_decompressed_size).

Definition in file zxc_dispatch.c.

Macro Definition Documentation

◆ ZXC_DEC_SFX

#define ZXC_DEC_SFX ( sfx)
Value:
sfx

Suffix of a role in the set of tier sfx.

Definition at line 356 of file zxc_dispatch.c.

◆ ZXC_ENC_SFX

#define ZXC_ENC_SFX ( sfx)
Value:
sfx

Definition at line 361 of file zxc_dispatch.c.

◆ ZXC_GLUE

#define ZXC_GLUE ( a,
b )
Value:
ZXC_GLUE_IMPL(a, b)

Definition at line 350 of file zxc_dispatch.c.

◆ ZXC_GLUE_IMPL

#define ZXC_GLUE_IMPL ( a,
b )
Value:
a##b

Definition at line 349 of file zxc_dispatch.c.

◆ ZXC_STATIC_CCTX_HDR_SIZE

#define ZXC_STATIC_CCTX_HDR_SIZE   ZXC_ALIGN_CL(sizeof(struct zxc_cctx_s))

Definition at line 2146 of file zxc_dispatch.c.

◆ ZXC_STATIC_DCTX_HDR_SIZE

#define ZXC_STATIC_DCTX_HDR_SIZE   ZXC_ALIGN_CL(sizeof(struct zxc_dctx_s))

Definition at line 2147 of file zxc_dispatch.c.

◆ ZXC_VARIANT_DICT

#define ZXC_VARIANT_DICT ( sfx)
Value:
.decompress_dict = ZXC_GLUE(zxc_decompress_chunk_wrapper_dict, ZXC_DEC_SFX(sfx)),
int zxc_decompress_chunk_wrapper_dict(const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index)
Public dictionary chunk decoder.
#define ZXC_DEC_SFX(sfx)
Suffix of a role in the set of tier sfx.

Definition at line 365 of file zxc_dispatch.c.

◆ ZXC_VARIANT_HUF

#define ZXC_VARIANT_HUF ( sfx)

Definition at line 377 of file zxc_dispatch.c.

◆ ZXC_VARIANT_SET

#define ZXC_VARIANT_SET ( sfx)
Value:
static const zxc_variant_set_t zxc_variants##sfx = { \
.decompress = ZXC_GLUE(zxc_decompress_chunk_wrapper, ZXC_DEC_SFX(sfx)), \
.compress = ZXC_GLUE(zxc_compress_chunk_wrapper, ZXC_ENC_SFX(sfx)), \
ZXC_VARIANT_DICT(sfx) ZXC_VARIANT_HUF(sfx)}
int zxc_compress_chunk_wrapper(zxc_cctx_t *ctx, const uint8_t *chunk, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index)
Compresses one chunk into a single ZXC block (the compression hot path).
int zxc_decompress_chunk_wrapper(const zxc_cctx_t *ctx, const uint8_t *src, const size_t src_sz, uint8_t *dst, const size_t dst_cap, const uint64_t block_index)
Public no-dict chunk decoder (decompression hot path).
static const zxc_variant_set_t * zxc_variants(void)
The variant set in use, selected on the first call.

Defines the constant variant set of tier sfx.

Definition at line 381 of file zxc_dispatch.c.

Typedef Documentation

◆ zxc_compress_func_t

typedef int(* zxc_compress_func_t) (zxc_cctx_t *, const uint8_t *, const size_t, uint8_t *, const size_t, const uint64_t)

Function pointer type for the chunk compressor.

Definition at line 210 of file zxc_dispatch.c.

◆ zxc_decompress_func_t

typedef int(* zxc_decompress_func_t) (const zxc_cctx_t *, const uint8_t *, const size_t, uint8_t *, const size_t, const uint64_t)

Function pointer type for the chunk decompressor.

Definition at line 207 of file zxc_dispatch.c.

Enumeration Type Documentation

◆ zxc_cpu_feature_t

Detected CPU SIMD capability level.

Enumerator
ZXC_CPU_GENERIC 

Scalar-only fallback.

ZXC_CPU_AVX2 

x86-64 AVX2 available.

ZXC_CPU_AVX512 

x86-64 AVX-512F+BW available.

ZXC_CPU_NEON 

ARM NEON available (dedicated variant on 32-bit ARM only; AArch64 baseline, served by _default there).

ZXC_CPU_SSE2 

x86 SSE2 available (no AVX2); x86-64 baseline, served by _default (no dedicated variant).

Definition at line 230 of file zxc_dispatch.c.

Function Documentation

◆ zxc_buffer_frame_info()

int zxc_buffer_frame_info ( const uint8_t * src,
const size_t src_size,
zxc_frame_info_t * info,
size_t * footer_len )
static

Validates a frame without decoding it: the check of zxc_read_frame_info() on a whole buffer, header first.

The footer's compressed size must be the whole input: one frame, starting at offset 0. Each caller adds its own policy on the result.

Parameters
[in]srcThe frame.
[in]src_sizeIts size.
[out]infoFilled on success.
[out]footer_lenFooter bytes, digest included; may be NULL.

Definition at line 753 of file zxc_dispatch.c.

References ZXC_ERROR_NULL_INPUT, zxc_scan_src_mem(), and zxc_scan_whole_frame().

Referenced by zxc_get_frame_info(), and zxc_inplace_probe().

◆ zxc_cctx_params()

const zxc_cparams_t * zxc_cctx_params ( const zxc_cctx * cctx)

Parameters a public context carries, for the FILE* and push paths.

Definition at line 1121 of file zxc_dispatch.c.

Referenced by zxc_cstream_create(), and zxc_stream_compress().

◆ zxc_compress_block_at()

int64_t zxc_compress_block_at ( zxc_cctx * cctx,
const void * src,
const size_t src_size,
void * dst,
const size_t dst_capacity,
const zxc_cparams_t * opts,
const uint64_t block_index )

◆ zxc_compress_block_resolved()

int64_t zxc_compress_block_resolved ( zxc_cctx * cctx,
const void * src,
const size_t src_size,
void * dst,
const size_t dst_capacity,
const zxc_cctx_opts_t o,
const zxc_cparams_t * opts,
const uint64_t block_index )
static

Block compression with resolved options o; opts supplies the dictionary only.

Produces one format-conformant block with no header / EOF / footer. With a dictionary in opts, [dict | block] is assembled in the cctx-owned bounce buffer before encoding. Inner buffers are re-initialised when the effective block size grows or a level raise needs the opt_scratch region; a static context, which cannot grow, refuses a source above its pinned block.

Definition at line 1853 of file zxc_dispatch.c.

References zxc_cctx_t::checksum_enabled, zxc_cctx_t::compression_level, zxc_cctx_t::dict_buffer, zxc_cctx_t::dict_size, zxc_cctx_t::opt_scratch, zxc_block_size_ceil(), zxc_cctx_free(), zxc_cctx_init(), zxc_compress_chunk_wrapper(), zxc_ctx_sync_dict_huf(), ZXC_ERROR_BAD_BLOCK_SIZE, ZXC_ERROR_CORRUPT_DATA, ZXC_ERROR_MEMORY, ZXC_LEVEL_DENSITY, ZXC_OK, ZXC_OPTS_DICT_HUF, and ZXC_OPTS_DICT_SIZE.

Referenced by zxc_compress_block_at().

◆ zxc_compress_cctx_resolved()

int64_t zxc_compress_cctx_resolved ( zxc_cctx * cctx,
const void * src,
const size_t src_size,
void * dst,
const size_t dst_capacity,
const zxc_cctx_opts_t o,
const zxc_cparams_t * opts )
static

◆ zxc_compress_chunk_wrapper()

int zxc_compress_chunk_wrapper ( zxc_cctx_t * ctx,
const uint8_t * src,
const size_t src_sz,
uint8_t * dst,
const size_t dst_cap,
const uint64_t block_index )

Public compression dispatcher.

Compresses one chunk through the runtime ISA dispatch.

Definition at line 547 of file zxc_dispatch.c.

References zxc_variants().

Referenced by zxc_compress_block_resolved(), and zxc_compress_cctx_resolved().

◆ zxc_cparam_bounds()

int zxc_cparam_bounds ( zxc_cparam_t param,
int64_t * min,
int64_t * max )

Reports the accepted range of a compression parameter.

Lets a caller, or a binding, validate a value before setting it, and tells whether this library knows param at all. The range is necessary, not always sufficient: ZXC_C_BLOCK_SIZE must also be a power of two, which only zxc_cctx_set_param() checks.

Parameters
[in]paramParameter identifier.
[out]minLowest accepted value; may be NULL.
[out]maxHighest accepted value; may be NULL.
Returns
ZXC_OK, or ZXC_ERROR_BAD_PARAM for an unknown param.

Definition at line 1123 of file zxc_dispatch.c.

References ZXC_BLOCK_SIZE_MAX, ZXC_BLOCK_SIZE_MIN, ZXC_C_BLOCK_SIZE, ZXC_C_CHECKSUM, ZXC_C_LEVEL, ZXC_C_SEEKABLE, ZXC_C_THREADS, ZXC_ERROR_BAD_PARAM, ZXC_LEVEL_FASTEST, ZXC_LEVEL_ULTRA, ZXC_MAX_THREADS, and ZXC_OK.

Referenced by zxc_cctx_set_param().

◆ zxc_cparams_defaults()

zxc_cparams_t zxc_cparams_defaults ( void )
static

The parameters every public context starts from.

Definition at line 1109 of file zxc_dispatch.c.

References ZXC_BLOCK_SIZE_DEFAULT, and ZXC_LEVEL_DEFAULT.

Referenced by zxc_cctx_reset(), zxc_compress(), zxc_create_cctx(), and zxc_init_static_cctx().

◆ zxc_cparams_resolve()

zxc_cctx_opts_t zxc_cparams_resolve ( const zxc_cparams_t * p)
static

Per-call options of a context; its level and block size are always resolved and in range (setters, defaults, static init).

Definition at line 1101 of file zxc_dispatch.c.

Referenced by zxc_compress(), zxc_compress_block_at(), and zxc_compress_cctx().

◆ zxc_ctx_sync_dict_huf()

int zxc_ctx_sync_dict_huf ( zxc_cctx_t * inner,
uint8_t * cache,
int * cached,
const uint8_t * dict_huf )
static

Attaches the shared literal table to inner; NULL detaches.

The tree is rebuilt only when the 128 bytes differ from cache, as a build costs about as much as decoding a small block. Clear cached whenever inner is re-initialised: the attached state dies with it.

Definition at line 1082 of file zxc_dispatch.c.

References zxc_cctx_attach_dict_huf(), ZXC_ERROR_CORRUPT_DATA, ZXC_HUF_TABLE_SIZE, and ZXC_OK.

Referenced by zxc_compress_block_resolved(), zxc_compress_cctx_resolved(), zxc_dctx_carve(), and zxc_decompress_block().

◆ zxc_dctx_carve()

int zxc_dctx_carve ( zxc_dctx * dctx,
const size_t chunk_size,
const size_t dict_size,
const int checksum,
const uint8_t * dict_huf )
static

Readies dctx for a frame: re-carves the inner buffers when the block or dictionary size changed (the block API shares this context), then syncs the checksum flag and the shared literal table.

Returns
ZXC_OK, or a negative zxc_error_t.

Definition at line 1612 of file zxc_dispatch.c.

References zxc_cctx_t::checksum_enabled, zxc_cctx_free(), zxc_cctx_init(), zxc_ctx_sync_dict_huf(), ZXC_ERROR_CORRUPT_DATA, ZXC_ERROR_MEMORY, and ZXC_OK.

Referenced by zxc_dctx_decode_frame().

◆ zxc_dctx_decode_container()

int64_t zxc_dctx_decode_container ( zxc_dctx * dctx,
const uint8_t * src,
size_t src_size,
uint8_t * dst,
size_t dst_capacity,
const zxc_dparams_t * opts )
static

◆ zxc_dctx_decode_frame()

int64_t zxc_dctx_decode_frame ( zxc_dctx * dctx,
const uint8_t * src,
const size_t src_size,
uint8_t * dst,
const size_t dst_capacity,
const zxc_dparams_t * opts,
const int inplace,
size_t * frame_end )
static

◆ zxc_dctx_params()

const zxc_dparams_t * zxc_dctx_params ( const zxc_dctx * dctx)

Definition at line 1446 of file zxc_dispatch.c.

◆ zxc_dctx_prepare()

int zxc_dctx_prepare ( zxc_dctx * dctx,
const size_t block_size,
const size_t dict_size,
const int checksum_enabled )
static

Recarves a heap dctx when block_size or dict_size changed; otherwise only refreshes the checksum flag.

Definition at line 1998 of file zxc_dispatch.c.

References zxc_cctx_free(), zxc_cctx_init(), ZXC_ERROR_MEMORY, and ZXC_OK.

Referenced by zxc_decompress_block(), and zxc_decompress_block_safe().

◆ zxc_dctx_probe()

int64_t zxc_dctx_probe ( const zxc_dctx * dctx,
const uint8_t * src,
const size_t src_size,
const zxc_dparams_t * opts )
static

Answers a no-destination decode on a reusable context.

This context's own rules come first: one that could never decode the archive has to say why, not "give me a buffer". The answer then comes from the shared probe, which walks a private workspace, so a read-only query leaves the buffers this context has carved untouched.

Definition at line 1555 of file zxc_dispatch.c.

References zxc_container_info_t::uses_dict, ZXC_ERROR_DICT_UNSUPPORTED, ZXC_OK, ZXC_OPTS_DICT_SIZE, zxc_probe_without_dst(), zxc_scan_container(), and zxc_scan_src_mem().

Referenced by zxc_decompress_dctx().

◆ zxc_decode_bounce()

int64_t zxc_decode_bounce ( zxc_cctx_t * ctx,
const uint8_t * src,
const size_t src_size,
uint8_t * dst,
const size_t dst_capacity,
const size_t carved )
static

Block decode through work_buf, for a dst too tight for the speculative writes, then copied out.

carved bounds the decoded size on a static context; 0 leaves it unbounded.

Definition at line 1951 of file zxc_dispatch.c.

References zxc_decompress_chunk_wrapper(), ZXC_ERROR_BAD_BLOCK_SIZE, and ZXC_ERROR_DST_TOO_SMALL.

Referenced by zxc_decompress_block(), and zxc_static_decompress_block().

◆ zxc_decompress_chunk_wrapper()

int zxc_decompress_chunk_wrapper ( const zxc_cctx_t * ctx,
const uint8_t * src,
const size_t src_sz,
uint8_t * dst,
const size_t dst_cap,
const uint64_t block_index )

Public decompression dispatcher.

Decompresses one chunk through the runtime ISA dispatch.

Definition at line 511 of file zxc_dispatch.c.

References zxc_variants().

Referenced by zxc_dctx_decode_frame(), zxc_decode_bounce(), zxc_decompress_block(), and zxc_static_decompress_block().

◆ zxc_decompress_chunk_wrapper_safe_public()

int zxc_decompress_chunk_wrapper_safe_public ( const zxc_cctx_t * ctx,
const uint8_t * src,
const size_t src_sz,
uint8_t * dst,
const size_t dst_cap,
const uint64_t block_index )
static

Internal safe-decompression dispatcher (strict dst_capacity == uncompressed_size).

Parameters
[in]ctxDecompression context.
[in]srcCompressed input chunk.
[in]src_szSize of src in bytes.
[out]dstDestination buffer (exactly the decoded size).
[in]dst_capCapacity of dst.
[in]block_indexFrame position of the block: the checksum seed.
Returns
Bytes written on success, or a negative zxc_error_t.

Definition at line 538 of file zxc_dispatch.c.

References zxc_decompress_safe_variant().

Referenced by zxc_decompress_block_safe(), and zxc_static_decompress_block().

◆ zxc_decompress_oneshot()

int64_t zxc_decompress_oneshot ( const uint8_t * src,
size_t src_size,
uint8_t * dst,
size_t dst_capacity,
const zxc_dparams_t * opts )
static

Definition at line 1830 of file zxc_dispatch.c.

◆ zxc_decompress_safe_resolve()

zxc_decompress_func_t zxc_decompress_safe_resolve ( void )
static

First call: the _safe decoder of the selected set, published.

Definition at line 476 of file zxc_dispatch.c.

References zxc_decompress_safe_ptr, ZXC_NOINLINE, and zxc_variants().

Referenced by zxc_decompress_safe_variant().

◆ zxc_decompress_safe_variant()

zxc_decompress_func_t zxc_decompress_safe_variant ( void )
inlinestatic

The _safe decoder in use, selected on the first call.

Definition at line 499 of file zxc_dispatch.c.

References ZXC_ALWAYS_INLINE, zxc_decompress_safe_ptr, and zxc_decompress_safe_resolve().

Referenced by zxc_decompress_chunk_wrapper_safe_public().

◆ zxc_detect_cpu_features()

zxc_cpu_feature_t zxc_detect_cpu_features ( void )
static

Probes the running CPU for SIMD support.

Uses CPUID on x86-64 (MSVC and GCC/Clang paths), getauxval on 32-bit ARM Linux, and compile-time constants on AArch64.

Returns
The highest zxc_cpu_feature_t level supported.

Definition at line 249 of file zxc_dispatch.c.

References ZXC_CPU_AVX2, ZXC_CPU_AVX512, ZXC_CPU_GENERIC, ZXC_CPU_NEON, and ZXC_CPU_SSE2.

Referenced by zxc_select_variants().

◆ zxc_dict_copy_set()

int zxc_dict_copy_set ( zxc_dict_copy_t * c,
const void * dict,
const size_t dict_size,
const void * dict_huf )
static

Replaces the copy with dict; a NULL or empty dict detaches.

The previous copy survives a refused call, so the parameter keeps its value.

Definition at line 1044 of file zxc_dispatch.c.

References ZXC_DICT_SIZE_MAX, ZXC_ERROR_DICT_TOO_LARGE, ZXC_ERROR_MEMORY, ZXC_FREE, ZXC_HUF_TABLE_SIZE, ZXC_MALLOC, and ZXC_OK.

Referenced by zxc_cctx_reset(), zxc_cctx_set_dict(), zxc_dctx_reset(), and zxc_dctx_set_dict().

◆ zxc_dparam_bounds()

int zxc_dparam_bounds ( zxc_dparam_t param,
int64_t * min,
int64_t * max )

Reports the accepted range of a decompression parameter.

See also
zxc_cparam_bounds

Definition at line 1448 of file zxc_dispatch.c.

References ZXC_D_CHECKSUM, ZXC_D_THREADS, ZXC_ERROR_BAD_PARAM, ZXC_MAX_THREADS, and ZXC_OK.

Referenced by zxc_dctx_set_param().

◆ zxc_huf_build_code_lengths()

int zxc_huf_build_code_lengths ( const uint32_t * freq,
uint8_t * code_len,
void * scratch,
const int max_code_len )

Build length-limited per-symbol Huffman code lengths from frequencies.

Build length-limited canonical Huffman code lengths from a frequency table.

Un-suffixed entry forwarding to zxc_huf_build_code_lengths_default; full contract in zxc_internal.h.

Definition at line 573 of file zxc_dispatch.c.

Referenced by zxc_dict_train_huf(), zxc_encode_block_spl(), and zxc_opt_estimate_lit_bits().

◆ zxc_huf_calc_size()

size_t zxc_huf_calc_size ( const uint32_t * freq,
const uint8_t * code_len,
const int with_header )

Un-suffixed forwarders for the PivCo section codec (tests, tools).

Exact encoded size (bytes) of a PivCo section for this histogram and code lengths; includes the 128-byte lengths header when with_header.

Definition at line 579 of file zxc_dispatch.c.

Referenced by zxc_encode_block_spl().

◆ zxc_huf_calc_size_dict()

size_t zxc_huf_calc_size_dict ( const uint32_t * freq,
const uint8_t * code_len,
const zxc_pivco_tree_t * tree )

zxc_huf_calc_size for a dict section: prebuilt tree, no header.

Definition at line 618 of file zxc_dispatch.c.

Referenced by zxc_encode_block_spl().

◆ zxc_huf_decode_section()

int zxc_huf_decode_section ( const uint8_t * payload,
size_t payload_size,
uint8_t * dst,
size_t n,
uint8_t * scratch )

Decode a PivCo literal section into dst (exactly n bytes).

dst needs ZXC_PAD_SIZE slack, scratch at least n + ZXC_PIVCO_SCRATCH_PAD.

Definition at line 590 of file zxc_dispatch.c.

References zxc_variants().

◆ zxc_huf_decode_section_dict()

int zxc_huf_decode_section_dict ( const uint8_t * payload,
const size_t payload_size,
uint8_t * dst,
const size_t n,
const zxc_pivco_tree_t * tree,
uint8_t * scratch )

Decode a PivCo dict section against a prebuilt dict tree.

Definition at line 608 of file zxc_dispatch.c.

References zxc_variants().

◆ zxc_huf_encode_section()

int zxc_huf_encode_section ( const uint8_t * literals,
const size_t n_literals,
const uint32_t * freq,
const uint8_t * code_len,
uint8_t * dst,
const size_t dst_cap )

Encode a PivCo literal section (128-byte lengths header + payload).

Definition at line 584 of file zxc_dispatch.c.

Referenced by zxc_encode_block_spl().

◆ zxc_huf_encode_section_dict()

int zxc_huf_encode_section_dict ( const uint8_t * literals,
const size_t n_literals,
const uint32_t * freq,
const uint8_t * code_len,
const zxc_pivco_tree_t * tree,
const uint32_t * codes,
uint8_t * dst,
const size_t dst_cap )

Encode a PivCo section against a prebuilt dict tree/codes (no header).

Definition at line 599 of file zxc_dispatch.c.

Referenced by zxc_encode_block_spl().

◆ zxc_huf_pack_lengths()

void zxc_huf_pack_lengths ( const uint8_t * code_len,
uint8_t * out )

Pack per-symbol code lengths into the 128-byte nibble header.

Pack per-symbol code lengths into the 128-byte (4-bit nibble) header.

Un-suffixed entry forwarding to zxc_huf_pack_lengths_default; full contract in zxc_internal.h.

Definition at line 629 of file zxc_dispatch.c.

Referenced by zxc_dict_train_huf().

◆ zxc_huf_unpack_lengths()

int zxc_huf_unpack_lengths ( const uint8_t * in,
uint8_t * code_len )

Unpack and validate a 128-byte packed lengths header.

Unpack and structurally validate a 128-byte packed lengths header.

Un-suffixed entry forwarding to zxc_huf_unpack_lengths_default; full contract in zxc_internal.h.

Definition at line 639 of file zxc_dispatch.c.

◆ zxc_inplace_margin()

uint64_t zxc_inplace_margin ( const uint64_t dsize,
const size_t chunk_size,
const int has_cs,
const int has_seek,
const size_t footer_len )
static

Bytes an in-place decode needs on top of the decompressed size.

The walk never writes into unread input; the margin keeps a full block of room for an archive its header and footer describe, so every block takes the fast path. Flush-right placement puts block 0 at capacity - comp_size, so the read cursor before block k sits at capacity - sum_{j>=k} (c_j + H) - trailing, and sum_{j<k} o_j + chunk_size + PAD <= R_k requires

capacity >= max_k [ sum_{j<k} o_j + chunk_size + sum_{j>=k} (c_j + H) ] + PAD + trailing

Incompressible input (all RAW, c_j = o_j = chunk_size) maximises the bracket at dsize + chunk_size + nblocks * H: the margin carries the whole accumulated per-block overhead, not just one block's.

trailing is everything written after the last data block: EOF header, the seek table when HAS_SEEK_TABLE announces one, and the footer. Like has_cs, the flag is taken on trust here and checked by the walk: a tail it does not announce is trailing bytes the bound did not count, as inserted padding is, and fails the tail check. Leaving out an announced table used to push the bound below comp_size for a seekable archive of incompressible data in small blocks.

Parameters
[in]dsizeDecompressed size, in bytes.
[in]chunk_sizeBlock size from the file header (0 = no blocks).
[in]has_csNon-zero if blocks carry checksums.
[in]has_seekNon-zero if the header announces a seek table.
[in]footer_lenThe archive's footer bytes, digest included.
Returns
Bytes to reserve beyond dsize.

Definition at line 812 of file zxc_dispatch.c.

References ZXC_BLOCK_CHECKSUM_SIZE, ZXC_BLOCK_HEADER_SIZE, ZXC_DECOMPRESS_TAIL_PAD, zxc_seek_block_count(), and zxc_seek_table_bytes().

Referenced by zxc_inplace_probe().

◆ zxc_inplace_prepare()

int zxc_inplace_prepare ( const void * buffer,
const size_t buffer_capacity,
const size_t comp_size,
const uint8_t ** comp )
static

Argument and buffer checks shared by the in-place entry points.

Runs before any allocation, so both entry points refuse the same calls with the same codes. On success comp is the start of the flush-right archive.

Parameters
[in]bufferCaller buffer holding the flush-right archive.
[in]buffer_capacityTotal size of buffer.
[in]comp_sizeSize of the archive.
[out]compStart of the archive inside buffer.
Returns
ZXC_OK, or a negative zxc_error_t.

Definition at line 910 of file zxc_dispatch.c.

References ZXC_ERROR_DST_TOO_SMALL, ZXC_ERROR_NULL_INPUT, zxc_inplace_probe(), and ZXC_OK.

Referenced by zxc_decompress_inplace(), and zxc_decompress_inplace_dctx().

◆ zxc_inplace_probe()

int zxc_inplace_probe ( const uint8_t * comp,
const size_t comp_size,
uint64_t * dsize,
uint64_t * margin,
uint64_t * floor )
static

Shared archive probe for the in-place entry points: validates the magic + file header, then reads the footer's decompressed size and derives the in-place margin.

Keeping this parse in one place guarantees zxc_decompress_inplace_bound and zxc_decompress_inplace always agree on what a buffer of at least the bound must satisfy.

The envelope is untrusted, so it goes through zxc_buffer_frame_info() like zxc_get_decompressed_size does; only the error mapping differs.

Parameters
[in]compCompressed archive; only the header and footer are read.
[in]comp_sizeSize of the archive in bytes. The caller guarantees it covers at least the file header and footer.
[out]dsizeDecompressed size read from the footer.
[out]marginIn-place margin for dsize, from zxc_inplace_margin.
[out]floorMinimum off: what has to separate the flush-right archive from the head of the buffer.
Returns
ZXC_OK, or a negative zxc_error_t on an invalid archive.

Definition at line 846 of file zxc_dispatch.c.

References zxc_frame_info_t::block_size, zxc_frame_info_t::decompressed_size, zxc_frame_info_t::has_checksum, zxc_frame_info_t::has_seek_table, zxc_buffer_frame_info(), ZXC_DECOMPRESS_TAIL_PAD, ZXC_ERROR_BAD_HEADER, ZXC_ERROR_BAD_MAGIC, ZXC_ERROR_CORRUPT_DATA, zxc_inplace_margin(), and ZXC_OK.

Referenced by zxc_decompress_inplace_bound(), and zxc_inplace_prepare().

◆ zxc_probe_without_dst()

int64_t zxc_probe_without_dst ( const uint8_t * src,
const size_t src_size,
const zxc_dparams_t * opts,
const zxc_container_info_t * scanned )
static

Answers a decode request that carries no destination.

Walks the surviving frame for real on a stand-in buffer, so the verdict is the one a caller with a destination would have got, by construction rather than by keeping a second copy of the checks in step.

Definition at line 767 of file zxc_dispatch.c.

References zxc_container_info_t::dsize, ZXC_ERROR_DST_TOO_SMALL, ZXC_OK, zxc_scan_container(), and zxc_scan_src_mem().

Referenced by zxc_dctx_probe(), and zxc_decompress().

◆ zxc_select_variants()

const zxc_variant_set_t * zxc_select_variants ( void )
static

Detects the CPU tier and returns the matching variant set.

Falls back to the _default (baseline) set when no ISA extension applies.

Definition at line 416 of file zxc_dispatch.c.

References ZXC_CPU_AVX2, ZXC_CPU_AVX512, ZXC_CPU_NEON, and zxc_detect_cpu_features().

Referenced by zxc_variants_resolve().

◆ zxc_static_decompress_block()

int64_t zxc_static_decompress_block ( zxc_dctx * dctx,
const uint8_t * src,
const size_t src_size,
uint8_t * dst,
const size_t dst_capacity,
const int checksum_enabled,
const int strict )
static

Block decode on a static dctx: the carved block is the effective capacity.

Fast decoder: carved block plus wild-copy margin; strict: at most that. A larger block still within the margin is ZXC_ERROR_BAD_BLOCK_SIZE, beyond it the decoder's own too-small-destination code, never reinterpreted.

Definition at line 1971 of file zxc_dispatch.c.

References zxc_cctx_t::checksum_enabled, zxc_cctx_t::dict_size, zxc_decode_bounce(), zxc_decompress_chunk_wrapper(), zxc_decompress_chunk_wrapper_safe_public(), ZXC_DECOMPRESS_TAIL_PAD, and ZXC_ERROR_BAD_BLOCK_SIZE.

Referenced by zxc_decompress_block(), and zxc_decompress_block_safe().

◆ zxc_variants()

const zxc_variant_set_t * zxc_variants ( void )
inlinestatic

◆ zxc_variants_resolve()

const zxc_variant_set_t * zxc_variants_resolve ( void )
static

First call: selects and publishes.

Cold and out of line, so the dispatchers inline only the load and the branch.

Definition at line 442 of file zxc_dispatch.c.

References ZXC_NOINLINE, zxc_select_variants(), and zxc_variants_ptr.

Referenced by zxc_variants().

◆ zxc_write_empty_frame()

int64_t zxc_write_empty_frame ( uint8_t * dst,
const size_t dst_capacity,
const size_t block_size,
const int checksum_enabled,
const int has_dict,
const uint32_t did,
const int seekable )
static

Writes the whole archive an empty source produces: file header, EOF block, the empty seek table when seekable, then the footer.

Both entry points return through here: same options, same empty archive, by construction. Neither carves a workspace: there is no block to encode.

Returns
Bytes written, or a negative zxc_error_t.

Definition at line 658 of file zxc_dispatch.c.

References zxc_seek_table_header(), zxc_write_block_header(), zxc_write_file_footer(), and zxc_write_file_header().

Referenced by zxc_compress_cctx_resolved().

◆ zxc_write_seek_table_from_blocks()

int64_t zxc_write_seek_table_from_blocks ( uint8_t * dst,
const size_t dst_capacity,
const uint8_t * blocks,
const uint8_t *const blocks_end,
const uint64_t num_blocks,
const int checksum_enabled )
static

Writes the seek table of the num_blocks blocks in [blocks, blocks_end), sizes read back from their headers.

Rereading spares the context API a per-call allocation. The walk must land exactly on the EOF block, or dst changed under us.

Returns
Bytes written, or a negative zxc_error_t.

Definition at line 693 of file zxc_dispatch.c.

References ZXC_BLOCK_CHECKSUM_SIZE, ZXC_BLOCK_HEADER_SIZE, ZXC_ERROR_CORRUPT_DATA, ZXC_ERROR_DST_TOO_SMALL, ZXC_ERROR_OVERFLOW, ZXC_FILE_HEADER_SIZE, zxc_le32(), ZXC_SEEK_ANCHOR_SIZE, ZXC_SEEK_GROUP, ZXC_SEEK_SIZE_ENTRY, zxc_seek_table_header(), zxc_seek_table_size(), zxc_store_le32(), and zxc_store_le64().

Referenced by zxc_compress_cctx_resolved().

Variable Documentation

◆ zxc_decompress_safe_ptr

_Atomic zxc_decompress_func_t zxc_decompress_safe_ptr = (zxc_decompress_func_t)0
static

The _safe decoder in use, NULL until the first call.

Definition at line 472 of file zxc_dispatch.c.

Referenced by zxc_decompress_safe_resolve(), and zxc_decompress_safe_variant().

◆ zxc_variants_default

const zxc_variant_set_t zxc_variants_default = { .decompress = zxc_decompress_chunk_wrapper_default , .compress = zxc_compress_chunk_wrapper_default , .decompress_dict = zxc_decompress_chunk_wrapper_dict_default , }
static

Definition at line 387 of file zxc_dispatch.c.

◆ zxc_variants_ptr

const zxc_variant_set_t* _Atomic zxc_variants_ptr = NULL
static

The selection, NULL until the first call.

Definition at line 437 of file zxc_dispatch.c.

Referenced by zxc_variants(), and zxc_variants_resolve().