Split trace.h into API/ABI sub-headers
[libside.git] / include / side / type-argument-abi.h
1 // SPDX-License-Identifier: MIT
2 /*
3 * Copyright 2022-2023 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 */
5
6 #ifndef SIDE_TYPE_ARGUMENT_ABI_H
7 #define SIDE_TYPE_ARGUMENT_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 #include <side/attribute-abi.h>
15 #include <side/type-description-abi.h>
16 #include <side/visitor-abi.h>
17
18 struct side_tracer_dynamic_struct_visitor_ctx;
19
20 #if (SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN)
21 # define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE
22 #else
23 # define SIDE_TYPE_BYTE_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
24 #endif
25
26 #if (SIDE_FLOAT_WORD_ORDER == SIDE_LITTLE_ENDIAN)
27 # define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_LE
28 #else
29 # define SIDE_TYPE_FLOAT_WORD_ORDER_HOST SIDE_TYPE_BYTE_ORDER_BE
30 #endif
31
32 union side_arg_static {
33 /* Stack-copy basic types */
34 union side_bool_value bool_value;
35 uint8_t byte_value;
36 side_ptr_t(const void) string_value; /* const {uint8_t, uint16_t, uint32_t} * */
37 union side_integer_value integer_value;
38 union side_float_value float_value;
39
40 /* Stack-copy compound types */
41 side_ptr_t(const struct side_arg_vec) side_struct;
42 side_ptr_t(const struct side_arg_variant) side_variant;
43 side_ptr_t(const struct side_arg_vec) side_array;
44 side_ptr_t(const struct side_arg_vec) side_vla;
45 void *side_vla_app_visitor_ctx;
46
47 /* Gather basic types */
48 side_ptr_t(const void) side_bool_gather_ptr;
49 side_ptr_t(const void) side_byte_gather_ptr;
50 side_ptr_t(const void) side_integer_gather_ptr;
51 side_ptr_t(const void) side_float_gather_ptr;
52 side_ptr_t(const void) side_string_gather_ptr;
53
54 /* Gather compound types */
55 side_ptr_t(const void) side_array_gather_ptr;
56 side_ptr_t(const void) side_struct_gather_ptr;
57 struct {
58 side_ptr_t(const void) ptr;
59 side_ptr_t(const void) length_ptr;
60 } SIDE_PACKED side_vla_gather;
61 side_padding(32);
62 } SIDE_PACKED;
63 side_check_size(union side_arg_static, 32);
64
65 struct side_arg_dynamic_vla {
66 side_ptr_t(const struct side_arg) sav;
67 side_ptr_t(const struct side_attr) attr;
68 uint32_t len;
69 uint32_t nr_attr;
70 } SIDE_PACKED;
71 side_check_size(struct side_arg_dynamic_vla, 40);
72
73 struct side_arg_dynamic_struct {
74 side_ptr_t(const struct side_arg_dynamic_field) fields;
75 side_ptr_t(const struct side_attr) attr;
76 uint32_t len;
77 uint32_t nr_attr;
78 } SIDE_PACKED;
79 side_check_size(struct side_arg_dynamic_struct, 40);
80
81 struct side_dynamic_struct_visitor {
82 side_func_ptr_t(side_dynamic_struct_visitor_func) visitor;
83 side_ptr_t(void) app_ctx;
84 side_ptr_t(const struct side_attr) attr;
85 uint32_t nr_attr;
86 } SIDE_PACKED;
87 side_check_size(struct side_dynamic_struct_visitor, 52);
88
89 struct side_dynamic_vla_visitor {
90 side_func_ptr_t(side_visitor_func) visitor;
91 side_ptr_t(void) app_ctx;
92 side_ptr_t(const struct side_attr) attr;
93 uint32_t nr_attr;
94 } SIDE_PACKED;
95 side_check_size(struct side_dynamic_vla_visitor, 52);
96
97 union side_arg_dynamic {
98 /* Dynamic basic types */
99 struct side_type_null side_null;
100 struct {
101 struct side_type_bool type;
102 union side_bool_value value;
103 } SIDE_PACKED side_bool;
104 struct {
105 struct side_type_byte type;
106 uint8_t value;
107 } SIDE_PACKED side_byte;
108 struct {
109 struct side_type_string type;
110 uint64_t value; /* const char * */
111 } SIDE_PACKED side_string;
112 struct {
113 struct side_type_integer type;
114 union side_integer_value value;
115 } SIDE_PACKED side_integer;
116 struct {
117 struct side_type_float type;
118 union side_float_value value;
119 } SIDE_PACKED side_float;
120
121 /* Dynamic compound types */
122 side_ptr_t(const struct side_arg_dynamic_struct) side_dynamic_struct;
123 side_ptr_t(const struct side_arg_dynamic_vla) side_dynamic_vla;
124
125 struct side_dynamic_struct_visitor side_dynamic_struct_visitor;
126 struct side_dynamic_vla_visitor side_dynamic_vla_visitor;
127
128 side_padding(58);
129 } SIDE_PACKED;
130 side_check_size(union side_arg_dynamic, 58);
131
132 struct side_arg {
133 side_enum_t(enum side_type_label, uint16_t) type;
134 union {
135 union side_arg_static side_static;
136 union side_arg_dynamic side_dynamic;
137 side_padding(62);
138 } SIDE_PACKED u;
139 } SIDE_PACKED;
140 side_check_size(struct side_arg, 64);
141
142 struct side_arg_variant {
143 struct side_arg selector;
144 struct side_arg option;
145 } SIDE_PACKED;
146 side_check_size(struct side_arg_variant, 128);
147
148 struct side_arg_vec {
149 side_ptr_t(const struct side_arg) sav;
150 uint32_t len;
151 } SIDE_PACKED;
152 side_check_size(struct side_arg_vec, 20);
153
154 struct side_arg_dynamic_field {
155 side_ptr_t(const char) field_name;
156 const struct side_arg elem;
157 } SIDE_PACKED;
158 side_check_size(struct side_arg_dynamic_field, 16 + sizeof(const struct side_arg));
159
160 #endif /* SIDE_TYPE_ARGUMENT_ABI_H */
This page took 0.032353 seconds and 4 git commands to generate.