Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Loading...
Searching...
No Matches
rte_safe_ptr.h
Go to the documentation of this file.
1
36#ifndef RTE_OAL_SAFE_PTR_H
37#define RTE_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
73rte_status_t rte_safe_ptr_init(rte_safe_ptr_t *sp, void *ptr, size_t size);
74
83
95rte_status_t rte_safe_ptr_get(const rte_safe_ptr_t *sp, void **out_ptr);
96
115rte_status_t rte_safe_ptr_offset(const rte_safe_ptr_t *sp, size_t offset, size_t length, void **out_ptr);
116
130
131#ifdef __cplusplus
132}
133#endif
134
135#endif /* RTE_OAL_SAFE_PTR_H */
136 /* SAFEPTR */
rte_status_t rte_safe_ptr_offset(const rte_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...
void rte_safe_ptr_invalidate(rte_safe_ptr_t *sp)
Invalidates sp: clears the wrapped pointer and the canary, so every subsequent access on sp fails RTE...
rte_status_t rte_safe_ptr_init(rte_safe_ptr_t *sp, void *ptr, size_t size)
Initializes sp to wrap [ptr, ptr + size), writing the canary.
rte_status_t rte_safe_ptr_get(const rte_safe_ptr_t *sp, void **out_ptr)
Retrieves the wrapped pointer directly (the whole region, no offset) after validating it.
bool rte_safe_ptr_is_valid(const rte_safe_ptr_t *sp)
Checks whether sp currently wraps a valid, non-invalidated region.
rte_status_t
Common result/status codes.
Definition rte_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 ...
uint32_t canary