asoma.dev · the C reference for libose
libose
the C library every o.se host is built on
Loading...
Searching...
No Matches
ose_abi.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2026 John MacCallum Permission is hereby granted,
3 free of charge, to any person obtaining a copy of this software
4 and associated documentation files (the "Software"), to deal in
5 the Software without restriction, including without limitation the
6 rights to use, copy, modify, merge, publish, distribute,
7 sublicense, and/or sell copies of the Software, and to permit
8 persons to whom the Software is furnished to do so, subject to the
9 following conditions:
10
11 The above copyright notice and this permission notice shall be
12 included in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 DEALINGS IN THE SOFTWARE.
22*/
23
49
50#ifndef OSE_ABI_H
51#define OSE_ABI_H
52
53#include <stdint.h>
54#include "ose.h"
55#include "ose_context.h"
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
68#define OSE_ABI_FIELDS(F) \
69 F(cache_size, OSE_CONTEXT_CACHE_SIZE) \
70 F(cache_items, OSE_CONTEXT_NUM_CACHE_ITEMS) \
71 F(cache_ttstrlen, OSE_CONTEXT_CACHE_TYPETAG_STRLEN) \
72 F(cache_offset, OSE_CONTEXT_CACHE_OFFSET) \
73 F(bundle_offset, OSE_CONTEXT_BUNDLE_OFFSET) \
74 F(alignment, OSE_CONTEXT_ALIGNMENT) \
75 F(ptr_size, (int32_t)sizeof(intptr_t)) \
76 F(types, OSE_ABI_TYPEMASK) \
77 F(wrapped_bundle, OSE_ABI_WRAP_BUNDLE_PTR) \
78 F(debug, OSE_ABI_DEBUG)
79
80/* The build configuration, which is an ABI difference and was not being
81 checked. OSE_CONF_DEBUG implies OSE_WRAP_BUNDLE_PTR, and that changes
82 ose_bundle from `char *` to a struct holding one -- so every function
83 taking a bundle changes signature. A debug module loaded cleanly into
84 a release host and answered (3, 4) /o/add correctly, which is the worst
85 possible outcome: on arm64 a one-pointer struct happens to be passed like
86 a pointer, so the mismatch shows up later, somewhere else, as what looks
87 like a library bug. Asserts are live in such a module too, and they abort
88 the host.
89
90 Kept as two fields rather than one so the message names which. */
91#ifdef OSE_WRAP_BUNDLE_PTR
92#define OSE_ABI_WRAP_BUNDLE_PTR 1
93#else
94#define OSE_ABI_WRAP_BUNDLE_PTR 0
95#endif
96
97#ifdef OSE_DEBUG
98#define OSE_ABI_DEBUG 1
99#else
100#define OSE_ABI_DEBUG 0
101#endif
102
103/* Which optional types this build provides. A module that believes
104 OSETT_DOUBLE exists sizes payloads differently from a host that does not
105 provide it, so the sets have to match. */
106#define OSE_ABI_TYPE(name, bit) OSE_ABI_TYPE_##name(bit)
107
108#define OSE_ABI_TYPEMASK \
109 ((int32_t)(0 \
110 OSE_ABI_TYPE(SYMBOL, 0) \
111 OSE_ABI_TYPE(DOUBLE, 1) \
112 OSE_ABI_TYPE(INT8, 2) \
113 OSE_ABI_TYPE(UINT8, 3) \
114 OSE_ABI_TYPE(INT16, 4) \
115 OSE_ABI_TYPE(UINT16, 5) \
116 OSE_ABI_TYPE(UINT32, 6) \
117 OSE_ABI_TYPE(INT64, 7) \
118 OSE_ABI_TYPE(UINT64, 8) \
119 OSE_ABI_TYPE(TIMETAG, 9) \
120 OSE_ABI_TYPE(TRUE, 10) \
121 OSE_ABI_TYPE(FALSE, 11) \
122 OSE_ABI_TYPE(NIL, 12) \
123 OSE_ABI_TYPE(INFINITUM, 13)))
124
125#ifdef OSE_PROVIDE_TYPE_SYMBOL
126#define OSE_ABI_TYPE_SYMBOL(b) | (1 << (b))
127#else
128#define OSE_ABI_TYPE_SYMBOL(b)
129#endif
130#ifdef OSE_PROVIDE_TYPE_DOUBLE
131#define OSE_ABI_TYPE_DOUBLE(b) | (1 << (b))
132#else
133#define OSE_ABI_TYPE_DOUBLE(b)
134#endif
135#ifdef OSE_PROVIDE_TYPE_INT8
136#define OSE_ABI_TYPE_INT8(b) | (1 << (b))
137#else
138#define OSE_ABI_TYPE_INT8(b)
139#endif
140#ifdef OSE_PROVIDE_TYPE_UINT8
141#define OSE_ABI_TYPE_UINT8(b) | (1 << (b))
142#else
143#define OSE_ABI_TYPE_UINT8(b)
144#endif
145#ifdef OSE_PROVIDE_TYPE_INT16
146#define OSE_ABI_TYPE_INT16(b) | (1 << (b))
147#else
148#define OSE_ABI_TYPE_INT16(b)
149#endif
150#ifdef OSE_PROVIDE_TYPE_UINT16
151#define OSE_ABI_TYPE_UINT16(b) | (1 << (b))
152#else
153#define OSE_ABI_TYPE_UINT16(b)
154#endif
155#ifdef OSE_PROVIDE_TYPE_UINT32
156#define OSE_ABI_TYPE_UINT32(b) | (1 << (b))
157#else
158#define OSE_ABI_TYPE_UINT32(b)
159#endif
160#ifdef OSE_PROVIDE_TYPE_INT64
161#define OSE_ABI_TYPE_INT64(b) | (1 << (b))
162#else
163#define OSE_ABI_TYPE_INT64(b)
164#endif
165#ifdef OSE_PROVIDE_TYPE_UINT64
166#define OSE_ABI_TYPE_UINT64(b) | (1 << (b))
167#else
168#define OSE_ABI_TYPE_UINT64(b)
169#endif
170#ifdef OSE_PROVIDE_TYPE_TIMETAG
171#define OSE_ABI_TYPE_TIMETAG(b) | (1 << (b))
172#else
173#define OSE_ABI_TYPE_TIMETAG(b)
174#endif
175#ifdef OSE_PROVIDE_TYPE_TRUE
176#define OSE_ABI_TYPE_TRUE(b) | (1 << (b))
177#else
178#define OSE_ABI_TYPE_TRUE(b)
179#endif
180#ifdef OSE_PROVIDE_TYPE_FALSE
181#define OSE_ABI_TYPE_FALSE(b) | (1 << (b))
182#else
183#define OSE_ABI_TYPE_FALSE(b)
184#endif
185#ifdef OSE_PROVIDE_TYPE_NIL
186#define OSE_ABI_TYPE_NIL(b) | (1 << (b))
187#else
188#define OSE_ABI_TYPE_NIL(b)
189#endif
190#ifdef OSE_PROVIDE_TYPE_INFINITUM
191#define OSE_ABI_TYPE_INFINITUM(b) | (1 << (b))
192#else
193#define OSE_ABI_TYPE_INFINITUM(b)
194#endif
195
198{
199#define OSE_ABI_FIELD_DECL(name, value) int32_t name;
200 OSE_ABI_FIELDS(OSE_ABI_FIELD_DECL)
201#undef OSE_ABI_FIELD_DECL
202};
203
210#define OSE_ABI_FIELD_VALUE(name, value) (value),
211#define OSE_ABI_INIT { OSE_ABI_FIELDS(OSE_ABI_FIELD_VALUE) }
212
214#define OSE_ABI_SYMBOL_NAME "ose_abi_expected"
215
217#define OSE_ABI_DECLARE \
218 const struct ose_abi ose_abi_expected = OSE_ABI_INIT
219
221void ose_abi_thisBuild(struct ose_abi *a);
222
235int32_t ose_abi_compatible(const struct ose_abi *host,
236 const struct ose_abi *mod,
237 char *buf,
238 int32_t buflen);
239
240#ifdef __cplusplus
241}
242#endif
243
244#endif
provides global definitions and types
void ose_abi_thisBuild(struct ose_abi *a)
Fill a with the values this build was compiled with.
Definition ose_abi.c:29
#define OSE_ABI_FIELDS(F)
The compatibility fields, listed once.
Definition ose_abi.h:68
int32_t ose_abi_compatible(const struct ose_abi *host, const struct ose_abi *mod, char *buf, int32_t buflen)
Compare two records.
Definition ose_abi.c:38
contains functions that structure an OSC bundle for use with other parts of this library
What a build was compiled to expect.
Definition ose_abi.h:198