Safe API Framework
0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
Toggle main menu visibility
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
39
#include "
rte/utils/status/rte_status.h
"
40
#include "
rte/utils/types/rte_types.h
"
41
42
#ifdef __cplusplus
43
extern
"C"
{
44
#endif
45
54
typedef
struct
55
{
56
void
*
ptr
;
57
size_t
size
;
58
uint32_t
canary
;
59
}
rte_safe_ptr_t
;
60
73
rte_status_t
rte_safe_ptr_init
(
rte_safe_ptr_t
*sp,
void
*ptr,
size_t
size);
74
82
bool
rte_safe_ptr_is_valid
(
const
rte_safe_ptr_t
*sp);
83
95
rte_status_t
rte_safe_ptr_get
(
const
rte_safe_ptr_t
*sp,
void
**out_ptr);
96
115
rte_status_t
rte_safe_ptr_offset
(
const
rte_safe_ptr_t
*sp,
size_t
offset,
size_t
length,
void
**out_ptr);
116
129
void
rte_safe_ptr_invalidate
(
rte_safe_ptr_t
*sp);
130
131
#ifdef __cplusplus
132
}
133
#endif
134
135
#endif
/* RTE_OAL_SAFE_PTR_H */
136
/* SAFEPTR */
rte_safe_ptr_offset
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...
Definition
rte_safe_ptr.c:66
rte_safe_ptr_invalidate
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...
Definition
rte_safe_ptr.c:105
rte_safe_ptr_init
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.
Definition
rte_safe_ptr.c:17
rte_safe_ptr_get
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.
Definition
rte_safe_ptr.c:46
rte_safe_ptr_is_valid
bool rte_safe_ptr_is_valid(const rte_safe_ptr_t *sp)
Checks whether sp currently wraps a valid, non-invalidated region.
Definition
rte_safe_ptr.c:33
rte_status_t
rte_status_t
Common result/status codes.
Definition
rte_status.h:27
rte_status.h
Common status/error codes returned by every Safe API Framework function. Shared across all OS Abstrac...
rte_types.h
Common fixed-width types and the caller-owned-storage handle pattern used by every OAL service (see A...
rte_safe_ptr_t
A bounds-checked, canary-protected wrapper around one raw memory region. Opaque to callers in spirit ...
Definition
rte_safe_ptr.h:55
rte_safe_ptr_t::size
size_t size
Definition
rte_safe_ptr.h:57
rte_safe_ptr_t::ptr
void * ptr
Definition
rte_safe_ptr.h:56
rte_safe_ptr_t::canary
uint32_t canary
Definition
rte_safe_ptr.h:58
include
rte
oal
memory
rte_safe_ptr.h
Generated by
1.18.0