Integer 128 split byte order helpers
[libside.git] / include / side / abi / type-value.h
CommitLineData
57553dfd
MD
1// SPDX-License-Identifier: MIT
2/*
3 * Copyright 2022-2023 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 */
5
b8dfb348
MD
6#ifndef SIDE_ABI_TYPE_VALUE_H
7#define SIDE_ABI_TYPE_VALUE_H
57553dfd
MD
8
9#include <stdint.h>
10#include <side/macros.h>
11#include <side/endian.h>
12
35e4f870
MD
13/*
14 * SIDE ABI for type values.
15 *
16 * The extensibility scheme for the SIDE ABI for type values is as
17 * follows:
18 *
19 * * Existing type values are never changed nor extended. Type values
20 * can be added to the ABI by reserving a label within enum
21 * side_type_label.
22 * * Each union part of the ABI has an explicit size defined by a
23 * side_padding() member. Each structure and union have a static
24 * assert validating its size.
25 * * Changing the semantic of the existing type value fields is a
26 * breaking ABI change.
27 *
28 * Handling of unknown type values by the tracers:
29 *
30 * * A tracer may choose to support only a subset of the type values
31 * supported by libside. When encountering an unknown or unsupported
32 * type value, the tracer has the option to either disallow the entire
33 * event or skip over the unknown type, both at event registration and
34 * when receiving the side_call arguments.
35 */
36
57553dfd
MD
37enum side_type_label_byte_order {
38 SIDE_TYPE_BYTE_ORDER_LE = 0,
39 SIDE_TYPE_BYTE_ORDER_BE = 1,
40};
41
465ba030
MD
42#if (SIDE_BYTE_ORDER == SIDE_LITTLE_ENDIAN)
43enum side_integer128_split_index {
44 SIDE_INTEGER128_SPLIT_LOW = 0,
45 SIDE_INTEGER128_SPLIT_HIGH = 1,
46 NR_SIDE_INTEGER128_SPLIT,
47};
48#else
49enum side_integer128_split_index {
50 SIDE_INTEGER128_SPLIT_HIGH = 0,
51 SIDE_INTEGER128_SPLIT_LOW = 1,
52 NR_SIDE_INTEGER128_SPLIT,
53};
54#endif
55
57553dfd
MD
56union side_integer_value {
57 uint8_t side_u8;
58 uint16_t side_u16;
59 uint32_t side_u32;
60 uint64_t side_u64;
465ba030
MD
61 /* Indexed with enum side_integer128_split_index */
62 uint64_t side_u128_split[NR_SIDE_INTEGER128_SPLIT];
57553dfd
MD
63 int8_t side_s8;
64 int16_t side_s16;
65 int32_t side_s32;
66 int64_t side_s64;
465ba030
MD
67 /* Indexed with enum side_integer128_split_index */
68 int64_t side_s128_split[NR_SIDE_INTEGER128_SPLIT];
57553dfd
MD
69 uintptr_t side_uptr;
70 side_padding(32);
71} SIDE_PACKED;
72side_check_size(union side_integer_value, 32);
73
74union side_bool_value {
75 uint8_t side_bool8;
76 uint16_t side_bool16;
77 uint32_t side_bool32;
78 uint64_t side_bool64;
79 side_padding(32);
80} SIDE_PACKED;
81side_check_size(union side_bool_value, 32);
82
83union side_float_value {
84#if __HAVE_FLOAT16
85 _Float16 side_float_binary16;
86#endif
87#if __HAVE_FLOAT32
88 _Float32 side_float_binary32;
89#endif
90#if __HAVE_FLOAT64
91 _Float64 side_float_binary64;
92#endif
93#if __HAVE_FLOAT128
94 _Float128 side_float_binary128;
95#endif
96 side_padding(32);
97} SIDE_PACKED;
98side_check_size(union side_float_value, 32);
99
100struct side_type_raw_string {
101 side_ptr_t(const void) p; /* pointer to string */
102 uint8_t unit_size; /* 1, 2, or 4 bytes */
103 side_enum_t(enum side_type_label_byte_order, uint8_t) byte_order;
104} SIDE_PACKED;
105side_check_size(struct side_type_raw_string, 18);
106
b8dfb348 107#endif /* SIDE_ABI_TYPE_VALUE_H */
This page took 0.026068 seconds and 4 git commands to generate.