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

Generated from ADR-003's template; see sapi_cast.h for behavior. Every function widens its input to the int64_t/uint64_t matching the source's signedness, then range-checks against the destination's limit macros before performing the explicit cast. More...

Include dependency graph for sapi_cast.c:

Go to the source code of this file.

Functions

sapi_status_t sapi_cast_i8_to_i16 (int8_t in, int16_t *out)
 Checked cast from int8_t to int16_t.
sapi_status_t sapi_cast_i8_to_i32 (int8_t in, int32_t *out)
 Checked cast from int8_t to int32_t.
sapi_status_t sapi_cast_i8_to_i64 (int8_t in, int64_t *out)
 Checked cast from int8_t to int64_t.
sapi_status_t sapi_cast_i8_to_u8 (int8_t in, uint8_t *out)
 Checked cast from int8_t to uint8_t.
sapi_status_t sapi_cast_i8_to_u16 (int8_t in, uint16_t *out)
 Checked cast from int8_t to uint16_t.
sapi_status_t sapi_cast_i8_to_u32 (int8_t in, uint32_t *out)
 Checked cast from int8_t to uint32_t.
sapi_status_t sapi_cast_i8_to_u64 (int8_t in, uint64_t *out)
 Checked cast from int8_t to uint64_t.
sapi_status_t sapi_cast_i8_to_size (int8_t in, size_t *out)
 Checked cast from int8_t to size_t.
sapi_status_t sapi_cast_i16_to_i8 (int16_t in, int8_t *out)
 Checked cast from int16_t to int8_t.
sapi_status_t sapi_cast_i16_to_i32 (int16_t in, int32_t *out)
 Checked cast from int16_t to int32_t.
sapi_status_t sapi_cast_i16_to_i64 (int16_t in, int64_t *out)
 Checked cast from int16_t to int64_t.
sapi_status_t sapi_cast_i16_to_u8 (int16_t in, uint8_t *out)
 Checked cast from int16_t to uint8_t.
sapi_status_t sapi_cast_i16_to_u16 (int16_t in, uint16_t *out)
 Checked cast from int16_t to uint16_t.
sapi_status_t sapi_cast_i16_to_u32 (int16_t in, uint32_t *out)
 Checked cast from int16_t to uint32_t.
sapi_status_t sapi_cast_i16_to_u64 (int16_t in, uint64_t *out)
 Checked cast from int16_t to uint64_t.
sapi_status_t sapi_cast_i16_to_size (int16_t in, size_t *out)
 Checked cast from int16_t to size_t.
sapi_status_t sapi_cast_i32_to_i8 (int32_t in, int8_t *out)
 Checked cast from int32_t to int8_t.
sapi_status_t sapi_cast_i32_to_i16 (int32_t in, int16_t *out)
 Checked cast from int32_t to int16_t.
sapi_status_t sapi_cast_i32_to_i64 (int32_t in, int64_t *out)
 Checked cast from int32_t to int64_t.
sapi_status_t sapi_cast_i32_to_u8 (int32_t in, uint8_t *out)
 Checked cast from int32_t to uint8_t.
sapi_status_t sapi_cast_i32_to_u16 (int32_t in, uint16_t *out)
 Checked cast from int32_t to uint16_t.
sapi_status_t sapi_cast_i32_to_u32 (int32_t in, uint32_t *out)
 Checked cast from int32_t to uint32_t.
sapi_status_t sapi_cast_i32_to_u64 (int32_t in, uint64_t *out)
 Checked cast from int32_t to uint64_t.
sapi_status_t sapi_cast_i32_to_size (int32_t in, size_t *out)
 Checked cast from int32_t to size_t.
sapi_status_t sapi_cast_i64_to_i8 (int64_t in, int8_t *out)
 Checked cast from int64_t to int8_t.
sapi_status_t sapi_cast_i64_to_i16 (int64_t in, int16_t *out)
 Checked cast from int64_t to int16_t.
sapi_status_t sapi_cast_i64_to_i32 (int64_t in, int32_t *out)
 Checked cast from int64_t to int32_t.
sapi_status_t sapi_cast_i64_to_u8 (int64_t in, uint8_t *out)
 Checked cast from int64_t to uint8_t.
sapi_status_t sapi_cast_i64_to_u16 (int64_t in, uint16_t *out)
 Checked cast from int64_t to uint16_t.
sapi_status_t sapi_cast_i64_to_u32 (int64_t in, uint32_t *out)
 Checked cast from int64_t to uint32_t.
sapi_status_t sapi_cast_i64_to_u64 (int64_t in, uint64_t *out)
 Checked cast from int64_t to uint64_t.
sapi_status_t sapi_cast_i64_to_size (int64_t in, size_t *out)
 Checked cast from int64_t to size_t.
sapi_status_t sapi_cast_u8_to_i8 (uint8_t in, int8_t *out)
 Checked cast from uint8_t to int8_t.
sapi_status_t sapi_cast_u8_to_i16 (uint8_t in, int16_t *out)
 Checked cast from uint8_t to int16_t.
sapi_status_t sapi_cast_u8_to_i32 (uint8_t in, int32_t *out)
 Checked cast from uint8_t to int32_t.
sapi_status_t sapi_cast_u8_to_i64 (uint8_t in, int64_t *out)
 Checked cast from uint8_t to int64_t.
sapi_status_t sapi_cast_u8_to_u16 (uint8_t in, uint16_t *out)
 Checked cast from uint8_t to uint16_t.
sapi_status_t sapi_cast_u8_to_u32 (uint8_t in, uint32_t *out)
 Checked cast from uint8_t to uint32_t.
sapi_status_t sapi_cast_u8_to_u64 (uint8_t in, uint64_t *out)
 Checked cast from uint8_t to uint64_t.
sapi_status_t sapi_cast_u8_to_size (uint8_t in, size_t *out)
 Checked cast from uint8_t to size_t.
sapi_status_t sapi_cast_u16_to_i8 (uint16_t in, int8_t *out)
 Checked cast from uint16_t to int8_t.
sapi_status_t sapi_cast_u16_to_i16 (uint16_t in, int16_t *out)
 Checked cast from uint16_t to int16_t.
sapi_status_t sapi_cast_u16_to_i32 (uint16_t in, int32_t *out)
 Checked cast from uint16_t to int32_t.
sapi_status_t sapi_cast_u16_to_i64 (uint16_t in, int64_t *out)
 Checked cast from uint16_t to int64_t.
sapi_status_t sapi_cast_u16_to_u8 (uint16_t in, uint8_t *out)
 Checked cast from uint16_t to uint8_t.
sapi_status_t sapi_cast_u16_to_u32 (uint16_t in, uint32_t *out)
 Checked cast from uint16_t to uint32_t.
sapi_status_t sapi_cast_u16_to_u64 (uint16_t in, uint64_t *out)
 Checked cast from uint16_t to uint64_t.
sapi_status_t sapi_cast_u16_to_size (uint16_t in, size_t *out)
 Checked cast from uint16_t to size_t.
sapi_status_t sapi_cast_u32_to_i8 (uint32_t in, int8_t *out)
 Checked cast from uint32_t to int8_t.
sapi_status_t sapi_cast_u32_to_i16 (uint32_t in, int16_t *out)
 Checked cast from uint32_t to int16_t.
sapi_status_t sapi_cast_u32_to_i32 (uint32_t in, int32_t *out)
 Checked cast from uint32_t to int32_t.
sapi_status_t sapi_cast_u32_to_i64 (uint32_t in, int64_t *out)
 Checked cast from uint32_t to int64_t.
sapi_status_t sapi_cast_u32_to_u8 (uint32_t in, uint8_t *out)
 Checked cast from uint32_t to uint8_t.
sapi_status_t sapi_cast_u32_to_u16 (uint32_t in, uint16_t *out)
 Checked cast from uint32_t to uint16_t.
sapi_status_t sapi_cast_u32_to_u64 (uint32_t in, uint64_t *out)
 Checked cast from uint32_t to uint64_t.
sapi_status_t sapi_cast_u32_to_size (uint32_t in, size_t *out)
 Checked cast from uint32_t to size_t.
sapi_status_t sapi_cast_u64_to_i8 (uint64_t in, int8_t *out)
 Checked cast from uint64_t to int8_t.
sapi_status_t sapi_cast_u64_to_i16 (uint64_t in, int16_t *out)
 Checked cast from uint64_t to int16_t.
sapi_status_t sapi_cast_u64_to_i32 (uint64_t in, int32_t *out)
 Checked cast from uint64_t to int32_t.
sapi_status_t sapi_cast_u64_to_i64 (uint64_t in, int64_t *out)
 Checked cast from uint64_t to int64_t.
sapi_status_t sapi_cast_u64_to_u8 (uint64_t in, uint8_t *out)
 Checked cast from uint64_t to uint8_t.
sapi_status_t sapi_cast_u64_to_u16 (uint64_t in, uint16_t *out)
 Checked cast from uint64_t to uint16_t.
sapi_status_t sapi_cast_u64_to_u32 (uint64_t in, uint32_t *out)
 Checked cast from uint64_t to uint32_t.
sapi_status_t sapi_cast_u64_to_size (uint64_t in, size_t *out)
 Checked cast from uint64_t to size_t.
sapi_status_t sapi_cast_size_to_i8 (size_t in, int8_t *out)
 Checked cast from size_t to int8_t.
sapi_status_t sapi_cast_size_to_i16 (size_t in, int16_t *out)
 Checked cast from size_t to int16_t.
sapi_status_t sapi_cast_size_to_i32 (size_t in, int32_t *out)
 Checked cast from size_t to int32_t.
sapi_status_t sapi_cast_size_to_i64 (size_t in, int64_t *out)
 Checked cast from size_t to int64_t.
sapi_status_t sapi_cast_size_to_u8 (size_t in, uint8_t *out)
 Checked cast from size_t to uint8_t.
sapi_status_t sapi_cast_size_to_u16 (size_t in, uint16_t *out)
 Checked cast from size_t to uint16_t.
sapi_status_t sapi_cast_size_to_u32 (size_t in, uint32_t *out)
 Checked cast from size_t to uint32_t.
sapi_status_t sapi_cast_size_to_u64 (size_t in, uint64_t *out)
 Checked cast from size_t to uint64_t.
sapi_status_t sapi_cast_checked_add_u32 (uint32_t a, uint32_t b, uint32_t *out)
 Checked addition: *out = a + b, only if the result fits uint32_t.
sapi_status_t sapi_cast_checked_sub_u32 (uint32_t a, uint32_t b, uint32_t *out)
 Checked subtraction: *out = a - b, only if b <= a (no underflow).
sapi_status_t sapi_cast_checked_mul_u32 (uint32_t a, uint32_t b, uint32_t *out)
 Checked multiplication: *out = a * b, only if the result fits uint32_t.
sapi_status_t sapi_cast_checked_add_size (size_t a, size_t b, size_t *out)
 Checked addition: *out = a + b, only if the result fits size_t.
sapi_status_t sapi_cast_checked_sub_size (size_t a, size_t b, size_t *out)
 Checked subtraction: *out = a - b, only if b <= a (no underflow).
sapi_status_t sapi_cast_checked_mul_size (size_t a, size_t b, size_t *out)
 Checked multiplication: *out = a * b, only if the result fits size_t.
sapi_status_t sapi_cast_bounds_check (size_t index, size_t count)
 Checked array/index bounds check: is index a valid index into an array of count elements?

Detailed Description

Generated from ADR-003's template; see sapi_cast.h for behavior. Every function widens its input to the int64_t/uint64_t matching the source's signedness, then range-checks against the destination's limit macros before performing the explicit cast.

Definition in file sapi_cast.c.