File dp_state.h¶
FileList > inc > dp_state.h
Go to the source code of this file
#include "clib_common.h"
Classes¶
| Type | Name |
|---|---|
| struct | dp_reader_t |
| struct | dp_state_hdr_t Common 16-byte envelope at the head of every state blob. |
| struct | dp_writer_t |
Public Static Functions¶
| Type | Name |
|---|---|
| void | dp_r_bytes (dp_reader_t * r, void * dst, size_t n) |
| void | dp_r_cf32 (dp_reader_t * r, float _Complex * p, size_t n) |
| void | dp_r_f32 (dp_reader_t * r, float * p, size_t n) |
| double | dp_r_f64 (dp_reader_t * r) |
| const void * | dp_r_reserve (dp_reader_t * r, size_t n) |
| uint32_t | dp_r_u32 (dp_reader_t * r) |
| uint64_t | dp_r_u64 (dp_reader_t * r) |
| dp_reader_t | dp_reader_init (const void * blob, size_t cap) |
| int | dp_state_validate (const void * blob, size_t expect_bytes, uint32_t magic, uint16_t version) Validate a blob's envelope before trusting its payload. |
| void | dp_w_bytes (dp_writer_t * w, const void * src, size_t n) |
| void | dp_w_cf32 (dp_writer_t * w, const float _Complex * p, size_t n) |
| void | dp_w_f32 (dp_writer_t * w, const float * p, size_t n) |
| void | dp_w_f64 (dp_writer_t * w, double v) |
| void | dp_w_hdr (dp_writer_t * w, uint32_t magic, uint16_t version, size_t total) |
| void * | dp_w_reserve (dp_writer_t * w, size_t n) |
| void | dp_w_u32 (dp_writer_t * w, uint32_t v) |
| void | dp_w_u64 (dp_writer_t * w, uint64_t v) |
| dp_writer_t | dp_writer_init (void * blob, size_t cap) |
Macros¶
| Type | Name |
|---|---|
| define | DP_DEFINE_POD_STATE (pfx, STATE_T, MAGIC, VERSION) /* multi line expression */Define the whole-struct state triplet for a pointer-free POD object. |
| define | DP_DEFINE_RUN (pfx, STATE_T, IN_T, OUT_T) /* multi line expression */Define the standard <pfx>_run pure-transducer wrapper. |
| define | DP_FOURCC (a, b, c, d) /* multi line expression */ |
| define | DP_GET_OPEN (MAGIC, VERSION, BYTES) /* multi line expression */ |
| define | DP_R_CHILD (r, pfx, child_ptr) /* multi line expression */ |
| define | DP_SET_OPEN (MAGIC, VERSION, BYTES) /* multi line expression */ |
| define | DP_STATE_ENDIAN 1u /\* little-endian (x86-64, arm64 — doppler targets) \*/ |
| define | DP_W_CHILD (w, pfx, child_ptr) /* multi line expression */ |
Public Static Functions Documentation¶
function dp_r_bytes¶
function dp_r_cf32¶
function dp_r_f32¶
function dp_r_f64¶
function dp_r_reserve¶
Borrow n bytes in place (for a child's set_state to read); NULL on overrun.
function dp_r_u32¶
function dp_r_u64¶
function dp_reader_init¶
function dp_state_validate¶
Validate a blob's envelope before trusting its payload.
static inline int dp_state_validate (
const void * blob,
size_t expect_bytes,
uint32_t magic,
uint16_t version
)
Every obj_set_state opens with this. expect_bytes is the receiving object's obj_state_bytes() — a blob from a different object (magic), format (version), endianness, or config/size (bytes) is rejected rather than reinterpreted.
Returns:
DP_OK, or DP_ERR_INVALID on any mismatch.
function dp_w_bytes¶
function dp_w_cf32¶
function dp_w_f32¶
function dp_w_f64¶
function dp_w_hdr¶
Stamp the standard envelope. total must equal obj_state_bytes().
function dp_w_reserve¶
Reserve n bytes and return the region (for a child's get_state to fill); NULL on overrun.
function dp_w_u32¶
function dp_w_u64¶
function dp_writer_init¶
Macro Definition Documentation¶
define DP_DEFINE_POD_STATE¶
Define the whole-struct state triplet for a pointer-free POD object.
Generates <pfx>_state_bytes/get_state/set_state that snapshot the entire STATE_T after the envelope. Correct only when the struct holds no pointers (the snapshot would capture a stale address): the running state and the derived config are serialized, and config restores identically into an identically-built instance. For a struct with pointers or a composition, hand-write the triplet (pack running fields / delegate to children) instead.
define DP_DEFINE_RUN¶
Define the standard <pfx>_run pure-transducer wrapper.
Generates size_t <pfx>_run(state, state_in, state_out, in, n_in, out,
max_out): restore state_in (or keep current), call <pfx>_execute, then export state_out — the (state_in, input) -> (state_out, output) face for elastic fan-out. For objects whose middle step is a single _execute; an object with a different step shape (e.g. acq's frame/push) defines its own.
define DP_FOURCC¶
dp_state.h — the standard state bytes interface for doppler.
Serialization is module-specific (only lo knows it holds a phase, only fir knows it holds a delay line); the bytes interface around it is not. This header owns that universal layer, once, for every serializable object:
- a self-describing envelope (
dp_state_hdr_t: magic / version / endian / size) that prefixes every state blob, - writer / reader cursors that turn hand-packing into a few bounds-checked calls,
dp_state_validate()— the one check everyset_stateopens with, so a wrong-object / wrong-config / foreign-endian blob is rejected, never silently reinterpreted, andDP_DEFINE_RUN()— the identicalobj_runpure-transducer wrapper.
The per-object ABI (the contract jm's serializable binding and the Rust FFI call) stays:
size_t obj_state_bytes(const obj_state_t *); void obj_get_state (const obj_state_t *, void *blob); int obj_set_state (obj_state_t *, const void *blob); // DP_OK / -err
Blob layout, every object: [ dp_state_hdr_t ][ module payload ] Compositions embed children as self-contained sub-blobs (each carries its own header): [ hdr ][ extra? ] [ child blob ]... with state_bytes = sizeof(hdr) + sizeof(extra) + Σ child_state_bytes.
Blobs are native-endian POD for same-machine / same-arch resume (thread, process, pod). The endian byte is stamped and rejected on mismatch; there is deliberately no cross-endian byte-swap.
define DP_GET_OPEN¶
define DP_R_CHILD¶
define DP_SET_OPEN¶
define DP_STATE_ENDIAN¶
define DP_W_CHILD¶
The documentation for this class was generated from the following file native/inc/dp_state.h