Expand description
Rust mirror of the canonical C ABI in <nros/platform.h>.
Every nros binary links exactly one platform implementation; the
free extern "C" symbols declared below are resolved at link time.
There is no runtime registration step. To inject a platform from
C, drop a translation unit defining the symbols (or link against
a static library that does).
Rust platform crates implement the nros_platform_api traits as
before; a sibling -cffi shim crate re-exports the Rust impl as
#[unsafe(no_mangle)] extern "C" symbols matching the names in the
header. That separation lets the same Rust impl serve both
trait-driven Rust callers and C-ABI consumers.
§Usage
- C implementor: implement the functions in
<nros/platform.h>and link against the nros binary. - Rust consumer: enable the
platform-cffifeature onnros-platform;CffiPlatformdispatches every trait call to the linked C symbols.
§Companion
Platform sits one tier below RMW. The Phase 117 RMW vtable
(<nros/rmw_vtable.h>) is a runtime-pluggable struct; the
platform layer is link-time-bound free symbols. Different choice
because RMW backends genuinely swap per session (zenoh vs cyclonedds
vs xrce in the same binary at test time) while a platform is fixed
for the life of a binary.
Macros§
- nros_
platform_ export - Convenience: emit every
nros_platform_*symbol declared in<nros/platform.h>by delegating to the correspondingnros_platform_api::Platform*trait method on$ty. The caller must implement every trait covered by the capability macros. - nros_
platform_ export_ alloc - Emit
nros_platform_{alloc,realloc,dealloc}delegating to<$ty as PlatformAlloc>. - nros_
platform_ export_ clock - Emit
nros_platform_clock_{ms,us}delegating to<$ty as PlatformClock>. - nros_
platform_ export_ critical_ section - Phase 121.9 — emit the two
nros_platform_critical_section_*symbols by delegating to the caller’sPlatformCriticalSectionimpl. - nros_
platform_ export_ log - Phase 88.11 — emit
nros_platform_log_write+nros_platform_log_flushfrom aPlatformLog-implementing ZST. Use this on bare-metal / custom platforms (mps2-an385, stm32f4, esp32-baremetal, …) that don’t ship a separate C implementation file. The implementor’swritereceives the rendered body + logger name as&[u8]slices. - nros_
platform_ export_ net - Emit every
nros_platform_tcp_*/nros_platform_udp_*/nros_platform_udp_mcast_*/nros_platform_socket_*/nros_platform_network_pollsymbol declared in<nros/platform_net.h>by delegating to the corresponding trait method on$ty. The caller must implementPlatformTcp,PlatformUdp,PlatformUdpMulticast,PlatformSocketHelpers, andPlatformNetworkPoll. - nros_
platform_ export_ random - Emit
nros_platform_random_*delegating to<$ty as PlatformRandom>. - nros_
platform_ export_ sleep - Emit
nros_platform_sleep_{us,ms,s}delegating to<$ty as PlatformSleep>. - nros_
platform_ export_ threading - Emit
nros_platform_task_*,nros_platform_mutex_*,nros_platform_mutex_rec_*, andnros_platform_condvar_*delegating to<$ty as PlatformThreading>. Skip this macro on platforms without kernel threads. - nros_
platform_ export_ time - Emit
nros_platform_time_*delegating to<$ty as PlatformTime>. - nros_
platform_ export_ timer - Emit every
nros_platform_timer_*symbol declared in<nros/platform_timer.h>by delegating to the correspondingPlatformTimertrait method on$ty. - nros_
platform_ export_ yield - Emit
nros_platform_yield_nowdelegating to<$ty as PlatformYield>.
Structs§
- Cffi
Platform - Zero-sized type implementing the platform traits via the canonical
nros_platform_*C symbols. - Cffi
Timer Handle
Constants§
Functions§
- nros_
platform_ ⚠alloc - nros_
platform_ ⚠clock_ ms - nros_
platform_ ⚠clock_ us - nros_
platform_ ⚠condvar_ drop - nros_
platform_ ⚠condvar_ init - nros_
platform_ ⚠condvar_ signal - nros_
platform_ ⚠condvar_ signal_ all - nros_
platform_ ⚠condvar_ signal_ from_ isr - Phase 124.B.7.a — ISR-safe variant of
signal. See<nros/platform.h>for per-platform contract. - nros_
platform_ ⚠condvar_ wait - nros_
platform_ ⚠condvar_ wait_ until - nros_
platform_ ⚠critical_ section_ acquire - nros_
platform_ ⚠critical_ section_ release - nros_
platform_ ⚠dealloc - nros_
platform_ ⚠heap_ total_ bytes - nros_
platform_ ⚠heap_ used_ bytes - nros_
platform_ ⚠log_ flush - nros_
platform_ ⚠log_ write - nros_
platform_ ⚠mutex_ drop - nros_
platform_ ⚠mutex_ init - nros_
platform_ ⚠mutex_ lock - nros_
platform_ ⚠mutex_ rec_ drop - nros_
platform_ ⚠mutex_ rec_ init - nros_
platform_ ⚠mutex_ rec_ lock - nros_
platform_ ⚠mutex_ rec_ try_ lock - nros_
platform_ ⚠mutex_ rec_ unlock - nros_
platform_ ⚠mutex_ try_ lock - nros_
platform_ ⚠mutex_ unlock - nros_
platform_ ⚠network_ poll - nros_
platform_ ⚠random_ fill - nros_
platform_ ⚠random_ u8 - nros_
platform_ ⚠random_ u16 - nros_
platform_ ⚠random_ u32 - nros_
platform_ ⚠random_ u64 - nros_
platform_ ⚠realloc - nros_
platform_ ⚠register_ log_ writer - Register a board writer + optional flusher (Phase 88.9). Available only when the linked platform impl is one of the no-native-logger backends (FreeRTOS / ThreadX / bare-metal).
- nros_
platform_ ⚠sleep_ ms - nros_
platform_ ⚠sleep_ s - nros_
platform_ ⚠sleep_ us - nros_
platform_ ⚠socket_ accept - nros_
platform_ ⚠socket_ close - nros_
platform_ ⚠socket_ set_ non_ blocking - nros_
platform_ ⚠socket_ wait_ event - nros_
platform_ ⚠task_ cancel - nros_
platform_ ⚠task_ detach - nros_
platform_ ⚠task_ exit - nros_
platform_ ⚠task_ free - nros_
platform_ ⚠task_ init - nros_
platform_ ⚠task_ join - nros_
platform_ ⚠tcp_ close - nros_
platform_ ⚠tcp_ create_ endpoint - nros_
platform_ ⚠tcp_ free_ endpoint - nros_
platform_ ⚠tcp_ listen - nros_
platform_ ⚠tcp_ open - nros_
platform_ ⚠tcp_ read - nros_
platform_ ⚠tcp_ read_ exact - nros_
platform_ ⚠tcp_ send - nros_
platform_ ⚠time_ now_ ms - nros_
platform_ ⚠time_ since_ epoch_ nanos - nros_
platform_ ⚠time_ since_ epoch_ secs - nros_
platform_ ⚠timer_ cancel - nros_
platform_ ⚠timer_ create_ oneshot - nros_
platform_ ⚠timer_ create_ periodic - nros_
platform_ ⚠timer_ destroy - nros_
platform_ ⚠udp_ close - nros_
platform_ ⚠udp_ create_ endpoint - nros_
platform_ ⚠udp_ free_ endpoint - nros_
platform_ ⚠udp_ listen - nros_
platform_ ⚠udp_ mcast_ close - nros_
platform_ ⚠udp_ mcast_ listen - nros_
platform_ ⚠udp_ mcast_ open - nros_
platform_ ⚠udp_ mcast_ read - nros_
platform_ ⚠udp_ mcast_ read_ exact - nros_
platform_ ⚠udp_ mcast_ send - nros_
platform_ ⚠udp_ open - nros_
platform_ ⚠udp_ read - nros_
platform_ ⚠udp_ read_ exact - nros_
platform_ ⚠udp_ send - nros_
platform_ ⚠udp_ set_ recv_ timeout - nros_
platform_ ⚠wake_ drop - nros_
platform_ ⚠wake_ init - nros_
platform_ ⚠wake_ signal - nros_
platform_ ⚠wake_ signal_ from_ isr - nros_
platform_ ⚠wake_ storage_ align - nros_
platform_ ⚠wake_ storage_ size - nros_
platform_ ⚠wake_ wait_ ms - nros_
platform_ ⚠yield_ now
Type Aliases§
- Nros
Platform LogFlush Fn - Board-supplied flush fn type. Pass
Nonetonros_platform_register_log_writerwhen the writer is fully synchronous. - Nros
Platform LogWriter Fn - Board-supplied writer fn type. ONLY meaningful on platforms whose
nros_platform_log_writeimpl is itself a thin dispatcher to a board-registered fn (FreeRTOS, ThreadX, bare-metal). On platforms with a native logger (POSIX, Zephyr, ESP-IDF, NuttX), the symbol is absent and the board should not link against it. - Nros
Platform Ret - Mirrors C
nros_platform_ret_t.