zuspec-rt-core 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zuspec/rt/core/__init__.py +41 -0
- zuspec/rt/core/__version__.py +20 -0
- zuspec/rt/core/build.py +84 -0
- zuspec/rt/core/share/include/zbc_format.h +199 -0
- zuspec/rt/core/share/include/zsp_alloc.h +28 -0
- zuspec/rt/core/share/include/zsp_indexed_pool.h +25 -0
- zuspec/rt/core/share/include/zsp_timebase.h +385 -0
- zuspec/rt/core/share/rt/zsp_alloc.c +22 -0
- zuspec/rt/core/share/rt/zsp_indexed_pool.c +68 -0
- zuspec/rt/core/share/rt/zsp_timebase.c +682 -0
- zuspec_rt_core-0.1.0.dist-info/METADATA +26 -0
- zuspec_rt_core-0.1.0.dist-info/RECORD +15 -0
- zuspec_rt_core-0.1.0.dist-info/WHEEL +5 -0
- zuspec_rt_core-0.1.0.dist-info/licenses/LICENSE +201 -0
- zuspec_rt_core-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""
|
|
2
|
+
zuspec.rt.core -- shared runtime-core substrate for the ZBC execution stack.
|
|
3
|
+
|
|
4
|
+
The package payload is the C substrate the native engine (``zuspec-rt-eng``) and
|
|
5
|
+
the AOT output (``zuspec-be-sw``) both link against, plus the generated ABI
|
|
6
|
+
header(s):
|
|
7
|
+
|
|
8
|
+
* ``share/include`` -- the generated ABI header (``zbc_format.h``, see
|
|
9
|
+
:mod:`zuspec.be.bc.format.emit_c`) and the migrated substrate headers.
|
|
10
|
+
* ``share/rt`` -- the migrated substrate C sources (scheduler, allocator, ...).
|
|
11
|
+
|
|
12
|
+
Downstream builds discover the headers + sources through :func:`include_dir` and
|
|
13
|
+
:func:`source_files`; :mod:`zuspec.rt.core.build` compiles them into a shared
|
|
14
|
+
library (used by the pytest+ctypes substrate tests, per project convention).
|
|
15
|
+
|
|
16
|
+
Migration is incremental (roadmap P2); ``zuspec-be-sw`` keeps its own copies as
|
|
17
|
+
shims until the cutover, so it is unaffected while the substrate lands here.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
import os
|
|
21
|
+
import glob
|
|
22
|
+
|
|
23
|
+
from .__version__ import version as __version__
|
|
24
|
+
|
|
25
|
+
#: Absolute path to the package's ``share`` tree (headers, runtime sources).
|
|
26
|
+
SHARE_DIR = os.path.join(os.path.dirname(__file__), "share")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def include_dir() -> str:
|
|
30
|
+
"""Return the absolute path to the C include directory (headers)."""
|
|
31
|
+
return os.path.join(SHARE_DIR, "include")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def rt_dir() -> str:
|
|
35
|
+
"""Return the absolute path to the runtime C source directory."""
|
|
36
|
+
return os.path.join(SHARE_DIR, "rt")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def source_files() -> list:
|
|
40
|
+
"""Return the absolute paths of the substrate C sources (sorted, stable)."""
|
|
41
|
+
return sorted(glob.glob(os.path.join(rt_dir(), "*.c")))
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
#****************************************************************************
|
|
3
|
+
# Copyright 2019-2025 Matthew Ballance and contributors
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#****************************************************************************
|
|
17
|
+
BASE="0.1.0"
|
|
18
|
+
SUFFIX=""
|
|
19
|
+
VERSION="%s%s" % (BASE, SUFFIX)
|
|
20
|
+
version=VERSION
|
zuspec/rt/core/build.py
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""
|
|
2
|
+
zuspec.rt.core.build -- compile the substrate into a shared library.
|
|
3
|
+
|
|
4
|
+
The runtime substrate is plain C with a stable ``zsp_`` ABI, so it is tested by
|
|
5
|
+
compiling it to a ``.so`` and driving it from Python through ``ctypes`` (the
|
|
6
|
+
project convention for native code -- no gtest). This module is that compile
|
|
7
|
+
step, factored out so both the substrate tests and any downstream consumer can
|
|
8
|
+
reuse it.
|
|
9
|
+
|
|
10
|
+
``build_shared_lib`` compiles :func:`zuspec.rt.core.source_files` (plus any
|
|
11
|
+
``extra_sources`` -- e.g. a test-support shim exposing struct accessors) against
|
|
12
|
+
:func:`zuspec.rt.core.include_dir` and returns the path to the produced library.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
import os
|
|
16
|
+
import subprocess
|
|
17
|
+
import sysconfig
|
|
18
|
+
from typing import Iterable, List, Optional
|
|
19
|
+
|
|
20
|
+
from . import include_dir, source_files
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def default_cc() -> str:
|
|
24
|
+
"""The C compiler to use (``$CC`` if set, else the platform default, else cc)."""
|
|
25
|
+
return os.environ.get("CC") or sysconfig.get_config_var("CC") or "cc"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _shared_flag() -> List[str]:
|
|
29
|
+
# macOS wants -dynamiclib; ELF platforms use -shared. Default to -shared.
|
|
30
|
+
if os.uname().sysname == "Darwin":
|
|
31
|
+
return ["-dynamiclib"]
|
|
32
|
+
return ["-shared"]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def build_shared_lib(out_path: str,
|
|
36
|
+
extra_sources: Optional[Iterable[str]] = None,
|
|
37
|
+
extra_include_dirs: Optional[Iterable[str]] = None,
|
|
38
|
+
extra_link_args: Optional[Iterable[str]] = None,
|
|
39
|
+
cc: Optional[str] = None) -> str:
|
|
40
|
+
"""Compile the substrate (+ ``extra_sources``) into ``out_path``.
|
|
41
|
+
|
|
42
|
+
``extra_link_args`` are appended after the sources (e.g. ``-L``/``-l``/
|
|
43
|
+
``-Wl,-rpath`` to link a downstream shared library such as libdv_solve).
|
|
44
|
+
|
|
45
|
+
Returns ``out_path`` on success; raises :class:`RuntimeError` with the
|
|
46
|
+
compiler output on failure.
|
|
47
|
+
"""
|
|
48
|
+
cc = cc or default_cc()
|
|
49
|
+
srcs = list(source_files()) + list(extra_sources or [])
|
|
50
|
+
incs = [include_dir()] + list(extra_include_dirs or [])
|
|
51
|
+
|
|
52
|
+
# $CC may carry flags (e.g. "gcc -pthread"); split so they are honored.
|
|
53
|
+
cmd = cc.split() + _shared_flag() + ["-fPIC", "-O2", "-g"]
|
|
54
|
+
for inc in incs:
|
|
55
|
+
cmd += ["-I", inc]
|
|
56
|
+
cmd += srcs + ["-o", out_path]
|
|
57
|
+
cmd += list(extra_link_args or [])
|
|
58
|
+
|
|
59
|
+
proc = subprocess.run(cmd, capture_output=True, text=True)
|
|
60
|
+
if proc.returncode != 0:
|
|
61
|
+
raise RuntimeError(
|
|
62
|
+
"failed to build rt-core shared lib:\n"
|
|
63
|
+
" cmd: %s\n%s%s" % (" ".join(cmd), proc.stdout, proc.stderr))
|
|
64
|
+
return out_path
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def compile_check(source: str, lang: str = "c",
|
|
68
|
+
extra_flags: Optional[Iterable[str]] = None,
|
|
69
|
+
compiler: Optional[str] = None) -> "tuple[bool, str]":
|
|
70
|
+
"""Compile ``source`` (syntax-only) against the substrate include dir.
|
|
71
|
+
|
|
72
|
+
``lang`` is ``"c"`` or ``"c++"``. Returns ``(ok, output)`` -- used by the
|
|
73
|
+
substrate hygiene tests to assert headers are self-contained and compile as
|
|
74
|
+
both C and C++.
|
|
75
|
+
"""
|
|
76
|
+
if compiler is None:
|
|
77
|
+
compiler = default_cc() if lang == "c" else (
|
|
78
|
+
os.environ.get("CXX") or "c++")
|
|
79
|
+
cmd = compiler.split() + ["-fsyntax-only", "-x", lang,
|
|
80
|
+
"-I", include_dir()]
|
|
81
|
+
cmd += list(extra_flags or [])
|
|
82
|
+
cmd += ["-"]
|
|
83
|
+
proc = subprocess.run(cmd, input=source, capture_output=True, text=True)
|
|
84
|
+
return proc.returncode == 0, (proc.stdout + proc.stderr)
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* zbc_format.h -- the .zbc container format, C view.
|
|
3
|
+
*
|
|
4
|
+
* GENERATED from zuspec.be.bc.format.spec -- DO NOT EDIT BY HAND.
|
|
5
|
+
* Regenerate with: python -m zuspec.be.bc.format.emit_c
|
|
6
|
+
* (A regen no-diff test guards this file against drift.)
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#ifndef ZUSPEC_ZBC_FORMAT_H
|
|
10
|
+
#define ZUSPEC_ZBC_FORMAT_H
|
|
11
|
+
|
|
12
|
+
#include <stdint.h>
|
|
13
|
+
|
|
14
|
+
#if defined(__cplusplus)
|
|
15
|
+
# define ZBC_STATIC_ASSERT(cond, msg) static_assert(cond, msg)
|
|
16
|
+
#else
|
|
17
|
+
# define ZBC_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg)
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
/* File identity */
|
|
21
|
+
#define ZBC_MAGIC0 0x5a
|
|
22
|
+
#define ZBC_MAGIC1 0x42
|
|
23
|
+
#define ZBC_MAGIC2 0x43
|
|
24
|
+
#define ZBC_MAGIC3 0x1a
|
|
25
|
+
#define ZBC_VERSION_MAJOR 1
|
|
26
|
+
#define ZBC_VERSION_MINOR 0
|
|
27
|
+
|
|
28
|
+
/* zbc_sec_kind: Section kinds. Readers skip unknown kinds (forward-compat). */
|
|
29
|
+
#define ZBC_SEC_CODE 0x0001 /* opcode stream */
|
|
30
|
+
#define ZBC_SEC_CORO 0x0002 /* coroutine/func descriptors */
|
|
31
|
+
#define ZBC_SEC_TYPE 0x0003 /* type/field metadata */
|
|
32
|
+
#define ZBC_SEC_CONST 0x0004 /* >64-bit literal constant pool */
|
|
33
|
+
#define ZBC_SEC_SOLVE 0x0005 /* SolveProblem blobs (P4) */
|
|
34
|
+
#define ZBC_SEC_STRB 0x0006 /* string blob */
|
|
35
|
+
#define ZBC_SEC_STRO 0x0007 /* string offsets */
|
|
36
|
+
#define ZBC_SEC_FILE 0x0008 /* file table */
|
|
37
|
+
#define ZBC_SEC_PROV 0x0009 /* provenance records */
|
|
38
|
+
#define ZBC_SEC_CMNT 0x000a /* comment records */
|
|
39
|
+
#define ZBC_SEC_LINE 0x000b /* pc->src_ref line table */
|
|
40
|
+
#define ZBC_SEC_BLOCK 0x000c /* FSM block table (zbc_block[]) */
|
|
41
|
+
#define ZBC_SEC_OPLIST 0x000d /* u32 operand lists (PAR/SELECT branch ids) */
|
|
42
|
+
#define ZBC_SEC_SELECT 0x000e /* weighted-SELECT descriptors (zbc_select[]) */
|
|
43
|
+
#define ZBC_SEC_SPROB 0x000f /* relocatable dv-solve SolveProblem blobs */
|
|
44
|
+
|
|
45
|
+
/* zbc_hdr_flags: Header flag bits. */
|
|
46
|
+
#define ZBC_HDR_HAS_PROV 0x0001 /* provenance sections present */
|
|
47
|
+
#define ZBC_HDR_PROFILE_RUNTIME 0x0002 /* runtime profile (provenance stripped) */
|
|
48
|
+
#define ZBC_HDR_COMP_INIT 0x0004 /* a coroutine constructs the component tree before the entry (P1.5) */
|
|
49
|
+
|
|
50
|
+
/* zbc_secf_flags: Per-section flag bits. */
|
|
51
|
+
#define ZBC_SECF_COMPRESSED 0x0001 /* payload is compressed */
|
|
52
|
+
|
|
53
|
+
/* zbc_prov_flags: Provenance granularity + attribute bits. */
|
|
54
|
+
#define ZBC_PROV_G_INSN 0x0001 /* granularity: instruction */
|
|
55
|
+
#define ZBC_PROV_G_BLOCK 0x0002 /* granularity: block */
|
|
56
|
+
#define ZBC_PROV_G_CORO 0x0004 /* granularity: coroutine */
|
|
57
|
+
#define ZBC_PROV_G_DECL 0x0008 /* granularity: declaration */
|
|
58
|
+
#define ZBC_PROV_F_SYNTH 0x0100 /* compiler-synthesized; no real source */
|
|
59
|
+
|
|
60
|
+
/* zbc_sel_flags: SELECT descriptor flag bits. */
|
|
61
|
+
#define ZBC_SEL_ALLOW_NONE 0x0001 /* no eligible branch -> run nothing (not an error) */
|
|
62
|
+
|
|
63
|
+
/* zbc_solve_flags: SOLVE descriptor flag bits. */
|
|
64
|
+
#define ZBC_SOLVE_SEED_FIXED 0x0001 /* use seed_value; else draw from the frame stream */
|
|
65
|
+
|
|
66
|
+
/* zbc_cmt_kind: Comment kinds. */
|
|
67
|
+
#define ZBC_CMT_LEADING 0x0001
|
|
68
|
+
#define ZBC_CMT_TRAILING 0x0002
|
|
69
|
+
#define ZBC_CMT_INLINE 0x0003
|
|
70
|
+
#define ZBC_CMT_DOC 0x0004
|
|
71
|
+
|
|
72
|
+
/* zbc_header: File header at offset 0. Magic is byte-order-fixed and checked first. */
|
|
73
|
+
typedef struct {
|
|
74
|
+
uint8_t magic[4]; /* 'Z','B','C',0x1A */
|
|
75
|
+
uint16_t version_major; /* incompatible bump -> engine REJECTS */
|
|
76
|
+
uint16_t version_minor; /* additive bump -> tolerated */
|
|
77
|
+
uint32_t flags; /* ZBC_HDR_* */
|
|
78
|
+
uint32_t header_size; /* sizeof(zbc_header); readers skip grown tail */
|
|
79
|
+
uint32_t abi_id; /* value-ABI version (D§11); must match engine */
|
|
80
|
+
uint32_t section_count;
|
|
81
|
+
uint32_t section_dir_off;
|
|
82
|
+
uint32_t entry_coro; /* index of root/entry coroutine descriptor */
|
|
83
|
+
uint64_t file_size; /* integrity: equals actual length */
|
|
84
|
+
uint64_t content_hash; /* hash of bytes after this field (0=none) */
|
|
85
|
+
} zbc_header;
|
|
86
|
+
|
|
87
|
+
/* zbc_section: Section directory entry; fixed size so it is itself trivially indexable. */
|
|
88
|
+
typedef struct {
|
|
89
|
+
uint32_t kind; /* ZBC_SEC_* */
|
|
90
|
+
uint32_t flags; /* ZBC_SECF_* */
|
|
91
|
+
uint64_t offset; /* from file start, 8-byte aligned */
|
|
92
|
+
uint64_t size; /* byte length */
|
|
93
|
+
uint32_t count; /* element count for record arrays (0=N/A) */
|
|
94
|
+
uint32_t elem_size; /* per-element stride (0=N/A); forward-compat lever */
|
|
95
|
+
} zbc_section;
|
|
96
|
+
|
|
97
|
+
/* zbc_prov: Provenance record (32 bytes). prov[0] is the reserved all-zero 'none' entry. */
|
|
98
|
+
typedef struct {
|
|
99
|
+
uint32_t name; /* StrId (0=none) */
|
|
100
|
+
uint32_t node_id; /* stable IR node id (0=none) */
|
|
101
|
+
uint32_t line; /* 1-based start line (0=unknown) */
|
|
102
|
+
uint32_t cmt_first; /* CMNT index of first attached comment */
|
|
103
|
+
uint16_t file; /* FileId */
|
|
104
|
+
uint16_t node_kind; /* origin-node-kind enum */
|
|
105
|
+
uint16_t col; /* start column (0=unknown) */
|
|
106
|
+
uint16_t col_end; /* end column (0=unknown) */
|
|
107
|
+
uint16_t line_end; /* end line (0=same as line) */
|
|
108
|
+
uint16_t flags; /* ZBC_PROV_* */
|
|
109
|
+
uint16_t cmt_count; /* comments in this record's run */
|
|
110
|
+
uint16_t _rsvd;
|
|
111
|
+
} zbc_prov;
|
|
112
|
+
|
|
113
|
+
/* zbc_comment: Comment record (8 bytes). A prov entry owns run [cmt_first, cmt_first+cmt_count). */
|
|
114
|
+
typedef struct {
|
|
115
|
+
uint32_t text; /* StrId */
|
|
116
|
+
uint8_t kind; /* ZBC_CMT_* */
|
|
117
|
+
uint8_t _pad;
|
|
118
|
+
uint16_t line; /* source line of the comment (0=unknown) */
|
|
119
|
+
} zbc_comment;
|
|
120
|
+
|
|
121
|
+
/* zbc_file: File-table entry (8 bytes). FileId = u16 index into files[]. */
|
|
122
|
+
typedef struct {
|
|
123
|
+
uint32_t path; /* StrId */
|
|
124
|
+
uint32_t _rsvd;
|
|
125
|
+
} zbc_file;
|
|
126
|
+
|
|
127
|
+
/* zbc_lineent: pc->src_ref line table entry (8 bytes). Binary-searched by pc. */
|
|
128
|
+
typedef struct {
|
|
129
|
+
uint32_t pc_start; /* sorted ascending */
|
|
130
|
+
uint32_t src_ref; /* prov index; src_at(pc)=largest pc_start<=pc */
|
|
131
|
+
} zbc_lineent;
|
|
132
|
+
|
|
133
|
+
/* zbc_instr: One fixed-width instruction (32 bytes). CODE section is zbc_instr[]. */
|
|
134
|
+
typedef struct {
|
|
135
|
+
uint16_t op; /* ZBC opcode (see model.Op) */
|
|
136
|
+
uint8_t nargs; /* count of valid args (0..4) */
|
|
137
|
+
uint8_t flags; /* per-op flags (e.g. CONST from pool) */
|
|
138
|
+
uint32_t src_ref; /* provenance index (0=none) */
|
|
139
|
+
uint64_t imm; /* immediate / const bits (two's complement) */
|
|
140
|
+
uint32_t arg0;
|
|
141
|
+
uint32_t arg1;
|
|
142
|
+
uint32_t arg2;
|
|
143
|
+
uint32_t arg3;
|
|
144
|
+
} zbc_instr;
|
|
145
|
+
|
|
146
|
+
/* zbc_coro: Coroutine/func descriptor (32 bytes). CORO section is zbc_coro[]. */
|
|
147
|
+
typedef struct {
|
|
148
|
+
uint32_t name; /* StrId (0=none/runtime profile) */
|
|
149
|
+
uint32_t code_start; /* first instr index into CODE */
|
|
150
|
+
uint32_t code_count; /* instr count */
|
|
151
|
+
uint32_t n_blocks; /* FSM block count */
|
|
152
|
+
uint32_t block_start; /* first entry into BLOCK table */
|
|
153
|
+
uint32_t frame_type; /* TYPE id of frame struct (0=none) */
|
|
154
|
+
uint32_t src_ref; /* provenance index (0=none) */
|
|
155
|
+
uint32_t _rsvd;
|
|
156
|
+
} zbc_coro;
|
|
157
|
+
|
|
158
|
+
/* zbc_block: FSM block (16 bytes). BLOCK section is zbc_block[]; a coro owns a run. */
|
|
159
|
+
typedef struct {
|
|
160
|
+
uint32_t idx; /* FSM block index */
|
|
161
|
+
uint32_t pc_start; /* first instr index (relative to coro) */
|
|
162
|
+
uint32_t pc_end; /* one past last instr index */
|
|
163
|
+
uint16_t suspend_op; /* orchestration op ending the block (0=terminal) */
|
|
164
|
+
uint16_t _rsvd;
|
|
165
|
+
} zbc_block;
|
|
166
|
+
|
|
167
|
+
/* zbc_select: Weighted-SELECT descriptor (16 bytes). SELECT section is zbc_select[]; arg0 of a SELECT instr indexes it. The OPLIST pool holds, contiguously from oplist_off, three u32 runs of length n_branches: branch coro ids, positive weights, then guard registers (0xFFFFFFFF = unguarded). */
|
|
168
|
+
typedef struct {
|
|
169
|
+
uint32_t oplist_off; /* start index into OPLIST u32 pool */
|
|
170
|
+
uint32_t n_branches; /* branch count */
|
|
171
|
+
uint32_t flags; /* ZBC_SEL_* (bit0 = allow_none) */
|
|
172
|
+
uint32_t _rsvd;
|
|
173
|
+
} zbc_select;
|
|
174
|
+
|
|
175
|
+
/* zbc_solve: SOLVE descriptor (32 bytes). SOLVE section is zbc_solve[]; arg0 of a SOLVE instr indexes it. The OPLIST pool holds, from oplist_off, n_writeback interleaved (field_slot, var_id) u32 pairs -- the value ABI write-back keyed by object slot. When prob_len > 0, the (prob_off, prob_len) slice of the SPROB pool is a relocatable dv-solve SolveProblem blob: the engine compiles + solves it with the drawn seed and writes dvs_solver_get_value(var_id) back to each field_slot. When prob_len == 0 the minimal M1 randomizer applies: slot = seed + var_id (FixedSolveBackend, base 0). Seed is seed_value if SEED_FIXED else the frame's next draw. */
|
|
176
|
+
typedef struct {
|
|
177
|
+
uint64_t seed_value; /* fixed-seed value (when flags & SEED_FIXED) */
|
|
178
|
+
uint32_t oplist_off; /* start of (field_slot, var_id) pairs in OPLIST */
|
|
179
|
+
uint32_t n_writeback; /* writeback pair count */
|
|
180
|
+
uint32_t flags; /* ZBC_SOLVE_* (bit0 = fixed seed) */
|
|
181
|
+
uint32_t prob_off; /* byte offset of the problem blob in the SPROB pool */
|
|
182
|
+
uint32_t prob_len; /* problem blob length in bytes (0 = minimal randomizer) */
|
|
183
|
+
uint32_t _rsvd;
|
|
184
|
+
} zbc_solve;
|
|
185
|
+
|
|
186
|
+
/* Layout guards: sizes must match the spec (natural alignment). */
|
|
187
|
+
ZBC_STATIC_ASSERT(sizeof(zbc_header) == 48, "zbc_header size mismatch");
|
|
188
|
+
ZBC_STATIC_ASSERT(sizeof(zbc_section) == 32, "zbc_section size mismatch");
|
|
189
|
+
ZBC_STATIC_ASSERT(sizeof(zbc_prov) == 32, "zbc_prov size mismatch");
|
|
190
|
+
ZBC_STATIC_ASSERT(sizeof(zbc_comment) == 8, "zbc_comment size mismatch");
|
|
191
|
+
ZBC_STATIC_ASSERT(sizeof(zbc_file) == 8, "zbc_file size mismatch");
|
|
192
|
+
ZBC_STATIC_ASSERT(sizeof(zbc_lineent) == 8, "zbc_lineent size mismatch");
|
|
193
|
+
ZBC_STATIC_ASSERT(sizeof(zbc_instr) == 32, "zbc_instr size mismatch");
|
|
194
|
+
ZBC_STATIC_ASSERT(sizeof(zbc_coro) == 32, "zbc_coro size mismatch");
|
|
195
|
+
ZBC_STATIC_ASSERT(sizeof(zbc_block) == 16, "zbc_block size mismatch");
|
|
196
|
+
ZBC_STATIC_ASSERT(sizeof(zbc_select) == 16, "zbc_select size mismatch");
|
|
197
|
+
ZBC_STATIC_ASSERT(sizeof(zbc_solve) == 32, "zbc_solve size mismatch");
|
|
198
|
+
|
|
199
|
+
#endif /* ZUSPEC_ZBC_FORMAT_H */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#ifndef INCLUDED_ZSP_ALLOC_H
|
|
2
|
+
#define INCLUDED_ZSP_ALLOC_H
|
|
3
|
+
|
|
4
|
+
#include <sys/types.h>
|
|
5
|
+
|
|
6
|
+
#ifdef __cplusplus
|
|
7
|
+
extern "C" {
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
struct zsp_alloc_s;
|
|
11
|
+
|
|
12
|
+
typedef void *(*zsp_alloc_func)(struct zsp_alloc_s *, size_t);
|
|
13
|
+
typedef void (*zsp_free_func)(struct zsp_alloc_s *, void *);
|
|
14
|
+
|
|
15
|
+
typedef struct zsp_alloc_s {
|
|
16
|
+
zsp_alloc_func alloc;
|
|
17
|
+
zsp_free_func free;
|
|
18
|
+
} zsp_alloc_t;
|
|
19
|
+
|
|
20
|
+
void zsp_alloc_malloc_init(zsp_alloc_t *alloc);
|
|
21
|
+
|
|
22
|
+
zsp_alloc_t *zsp_alloc_malloc_create();
|
|
23
|
+
|
|
24
|
+
#ifdef __cplusplus
|
|
25
|
+
}
|
|
26
|
+
#endif
|
|
27
|
+
|
|
28
|
+
#endif /* INCLUDED_ZSP_ALLOC_H */
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#ifndef INCLUDED_ZSP_INDEXED_POOL_H
|
|
2
|
+
#define INCLUDED_ZSP_INDEXED_POOL_H
|
|
3
|
+
|
|
4
|
+
#include <stdint.h>
|
|
5
|
+
|
|
6
|
+
#ifdef __cplusplus
|
|
7
|
+
extern "C" {
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
typedef struct zsp_indexed_pool_s {
|
|
11
|
+
uint32_t size;
|
|
12
|
+
uint32_t *used_mask; /* one bit per slot */
|
|
13
|
+
uint32_t seed; /* for random selection */
|
|
14
|
+
} zsp_indexed_pool_t;
|
|
15
|
+
|
|
16
|
+
void zsp_indexed_pool_init(zsp_indexed_pool_t *p, uint32_t size);
|
|
17
|
+
int zsp_indexed_pool_acquire(zsp_indexed_pool_t *p, int idx);
|
|
18
|
+
int zsp_indexed_pool_acquire_random(zsp_indexed_pool_t *p);
|
|
19
|
+
void zsp_indexed_pool_release(zsp_indexed_pool_t *p, int idx);
|
|
20
|
+
|
|
21
|
+
#ifdef __cplusplus
|
|
22
|
+
}
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
#endif /* INCLUDED_ZSP_INDEXED_POOL_H */
|