Skip to main content

nros_platform_cffi/
generated.rs

1//! AUTO-GENERATED by scripts/gen-abi-bindings.sh (bindgen 0.72.1) — DO NOT EDIT.
2//!
3//! Source of truth: `packages/platform/nros-platform-api/include/nros/platform*.h` (RFC-0054).
4//! Edit the headers, rerun the script, commit both.
5#![allow(non_camel_case_types, non_snake_case, non_upper_case_globals)]
6#![allow(unsafe_op_in_unsafe_fn, clippy::missing_safety_doc)]
7/* automatically generated by rust-bindgen 0.72.1 */
8
9pub type nros_platform_ret_t = i8;
10pub type nros_platform_log_writer_fn_t = ::core::option::Option<
11    unsafe extern "C" fn(
12        severity: u8,
13        name_ptr: *const u8,
14        name_len: usize,
15        msg_ptr: *const u8,
16        msg_len: usize,
17    ),
18>;
19pub type nros_platform_log_flush_fn_t = ::core::option::Option<unsafe extern "C" fn()>;
20#[doc = " @file platform_timer.h\n @brief Canonical C ABI for the nros platform timer surface.\n\n Companion to `<nros/platform.h>`; sits beside the core 39-symbol\n ABI as the platform-timer interface. Carved into a\n separate header because bare-metal / single-shot consumers can\n omit timer support without losing the canonical platform symbols.\n\n # Handle model\n\n  Platform timer handles are opaque `void *`. The implementation\n  allocates whatever it needs to track the underlying primitive\n  (`TimerHandle_t` on FreeRTOS, `TX_TIMER *` on ThreadX, `timer_t`\n  on POSIX, `*mut k_timer` on Zephyr); the runtime never inspects\n  the bytes pointed at.\n\n # Return-value conventions\n\n  - `create_periodic` / `create_oneshot` return non-NULL on success\n    and `NULL` on failure (analogous to libc `malloc`).\n  - `cancel` returns 1 when the cancellation prevented the callback\n    from firing, 0 if the callback already fired (or the timer was\n    already cancelled or destroyed), -1 on unrecoverable error.\n  - `destroy` is best-effort; idempotent on already-destroyed handles.\n\n # Threading / context\n\n  Callbacks are invoked from a platform-defined timer context — a\n  direct ISR on Zephyr / bare-metal, deferred to the FreeRTOS timer\n  task on FreeRTOS, a real-time signal on POSIX. Callback bodies\n  must be short, must not call back into nros_platform_* heap or\n  blocking primitives, and must use atomic operations for shared\n  state. `user_data` must outlive the timer handle."]
21pub type nros_platform_timer_callback_t =
22    ::core::option::Option<unsafe extern "C" fn(user_data: *mut core::ffi::c_void)>;
23#[doc = " What the wall-clock stamps mean right now."]
24#[repr(C)]
25#[derive(Debug, Copy, Clone)]
26pub struct nros_wall_clock_state_t {
27    #[doc = " `true`: `nros_platform_time_now_ns` answers real UNIX time. `false`:\n  it answers 0, and every `header.stamp` is ROS's \"unset\" time."]
28    pub synced: bool,
29    #[doc = " The source answering, or that will answer once it syncs: one of\n  `NROS_WALL_CLOCK_SOURCE_*`."]
30    pub source: u8,
31    #[doc = " How many times the answering source has CHANGED since boot. 0 for an\n  image whose stamps all come from one clock."]
32    pub steps: u32,
33}
34#[repr(C)]
35#[derive(Debug, Copy, Clone)]
36pub struct nros_platform_task_attr_t {
37    #[doc = " Task name for the kernel's own tables and crash dumps. `NULL` = the\n  port's default. Ports whose kernel has no name concept ignore it."]
38    pub name: *const core::ffi::c_char,
39    #[doc = " Minimum stack size in BYTES. `0` = the port's default.\n\n  A FLOOR, not an exact size. Every port has a minimum of its\n  own — `PTHREAD_STACK_MIN`, `configMINIMAL_STACK_SIZE`, `TX_MINIMUM_STACK`\n  — and those differ by an order of magnitude, and on POSIX differ by\n  ARCHITECTURE (16384 on glibc/x86_64, 131072 on glibc/aarch64). So no\n  portable caller can name a number that is legal everywhere, and a port\n  that treats a small request as an error turns a reasonable ask into a\n  dead capability: that is exactly how `Executor::signal_fd()` returned\n  `NotInitialized` on every Linux host. A port raises this to its own\n  minimum; it never lowers it, and never refuses for being too small.\n\n  Always bytes, never words: FreeRTOS's `xTaskCreate` takes words, and the\n  private struct it replaced called the field `stack_depth` while ThreadX's\n  identically-named field was bytes. The conversion belongs in the one port\n  that needs it, not in every caller."]
40    pub stack_bytes: usize,
41    #[doc = " Caller-provided stack memory, or `NULL` to let the port obtain it.\n\n  ThreadX requires the stack from its caller; POSIX, FreeRTOS and ESP-IDF\n  let the kernel allocate and ignore this. A port that needs memory and is\n  given `NULL` obtains it itself and releases it in `task_free`."]
42    pub stack_mem: *mut core::ffi::c_void,
43    #[doc = " Scheduling priority in the NORMALISED band: `0` = least urgent, larger\n  = more urgent, `NROS_PLATFORM_PRIORITY_INHERIT` = keep the creating\n  task's.\n\n  This was once \"platform-native\", and the natives disagree: `0`\n  is the HIGHEST priority on ThreadX and the LOWEST on FreeRTOS, while\n  Zephyr runs lower-is-more-urgent with negatives reserved for cooperative\n  threads. A sched task priority is authored ONCE, in `system.toml`, and\n  deployed to several of them — so the same number meant \"run me first\" on\n  one board and \"run me last\" on another, with nothing in the ABI\n  recording which convention a port used.\n\n  Each port maps this band onto its own range and documents the map at its\n  `task_init`. Use `NROS_PLATFORM_PRIORITY_RAW(n)` to bypass the band when\n  tuning one RTOS against its own documentation — that is a legitimate\n  thing to do, and the band should not make it impossible."]
44    pub priority: i32,
45    #[doc = " SMP core to pin to, or `-1` for unpinned. Ignored on single-core."]
46    pub core: i8,
47    #[doc = " `NROS_PLATFORM_TASK_*` flags below."]
48    pub flags: u8,
49}
50#[doc = " One CAN or CAN FD frame. `len` is the payload in BYTES, never a DLC: the\n  backend maps bytes to the wire DLC, and a length that is not a valid size\n  is refused, never padded (padding is payload layout, the application's)."]
51#[repr(C)]
52#[derive(Debug, Copy, Clone)]
53pub struct nros_platform_can_frame_t {
54    #[doc = " 11- or 29-bit identifier, per `NROS_PLATFORM_CAN_FLAG_EXT`."]
55    pub id: u32,
56    #[doc = " `NROS_PLATFORM_CAN_FLAG_*` / `NROS_PLATFORM_CAN_SEND_WAIT_TX`."]
57    pub flags: u8,
58    #[doc = " Payload bytes: 0..8 classic; 0..8, 12, 16, 20, 24, 32, 48, 64 FD."]
59    pub len: u8,
60    #[doc = " Payload; bytes past `len` are ignored on send and unspecified on recv."]
61    pub data: [u8; 64usize],
62}
63#[doc = " A CAN handle: caller storage, the backend's state lives inside it."]
64#[repr(C)]
65#[derive(Debug, Copy, Clone)]
66pub struct nros_platform_can_t {
67    pub opaque: [u64; 16usize],
68}
69pub const NROS_PLATFORM_RET_OK: i32 = 0;
70pub const NROS_PLATFORM_RET_ERROR: i32 = -1;
71pub const NROS_PLATFORM_RET_UNSUPPORTED: i32 = -5;
72pub const NROS_PLATFORM_RET_NOMEM: i32 = -6;
73pub const NROS_PLATFORM_RET_INVALID: i32 = -7;
74pub const NROS_PLATFORM_RET_TIMEOUT: i32 = -8;
75pub const NROS_PLATFORM_TASK_DETACHED: i32 = 1;
76pub const NROS_PLATFORM_PRIORITY_MIN: i32 = 0;
77pub const NROS_PLATFORM_PRIORITY_MAX: i32 = 255;
78pub const NROS_PLATFORM_PRIORITY_INHERIT: i32 = -2147483648;
79pub const NROS_PLATFORM_TASK_STORAGE_SIZE: i32 = 512;
80pub const NROS_PLATFORM_MUTEX_STORAGE_SIZE: i32 = 256;
81pub const NROS_PLATFORM_MUTEX_REC_STORAGE_SIZE: i32 = 256;
82pub const NROS_PLATFORM_CONDVAR_STORAGE_SIZE: i32 = 256;
83pub const NROS_PLATFORM_STORAGE_ALIGN: i32 = 8;
84pub const NROS_PLATFORM_PARK_SIGNALLED: i32 = 0;
85pub const NROS_PLATFORM_PARK_EXPIRED: i32 = 1;
86pub const NROS_PLATFORM_PARK_YIELDED: i32 = 2;
87pub const NROS_PLATFORM_CAN_FLAG_EXT: i32 = 1;
88pub const NROS_PLATFORM_CAN_FLAG_FD: i32 = 2;
89pub const NROS_PLATFORM_CAN_FLAG_BRS: i32 = 4;
90pub const NROS_PLATFORM_CAN_SEND_WAIT_TX: i32 = 128;
91pub const NROS_PLATFORM_CAN_FLAGS_KNOWN: i32 = 135;
92pub const NROS_PLATFORM_CAN_STD_ID_MAX: i32 = 2047;
93pub const NROS_PLATFORM_CAN_EXT_ID_MAX: i32 = 536870911;
94pub const NROS_PLATFORM_CAN_CLASSIC_MAX_LEN: i32 = 8;
95pub const NROS_PLATFORM_CAN_FD_MAX_LEN: i32 = 64;
96pub const NROS_PLATFORM_CAN_OK: i32 = 0;
97pub const NROS_PLATFORM_CAN_EINVAL: i32 = -1;
98pub const NROS_PLATFORM_CAN_ENOTOPEN: i32 = -2;
99pub const NROS_PLATFORM_CAN_ENOFD: i32 = -3;
100pub const NROS_PLATFORM_CAN_EAGAIN: i32 = -4;
101pub const NROS_PLATFORM_CAN_EBUSOFF: i32 = -5;
102pub const NROS_PLATFORM_CAN_ENOTSUP: i32 = -6;
103pub const NROS_PLATFORM_CAN_ENODEV: i32 = -7;
104pub const NROS_PLATFORM_CAN_EIO: i32 = -8;
105pub const NROS_PLATFORM_CAN_OPAQUE_U64S: i32 = 16;
106unsafe extern "C" {
107    #[doc = " Monotonic nanoseconds since a platform-defined epoch (boot, program\n  start, …). Never decreases. Wraps after ~584 years.\n\n  Must be backed by a hardware counter or the OS tick — never by a\n  software counter that only advances when polled.\n\n  Available immediately after platform init, before any other nros\n  subsystem. SHOULD be callable from an ISR; a port whose clock is not\n  ISR-safe must say so in its port documentation.\n\n  This replaced the former `clock_ms` / `clock_us` pair. Ports\n  that can convert without a runtime division should — where the counter\n  frequency divides 1e9 (25/50/100/125/200/250 MHz) a compile-time\n  ns-per-cycle multiply is ~2.5x cheaper than the divide it replaces."]
108    pub fn nros_platform_clock_ns() -> u64;
109}
110unsafe extern "C" {
111    #[doc = " Granularity of `nros_platform_clock_ns`, in nanoseconds: the smallest\n  non-zero difference two successive reads can report.\n\n  Examples: 1000000 for a 1 kHz tick, 40 for a 25 MHz cycle counter,\n  1000 for a microsecond hardware timer.\n\n  Must be non-zero, and constant for the lifetime of the program after\n  platform init. A port whose underlying rate is only known at runtime\n  returns the resolved value; one whose rate can change under it returns\n  the COARSEST value it may exhibit. There is no \"unknown\" encoding — a\n  port that cannot answer honestly is reporting a clock it cannot\n  honestly offer."]
112    pub fn nros_platform_clock_resolution_ns() -> u64;
113}
114unsafe extern "C" {
115    #[doc = " Microseconds since the UNIX EPOCH (1970-01-01T00:00:00Z), or `0` when\n  this platform has no wall-clock source.\n\n  READ THIS BEFORE REACHING FOR `nros_platform_clock_ns`.\n  The two clocks in this header differ by one word in their names and by\n  the only property that matters for interop:\n\n    - `nros_platform_clock_ns` is MONOTONIC and boot-relative. Use it for\n      durations, deadlines, spin gaps, timeouts — anything comparing two\n      readings from THIS image. It is meaningless to a peer.\n    - `nros_platform_epoch_us` is ABSOLUTE. Use it for message stamps and\n      anything a peer will compare against its own clock.\n\n  Reaching for the wrong one does not fail to build and does not fail\n  locally; it fails at a peer, which is the expensive place to find out.\n  The concrete case is the consumer this exists for: an embedded island\n  stamped control commands from its boot epoch and Autoware's\n  `vehicle_cmd_gate` rejected every one as stale, so autonomous mode could\n  never actuate.\n\n  `0` MEANS \"NO WALL CLOCK\", not \"the epoch\". Per this header's clock rule\n  (see the top of file: \"If the platform has no clock, return `0`\") this\n  never errors. A caller that gets `0` knows the image cannot stamp\n  absolute time and publishes its stamps as unset (`0`, ROS's \"unset\"\n  time) knowingly, rather than a confidently wrong absolute one. 1970 is not a\n  plausible reading, so the sentinel costs no real value.\n\n  Not required to be monotonic: a platform that acquires its epoch after\n  boot (SNTP, RTC handoff) will JUMP when it does, and may jump backwards.\n  Callers needing monotonicity use `nros_platform_clock_ns`.\n\n  Need not be ISR-safe, and unlike `nros_platform_clock_ns` need not be\n  available immediately after platform init — a port that acquires its\n  epoch over the network necessarily answers `0` until it has."]
116    pub fn nros_platform_epoch_us() -> u64;
117}
118unsafe extern "C" {
119    #[doc = " Allocate `size` bytes; return `NULL` on failure. May be called from\n  any thread."]
120    pub fn nros_platform_alloc(size: usize) -> *mut core::ffi::c_void;
121}
122unsafe extern "C" {
123    #[doc = " Resize the block at `ptr` to `size` bytes. Equivalent to libc\n  `realloc`: `NULL` ptr → fresh alloc; `0` size → free + return `NULL`.\n  Preserves contents up to `min(old, new)`."]
124    pub fn nros_platform_realloc(
125        ptr: *mut core::ffi::c_void,
126        size: usize,
127    ) -> *mut core::ffi::c_void;
128}
129unsafe extern "C" {
130    #[doc = " Free a previously allocated block. `NULL` is a no-op."]
131    pub fn nros_platform_dealloc(ptr: *mut core::ffi::c_void);
132}
133unsafe extern "C" {
134    #[doc = " Bytes currently allocated from the platform heap, or `0` if the port\n  does not instrument it. The true unified figure\n  where the platform owns one kernel heap shared by the C side and the\n  Rust `#[global_allocator]`."]
135    pub fn nros_platform_heap_used_bytes() -> usize;
136}
137unsafe extern "C" {
138    #[doc = " Smallest number of bytes ever left unused on the CALLING task's stack, or\n  `0` if this port cannot report it.\n\n  HEADROOM, not usage, because that is what both kernels natively track and\n  it is the number a safety argument needs: how close the worst observed\n  excursion came to the end of the stack.\n\n  The heap has long had `nros_platform_heap_used_bytes`; the\n  stack had nothing, and stack overflow is the classic way one component\n  corrupts another's state. ISO 26262 treats spatial freedom from\n  interference as a first-class requirement and AUTOSAR pairs memory\n  protection with stack monitoring for exactly this reason. Without a\n  portable probe the only recourse is a per-RTOS one: this repo's Zephyr\n  lane greps `thread_analyzer` printk output in CI, which is a text scrape\n  of a debug facility standing in for a platform capability, and reports\n  nothing on any other port.\n\n  SELF only, deliberately. Both kernels answer for the calling task with no\n  handle (`uxTaskGetStackHighWaterMark(NULL)`, `k_thread_stack_space_get`\n  with `k_current_get()`), whereas answering for an arbitrary task needs a\n  native handle this ABI does not carry -- on Zephyr the task storage is a\n  `pthread_t` and the mapping to `k_thread *` is not public. A task\n  reporting its own headroom is also the shape the callers want: each sched task\n  says how much of its own stack it has ever needed.\n\n  `0` means \"this port does not instrument it\", matching\n  `nros_platform_heap_used_bytes`. It is not a claim that the stack is\n  full."]
139    pub fn nros_platform_task_stack_unused_bytes() -> usize;
140}
141unsafe extern "C" {
142    #[doc = " The same query, capped: `min(unused, limit)`, reading at most `limit`\n  bytes of the stack.\n\n  The executor's `stack-headroom-runtime` rule asks one question, \"are at\n  least `limit` bytes unused?\", and on a painted stack that is true exactly\n  when the `limit` bytes at the stack's deep end still hold the paint. So a\n  port that SCANS (Zephyr walks from `stack_info.start`) answers it by\n  reading those bytes only, never the whole unused region: on an Autoware\n  reference image's FVP build the full scan was a 32.6 ms stall once a second.\n  Below `limit` the scan stops at the first used byte, so the answer is the\n  exact headroom and a breach needs no second, full scan.\n\n  A port with a cheaper or no measurement answers\n  `min(nros_platform_task_stack_unused_bytes(), limit)`. `0` keeps the\n  meaning above: not instrumented."]
143    pub fn nros_platform_task_stack_unused_bytes_upto(limit: usize) -> usize;
144}
145unsafe extern "C" {
146    #[doc = " Total managed heap size in bytes (used + free), or `0` if unknown."]
147    pub fn nros_platform_heap_total_bytes() -> usize;
148}
149unsafe extern "C" {
150    #[doc = " Sleep at least `us` microseconds. Spin if the platform clock has no\n  sub-millisecond timer."]
151    pub fn nros_platform_sleep_us(us: usize);
152}
153unsafe extern "C" {
154    #[doc = " Sleep at least `ms` milliseconds."]
155    pub fn nros_platform_sleep_ms(ms: usize);
156}
157unsafe extern "C" {
158    #[doc = " Sleep at least `s` seconds."]
159    pub fn nros_platform_sleep_s(s: usize);
160}
161unsafe extern "C" {
162    #[doc = " Voluntarily yield the current task / thread. On bare-metal,\n  `core::hint::spin_loop()` is acceptable; on RTOSes use the native\n  cooperative-yield primitive (`k_yield`, `vPortYield`,\n  `tx_thread_relinquish`, `sched_yield`, …). RTOS yields are **not**\n  ISR-safe."]
163    pub fn nros_platform_yield_now();
164}
165unsafe extern "C" {
166    #[doc = " Random `u8`. Cryptographically random where the platform has an\n  entropy source; otherwise a seeded PRNG. Must be deterministic\n  within a single test session for reproducibility."]
167    pub fn nros_platform_random_u8() -> u8;
168}
169unsafe extern "C" {
170    #[doc = " Random `u16`. See `random_u8` notes."]
171    pub fn nros_platform_random_u16() -> u16;
172}
173unsafe extern "C" {
174    #[doc = " Random `u32`. See `random_u8` notes."]
175    pub fn nros_platform_random_u32() -> u32;
176}
177unsafe extern "C" {
178    #[doc = " Random `u64`. See `random_u8` notes."]
179    pub fn nros_platform_random_u64() -> u64;
180}
181unsafe extern "C" {
182    #[doc = " Fill `len` bytes at `buf` with random data."]
183    pub fn nros_platform_random_fill(buf: *mut core::ffi::c_void, len: usize);
184}
185unsafe extern "C" {
186    #[doc = " Wall-clock nanoseconds since the Unix epoch, or `0` if the platform has\n  no real-time clock.\n\n  ONE symbol for one fact, mirroring `nros_platform_clock_ns` for the\n  monotonic clock. It replaced `time_now_ms` + `time_since_epoch_secs` +\n  `time_since_epoch_nanos`.\n\n  Why the split had to go, beyond tidiness: the ABI spent ONE INSTANT over\n  two symbols, and each call sampled the clock separately (the POSIX port\n  issued its own `clock_gettime` in each). A second boundary landing between\n  the two reads paired the OLD second with the NEW sub-second remainder — a\n  timestamp that jumped a full second BACKWARDS, rarely and silently. Both\n  `nros-core` and `nros-node` carried a bounded re-read loop to paper over\n  it; a single read cannot tear, so those loops are gone.\n\n  `u64` ns spans ~584 years from 1970, so it also retires the `uint32_t`\n  seconds field, which overflowed in 2106.\n\n  Ports convert from whatever they have — a port with only seconds returns\n  `secs * 1000000000ULL`, and one with no RTC returns 0. Callers wanting\n  milliseconds divide by 1000000; wanting a `(secs, nanos)` pair, divide and\n  remainder by 1000000000."]
187    pub fn nros_platform_time_now_ns() -> u64;
188}
189unsafe extern "C" {
190    #[doc = " The wall clock's state, for an application that must not publish\n  unstamped data: ask before publishing, rather than a board hook deciding\n  by exiting.\n\n  Every port DEFINES this; there is no default, so a port that does not is\n  a link error naming the symbol, never a silent answer. A port with no\n  real-time clock answers `{ false, NROS_WALL_CLOCK_SOURCE_PLATFORM, 0 }`,\n  matching its 0 from `nros_platform_time_now_ns`. A port that calibrates\n  through `<nros/clock_epoch.h>` answers from that store."]
191    pub fn nros_platform_wall_clock_state() -> nros_wall_clock_state_t;
192}
193unsafe extern "C" {
194    #[doc = " Fill `attr` with the defaults — equivalent to passing `NULL` to\n  `task_init`.\n\n  Callers use this rather than a designated initialiser so that a field added\n  to the struct later stays source-compatible for out-of-tree ports."]
195    pub fn nros_platform_task_attr_init(attr: *mut nros_platform_task_attr_t);
196}
197unsafe extern "C" {
198    #[doc = " Spawn a new task. `task` is opaque caller-provided storage (size from\n  `nros_platform_task_storage_size`); `attr` is a\n  `nros_platform_task_attr_t *`, or `NULL` for every default; `entry` is the\n  task entry point; `arg` is forwarded to `entry`.\n\n  Returns `NROS_PLATFORM_RET_OK`, or `INVALID` (a NULL where storage or an\n  entry is required), `NOMEM` (resources exhausted now — retry may succeed) or\n  `UNSUPPORTED` (this port has no tasks at all)."]
199    pub fn nros_platform_task_init(
200        task: *mut core::ffi::c_void,
201        attr: *mut core::ffi::c_void,
202        entry: ::core::option::Option<
203            unsafe extern "C" fn(arg1: *mut core::ffi::c_void) -> *mut core::ffi::c_void,
204        >,
205        arg: *mut core::ffi::c_void,
206    ) -> i8;
207}
208unsafe extern "C" {
209    #[doc = " Block until `task` exits. Cleans up task storage on success."]
210    pub fn nros_platform_task_join(task: *mut core::ffi::c_void) -> i8;
211}
212unsafe extern "C" {
213    #[doc = " Mark `task` as detached — its storage is reclaimed on exit without\n  a join."]
214    pub fn nros_platform_task_detach(task: *mut core::ffi::c_void) -> i8;
215}
216unsafe extern "C" {
217    #[doc = " Request `task` to terminate at the next cancellation point.\n  Cooperative: a task that never reaches a cancel point will not stop."]
218    pub fn nros_platform_task_cancel(task: *mut core::ffi::c_void) -> i8;
219}
220unsafe extern "C" {
221    #[doc = " Terminate the calling task immediately. Does not return."]
222    pub fn nros_platform_task_exit();
223}
224unsafe extern "C" {
225    #[doc = " Free task storage allocated by `task_init`. Called after `task_join`\n  or `task_detach + exit`."]
226    pub fn nros_platform_task_free(task: *mut *mut core::ffi::c_void);
227}
228unsafe extern "C" {
229    #[doc = " Opaque-storage sizing for `task`, mirroring the wake primitive's\n  probes below. Both are pure functions (no global state) and may be\n  called before `nros_platform_task_init`.\n\n  Added because `task_init`'s \"size determined by the\n  implementor\" had no way to ASK. A C caller can write\n  `pthread_t t;` and pass `&t`; a Rust caller cannot, and hard-coding\n  a size is precisely how Rust's 20-byte `pthread_attr_t` once met\n  NuttX's 56-byte one and smashed the caller's frame. The wake\n  primitive already solved this the right way; tasks now match it."]
230    pub fn nros_platform_task_storage_size() -> usize;
231}
232unsafe extern "C" {
233    pub fn nros_platform_task_storage_align() -> usize;
234}
235unsafe extern "C" {
236    #[doc = " Opaque-storage sizing for the lock family, matching `wake` and `task`.\n  Pure functions, callable before the corresponding `_init`."]
237    pub fn nros_platform_mutex_storage_size() -> usize;
238}
239unsafe extern "C" {
240    pub fn nros_platform_mutex_storage_align() -> usize;
241}
242unsafe extern "C" {
243    pub fn nros_platform_mutex_rec_storage_size() -> usize;
244}
245unsafe extern "C" {
246    pub fn nros_platform_mutex_rec_storage_align() -> usize;
247}
248unsafe extern "C" {
249    pub fn nros_platform_condvar_storage_size() -> usize;
250}
251unsafe extern "C" {
252    pub fn nros_platform_condvar_storage_align() -> usize;
253}
254unsafe extern "C" {
255    pub fn nros_platform_mutex_init(m: *mut core::ffi::c_void) -> i8;
256}
257unsafe extern "C" {
258    pub fn nros_platform_mutex_drop(m: *mut core::ffi::c_void) -> i8;
259}
260unsafe extern "C" {
261    pub fn nros_platform_mutex_lock(m: *mut core::ffi::c_void) -> i8;
262}
263unsafe extern "C" {
264    pub fn nros_platform_mutex_try_lock(m: *mut core::ffi::c_void) -> i8;
265}
266unsafe extern "C" {
267    pub fn nros_platform_mutex_unlock(m: *mut core::ffi::c_void) -> i8;
268}
269unsafe extern "C" {
270    #[doc = " Initialise a recursive mutex (same-thread re-entry permitted).\n  Required by zenoh-pico."]
271    pub fn nros_platform_mutex_rec_init(m: *mut core::ffi::c_void) -> i8;
272}
273unsafe extern "C" {
274    pub fn nros_platform_mutex_rec_drop(m: *mut core::ffi::c_void) -> i8;
275}
276unsafe extern "C" {
277    pub fn nros_platform_mutex_rec_lock(m: *mut core::ffi::c_void) -> i8;
278}
279unsafe extern "C" {
280    pub fn nros_platform_mutex_rec_try_lock(m: *mut core::ffi::c_void) -> i8;
281}
282unsafe extern "C" {
283    pub fn nros_platform_mutex_rec_unlock(m: *mut core::ffi::c_void) -> i8;
284}
285unsafe extern "C" {
286    pub fn nros_platform_condvar_init(cv: *mut core::ffi::c_void) -> i8;
287}
288unsafe extern "C" {
289    pub fn nros_platform_condvar_drop(cv: *mut core::ffi::c_void) -> i8;
290}
291unsafe extern "C" {
292    pub fn nros_platform_condvar_signal(cv: *mut core::ffi::c_void) -> i8;
293}
294unsafe extern "C" {
295    pub fn nros_platform_condvar_signal_all(cv: *mut core::ffi::c_void) -> i8;
296}
297unsafe extern "C" {
298    #[doc = " ISR-safe signal.\n\n  Callable from interrupt context. `nros_platform_condvar_signal`\n  is NOT ISR-safe on every platform (POSIX `pthread_cond_signal`\n  isn't on the async-signal-safe function list; RTOS condvar\n  primitives often require thread context). Backends MUST use\n  this variant when triggering from an ISR or POSIX signal handler.\n\n  Per-platform implementation:\n  * POSIX: `pipe` write — async-signal-safe; a runtime worker thread\n    forwards to the underlying condvar. (Linux may use `eventfd`\n    instead, which is NOT POSIX — `signalfd`/`eventfd` are Linux\n    syscalls, which is why `nros-node`'s worker is\n    `target_os = \"linux\"`-gated.)\n  * Zephyr: `k_sem_give` on the wake semaphore (ISR-safe).\n  * FreeRTOS: `xSemaphoreGiveFromISR` + `portYIELD_FROM_ISR` on\n    the wake semaphore.\n  * NuttX: `sem_post` (POSIX-safe under NuttX) on the wake sem.\n  * ThreadX: `tx_event_flags_set` on the wake event flag group\n    (ISR-safe).\n  * Bare-metal: atomic flag store + `__SEV()` (Cortex-M).\n\n  Returns non-zero on error (e.g. ISR-unsafe call on a backend\n  that mandates ISR-context-only via a separate primitive).\n  Backends without an ISR-safe path return non-zero so callers\n  can fall back to thread-context signal (with the obvious\n  latency cost)."]
299    pub fn nros_platform_condvar_signal_from_isr(cv: *mut core::ffi::c_void) -> i8;
300}
301unsafe extern "C" {
302    #[doc = " Atomically release `m` and block on `cv` until signalled or until the\n  absolute monotonic deadline `abstime`, in MILLISECONDS on the\n  `nros_platform_clock_ns()` epoch — i.e. `clock_ns() / 1000000`. The mutex\n  is re-acquired before this returns. Returns 0 when signalled, 1 on timeout\n  and -1 on error, the same codes as `nros_platform_wake_wait_ms` (issue\n  1906: FreeRTOS returned -1 on timeout, so a caller could not tell a\n  timeout from a failure). A port rounds the remaining time UP to its tick,\n  so the wait never times out before its deadline.\n\n  This is the ONLY condvar wait in the ABI. The unbounded\n  `nros_platform_condvar_wait` was removed: it sat\n  here with a neutral name, every port implemented it with its forever\n  spelling, and \"no unbounded wait\" is only a property of the system if it\n  is a property of the API. A caller whose own contract is unbounded — the\n  zenoh-pico shim's `_z_condvar_wait` was the last one — loops over bounded\n  waits and re-tests its predicate, which a condvar caller must do anyway\n  because of spurious wakeups. `scripts/check-no-unbounded-condvar-wait.sh`\n  keeps the symbol from coming back.\n\n  The unit is spelt out because this said \"`clock_ms` units\" after\n  `nros_platform_clock_ms` was retired; it never changed — every\n  port names the parameter `abstime_ms`."]
303    pub fn nros_platform_condvar_wait_until(
304        cv: *mut core::ffi::c_void,
305        m: *mut core::ffi::c_void,
306        abstime: u64,
307    ) -> i8;
308}
309unsafe extern "C" {
310    pub fn nros_platform_wake_init(w: *mut core::ffi::c_void) -> i8;
311}
312unsafe extern "C" {
313    pub fn nros_platform_wake_drop(w: *mut core::ffi::c_void) -> i8;
314}
315unsafe extern "C" {
316    pub fn nros_platform_wake_wait_ms(w: *mut core::ffi::c_void, timeout_ms: u32) -> i8;
317}
318unsafe extern "C" {
319    pub fn nros_platform_wake_signal(w: *mut core::ffi::c_void) -> i8;
320}
321unsafe extern "C" {
322    pub fn nros_platform_wake_signal_from_isr(w: *mut core::ffi::c_void) -> i8;
323}
324unsafe extern "C" {
325    #[doc = " OPTIONAL microsecond park, the `ParkUntilFn` a port may\n  install through `nros_cpp_executor_set_park_primitive`.\n\n  `nros_platform_wake_wait_ms` above is the required primitive and floors\n  every wait at a millisecond through its own signature; this is the same\n  wait without that floor, for kernels whose timeout type is finer (issue\n  1242). Ports that cannot do better than a millisecond need not define it.\n\n  `w` MUST be the executor's own wake object — the backend's listener signals\n  that one, and a park on anything else cannot be broken by data arriving.\n\n  Returns `NROS_PLATFORM_PARK_SIGNALLED` (0) when signalled,\n  `NROS_PLATFORM_PARK_EXPIRED` (1) when the deadline expired,\n  `NROS_PLATFORM_PARK_YIELDED` (2) when it did not wait but handed the wait\n  to its framework's scheduler, and negative when it cannot park.\n\n  YIELDED is the answer of a park slot\n  installed for a tier a FRAMEWORK schedules (a PX4 work item): it arms the\n  framework's wake at `deadline_us` (`ScheduleDelayed`, or `ScheduleClear`\n  with no deadline) and returns at once, and the executor's `spin_once`\n  returns to the framework instead of blocking. A wake already pending when\n  it answers keeps the pass running. A port's own park never yields."]
326    pub fn nros_platform_wake_park_until_us(w: *mut core::ffi::c_void, deadline_us: u64) -> i8;
327}
328unsafe extern "C" {
329    #[doc = " The finest park `nros_platform_wake_park_until_us` can express, in\n  microseconds. An RTOS tick is a coarser limit than the ABI signature and a\n  timespec primitive a finer one, so only the port can answer."]
330    pub fn nros_platform_wake_park_granularity_us() -> u64;
331}
332unsafe extern "C" {
333    #[doc = " Park on the wake object AND on OS handles.\n\n  The same park as `nros_platform_wake_park_until_us`, ended also when any\n  of the `n` handles in `handles` becomes readable. A handle is what an RMW\n  session's `readiness_source` reported as `NROS_RMW_READINESS_WAITABLE`: a\n  file descriptor on POSIX and NuttX. The park does not read the handles; the\n  executor drives the session non-blockingly after it returns.\n\n  `w` MUST be the executor's own wake object, as for the park above.\n\n  Returns 0 when signalled or a handle is readable, 1 when the deadline\n  expired, and -1 when this port cannot wait on OS handles. Every port\n  defines it: one with no such handles returns -1, and the executor then\n  keeps the wait it had."]
334    pub fn nros_platform_wake_park_handles_us(
335        w: *mut core::ffi::c_void,
336        handles: *const i32,
337        n: usize,
338        deadline_us: u64,
339    ) -> i8;
340}
341unsafe extern "C" {
342    #[doc = " Opaque-storage sizing. Both helpers are pure functions (no global\n  state) and may be called before `nros_platform_wake_init`."]
343    pub fn nros_platform_wake_storage_size() -> usize;
344}
345unsafe extern "C" {
346    pub fn nros_platform_wake_storage_align() -> usize;
347}
348unsafe extern "C" {
349    pub fn nros_platform_critical_section_acquire() -> u32;
350}
351unsafe extern "C" {
352    pub fn nros_platform_critical_section_release(token: u32);
353}
354unsafe extern "C" {
355    pub fn nros_platform_log_write(
356        severity: u8,
357        name_ptr: *const u8,
358        name_len: usize,
359        msg_ptr: *const u8,
360        msg_len: usize,
361    );
362}
363unsafe extern "C" {
364    pub fn nros_platform_log_flush();
365}
366unsafe extern "C" {
367    pub fn nros_platform_register_log_writer(
368        writer: nros_platform_log_writer_fn_t,
369        flusher: nros_platform_log_flush_fn_t,
370    );
371}
372unsafe extern "C" {
373    pub fn nros_platform_panic(msg: *const core::ffi::c_char, len: usize);
374}
375unsafe extern "C" {
376    #[doc = " Resolve `(address, port)` strings into the caller-allocated endpoint\n  storage at `ep`. Both strings are NUL-terminated."]
377    pub fn nros_platform_tcp_create_endpoint(
378        ep: *mut core::ffi::c_void,
379        address: *const u8,
380        port: *const u8,
381    ) -> i8;
382}
383unsafe extern "C" {
384    #[doc = " Release any resources held by the endpoint at `ep`."]
385    pub fn nros_platform_tcp_free_endpoint(ep: *mut core::ffi::c_void);
386}
387unsafe extern "C" {
388    #[doc = " Open a TCP client connection to `endpoint`."]
389    pub fn nros_platform_tcp_open(
390        sock: *mut core::ffi::c_void,
391        endpoint: *const core::ffi::c_void,
392        timeout_ms: u32,
393    ) -> i8;
394}
395unsafe extern "C" {
396    #[doc = " `nros_platform_tcp_open` whose connect gives up after\n  `connect_timeout_ms`. `timeout_ms` keeps its meaning in\n  `nros_platform_tcp_open`. A negative `connect_timeout_ms` states no bound:\n  the call then behaves exactly as `nros_platform_tcp_open`, connect limit\n  included. zenoh-pico passes what is left of a client's connect budget\n  (`[knobs.zenoh.limits] connect_timeout_ms`), so a peer that drops the SYN\n  ends the attempt at the budget instead of at the stack's own SYN-retry\n  limit. A port that cannot bound its connect says so in its implementation\n  and keeps its own limit."]
397    pub fn nros_platform_tcp_open_within(
398        sock: *mut core::ffi::c_void,
399        endpoint: *const core::ffi::c_void,
400        timeout_ms: u32,
401        connect_timeout_ms: i32,
402    ) -> i8;
403}
404unsafe extern "C" {
405    #[doc = " Open a listening TCP socket bound to `endpoint`."]
406    pub fn nros_platform_tcp_listen(
407        sock: *mut core::ffi::c_void,
408        endpoint: *const core::ffi::c_void,
409    ) -> i8;
410}
411unsafe extern "C" {
412    #[doc = " Close a TCP socket."]
413    pub fn nros_platform_tcp_close(sock: *mut core::ffi::c_void);
414}
415unsafe extern "C" {
416    #[doc = " Read up to `len` bytes. Returns bytes received (0: nothing yet),\n  `NROS_PLATFORM_NET_SOCKET_EOF` when the peer closed the stream, or\n  `NROS_PLATFORM_NET_SOCKET_ERROR` on error."]
417    pub fn nros_platform_tcp_read(
418        sock: *const core::ffi::c_void,
419        buf: *mut u8,
420        len: usize,
421    ) -> usize;
422}
423unsafe extern "C" {
424    #[doc = " Read exactly `len` bytes. Returns `len` on success,\n  `NROS_PLATFORM_NET_SOCKET_EOF` when the peer closed the stream first, or\n  `NROS_PLATFORM_NET_SOCKET_ERROR` on error."]
425    pub fn nros_platform_tcp_read_exact(
426        sock: *const core::ffi::c_void,
427        buf: *mut u8,
428        len: usize,
429    ) -> usize;
430}
431unsafe extern "C" {
432    #[doc = " Send up to `len` bytes, waiting at most about the socket's timeout (the\n  `timeout_ms` it was opened with) for the stack to take them. Returns the\n  bytes taken, which may be fewer than `len` and is `0` when the stack took\n  none in that time, or `NROS_PLATFORM_NET_SOCKET_ERROR` when the connection\n  is broken. It never waits for a peer that has stopped reading:\n  a caller that needs every byte loops, and decides how long a stall it\n  tolerates (zenoh-pico: `Z_TRANSPORT_TX_WAIT_BEFORE_CLOSE`). A socket opened\n  with `timeout_ms == 0` states no bound."]
433    pub fn nros_platform_tcp_send(
434        sock: *const core::ffi::c_void,
435        buf: *const u8,
436        len: usize,
437    ) -> usize;
438}
439unsafe extern "C" {
440    #[doc = " Install (`notify != NULL`) or remove the\n  receive notification on a connected TCP socket: the stack calls\n  `notify(ctx)` each time data is queued on it, from the stack's own context\n  (NetX's IP thread), so `notify` must only signal. Data already queued at\n  install calls it once before this returns; once a removal returns, the\n  previous `notify` is never called again. A zenoh session in CALLER mode\n  over `sock` reports this as `NROS_RMW_READINESS_NOTIFY`.\n\n  Returns 0 when installed (or removed), -1 where the stack offers no such\n  hook (every stack whose zenoh sessions read the link on their own thread\n  needs none)."]
441    pub fn nros_platform_tcp_set_rx_notify(
442        sock: *const core::ffi::c_void,
443        notify: ::core::option::Option<unsafe extern "C" fn(ctx: *mut core::ffi::c_void)>,
444        ctx: *mut core::ffi::c_void,
445    ) -> i8;
446}
447unsafe extern "C" {
448    pub fn nros_platform_udp_create_endpoint(
449        ep: *mut core::ffi::c_void,
450        address: *const u8,
451        port: *const u8,
452    ) -> i8;
453}
454unsafe extern "C" {
455    pub fn nros_platform_udp_free_endpoint(ep: *mut core::ffi::c_void);
456}
457unsafe extern "C" {
458    pub fn nros_platform_udp_open(
459        sock: *mut core::ffi::c_void,
460        endpoint: *const core::ffi::c_void,
461        timeout_ms: u32,
462    ) -> i8;
463}
464unsafe extern "C" {
465    #[doc = " Bind a UDP socket in listen / server mode. Optional — return -1\n  on platforms that don't expose a UDP-server primitive."]
466    pub fn nros_platform_udp_listen(
467        sock: *mut core::ffi::c_void,
468        endpoint: *const core::ffi::c_void,
469        timeout_ms: u32,
470    ) -> i8;
471}
472unsafe extern "C" {
473    pub fn nros_platform_udp_close(sock: *mut core::ffi::c_void);
474}
475unsafe extern "C" {
476    pub fn nros_platform_udp_read(
477        sock: *const core::ffi::c_void,
478        buf: *mut u8,
479        len: usize,
480    ) -> usize;
481}
482unsafe extern "C" {
483    pub fn nros_platform_udp_read_exact(
484        sock: *const core::ffi::c_void,
485        buf: *mut u8,
486        len: usize,
487    ) -> usize;
488}
489unsafe extern "C" {
490    #[doc = " Send `len` bytes to `endpoint`."]
491    pub fn nros_platform_udp_send(
492        sock: *const core::ffi::c_void,
493        buf: *const u8,
494        len: usize,
495        endpoint: *const core::ffi::c_void,
496    ) -> usize;
497}
498unsafe extern "C" {
499    #[doc = " Set the recv timeout in milliseconds; `0` means block indefinitely."]
500    pub fn nros_platform_udp_set_recv_timeout(sock: *const core::ffi::c_void, timeout_ms: u32);
501}
502unsafe extern "C" {
503    #[doc = " The OS handle that becomes readable when a\n  datagram arrives on `sock`: its file descriptor on POSIX and NuttX. An RMW\n  session reports it as `NROS_RMW_READINESS_WAITABLE`, and the executor parks\n  on it (`nros_platform_wake_park_handles_us`) instead of blocking in\n  `read`. Returns -1 where the stack has no such handle (lwIP, NetX, a\n  bare-metal stack); those report readiness as a Notify instead."]
504    pub fn nros_platform_udp_readiness_handle(sock: *const core::ffi::c_void) -> i32;
505}
506unsafe extern "C" {
507    #[doc = " Install (`notify != NULL`) or remove the\n  receive notification on `sock`: the stack calls `notify(ctx)` each time a\n  datagram is queued on it, from the stack's own context (lwIP's tcpip\n  thread, NetX's IP thread), so `notify` must only signal. Data already\n  queued at install calls it once before this returns; once a removal\n  returns, the previous `notify` is never called again. An RMW session over\n  `sock` reports this as `NROS_RMW_READINESS_NOTIFY`.\n\n  Returns 0 when installed (or removed), -1 where the stack offers no such\n  hook — POSIX/NuttX, which have `nros_platform_udp_readiness_handle`\n  instead, and stacks not yet given one."]
508    pub fn nros_platform_udp_set_rx_notify(
509        sock: *const core::ffi::c_void,
510        notify: ::core::option::Option<unsafe extern "C" fn(ctx: *mut core::ffi::c_void)>,
511        ctx: *mut core::ffi::c_void,
512    ) -> i8;
513}
514unsafe extern "C" {
515    pub fn nros_platform_udp_mcast_open(
516        sock: *mut core::ffi::c_void,
517        endpoint: *const core::ffi::c_void,
518        lep: *mut core::ffi::c_void,
519        timeout_ms: u32,
520        iface: *const u8,
521    ) -> i8;
522}
523unsafe extern "C" {
524    pub fn nros_platform_udp_mcast_listen(
525        sock: *mut core::ffi::c_void,
526        endpoint: *const core::ffi::c_void,
527        timeout_ms: u32,
528        iface: *const u8,
529        join: *const u8,
530    ) -> i8;
531}
532unsafe extern "C" {
533    pub fn nros_platform_udp_mcast_close(
534        sockrecv: *mut core::ffi::c_void,
535        socksend: *mut core::ffi::c_void,
536        rep: *const core::ffi::c_void,
537        lep: *const core::ffi::c_void,
538    );
539}
540unsafe extern "C" {
541    pub fn nros_platform_udp_mcast_read(
542        sock: *const core::ffi::c_void,
543        buf: *mut u8,
544        len: usize,
545        lep: *const core::ffi::c_void,
546        addr: *mut core::ffi::c_void,
547    ) -> usize;
548}
549unsafe extern "C" {
550    pub fn nros_platform_udp_mcast_read_exact(
551        sock: *const core::ffi::c_void,
552        buf: *mut u8,
553        len: usize,
554        lep: *const core::ffi::c_void,
555        addr: *mut core::ffi::c_void,
556    ) -> usize;
557}
558unsafe extern "C" {
559    pub fn nros_platform_udp_mcast_send(
560        sock: *const core::ffi::c_void,
561        buf: *const u8,
562        len: usize,
563        endpoint: *const core::ffi::c_void,
564    ) -> usize;
565}
566unsafe extern "C" {
567    #[doc = " Switch a socket to non-blocking mode."]
568    pub fn nros_platform_socket_set_non_blocking(sock: *const core::ffi::c_void) -> i8;
569}
570unsafe extern "C" {
571    #[doc = " Accept a pending connection from `sock_in` into `sock_out`."]
572    pub fn nros_platform_socket_accept(
573        sock_in: *const core::ffi::c_void,
574        sock_out: *mut core::ffi::c_void,
575    ) -> i8;
576}
577unsafe extern "C" {
578    #[doc = " Socket-layer shutdown + close. Distinct from\n  `nros_platform_tcp_close` because zenoh-pico's helper layer\n  exposes both."]
579    pub fn nros_platform_socket_close(sock: *mut core::ffi::c_void);
580}
581unsafe extern "C" {
582    #[doc = " Wait for socket events on a multi-peer set. Optional on platforms\n  without a poll/select primitive."]
583    pub fn nros_platform_socket_wait_event(
584        peers: *mut core::ffi::c_void,
585        mutex: *mut core::ffi::c_void,
586    ) -> i8;
587}
588unsafe extern "C" {
589    #[doc = " Pump the underlying network stack to process pending I/O.\n  No-op on platforms with a kernel-driven socket layer (POSIX,\n  Zephyr, lwIP, NetX Duo). Bare-metal smoltcp targets advance\n  the stack from this entry point."]
590    pub fn nros_platform_network_poll();
591}
592unsafe extern "C" {
593    #[doc = " Register a periodic timer that invokes `callback(user_data)` every\n  `period_us` microseconds. Returns the platform-native handle on\n  success, NULL on failure."]
594    pub fn nros_platform_timer_create_periodic(
595        period_us: u32,
596        callback: nros_platform_timer_callback_t,
597        user_data: *mut core::ffi::c_void,
598    ) -> *mut core::ffi::c_void;
599}
600unsafe extern "C" {
601    #[doc = " Register a one-shot timer that invokes `callback(user_data)` once\n  after `timeout_us` microseconds. Returns the platform-native\n  handle on success, NULL on failure."]
602    pub fn nros_platform_timer_create_oneshot(
603        timeout_us: u32,
604        callback: nros_platform_timer_callback_t,
605        user_data: *mut core::ffi::c_void,
606    ) -> *mut core::ffi::c_void;
607}
608unsafe extern "C" {
609    #[doc = " Cancel + free the timer. Drains in-flight callback invocations\n  before returning so `user_data` is no longer accessed. Idempotent\n  on already-destroyed handles."]
610    pub fn nros_platform_timer_destroy(handle: *mut core::ffi::c_void);
611}
612unsafe extern "C" {
613    #[doc = " Cancel a previously-armed timer. Returns:\n\n   - 1 if cancellation prevented the callback from firing,\n   - 0 if the callback already fired (or the timer was already\n     cancelled / destroyed),\n   - -1 on unrecoverable error.\n\n  Distinct from `destroy` — the handle remains valid after\n  `cancel` and may be re-armed by the application's own\n  bookkeeping if the implementation supports it."]
614    pub fn nros_platform_timer_cancel(handle: *mut core::ffi::c_void) -> i8;
615}
616unsafe extern "C" {
617    #[doc = " Open `device` into the caller's handle storage. `device` NULL opens the\n  image's device (the one its board stack names); a non-NULL name opens that\n  device instead. `want_fd` non-zero asks for CAN FD: afterwards\n  `nros_platform_can_fd_active` says whether FD is active. A backend that can\n  tell at open that the device does not carry FD (SocketCAN: the interface\n  MTU) fails here with `NROS_PLATFORM_CAN_ENOFD`; one that learns it from\n  the device's mode (Zephyr: the controller's `CAN_MODE_FD`, set at\n  bring-up) opens and reports it through `fd_active`. Either way an FD send\n  on a handle whose FD is not active returns `NROS_PLATFORM_CAN_ENOFD`."]
618    pub fn nros_platform_can_open(
619        can: *mut nros_platform_can_t,
620        device: *const core::ffi::c_char,
621        want_fd: u8,
622    ) -> i8;
623}
624unsafe extern "C" {
625    #[doc = " Send one frame, waiting at most `timeout_us` for the controller to take\n  it (`0`: do not wait). See the file comment for what `0` means."]
626    pub fn nros_platform_can_send(
627        can: *mut nros_platform_can_t,
628        frame: *const nros_platform_can_frame_t,
629        timeout_us: u32,
630    ) -> i8;
631}
632unsafe extern "C" {
633    #[doc = " Non-zero when the handle was opened with `want_fd` and the device carries\n  CAN FD; zero otherwise, a closed handle included."]
634    pub fn nros_platform_can_fd_active(can: *const nros_platform_can_t) -> u8;
635}
636unsafe extern "C" {
637    #[doc = " Receive one frame, waiting at most `timeout_us` (`0`: poll).\n  `NROS_PLATFORM_CAN_EAGAIN` when nothing arrived; `NROS_PLATFORM_CAN_ENOTSUP`\n  on a backend without receive."]
638    pub fn nros_platform_can_recv(
639        can: *mut nros_platform_can_t,
640        frame: *mut nros_platform_can_frame_t,
641        timeout_us: u32,
642    ) -> i8;
643}
644unsafe extern "C" {
645    #[doc = " Close the handle. Idempotent; a closed or never-opened handle is a no-op."]
646    pub fn nros_platform_can_close(can: *mut nros_platform_can_t);
647}