| 1 | // SPDX-License-Identifier: MIT |
| 2 | /* |
| 3 | * Copyright 2022-2023 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
| 4 | */ |
| 5 | |
| 6 | #ifndef SIDE_TYPE_VALUE_ABI_H |
| 7 | #define SIDE_TYPE_VALUE_ABI_H |
| 8 | |
| 9 | #include <stdint.h> |
| 10 | #include <side/macros.h> |
| 11 | #include <side/endian.h> |
| 12 | |
| 13 | enum side_type_label_byte_order { |
| 14 | SIDE_TYPE_BYTE_ORDER_LE = 0, |
| 15 | SIDE_TYPE_BYTE_ORDER_BE = 1, |
| 16 | }; |
| 17 | |
| 18 | union side_integer_value { |
| 19 | uint8_t side_u8; |
| 20 | uint16_t side_u16; |
| 21 | uint32_t side_u32; |
| 22 | uint64_t side_u64; |
| 23 | int8_t side_s8; |
| 24 | int16_t side_s16; |
| 25 | int32_t side_s32; |
| 26 | int64_t side_s64; |
| 27 | uintptr_t side_uptr; |
| 28 | side_padding(32); |
| 29 | } SIDE_PACKED; |
| 30 | side_check_size(union side_integer_value, 32); |
| 31 | |
| 32 | union side_bool_value { |
| 33 | uint8_t side_bool8; |
| 34 | uint16_t side_bool16; |
| 35 | uint32_t side_bool32; |
| 36 | uint64_t side_bool64; |
| 37 | side_padding(32); |
| 38 | } SIDE_PACKED; |
| 39 | side_check_size(union side_bool_value, 32); |
| 40 | |
| 41 | union side_float_value { |
| 42 | #if __HAVE_FLOAT16 |
| 43 | _Float16 side_float_binary16; |
| 44 | #endif |
| 45 | #if __HAVE_FLOAT32 |
| 46 | _Float32 side_float_binary32; |
| 47 | #endif |
| 48 | #if __HAVE_FLOAT64 |
| 49 | _Float64 side_float_binary64; |
| 50 | #endif |
| 51 | #if __HAVE_FLOAT128 |
| 52 | _Float128 side_float_binary128; |
| 53 | #endif |
| 54 | side_padding(32); |
| 55 | } SIDE_PACKED; |
| 56 | side_check_size(union side_float_value, 32); |
| 57 | |
| 58 | struct side_type_raw_string { |
| 59 | side_ptr_t(const void) p; /* pointer to string */ |
| 60 | uint8_t unit_size; /* 1, 2, or 4 bytes */ |
| 61 | side_enum_t(enum side_type_label_byte_order, uint8_t) byte_order; |
| 62 | } SIDE_PACKED; |
| 63 | side_check_size(struct side_type_raw_string, 18); |
| 64 | |
| 65 | #endif /* SIDE_TYPE_VALUE_ABI_H */ |