API requirements¶
Every public function shall return Rationale: One error-reporting path keeps call sites uniform and works from ISRs and across partitions; EmbCC compiles thread-local storage to a single instance on embedded targets, which rules out Status: Accepted 2026-10-07 Verification: Analysis: Trace: SPEC-001 §4.4; ADR-002; 05 §1.2 |
Every public function that may block shall take an Rationale: Unbounded waits hidden in signatures are the first cause of hangs; absolute deadlines are what periodic real-time code needs to avoid drift (KRN-TIM-011). Status: Accepted 2026-10-07 Verification: Analysis: Trace: SPEC-001 §3, §7.4; ADR-002 |
Every public function shall carry the annotation tags Rationale: Documentation, static analysis, and the conformance-suite generator must read the same contract, or they drift from each other and from the code. Status: Accepted 2026-10-07 Verification: Analysis: Trace: SPEC-001 §9; 05 §1.4 |
Every public header shall compile without warnings under the project warning set as C11 ( Rationale: The headers are the contract with three compilers and two languages; EmbCC does not enforce a standard level, so GCC and Clang do (09 §3). Status: Accepted 2026-10-07 Verification: Test: Trace: SPEC-001 §8; ADR-023 |
The public API shall be identical in names, signatures, and documented semantics for privileged and unprivileged callers. The build shall select a direct call or a system-call stub per partition without changing the header a caller includes. Rationale: Application source must move between the tiny, base, and isolated profiles unchanged (principle 9). Status: Accepted 2026-10-07 Verification: Test: the conformance suite builds and passes once as privileged and once inside an unprivileged partition on the isolated profile, from the same sources. Trace: SPEC-001 §5.3; 03 §8.1; KRN-CAP-001 |
Identifiers beginning with Rationale: A predictable prefix lets tooling key on the API, and Status: Accepted 2026-10-07 Verification: Analysis: identifier scan in CI over Trace: SPEC-001 §2; ADR-002 |
Every public function shall be named Rationale: Uniform names make the API learnable from one example per verb and let generated documentation group operations by subject. Status: Accepted 2026-10-07 Verification: Analysis: Trace: SPEC-001 §3 |
Public function parameters shall appear in the order: object handle, input parameters, timeout/deadline where applicable, then output parameters named with the prefix Rationale: A fixed order removes a class of call-site mistakes and lets the annotation checker identify the typed timeout and explicit argument relationships mechanically (API-002). Status: Accepted 2026-10-07 Verification: Analysis: Trace: SPEC-001 §3 |
The public API shall not define functions whose names end in Rationale: A zero timeout is Status: Accepted 2026-10-07 Verification: Analysis: identifier scan. Trace: SPEC-001 §3, §5.2; ADR-003 |
Each status code’s numeric value shall be fixed when first released and shall never change or be reused. Kernel core codes shall occupy -1 to -31, kernel reserved -32 to -63, driver classes and subsystems -64 to -127, application-defined -128 to -255. No status value below -255 shall be defined. Rationale: Status values cross the syscall boundary, appear in trace and crash records, and are stored by applications; they are ABI. Status: Accepted 2026-10-07 Verification: Test: Trace: SPEC-001 §4.2 |
The kernel shall define exactly the status codes Rationale: A closed, small set keeps error handling uniform and each code’s meaning unambiguous across subsystems. Status: Accepted 2026-10-07 Verification: Test: Trace: SPEC-001 §4.2 |
A blocking function whose awaited condition does not become true within the allowed wait shall return Rationale: One outcome, one code; the wait protocol produces the single result Status: Accepted 2026-10-07 Verification: Test: conformance tests for every blocking primitive with Trace: SPEC-001 §4.2; KRN-WAIT-004 |
When more than one error applies to a call, the function shall report in this order: Rationale: Callers and tests can rely on a deterministic code when several faults coincide. Status: Accepted 2026-10-07 Verification: Test: conformance misuse tests that combine two faults. Trace: SPEC-001 §4.4 |
Every public function shall belong to exactly one context class declared by its Rationale: The context class is the contract that replaces duplicated ISR variants (ADR-003) and is what static analysis checks at call sites. Status: Accepted 2026-10-07 Verification: Analysis: Trace: SPEC-001 §5.2; KRN-IRQ-010, KRN-IRQ-011 |
API misuse (wrong context, blocking with a nonzero timeout while the scheduler is locked or in a critical section, invalid handle, null required pointer, out-of-range constant, non-owner unlock, destroy with waiters without Rationale: Fail loudly in development and predictably in production, without ever silently converting misuse into different behavior (principle 11). Status: Accepted 2026-10-07 Verification: Test: Trace: SPEC-001 §5.3; 01 §3 principle 11 |
In isolated profiles, a call entering the kernel from an unprivileged partition shall have every check of API-015 performed at the system-call boundary and shall return a status to the caller; it shall never raise a kernel fault. Rationale: A partition must not be able to take the system down by misusing the API (KRN-CAP-002, KRN-PART-003). Status: Accepted 2026-10-07 Verification: Test: the misuse suite runs inside an unprivileged partition and observes statuses only. Trace: SPEC-001 §5.3; KRN-CAP-002 |
A kernel fault raised by API misuse shall record the fault class, the public function identifier, and the index of the offending argument in the crash record. Rationale: A fault without its cause costs a reproduction; the crash record exists to avoid that (FLT-001). Status: Accepted 2026-10-07 Verification: Test: provoke each misuse class on the native port and decode the crash record. Trace: SPEC-001 §5.3; 03 §10.2 |
Every kernel object handle shall be a struct type containing a single Rationale: One word costs the same as a pointer on every ABI, the struct keeps object types apart at compile time, and the representation can change by profile without changing a signature (ADR-014). Status: Accepted 2026-10-07 Verification: Analysis: header check that every Trace: SPEC-001 §6.1; KRN-CAP-001 |
Every kernel object type shall have a generated storage type Rationale: Opaque objects and static allocation are both required (KRN-MEM-002, KRN-TCB-008); generated sizes reconcile them without compiler extensions (ADR-006). Status: Accepted 2026-10-07 Verification: Analysis: Trace: SPEC-001 §6.2; ADR-006 |
Construction options shall be passed in a plain struct Rationale: Fixed-width fields keep layout independent of enum size (EmbCC enums are Status: Accepted 2026-10-07 Verification: Analysis: header check of attribute struct field types; Test: Trace: SPEC-001 §6.3 |
Every object type shall provide Rationale: Static definition without hand-written init code is how tables of objects stay in data, not code (principle 14). Status: Accepted 2026-10-07 Verification: Test: conformance init/destroy and Trace: SPEC-001 §6.4; KRN-OBJ-001, KRN-OBJ-003 |
The public API shall use three distinct struct types over Rationale: Passing an instant where a duration is expected is a silent real-time bug in scalar-typed APIs; the struct makes it a compile error (ADR-002). Macros avoid EmbCC’s inliner limit on struct-valued helpers (09 §7). Status: Accepted 2026-10-07 Verification: Test: negative compile tests that mixing the types fails; positive tests of constant initializers on all compilers. Trace: SPEC-001 §7.1, §7.3; KRN-TIM-010 |
The tick length shall be the configuration constant Rationale: A wait must never be shorter than requested, and silent truncation is the overflow class KRN-TIM-007 forbids. Status: Accepted 2026-10-07 Verification: Test: Trace: SPEC-001 §7.2, §7.3; KRN-TIM-007 |
Satisfaction, cancellation or destruction may complete a blocking call before its timeout. For an unsatisfied wait, expiry shall make the waiter eligible to return a timeout result; actual return shall include dispatch delay, suspension/eligibility and any mandatory mutex reacquisition. A finite return-time bound shall be claimed only under documented workload/resource assumptions. Rationale: These are the timing promises applications build periodic and watchdog logic on; they must be stated to be measured (KRN-RT-001). Status: Accepted 2026-10-07 Verification: Test: timeout accuracy tests on the native port with virtual time; Demonstration: HIL latency benchmarks record the bound per board. Trace: SPEC-001 §7.4; KRN-TIM-001, KRN-TIM-003, KRN-TIM-011 |
Every public header shall have an include guard named Rationale: Headers are the ABI surface for three compilers and two languages (API-004); each rule removes a known portability or layout hazard, including those EmbCC documents (09 §3, §4). Status: Accepted 2026-10-07 Verification: Analysis: header lint in CI (guard names, include list, forbidden constructs); Inspection for padding. Trace: SPEC-001 §8 |
No public identifier, parameter name, or struct member shall be a C++17 keyword. Rationale: The headers are included from C++ unchanged (API-004). Status: Accepted 2026-10-07 Verification: Analysis: identifier scan against the C++17 keyword list. Trace: SPEC-001 §8 |
A struct that crosses the API shall store enumeration values in fixed-width integer fields, not in Rationale: EmbCC’s enums are always Status: Accepted 2026-10-07 Verification: Analysis: header lint. Trace: SPEC-001 §6.3, §8 |
The annotation tool shall export one JSON object per public function containing every tag of API-003 with parsed values, validated against a published schema, and the reference manual, the static-analysis rules, and the conformance-suite generator shall consume that export rather than re-parsing headers. Rationale: One parser, one truth; three consumers that each parse would disagree in corner cases. Status: Accepted 2026-10-07 Verification: Analysis: schema validation in CI; Inspection that the three consumers import the export. Trace: SPEC-001 §9; 05 §1.4 |
Generic kernel, port-independent, driver, and subsystem code shall express compiler-specific attributes and builtins only through the macros of SPEC-001 §10, defined in Rationale: Scattered Status: Accepted 2026-10-07 Verification: Analysis: CI grep forbids Trace: SPEC-001 §10; PORT-ABI-002; BLD-002 |
The headers shall define Rationale: Products on long support windows need a written compatibility promise (05 §7.1). Status: Accepted 2026-10-07 Verification: Analysis: API export diff between releases fails CI on an incompatible change to a Trace: SPEC-001 §11; 05 §7 |
Every public callback type shall document its execution context in the same terms as Rationale: Callback context confusion is a classic RTOS bug class; variadics defeat annotation and type checking and are poorly supported for inlining on EmbCC (09 §7). Status: Accepted 2026-10-07 Verification: Analysis: prototype scan for Trace: SPEC-001 §12; ADR-009 |
The kernel shall keep no global or per-thread last-error state. Rationale: Hidden state is unsafe from ISRs and across partitions and is impossible on targets where thread-local storage is a single instance (09 §3). Status: Accepted 2026-10-07 Verification: Analysis: symbol scan of the kernel image for error-state objects; Test: Trace: SPEC-001 §4.3; KRN-THR-014 |