Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
Common Types

Fixed-width types and the caller-owned-storage handle pattern. More...

Macros

#define SAFEAPI_STORAGE_ALIGN   8U
 Alignment (bytes) guaranteed for every opaque storage block.
#define SAFEAPI_ALIGNED_(n)
 Portable alignment specifier used ahead of a storage byte array (e.g. in SAFEAPI_DECLARE_STORAGE) so its address is suitable for the backend's internal struct layout. Expands to the best available mechanism for the compiler (C11 _Alignas, MSVC declspec, or GCC/Clang __attribute); expands to nothing on compilers with no portable alignment control.
#define SAFEAPI_DECLARE_STORAGE(type_name, byte_size)
 Declares an opaque, fixed-size, aligned storage type for a service's handle. The real internal layout is private to the backend implementation; callers only reserve the bytes.

Typedefs

typedef uint32_t sapi_duration_ms_t
typedef uint64_t sapi_timestamp_ms_t

Detailed Description

Fixed-width types and the caller-owned-storage handle pattern.

Macro Definition Documentation

◆ SAFEAPI_STORAGE_ALIGN

#define SAFEAPI_STORAGE_ALIGN   8U

Alignment (bytes) guaranteed for every opaque storage block.

Definition at line 36 of file sapi_types.h.

◆ SAFEAPI_ALIGNED_

#define SAFEAPI_ALIGNED_ ( n)

Portable alignment specifier used ahead of a storage byte array (e.g. in SAFEAPI_DECLARE_STORAGE) so its address is suitable for the backend's internal struct layout. Expands to the best available mechanism for the compiler (C11 _Alignas, MSVC declspec, or GCC/Clang __attribute); expands to nothing on compilers with no portable alignment control.

Parameters
nRequested alignment in bytes.

Definition at line 58 of file sapi_types.h.

◆ SAFEAPI_DECLARE_STORAGE

#define SAFEAPI_DECLARE_STORAGE ( type_name,
byte_size )
Value:
typedef struct \
{ \
SAFEAPI_ALIGNED_(SAFEAPI_STORAGE_ALIGN) \
unsigned char reserved_[(byte_size)]; \
} type_name
#define SAFEAPI_STORAGE_ALIGN
Alignment (bytes) guaranteed for every opaque storage block.
Definition sapi_types.h:36

Declares an opaque, fixed-size, aligned storage type for a service's handle. The real internal layout is private to the backend implementation; callers only reserve the bytes.

Usage: SAFEAPI_DECLARE_STORAGE(sapi_timer_storage_t, 64U);

Definition at line 69 of file sapi_types.h.

Typedef Documentation

◆ sapi_duration_ms_t

typedef uint32_t sapi_duration_ms_t

Milliseconds, used by all timer/deadline related APIs.

Definition at line 27 of file sapi_types.h.

◆ sapi_timestamp_ms_t

typedef uint64_t sapi_timestamp_ms_t

Monotonic timestamp in milliseconds since an arbitrary epoch.

Definition at line 30 of file sapi_types.h.