Commit | Line | Data |
---|---|---|
57553dfd MD |
1 | // SPDX-License-Identifier: MIT |
2 | /* | |
3 | * Copyright 2022-2023 Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
4 | */ | |
5 | ||
6 | #ifndef SIDE_ATTRIBUTE_ABI_H | |
7 | #define SIDE_ATTRIBUTE_ABI_H | |
8 | ||
9 | #include <stdint.h> | |
10 | #include <side/macros.h> | |
11 | #include <side/endian.h> | |
12 | ||
13 | #include <side/type-value-abi.h> | |
14 | ||
15 | enum side_attr_type { | |
16 | SIDE_ATTR_TYPE_NULL, | |
17 | SIDE_ATTR_TYPE_BOOL, | |
18 | SIDE_ATTR_TYPE_U8, | |
19 | SIDE_ATTR_TYPE_U16, | |
20 | SIDE_ATTR_TYPE_U32, | |
21 | SIDE_ATTR_TYPE_U64, | |
22 | SIDE_ATTR_TYPE_S8, | |
23 | SIDE_ATTR_TYPE_S16, | |
24 | SIDE_ATTR_TYPE_S32, | |
25 | SIDE_ATTR_TYPE_S64, | |
26 | SIDE_ATTR_TYPE_FLOAT_BINARY16, | |
27 | SIDE_ATTR_TYPE_FLOAT_BINARY32, | |
28 | SIDE_ATTR_TYPE_FLOAT_BINARY64, | |
29 | SIDE_ATTR_TYPE_FLOAT_BINARY128, | |
30 | SIDE_ATTR_TYPE_STRING, | |
31 | ||
32 | _NR_SIDE_ATTR_TYPE, /* Last entry. */ | |
33 | }; | |
34 | ||
35 | struct side_attr_value { | |
36 | side_enum_t(enum side_attr_type, uint32_t) type; | |
37 | union { | |
38 | uint8_t bool_value; | |
39 | struct side_type_raw_string string_value; | |
40 | union side_integer_value integer_value; | |
41 | union side_float_value float_value; | |
42 | side_padding(32); | |
43 | } SIDE_PACKED u; | |
44 | }; | |
45 | side_check_size(struct side_attr_value, 36); | |
46 | ||
47 | struct side_attr { | |
48 | const struct side_type_raw_string key; | |
49 | const struct side_attr_value value; | |
50 | } SIDE_PACKED; | |
51 | side_check_size(struct side_attr, 54); | |
52 | ||
53 | #endif /* SIDE_ATTRIBUTE_ABI_H */ |