Abstraction Layer (al)#
- group al
Abstraction layer over the target platform (POSIX or bare metal).
rcsw/al/al.h#
Platform selection (POSIX or bare metal) for the abstraction layer.
rcsw/al/clock.h#
Includes the clock interface for the platform RCSW is built for:
rcsw/al/posix/clock.h or rcsw/al/baremetal/clock.h. Both declare the
same functions.
-
struct timespec clock_monotime(void)#
Get the monotonic system time.
- Returns:
The time.
-
struct timespec clock_realtime(void)#
Get the real system time.
- Returns:
The time.
rcsw/al/types.h#
Base type definitions for RCSW.
Defines
-
__linux__#
-
bool_t#
A C boolean type: the same as
bool(from<stdbool.h>) on all supported platforms.
Typedefs
-
typedef uint32_t dptr_t#
A C data pointer type.
All persistent runtime data in RCSW is stored via this type so that casts like:
(struct mystruct*)node->data
work as intended on all targets, provided the data structure’s
elt_sizeissizeof(struct mystruct): elementiof a pool is ati*elt_sizefrom a base aligned toRCSW_CONFIG_PTR_ALIGN, exactly like a C array of that type, so each element has its type’s alignment. (Anelt_sizethat is not a multiple ofRCSW_CONFIG_PTR_ALIGNdoes not give every element that stronger alignment.) On some embedded targets (e.g., ARM), ifnode->datapoints to a stack address with alignment 1, casting to a struct with alignment > 1 can cause a hardware trap because the compiler generates load/store instructions that assume the required alignment.- Choosing a value
Use the alignment of the most strictly aligned type stored in RCSW-managed memory. The library itself stores pointers and
int32_tthere, so it must be at least the target’s alignment of both (checked when the library is built): e.g., 8 on 64-bit targets, 4 on most 32-bit ones.- Implementation
Alignment is enforced by choosing an integer typedef whose natural alignment matches
RCSW_CONFIG_PTR_ALIGN, so that array elements of that type are aligned to it. This is checked when the library is built: some ABIs (e.g., 32-bit x86) alignuint64_tto 4 bytes, and 8 is rejected there.
Note
A C11
_Alignasapproach was considered but rejected:_Alignasis not permitted on atypedef(C11 §6.7.5), and placing it on a single-member struct wrapper would change howdptr_tis used at every call site. The integer-width trick is already sufficient —_Alignof(uint32_t)==4guarantees 4-byte-aligned array elements just as reliably as_Alignas(4)would.