Safe API Framework
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
sapi_safe_ptr.h
Go to the documentation of this file.
1
36#ifndef SAFEAPI_OAL_SAFE_PTR_H
37#define SAFEAPI_OAL_SAFE_PTR_H
38
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
54typedef struct
55{
56 void *ptr;
57 size_t size;
58 uint32_t canary;
60
73sapi_status_t sapi_safe_ptr_init(sapi_safe_ptr_t *sp, void *ptr, size_t size);
74
83
95sapi_status_t sapi_safe_ptr_get(const sapi_safe_ptr_t *sp, void **out_ptr);
96
115sapi_status_t sapi_safe_ptr_offset(const sapi_safe_ptr_t *sp, size_t offset, size_t length, void **out_ptr);
116
130
131#ifdef __cplusplus
132}
133#endif
134
135#endif /* SAFEAPI_OAL_SAFE_PTR_H */
136 /* SAFEPTR */
bool sapi_safe_ptr_is_valid(const sapi_safe_ptr_t *sp)
Checks whether sp currently wraps a valid, non-invalidated region.
void sapi_safe_ptr_invalidate(sapi_safe_ptr_t *sp)
Invalidates sp: clears the wrapped pointer and the canary, so every subsequent access on sp fails SAP...
sapi_status_t sapi_safe_ptr_get(const sapi_safe_ptr_t *sp, void **out_ptr)
Retrieves the wrapped pointer directly (the whole region, no offset) after validating it.
sapi_status_t sapi_safe_ptr_init(sapi_safe_ptr_t *sp, void *ptr, size_t size)
Initializes sp to wrap [ptr, ptr + size), writing the canary.
sapi_status_t sapi_safe_ptr_offset(const sapi_safe_ptr_t *sp, size_t offset, size_t length, void **out_ptr)
Computes a bounds-checked pointer at offset within sp's region, verifying the caller's intended acces...
sapi_status_t
Common result/status codes.
Definition sapi_status.h:27
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
A bounds-checked, canary-protected wrapper around one raw memory region. Opaque to callers in spirit ...