1pub const __bool_true_false_are_defined: u32 = 1;
4pub const true_: u32 = 1;
5pub const false_: u32 = 0;
6pub const NAME_ENTRY_LEN: u32 = 256;
7pub type wchar_t = ::core::ffi::c_int;
8#[repr(C)]
9#[repr(align(16))]
10#[derive(Debug, Default, Copy, Clone)]
11pub struct max_align_t {
12 pub __clang_max_align_nonce1: ::core::ffi::c_longlong,
13 pub __bindgen_padding_0: u64,
14 pub __clang_max_align_nonce2: u128,
15}
16#[allow(clippy::unnecessary_operation, clippy::identity_op)]
17const _: () = {
18 ["Size of max_align_t"][::core::mem::size_of::<max_align_t>() - 32usize];
19 ["Alignment of max_align_t"][::core::mem::align_of::<max_align_t>() - 16usize];
20 ["Offset of field: max_align_t::__clang_max_align_nonce1"]
21 [::core::mem::offset_of!(max_align_t, __clang_max_align_nonce1) - 0usize];
22 ["Offset of field: max_align_t::__clang_max_align_nonce2"]
23 [::core::mem::offset_of!(max_align_t, __clang_max_align_nonce2) - 16usize];
24};
25pub type int_least64_t = i64;
26pub type uint_least64_t = u64;
27pub type int_fast64_t = i64;
28pub type uint_fast64_t = u64;
29pub type int_least32_t = i32;
30pub type uint_least32_t = u32;
31pub type int_fast32_t = i32;
32pub type uint_fast32_t = u32;
33pub type int_least16_t = i16;
34pub type uint_least16_t = u16;
35pub type int_fast16_t = i16;
36pub type uint_fast16_t = u16;
37pub type int_least8_t = i8;
38pub type uint_least8_t = u8;
39pub type int_fast8_t = i8;
40pub type uint_fast8_t = u8;
41pub type intmax_t = ::core::ffi::c_long;
42pub type uintmax_t = ::core::ffi::c_ulong;
43#[doc = " Object ID"]
44pub type objid = __uint128_t;
45#[doc = " Duration, containing seconds and nanoseconds."]
46#[repr(C)]
47#[derive(Debug, Default, Copy, Clone)]
48pub struct duration {
49 pub seconds: u64,
50 pub nanos: u32,
51}
52#[allow(clippy::unnecessary_operation, clippy::identity_op)]
53const _: () = {
54 ["Size of duration"][::core::mem::size_of::<duration>() - 16usize];
55 ["Alignment of duration"][::core::mem::align_of::<duration>() - 8usize];
56 ["Offset of field: duration::seconds"][::core::mem::offset_of!(duration, seconds) - 0usize];
57 ["Offset of field: duration::nanos"][::core::mem::offset_of!(duration, nanos) - 8usize];
58};
59#[doc = " Optional duration."]
60#[repr(C)]
61#[derive(Debug, Default, Copy, Clone)]
62pub struct option_duration {
63 pub dur: duration,
64 pub is_some: i32,
65}
66#[allow(clippy::unnecessary_operation, clippy::identity_op)]
67const _: () = {
68 ["Size of option_duration"][::core::mem::size_of::<option_duration>() - 24usize];
69 ["Alignment of option_duration"][::core::mem::align_of::<option_duration>() - 8usize];
70 ["Offset of field: option_duration::dur"]
71 [::core::mem::offset_of!(option_duration, dur) - 0usize];
72 ["Offset of field: option_duration::is_some"]
73 [::core::mem::offset_of!(option_duration, is_some) - 16usize];
74};
75unsafe extern "C" {
76 pub static NO_DURATION: option_duration;
77}
78pub type twz_error = u64;
79pub type twz_error_code = u16;
80pub type twz_error_category = u16;
81pub const ERROR_CODE_SHIFT: twz_error = 0;
82pub const ERROR_CODE_MASK: twz_error = 65535;
83pub const ERROR_CATEGORY_MASK: twz_error = 281470681743360;
84pub const ERROR_CATEGORY_SHIFT: twz_error = 32;
85pub const SUCCESS: twz_error_code = 0;
86pub const OTHER_ERROR: twz_error_code = 0;
87pub const NOT_SUPPORTED: twz_error_code = 1;
88pub const INTERNAL: twz_error_code = 2;
89pub const WOULD_BLOCK: twz_error_code = 3;
90pub const TIMED_OUT: twz_error_code = 4;
91pub const ACCESS_DENIED: twz_error_code = 5;
92pub const NO_SUCH_OPERATION: twz_error_code = 6;
93pub const INTERRUPTED: twz_error_code = 7;
94pub const IN_PROGRESS: twz_error_code = 8;
95pub const INVALID_ARGUMENT: twz_error_code = 1;
96pub const WRONG_TYPE: twz_error_code = 2;
97pub const INVALID_ADDRESS: twz_error_code = 3;
98pub const BAD_HANDLE: twz_error_code = 4;
99pub const OUT_OF_MEMORY: twz_error_code = 1;
100pub const OUT_OF_RESOURCES: twz_error_code = 2;
101pub const OUT_OF_NAMES: twz_error_code = 3;
102pub const UNAVAILABLE: twz_error_code = 4;
103pub const BUSY: twz_error_code = 5;
104pub const NOT_CONNECTED: twz_error_code = 6;
105pub const UNREACHABLE: twz_error_code = 7;
106pub const REFUSED: twz_error_code = 8;
107pub const NON_ATOMIC: twz_error_code = 9;
108pub const NOT_FOUND: twz_error_code = 1;
109pub const ALREADY_EXISTS: twz_error_code = 2;
110pub const WRONG_NAME_KIND: twz_error_code = 3;
111pub const ALREADY_BOUND: twz_error_code = 4;
112pub const INVALID_NAME: twz_error_code = 5;
113pub const LINK_LOOP: twz_error_code = 6;
114pub const NOT_EMPTY: twz_error_code = 7;
115pub const MAPPING_FAILED: twz_error_code = 1;
116pub const NOT_MAPPED: twz_error_code = 2;
117pub const INVALID_FOTE: twz_error_code = 3;
118pub const INVALID_PTR: twz_error_code = 4;
119pub const INVALID_META: twz_error_code = 5;
120pub const BASETYPE_MISMATCH: twz_error_code = 6;
121pub const NO_SUCH_OBJECT: twz_error_code = 7;
122pub const OTHER_IO_ERROR: twz_error_code = 1;
123pub const DATA_LOSS: twz_error_code = 2;
124pub const DEVICE_ERROR: twz_error_code = 3;
125pub const SEEK_FAILED: twz_error_code = 4;
126pub const RESET: twz_error_code = 5;
127pub const INVALID_KEY: twz_error_code = 1;
128pub const INVALID_SCHEME: twz_error_code = 2;
129pub const SIGNATURE_MISMATCH: twz_error_code = 3;
130pub const GATE_DENIED: twz_error_code = 4;
131pub const INVALID_GATE: twz_error_code = 5;
132pub const UNCATEGORIZED_ERROR: twz_error_category = 0;
133pub const GENERIC_ERROR: twz_error_category = 1;
134pub const ARGUMENT_ERROR: twz_error_category = 2;
135pub const RESOURCE_ERROR: twz_error_category = 3;
136pub const NAMING_ERROR: twz_error_category = 4;
137pub const OBJECT_ERROR: twz_error_category = 5;
138pub const IO_ERROR: twz_error_category = 6;
139pub const SECURITY_ERROR: twz_error_category = 7;
140#[doc = " Error or value"]
141#[repr(C)]
142#[derive(Debug, Default, Copy, Clone)]
143pub struct u32_result {
144 pub err: twz_error,
145 pub val: u32,
146}
147#[allow(clippy::unnecessary_operation, clippy::identity_op)]
148const _: () = {
149 ["Size of u32_result"][::core::mem::size_of::<u32_result>() - 16usize];
150 ["Alignment of u32_result"][::core::mem::align_of::<u32_result>() - 8usize];
151 ["Offset of field: u32_result::err"][::core::mem::offset_of!(u32_result, err) - 0usize];
152 ["Offset of field: u32_result::val"][::core::mem::offset_of!(u32_result, val) - 8usize];
153};
154#[doc = " Error or value"]
155#[repr(C)]
156#[derive(Debug, Default, Copy, Clone)]
157pub struct u64_result {
158 pub err: twz_error,
159 pub val: u64,
160}
161#[allow(clippy::unnecessary_operation, clippy::identity_op)]
162const _: () = {
163 ["Size of u64_result"][::core::mem::size_of::<u64_result>() - 16usize];
164 ["Alignment of u64_result"][::core::mem::align_of::<u64_result>() - 8usize];
165 ["Offset of field: u64_result::err"][::core::mem::offset_of!(u64_result, err) - 0usize];
166 ["Offset of field: u64_result::val"][::core::mem::offset_of!(u64_result, val) - 8usize];
167};
168#[doc = " Error or value"]
169#[repr(C)]
170#[repr(align(16))]
171#[derive(Debug, Default, Copy, Clone)]
172pub struct objid_result {
173 pub err: twz_error,
174 pub __bindgen_padding_0: u64,
175 pub val: objid,
176}
177#[allow(clippy::unnecessary_operation, clippy::identity_op)]
178const _: () = {
179 ["Size of objid_result"][::core::mem::size_of::<objid_result>() - 32usize];
180 ["Alignment of objid_result"][::core::mem::align_of::<objid_result>() - 16usize];
181 ["Offset of field: objid_result::err"][::core::mem::offset_of!(objid_result, err) - 0usize];
182 ["Offset of field: objid_result::val"][::core::mem::offset_of!(objid_result, val) - 16usize];
183};
184#[doc = " Error or value"]
185#[repr(C)]
186#[derive(Debug, Copy, Clone)]
187pub struct ptr_result {
188 pub err: twz_error,
189 pub val: *mut ::core::ffi::c_void,
190}
191#[allow(clippy::unnecessary_operation, clippy::identity_op)]
192const _: () = {
193 ["Size of ptr_result"][::core::mem::size_of::<ptr_result>() - 16usize];
194 ["Alignment of ptr_result"][::core::mem::align_of::<ptr_result>() - 8usize];
195 ["Offset of field: ptr_result::err"][::core::mem::offset_of!(ptr_result, err) - 0usize];
196 ["Offset of field: ptr_result::val"][::core::mem::offset_of!(ptr_result, val) - 8usize];
197};
198impl Default for ptr_result {
199 fn default() -> Self {
200 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
201 unsafe {
202 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
203 s.assume_init()
204 }
205 }
206}
207#[doc = " Error or value"]
208#[repr(C)]
209#[derive(Debug, Default, Copy, Clone)]
210pub struct io_result {
211 pub err: twz_error,
212 pub val: usize,
213}
214#[allow(clippy::unnecessary_operation, clippy::identity_op)]
215const _: () = {
216 ["Size of io_result"][::core::mem::size_of::<io_result>() - 16usize];
217 ["Alignment of io_result"][::core::mem::align_of::<io_result>() - 8usize];
218 ["Offset of field: io_result::err"][::core::mem::offset_of!(io_result, err) - 0usize];
219 ["Offset of field: io_result::val"][::core::mem::offset_of!(io_result, val) - 8usize];
220};
221#[doc = " Allocation flags"]
222pub type alloc_flags = u32;
223#[doc = " Zero memory during operation"]
224pub const ZERO_MEMORY: alloc_flags = 1;
225unsafe extern "C-unwind" {
226 #[doc = " Allocate memory, zeroing it first if the flag is set."]
227 pub fn twz_rt_malloc(sz: usize, align: usize, flags: alloc_flags) -> *mut ::core::ffi::c_void;
228}
229unsafe extern "C-unwind" {
230 #[doc = " Deallocate memory. If ZERO_MEMORY is set, will clear the memory before freeing."]
231 pub fn twz_rt_dealloc(
232 ptr: *mut ::core::ffi::c_void,
233 sz: usize,
234 align: usize,
235 flags: alloc_flags,
236 );
237}
238unsafe extern "C-unwind" {
239 #[doc = " Reallocate memory. If ZERO_MEMORY is set, will zero new memory before returning and zero to-be-freed memory before freeing."]
240 pub fn twz_rt_realloc(
241 ptr: *mut ::core::ffi::c_void,
242 sz: usize,
243 align: usize,
244 new_size: usize,
245 flags: alloc_flags,
246 ) -> *mut ::core::ffi::c_void;
247}
248#[doc = " Exit code type"]
249pub type exit_code = i32;
250#[doc = " Basic OS information provided to rust libstd"]
251#[repr(C)]
252#[derive(Debug, Copy, Clone)]
253pub struct basic_aux {
254 #[doc = " Number of arguments"]
255 pub argc: usize,
256 #[doc = " Pointer to args"]
257 pub args: *mut *mut ::core::ffi::c_char,
258 #[doc = " Environment pointer"]
259 pub env: *mut *mut ::core::ffi::c_char,
260}
261#[allow(clippy::unnecessary_operation, clippy::identity_op)]
262const _: () = {
263 ["Size of basic_aux"][::core::mem::size_of::<basic_aux>() - 24usize];
264 ["Alignment of basic_aux"][::core::mem::align_of::<basic_aux>() - 8usize];
265 ["Offset of field: basic_aux::argc"][::core::mem::offset_of!(basic_aux, argc) - 0usize];
266 ["Offset of field: basic_aux::args"][::core::mem::offset_of!(basic_aux, args) - 8usize];
267 ["Offset of field: basic_aux::env"][::core::mem::offset_of!(basic_aux, env) - 16usize];
268};
269impl Default for basic_aux {
270 fn default() -> Self {
271 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
272 unsafe {
273 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
274 s.assume_init()
275 }
276 }
277}
278#[doc = " Return info from rust libstd"]
279#[repr(C)]
280#[derive(Debug, Default, Copy, Clone)]
281pub struct basic_return {
282 pub code: exit_code,
283}
284#[allow(clippy::unnecessary_operation, clippy::identity_op)]
285const _: () = {
286 ["Size of basic_return"][::core::mem::size_of::<basic_return>() - 4usize];
287 ["Alignment of basic_return"][::core::mem::align_of::<basic_return>() - 4usize];
288 ["Offset of field: basic_return::code"][::core::mem::offset_of!(basic_return, code) - 0usize];
289};
290#[repr(C)]
291#[derive(Debug, Copy, Clone)]
292pub struct ctor_set {
293 #[doc = " Fn ptr to _init"]
294 pub legacy_init: ::core::option::Option<unsafe extern "C-unwind" fn()>,
295 #[doc = " Pointer to the init array"]
296 pub init_array: *mut ::core::option::Option<unsafe extern "C-unwind" fn()>,
297 #[doc = " Length of init array"]
298 pub init_array_len: usize,
299}
300#[allow(clippy::unnecessary_operation, clippy::identity_op)]
301const _: () = {
302 ["Size of ctor_set"][::core::mem::size_of::<ctor_set>() - 24usize];
303 ["Alignment of ctor_set"][::core::mem::align_of::<ctor_set>() - 8usize];
304 ["Offset of field: ctor_set::legacy_init"]
305 [::core::mem::offset_of!(ctor_set, legacy_init) - 0usize];
306 ["Offset of field: ctor_set::init_array"]
307 [::core::mem::offset_of!(ctor_set, init_array) - 8usize];
308 ["Offset of field: ctor_set::init_array_len"]
309 [::core::mem::offset_of!(ctor_set, init_array_len) - 16usize];
310};
311impl Default for ctor_set {
312 fn default() -> Self {
313 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
314 unsafe {
315 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
316 s.assume_init()
317 }
318 }
319}
320#[doc = " Init information for compartments"]
321#[repr(C)]
322#[derive(Debug, Copy, Clone)]
323pub struct comp_init_info {
324 #[doc = " Pointer to ctor_set list"]
325 pub ctor_set_array: *mut ctor_set,
326 #[doc = " Length of ctor_set array"]
327 pub ctor_set_len: usize,
328 #[doc = " Pointer to compartment config info"]
329 pub comp_config_info: *mut ::core::ffi::c_void,
330}
331#[allow(clippy::unnecessary_operation, clippy::identity_op)]
332const _: () = {
333 ["Size of comp_init_info"][::core::mem::size_of::<comp_init_info>() - 24usize];
334 ["Alignment of comp_init_info"][::core::mem::align_of::<comp_init_info>() - 8usize];
335 ["Offset of field: comp_init_info::ctor_set_array"]
336 [::core::mem::offset_of!(comp_init_info, ctor_set_array) - 0usize];
337 ["Offset of field: comp_init_info::ctor_set_len"]
338 [::core::mem::offset_of!(comp_init_info, ctor_set_len) - 8usize];
339 ["Offset of field: comp_init_info::comp_config_info"]
340 [::core::mem::offset_of!(comp_init_info, comp_config_info) - 16usize];
341};
342impl Default for comp_init_info {
343 fn default() -> Self {
344 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
345 unsafe {
346 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
347 s.assume_init()
348 }
349 }
350}
351#[doc = " Init information for minimal runtime"]
352#[repr(C)]
353#[derive(Debug, Copy, Clone)]
354pub struct minimal_init_info {
355 #[doc = " Pointer to program headers"]
356 pub phdrs: *mut ::core::ffi::c_void,
357 #[doc = " Number of program headers"]
358 pub nr_phdrs: usize,
359}
360#[allow(clippy::unnecessary_operation, clippy::identity_op)]
361const _: () = {
362 ["Size of minimal_init_info"][::core::mem::size_of::<minimal_init_info>() - 16usize];
363 ["Alignment of minimal_init_info"][::core::mem::align_of::<minimal_init_info>() - 8usize];
364 ["Offset of field: minimal_init_info::phdrs"]
365 [::core::mem::offset_of!(minimal_init_info, phdrs) - 0usize];
366 ["Offset of field: minimal_init_info::nr_phdrs"]
367 [::core::mem::offset_of!(minimal_init_info, nr_phdrs) - 8usize];
368};
369impl Default for minimal_init_info {
370 fn default() -> Self {
371 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
372 unsafe {
373 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
374 s.assume_init()
375 }
376 }
377}
378#[doc = " Possible init info types"]
379#[repr(C)]
380#[derive(Copy, Clone)]
381pub union init_info_ptrs {
382 pub comp: *mut comp_init_info,
383 pub min: *mut minimal_init_info,
384 pub monitor: *mut ::core::ffi::c_void,
385}
386#[allow(clippy::unnecessary_operation, clippy::identity_op)]
387const _: () = {
388 ["Size of init_info_ptrs"][::core::mem::size_of::<init_info_ptrs>() - 8usize];
389 ["Alignment of init_info_ptrs"][::core::mem::align_of::<init_info_ptrs>() - 8usize];
390 ["Offset of field: init_info_ptrs::comp"]
391 [::core::mem::offset_of!(init_info_ptrs, comp) - 0usize];
392 ["Offset of field: init_info_ptrs::min"][::core::mem::offset_of!(init_info_ptrs, min) - 0usize];
393 ["Offset of field: init_info_ptrs::monitor"]
394 [::core::mem::offset_of!(init_info_ptrs, monitor) - 0usize];
395};
396impl Default for init_info_ptrs {
397 fn default() -> Self {
398 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
399 unsafe {
400 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
401 s.assume_init()
402 }
403 }
404}
405#[doc = " Runtime initialization info."]
406#[repr(C)]
407#[derive(Copy, Clone)]
408pub struct runtime_info {
409 pub flags: i32,
410 #[doc = " Discrim. for init_info."]
411 pub kind: i32,
412 #[doc = " Pointer to args"]
413 pub args: *mut *mut ::core::ffi::c_char,
414 #[doc = " Number of args"]
415 pub argc: usize,
416 #[doc = " Environment pointer"]
417 pub envp: *mut *mut ::core::ffi::c_char,
418 pub init_info: init_info_ptrs,
419}
420#[allow(clippy::unnecessary_operation, clippy::identity_op)]
421const _: () = {
422 ["Size of runtime_info"][::core::mem::size_of::<runtime_info>() - 40usize];
423 ["Alignment of runtime_info"][::core::mem::align_of::<runtime_info>() - 8usize];
424 ["Offset of field: runtime_info::flags"][::core::mem::offset_of!(runtime_info, flags) - 0usize];
425 ["Offset of field: runtime_info::kind"][::core::mem::offset_of!(runtime_info, kind) - 4usize];
426 ["Offset of field: runtime_info::args"][::core::mem::offset_of!(runtime_info, args) - 8usize];
427 ["Offset of field: runtime_info::argc"][::core::mem::offset_of!(runtime_info, argc) - 16usize];
428 ["Offset of field: runtime_info::envp"][::core::mem::offset_of!(runtime_info, envp) - 24usize];
429 ["Offset of field: runtime_info::init_info"]
430 [::core::mem::offset_of!(runtime_info, init_info) - 32usize];
431};
432impl Default for runtime_info {
433 fn default() -> Self {
434 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
435 unsafe {
436 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
437 s.assume_init()
438 }
439 }
440}
441#[doc = " Minimal runtime info"]
442pub const RUNTIME_INIT_MIN: i32 = 0;
443#[doc = " Info for monitor"]
444pub const RUNTIME_INIT_MONITOR: i32 = 1;
445#[doc = " Info for compartments"]
446pub const RUNTIME_INIT_COMP: i32 = 2;
447#[doc = " Optional exit code"]
448#[repr(C)]
449#[derive(Debug, Default, Copy, Clone)]
450pub struct option_exit_code {
451 pub is_some: i32,
452 pub value: exit_code,
453}
454#[allow(clippy::unnecessary_operation, clippy::identity_op)]
455const _: () = {
456 ["Size of option_exit_code"][::core::mem::size_of::<option_exit_code>() - 8usize];
457 ["Alignment of option_exit_code"][::core::mem::align_of::<option_exit_code>() - 4usize];
458 ["Offset of field: option_exit_code::is_some"]
459 [::core::mem::offset_of!(option_exit_code, is_some) - 0usize];
460 ["Offset of field: option_exit_code::value"]
461 [::core::mem::offset_of!(option_exit_code, value) - 4usize];
462};
463unsafe extern "C-unwind" {
464 #[doc = " Exit with provided code"]
465 pub fn twz_rt_exit(code: exit_code);
466}
467unsafe extern "C-unwind" {
468 #[doc = " Abort immediately"]
469 pub fn twz_rt_abort();
470}
471unsafe extern "C-unwind" {
472 #[doc = " Signal the runtime to prep for entry from another compartment"]
473 pub fn twz_rt_cross_compartment_entry() -> bool;
474}
475unsafe extern "C-unwind" {
476 #[doc = " Set the handler for an upcall from kernel"]
477 pub fn twz_rt_set_upcall_handler(
478 handler: ::core::option::Option<
479 unsafe extern "C-unwind" fn(
480 frame: *mut ::core::ffi::c_void,
481 data: *const ::core::ffi::c_void,
482 ),
483 >,
484 );
485}
486unsafe extern "C-unwind" {
487 pub fn twz_rt_pre_main_hook() -> option_exit_code;
488}
489unsafe extern "C-unwind" {
490 pub fn twz_rt_post_main_hook();
491}
492unsafe extern "C-unwind" {
493 pub fn twz_rt_runtime_entry(
494 arg: *const runtime_info,
495 std_entry: ::core::option::Option<
496 unsafe extern "C-unwind" fn(arg1: basic_aux) -> basic_return,
497 >,
498 );
499}
500#[doc = " Futex type, based on linux futex."]
501pub type futex_word = u32;
502unsafe extern "C-unwind" {
503 #[doc = " If *ptr == expected, wait until signal, optionally timing out."]
504 pub fn twz_rt_futex_wait(
505 ptr: *mut futex_word,
506 expected: futex_word,
507 timeout: option_duration,
508 ) -> bool;
509}
510unsafe extern "C-unwind" {
511 #[doc = " Wake up up to max threads waiting on ptr. If max is set to FUTEX_WAKE_ALL, wake all threads."]
512 pub fn twz_rt_futex_wake(ptr: *mut futex_word, max: i64) -> bool;
513}
514#[doc = " Wake all threads instead of a maximum number"]
515pub const FUTEX_WAKE_ALL: i64 = -1;
516unsafe extern "C-unwind" {
517 #[doc = " Yield the thread now."]
518 pub fn twz_rt_yield_now();
519}
520unsafe extern "C-unwind" {
521 #[doc = " Set the name of the calling thread."]
522 pub fn twz_rt_set_name(name: *const ::core::ffi::c_char);
523}
524unsafe extern "C-unwind" {
525 #[doc = " Sleep the calling thread for specified duration."]
526 pub fn twz_rt_sleep(dur: duration);
527}
528#[doc = " TLS index, module ID and offset."]
529#[repr(C)]
530#[derive(Debug, Default, Copy, Clone)]
531pub struct tls_index {
532 pub mod_id: usize,
533 pub offset: usize,
534}
535#[allow(clippy::unnecessary_operation, clippy::identity_op)]
536const _: () = {
537 ["Size of tls_index"][::core::mem::size_of::<tls_index>() - 16usize];
538 ["Alignment of tls_index"][::core::mem::align_of::<tls_index>() - 8usize];
539 ["Offset of field: tls_index::mod_id"][::core::mem::offset_of!(tls_index, mod_id) - 0usize];
540 ["Offset of field: tls_index::offset"][::core::mem::offset_of!(tls_index, offset) - 8usize];
541};
542unsafe extern "C-unwind" {
543 #[doc = " Resolve the TLS index and get back the TLS data pointer."]
544 pub fn twz_rt_tls_get_addr(index: *mut tls_index) -> *mut ::core::ffi::c_void;
545}
546#[doc = " A TLS desc struct, with a resolver and value"]
547#[repr(C)]
548#[derive(Debug, Copy, Clone)]
549pub struct tls_desc {
550 #[doc = " Pointer to resolver"]
551 pub resolver: *mut ::core::ffi::c_void,
552 #[doc = " Value to pass to the resolver"]
553 pub value: u64,
554}
555#[allow(clippy::unnecessary_operation, clippy::identity_op)]
556const _: () = {
557 ["Size of tls_desc"][::core::mem::size_of::<tls_desc>() - 16usize];
558 ["Alignment of tls_desc"][::core::mem::align_of::<tls_desc>() - 8usize];
559 ["Offset of field: tls_desc::resolver"][::core::mem::offset_of!(tls_desc, resolver) - 0usize];
560 ["Offset of field: tls_desc::value"][::core::mem::offset_of!(tls_desc, value) - 8usize];
561};
562impl Default for tls_desc {
563 fn default() -> Self {
564 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
565 unsafe {
566 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
567 s.assume_init()
568 }
569 }
570}
571unsafe extern "C-unwind" {
572 #[doc = " Resolver for tls_desc"]
573 pub fn twz_rt_tls_desc_resolve(arg: *mut tls_desc) -> *mut ::core::ffi::c_void;
574}
575#[doc = " Runtime-internal ID of a thread"]
576pub type thread_id = u32;
577#[doc = " Arguments to spawn"]
578#[repr(C)]
579#[derive(Debug, Default, Copy, Clone)]
580pub struct spawn_args {
581 #[doc = " Size of stack to allocate"]
582 pub stack_size: usize,
583 #[doc = " Starting address"]
584 pub start: usize,
585 #[doc = " Starting argument"]
586 pub arg: usize,
587}
588#[allow(clippy::unnecessary_operation, clippy::identity_op)]
589const _: () = {
590 ["Size of spawn_args"][::core::mem::size_of::<spawn_args>() - 24usize];
591 ["Alignment of spawn_args"][::core::mem::align_of::<spawn_args>() - 8usize];
592 ["Offset of field: spawn_args::stack_size"]
593 [::core::mem::offset_of!(spawn_args, stack_size) - 0usize];
594 ["Offset of field: spawn_args::start"][::core::mem::offset_of!(spawn_args, start) - 8usize];
595 ["Offset of field: spawn_args::arg"][::core::mem::offset_of!(spawn_args, arg) - 16usize];
596};
597#[doc = " Spawn result."]
598#[repr(C)]
599#[derive(Debug, Default, Copy, Clone)]
600pub struct spawn_result {
601 #[doc = " Thread id, if err is set to Success."]
602 pub id: thread_id,
603 pub err: twz_error,
604}
605#[allow(clippy::unnecessary_operation, clippy::identity_op)]
606const _: () = {
607 ["Size of spawn_result"][::core::mem::size_of::<spawn_result>() - 16usize];
608 ["Alignment of spawn_result"][::core::mem::align_of::<spawn_result>() - 8usize];
609 ["Offset of field: spawn_result::id"][::core::mem::offset_of!(spawn_result, id) - 0usize];
610 ["Offset of field: spawn_result::err"][::core::mem::offset_of!(spawn_result, err) - 8usize];
611};
612unsafe extern "C-unwind" {
613 #[doc = " Sawn a thread. On success, that thread starts executing concurrently with this function's return."]
614 pub fn twz_rt_spawn_thread(args: spawn_args) -> spawn_result;
615}
616unsafe extern "C-unwind" {
617 #[doc = " Wait for a thread to exit, optionally timing out."]
618 pub fn twz_rt_join_thread(id: thread_id, timeout: option_duration) -> twz_error;
619}
620#[doc = " Mapping flags"]
621pub type map_flags = u32;
622#[doc = " Object handle"]
623#[repr(C)]
624#[repr(align(16))]
625#[derive(Debug, Copy, Clone)]
626pub struct object_handle {
627 #[doc = " ID for this handle"]
628 pub id: objid,
629 #[doc = " Pointer to per-runtime info. The first 64-bits of this data must be an atomic u64 value used for reference counting."]
630 pub runtime_info: *mut ::core::ffi::c_void,
631 #[doc = " Pointer to start of object data."]
632 pub start: *mut ::core::ffi::c_void,
633 #[doc = " Pointer to object meta struct."]
634 pub meta: *mut ::core::ffi::c_void,
635 #[doc = " Mapping flags"]
636 pub map_flags: map_flags,
637 #[doc = " Number of valid bytes after start pointer for this object handle, in multiples of of LEN_MUL"]
638 pub valid_len: u32,
639}
640#[allow(clippy::unnecessary_operation, clippy::identity_op)]
641const _: () = {
642 ["Size of object_handle"][::core::mem::size_of::<object_handle>() - 48usize];
643 ["Alignment of object_handle"][::core::mem::align_of::<object_handle>() - 16usize];
644 ["Offset of field: object_handle::id"][::core::mem::offset_of!(object_handle, id) - 0usize];
645 ["Offset of field: object_handle::runtime_info"]
646 [::core::mem::offset_of!(object_handle, runtime_info) - 16usize];
647 ["Offset of field: object_handle::start"]
648 [::core::mem::offset_of!(object_handle, start) - 24usize];
649 ["Offset of field: object_handle::meta"]
650 [::core::mem::offset_of!(object_handle, meta) - 32usize];
651 ["Offset of field: object_handle::map_flags"]
652 [::core::mem::offset_of!(object_handle, map_flags) - 40usize];
653 ["Offset of field: object_handle::valid_len"]
654 [::core::mem::offset_of!(object_handle, valid_len) - 44usize];
655};
656impl Default for object_handle {
657 fn default() -> Self {
658 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
659 unsafe {
660 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
661 s.assume_init()
662 }
663 }
664}
665#[doc = " Multiplier to valid_len."]
666pub const LEN_MUL: usize = 4096;
667#[doc = " An open descriptor for a runtime file handle."]
668pub type descriptor = i32;
669#[doc = " Options for creating the file."]
670#[repr(C)]
671#[repr(align(16))]
672#[derive(Debug, Default, Copy, Clone)]
673pub struct create_options {
674 #[doc = " Object ID to bind the name to, optional. 0 if not present."]
675 pub id: objid,
676 #[doc = " The kind of open/create operation. See CREATE_KIND_*."]
677 pub kind: u8,
678}
679#[allow(clippy::unnecessary_operation, clippy::identity_op)]
680const _: () = {
681 ["Size of create_options"][::core::mem::size_of::<create_options>() - 32usize];
682 ["Alignment of create_options"][::core::mem::align_of::<create_options>() - 16usize];
683 ["Offset of field: create_options::id"][::core::mem::offset_of!(create_options, id) - 0usize];
684 ["Offset of field: create_options::kind"]
685 [::core::mem::offset_of!(create_options, kind) - 16usize];
686};
687#[doc = " Information for opening a file."]
688#[repr(C)]
689#[repr(align(16))]
690#[derive(Debug, Copy, Clone)]
691pub struct open_info {
692 #[doc = " File name pointer."]
693 pub name: *const ::core::ffi::c_char,
694 #[doc = " Length of file name in bytes."]
695 pub len: usize,
696 #[doc = " Creation options"]
697 pub create: create_options,
698 #[doc = " Operation flags"]
699 pub flags: u32,
700}
701#[allow(clippy::unnecessary_operation, clippy::identity_op)]
702const _: () = {
703 ["Size of open_info"][::core::mem::size_of::<open_info>() - 64usize];
704 ["Alignment of open_info"][::core::mem::align_of::<open_info>() - 16usize];
705 ["Offset of field: open_info::name"][::core::mem::offset_of!(open_info, name) - 0usize];
706 ["Offset of field: open_info::len"][::core::mem::offset_of!(open_info, len) - 8usize];
707 ["Offset of field: open_info::create"][::core::mem::offset_of!(open_info, create) - 16usize];
708 ["Offset of field: open_info::flags"][::core::mem::offset_of!(open_info, flags) - 48usize];
709};
710impl Default for open_info {
711 fn default() -> Self {
712 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
713 unsafe {
714 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
715 s.assume_init()
716 }
717 }
718}
719#[doc = " Open the file only if it already exists."]
720pub const CREATE_KIND_EXISTING: u8 = 0;
721#[doc = " Open only if it doesn't exist, and create it."]
722pub const CREATE_KIND_NEW: u8 = 1;
723#[doc = " Open if it already exists, or create it if it doesn't."]
724pub const CREATE_KIND_EITHER: u8 = 2;
725#[doc = " Open the file with read access."]
726pub const OPEN_FLAG_READ: u32 = 1;
727#[doc = " Open the file with write access."]
728pub const OPEN_FLAG_WRITE: u32 = 2;
729#[doc = " Truncate the file on open. Requires write access."]
730pub const OPEN_FLAG_TRUNCATE: u32 = 4;
731#[doc = " Always use the end of the file as the position."]
732pub const OPEN_FLAG_TAIL: u32 = 8;
733#[doc = " If the file is a symlink, open the link instead of the target."]
734pub const OPEN_FLAG_SYMLINK: u32 = 16;
735#[doc = " Result of open call."]
736#[repr(C)]
737#[derive(Debug, Default, Copy, Clone)]
738pub struct open_result {
739 #[doc = " If error is Success, this contains a valid descriptor."]
740 pub fd: descriptor,
741 #[doc = " Error code, or success."]
742 pub err: twz_error,
743}
744#[allow(clippy::unnecessary_operation, clippy::identity_op)]
745const _: () = {
746 ["Size of open_result"][::core::mem::size_of::<open_result>() - 16usize];
747 ["Alignment of open_result"][::core::mem::align_of::<open_result>() - 8usize];
748 ["Offset of field: open_result::fd"][::core::mem::offset_of!(open_result, fd) - 0usize];
749 ["Offset of field: open_result::err"][::core::mem::offset_of!(open_result, err) - 8usize];
750};
751unsafe extern "C-unwind" {
752 #[doc = " Open a file."]
753 pub fn twz_rt_fd_open(info: open_info) -> open_result;
754}
755pub const open_anon_kind_AnonKind_Pipe: open_anon_kind = 0;
756pub const open_anon_kind_AnonKind_SocketConnect: open_anon_kind = 1;
757pub const open_anon_kind_AnonKind_SocketBind: open_anon_kind = 2;
758pub type open_anon_kind = ::core::ffi::c_uint;
759pub const addr_kind_AddrKind_Ipv4: addr_kind = 0;
760pub const addr_kind_AddrKind_Ipv6: addr_kind = 1;
761pub type addr_kind = ::core::ffi::c_uint;
762#[repr(C)]
763#[derive(Copy, Clone)]
764pub union socket_address_addrs {
765 pub v4: [u8; 4usize],
766 pub v6: [u8; 16usize],
767}
768#[allow(clippy::unnecessary_operation, clippy::identity_op)]
769const _: () = {
770 ["Size of socket_address_addrs"][::core::mem::size_of::<socket_address_addrs>() - 16usize];
771 ["Alignment of socket_address_addrs"][::core::mem::align_of::<socket_address_addrs>() - 1usize];
772 ["Offset of field: socket_address_addrs::v4"]
773 [::core::mem::offset_of!(socket_address_addrs, v4) - 0usize];
774 ["Offset of field: socket_address_addrs::v6"]
775 [::core::mem::offset_of!(socket_address_addrs, v6) - 0usize];
776};
777impl Default for socket_address_addrs {
778 fn default() -> Self {
779 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
780 unsafe {
781 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
782 s.assume_init()
783 }
784 }
785}
786#[repr(C)]
787#[derive(Copy, Clone)]
788pub struct socket_address {
789 pub kind: addr_kind,
790 pub addr_octets: socket_address_addrs,
791 pub port: u16,
792 pub scope_id: u32,
793 pub flowinfo: u32,
794}
795#[allow(clippy::unnecessary_operation, clippy::identity_op)]
796const _: () = {
797 ["Size of socket_address"][::core::mem::size_of::<socket_address>() - 32usize];
798 ["Alignment of socket_address"][::core::mem::align_of::<socket_address>() - 4usize];
799 ["Offset of field: socket_address::kind"]
800 [::core::mem::offset_of!(socket_address, kind) - 0usize];
801 ["Offset of field: socket_address::addr_octets"]
802 [::core::mem::offset_of!(socket_address, addr_octets) - 4usize];
803 ["Offset of field: socket_address::port"]
804 [::core::mem::offset_of!(socket_address, port) - 20usize];
805 ["Offset of field: socket_address::scope_id"]
806 [::core::mem::offset_of!(socket_address, scope_id) - 24usize];
807 ["Offset of field: socket_address::flowinfo"]
808 [::core::mem::offset_of!(socket_address, flowinfo) - 28usize];
809};
810impl Default for socket_address {
811 fn default() -> Self {
812 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
813 unsafe {
814 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
815 s.assume_init()
816 }
817 }
818}
819unsafe extern "C-unwind" {
820 #[doc = " Open a non-named file. The value pointed to by bind_info is dependent on the kind specified in the first\n argument. For pipe, bind_info is ignored. For Socket* kinds, bind_info points to a socket_address."]
821 pub fn twz_rt_fd_open_anon(
822 kind: open_anon_kind,
823 flags: u32,
824 bind_info: *mut ::core::ffi::c_void,
825 bind_info_len: usize,
826 ) -> open_result;
827}
828unsafe extern "C-unwind" {
829 #[doc = " Close a file descriptor. If the file descriptor is invalid\n or already closed, this function does nothing."]
830 pub fn twz_rt_fd_close(fd: descriptor);
831}
832#[doc = " Flags a descriptor can have."]
833pub type fd_flags = u32;
834#[doc = " This file descriptor is a terminal."]
835pub const FD_IS_TERMINAL: fd_flags = 1;
836#[doc = " Regular file"]
837pub const fd_kind_FdKind_Regular: fd_kind = 0;
838#[doc = " Directory"]
839pub const fd_kind_FdKind_Directory: fd_kind = 1;
840#[doc = " Symbolic link"]
841pub const fd_kind_FdKind_SymLink: fd_kind = 2;
842#[doc = " Kinds of underlying fd objects"]
843pub type fd_kind = ::core::ffi::c_uint;
844#[doc = " Information about a file descriptor."]
845#[repr(C)]
846#[repr(align(16))]
847#[derive(Debug, Copy, Clone)]
848pub struct fd_info {
849 #[doc = " Underlying root objid."]
850 pub id: objid,
851 #[doc = " Length of underlying object, or 0 if undefined."]
852 pub len: u64,
853 #[doc = " Flags for the descriptor."]
854 pub flags: fd_flags,
855 #[doc = " Underlying fd kind"]
856 pub kind: fd_kind,
857 pub created: duration,
858 pub accessed: duration,
859 pub modified: duration,
860 pub unix_mode: u32,
861}
862#[allow(clippy::unnecessary_operation, clippy::identity_op)]
863const _: () = {
864 ["Size of fd_info"][::core::mem::size_of::<fd_info>() - 96usize];
865 ["Alignment of fd_info"][::core::mem::align_of::<fd_info>() - 16usize];
866 ["Offset of field: fd_info::id"][::core::mem::offset_of!(fd_info, id) - 0usize];
867 ["Offset of field: fd_info::len"][::core::mem::offset_of!(fd_info, len) - 16usize];
868 ["Offset of field: fd_info::flags"][::core::mem::offset_of!(fd_info, flags) - 24usize];
869 ["Offset of field: fd_info::kind"][::core::mem::offset_of!(fd_info, kind) - 28usize];
870 ["Offset of field: fd_info::created"][::core::mem::offset_of!(fd_info, created) - 32usize];
871 ["Offset of field: fd_info::accessed"][::core::mem::offset_of!(fd_info, accessed) - 48usize];
872 ["Offset of field: fd_info::modified"][::core::mem::offset_of!(fd_info, modified) - 64usize];
873 ["Offset of field: fd_info::unix_mode"][::core::mem::offset_of!(fd_info, unix_mode) - 80usize];
874};
875impl Default for fd_info {
876 fn default() -> Self {
877 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
878 unsafe {
879 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
880 s.assume_init()
881 }
882 }
883}
884unsafe extern "C-unwind" {
885 #[doc = " Get information about a descriptor. If this returns true, the fd was valid\n and the data pointed to by info is filled with fd_info data."]
886 pub fn twz_rt_fd_get_info(fd: descriptor, info: *mut fd_info) -> bool;
887}
888#[doc = " Commands for descriptors."]
889pub type fd_cmd = u32;
890#[doc = " Duplicate this descriptor. The arg argument is ignored. The ret argument points to a descriptor."]
891pub const FD_CMD_DUP: fd_cmd = 0;
892#[doc = " Sync the underlying storage of the file descriptor."]
893pub const FD_CMD_SYNC: fd_cmd = 1;
894#[doc = " Truncate the underlying storage of the file descriptor. The arg argument points to a u64 length."]
895pub const FD_CMD_TRUNCATE: fd_cmd = 2;
896unsafe extern "C-unwind" {
897 #[doc = " Perform a command on the descriptor. The arguments arg and ret are interpreted according to\n the command specified."]
898 pub fn twz_rt_fd_cmd(
899 fd: descriptor,
900 cmd: fd_cmd,
901 arg: *mut ::core::ffi::c_void,
902 ret: *mut ::core::ffi::c_void,
903 ) -> twz_error;
904}
905#[repr(C)]
906#[repr(align(16))]
907#[derive(Debug, Copy, Clone)]
908pub struct name_entry {
909 pub info: fd_info,
910 pub name_len: u32,
911 pub linkname_len: u32,
912 pub name: [u8; 256usize],
913}
914#[allow(clippy::unnecessary_operation, clippy::identity_op)]
915const _: () = {
916 ["Size of name_entry"][::core::mem::size_of::<name_entry>() - 368usize];
917 ["Alignment of name_entry"][::core::mem::align_of::<name_entry>() - 16usize];
918 ["Offset of field: name_entry::info"][::core::mem::offset_of!(name_entry, info) - 0usize];
919 ["Offset of field: name_entry::name_len"]
920 [::core::mem::offset_of!(name_entry, name_len) - 96usize];
921 ["Offset of field: name_entry::linkname_len"]
922 [::core::mem::offset_of!(name_entry, linkname_len) - 100usize];
923 ["Offset of field: name_entry::name"][::core::mem::offset_of!(name_entry, name) - 104usize];
924};
925impl Default for name_entry {
926 fn default() -> Self {
927 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
928 unsafe {
929 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
930 s.assume_init()
931 }
932 }
933}
934unsafe extern "C-unwind" {
935 #[doc = " Enumerate sub-names in an fd (e.g. directory entries). The buf and len arguments form a &mut [name_entry] slice, and the off argument specifies how many names to skip for this read. The return value is the number of entries read, or\n 0 if at end of list."]
936 pub fn twz_rt_fd_enumerate_names(
937 fd: descriptor,
938 buf: *mut name_entry,
939 len: usize,
940 off: usize,
941 ) -> io_result;
942}
943unsafe extern "C-unwind" {
944 #[doc = " Remove a name in the namespace."]
945 pub fn twz_rt_fd_remove(name: *const ::core::ffi::c_char, name_len: usize) -> twz_error;
946}
947unsafe extern "C-unwind" {
948 #[doc = " Create a new namespace."]
949 pub fn twz_rt_fd_mkns(name: *const ::core::ffi::c_char, name_len: usize) -> twz_error;
950}
951unsafe extern "C-unwind" {
952 #[doc = " Create a new symlink."]
953 pub fn twz_rt_fd_symlink(
954 name: *const ::core::ffi::c_char,
955 name_len: usize,
956 target: *const ::core::ffi::c_char,
957 target_len: usize,
958 ) -> twz_error;
959}
960unsafe extern "C-unwind" {
961 #[doc = " Read symlink."]
962 pub fn twz_rt_fd_readlink(
963 name: *const ::core::ffi::c_char,
964 name_len: usize,
965 buf: *mut ::core::ffi::c_char,
966 buf_len: usize,
967 out_buf_len: *mut u64,
968 ) -> twz_error;
969}
970#[doc = " Type of whence values for seek."]
971pub type whence = u32;
972#[doc = " Flags for IO operations"]
973pub type io_flags = u32;
974#[doc = " Non-blocking behavior specified. If the operation would block, return io_result with error set to WouldBlock instead."]
975pub const IO_NONBLOCKING: io_flags = 1;
976#[doc = " Seek offset from start of file"]
977pub const WHENCE_START: whence = 0;
978#[doc = " Seek offset from end of file"]
979pub const WHENCE_END: whence = 1;
980#[doc = " Seek offset from current fd position"]
981pub const WHENCE_CURRENT: whence = 2;
982#[doc = " Optional offset. If value is FD_POS, use the file descriptor position."]
983pub type optional_offset = i64;
984pub const FD_POS: optional_offset = -1;
985#[doc = " Context for I/O operations."]
986#[repr(C)]
987#[derive(Debug, Default, Copy, Clone)]
988pub struct io_ctx {
989 pub flags: io_flags,
990 pub offset: optional_offset,
991 pub timeout: option_duration,
992}
993#[allow(clippy::unnecessary_operation, clippy::identity_op)]
994const _: () = {
995 ["Size of io_ctx"][::core::mem::size_of::<io_ctx>() - 40usize];
996 ["Alignment of io_ctx"][::core::mem::align_of::<io_ctx>() - 8usize];
997 ["Offset of field: io_ctx::flags"][::core::mem::offset_of!(io_ctx, flags) - 0usize];
998 ["Offset of field: io_ctx::offset"][::core::mem::offset_of!(io_ctx, offset) - 8usize];
999 ["Offset of field: io_ctx::timeout"][::core::mem::offset_of!(io_ctx, timeout) - 16usize];
1000};
1001pub const endpoint_kind_Endpoint_Unspecified: endpoint_kind = 0;
1002pub const endpoint_kind_Endpoint_Socket: endpoint_kind = 1;
1003pub type endpoint_kind = ::core::ffi::c_uint;
1004#[repr(C)]
1005#[derive(Copy, Clone)]
1006pub union endpoint_addrs {
1007 pub socket_addr: socket_address,
1008}
1009#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1010const _: () = {
1011 ["Size of endpoint_addrs"][::core::mem::size_of::<endpoint_addrs>() - 32usize];
1012 ["Alignment of endpoint_addrs"][::core::mem::align_of::<endpoint_addrs>() - 4usize];
1013 ["Offset of field: endpoint_addrs::socket_addr"]
1014 [::core::mem::offset_of!(endpoint_addrs, socket_addr) - 0usize];
1015};
1016impl Default for endpoint_addrs {
1017 fn default() -> Self {
1018 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
1019 unsafe {
1020 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1021 s.assume_init()
1022 }
1023 }
1024}
1025#[doc = " Endpoint addresses, for example, socket address."]
1026#[repr(C)]
1027#[derive(Copy, Clone)]
1028pub struct endpoint {
1029 pub kind: endpoint_kind,
1030 pub addr: endpoint_addrs,
1031}
1032#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1033const _: () = {
1034 ["Size of endpoint"][::core::mem::size_of::<endpoint>() - 36usize];
1035 ["Alignment of endpoint"][::core::mem::align_of::<endpoint>() - 4usize];
1036 ["Offset of field: endpoint::kind"][::core::mem::offset_of!(endpoint, kind) - 0usize];
1037 ["Offset of field: endpoint::addr"][::core::mem::offset_of!(endpoint, addr) - 4usize];
1038};
1039impl Default for endpoint {
1040 fn default() -> Self {
1041 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
1042 unsafe {
1043 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1044 s.assume_init()
1045 }
1046 }
1047}
1048unsafe extern "C-unwind" {
1049 #[doc = " Read from a file. May read less than specified len."]
1050 pub fn twz_rt_fd_pread(
1051 fd: descriptor,
1052 buf: *mut ::core::ffi::c_void,
1053 len: usize,
1054 ctx: *mut io_ctx,
1055 ) -> io_result;
1056}
1057unsafe extern "C-unwind" {
1058 #[doc = " Write to a file. May write less than specified len."]
1059 pub fn twz_rt_fd_pwrite(
1060 fd: descriptor,
1061 buf: *const ::core::ffi::c_void,
1062 len: usize,
1063 ctx: *mut io_ctx,
1064 ) -> io_result;
1065}
1066unsafe extern "C-unwind" {
1067 #[doc = " Seek to a specified point in the file."]
1068 pub fn twz_rt_fd_seek(fd: descriptor, whence: whence, offset: i64) -> io_result;
1069}
1070unsafe extern "C-unwind" {
1071 #[doc = " Read from a file. May read less than specified len. Fill *ep with information about the source of the I/O (e.g. socket address)."]
1072 pub fn twz_rt_fd_pread_from(
1073 fd: descriptor,
1074 buf: *mut ::core::ffi::c_void,
1075 len: usize,
1076 ctx: *mut io_ctx,
1077 ep: *mut endpoint,
1078 ) -> io_result;
1079}
1080unsafe extern "C-unwind" {
1081 #[doc = " Write to a file. May write less than specified len. Send to specified endpoint (e.g. socket address)."]
1082 pub fn twz_rt_fd_pwrite_to(
1083 fd: descriptor,
1084 buf: *const ::core::ffi::c_void,
1085 len: usize,
1086 ctx: *mut io_ctx,
1087 ep: *const endpoint,
1088 ) -> io_result;
1089}
1090#[doc = " Io vec, a buffer and a len."]
1091#[repr(C)]
1092#[derive(Debug, Copy, Clone)]
1093pub struct io_vec {
1094 #[doc = " Pointer to buffer."]
1095 pub buf: *mut ::core::ffi::c_char,
1096 #[doc = " Length of buffer in bytes."]
1097 pub len: usize,
1098}
1099#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1100const _: () = {
1101 ["Size of io_vec"][::core::mem::size_of::<io_vec>() - 16usize];
1102 ["Alignment of io_vec"][::core::mem::align_of::<io_vec>() - 8usize];
1103 ["Offset of field: io_vec::buf"][::core::mem::offset_of!(io_vec, buf) - 0usize];
1104 ["Offset of field: io_vec::len"][::core::mem::offset_of!(io_vec, len) - 8usize];
1105};
1106impl Default for io_vec {
1107 fn default() -> Self {
1108 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
1109 unsafe {
1110 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1111 s.assume_init()
1112 }
1113 }
1114}
1115unsafe extern "C-unwind" {
1116 #[doc = " Do vectored IO read."]
1117 pub fn twz_rt_fd_preadv(
1118 fd: descriptor,
1119 iovs: *const io_vec,
1120 nr_iovs: usize,
1121 ctx: *mut io_ctx,
1122 ) -> io_result;
1123}
1124unsafe extern "C-unwind" {
1125 #[doc = " Do vectored IO write."]
1126 pub fn twz_rt_fd_pwritev(
1127 fd: descriptor,
1128 iovs: *const io_vec,
1129 nr_iovs: usize,
1130 ctx: *mut io_ctx,
1131 ) -> io_result;
1132}
1133pub type wait_kind = u32;
1134pub const WAIT_READ: wait_kind = 1;
1135pub const WAIT_WRITE: wait_kind = 2;
1136unsafe extern "C-unwind" {
1137 #[doc = " Get a word and value to wait on for determining if reads or writes are available."]
1138 pub fn twz_rt_fd_waitpoint(
1139 fd: descriptor,
1140 ek: wait_kind,
1141 point: *mut *mut u64,
1142 val: u64,
1143 ) -> twz_error;
1144}
1145unsafe extern "C-unwind" {
1146 #[doc = " Get a config value for register reg."]
1147 pub fn twz_rt_fd_get_config(
1148 fd: descriptor,
1149 reg: u32,
1150 val: *mut ::core::ffi::c_void,
1151 len: usize,
1152 ) -> twz_error;
1153}
1154unsafe extern "C-unwind" {
1155 #[doc = " Set a config value for register reg. Setting a register may have side effects."]
1156 pub fn twz_rt_fd_set_config(
1157 fd: descriptor,
1158 reg: u32,
1159 val: *mut ::core::ffi::c_void,
1160 len: usize,
1161 ) -> twz_error;
1162}
1163#[doc = " Result map_object call"]
1164#[repr(C)]
1165#[repr(align(16))]
1166#[derive(Debug, Copy, Clone)]
1167pub struct map_result {
1168 #[doc = " Handle, if error is set to Success."]
1169 pub handle: object_handle,
1170 pub error: twz_error,
1171}
1172#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1173const _: () = {
1174 ["Size of map_result"][::core::mem::size_of::<map_result>() - 64usize];
1175 ["Alignment of map_result"][::core::mem::align_of::<map_result>() - 16usize];
1176 ["Offset of field: map_result::handle"][::core::mem::offset_of!(map_result, handle) - 0usize];
1177 ["Offset of field: map_result::error"][::core::mem::offset_of!(map_result, error) - 48usize];
1178};
1179impl Default for map_result {
1180 fn default() -> Self {
1181 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
1182 unsafe {
1183 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1184 s.assume_init()
1185 }
1186 }
1187}
1188#[doc = " Map with READ permission."]
1189pub const MAP_FLAG_R: map_flags = 1;
1190#[doc = " Map with WRITE permission."]
1191pub const MAP_FLAG_W: map_flags = 2;
1192#[doc = " Map with EXEC permission."]
1193pub const MAP_FLAG_X: map_flags = 4;
1194#[doc = " Persist changes on flush."]
1195pub const MAP_FLAG_PERSIST: map_flags = 8;
1196#[doc = " Allow the runtime to provide additional safety properties."]
1197pub const MAP_FLAG_INDIRECT: map_flags = 16;
1198#[doc = " Don't map a null page for the object."]
1199pub const MAP_FLAG_NO_NULLPAGE: map_flags = 32;
1200#[doc = " Mapping flags"]
1201pub type release_flags = u32;
1202#[doc = " Don't cache this handle on release."]
1203pub const RELEASE_NO_CACHE: release_flags = 1;
1204unsafe extern "C-unwind" {
1205 #[doc = " Create a new runtime (volatile, tied to this runtime) object."]
1206 pub fn twz_rt_create_rtobj() -> objid_result;
1207}
1208unsafe extern "C-unwind" {
1209 #[doc = " Map an object with a given ID and flags."]
1210 pub fn twz_rt_map_object(id: objid, flags: map_flags) -> map_result;
1211}
1212unsafe extern "C-unwind" {
1213 #[doc = " Release an object handle. After calling this, the handle may not be used."]
1214 pub fn twz_rt_release_handle(handle: *mut object_handle, flags: release_flags);
1215}
1216pub type object_cmd = u32;
1217pub const OBJECT_CMD_DELETE: object_cmd = 1;
1218unsafe extern "C-unwind" {
1219 #[doc = " Modify an object."]
1220 pub fn twz_rt_object_cmd(handle: *mut object_handle, cmd: object_cmd, arg: u64) -> twz_error;
1221}
1222unsafe extern "C-unwind" {
1223 #[doc = " Update an object handle."]
1224 pub fn twz_rt_update_handle(handle: *mut object_handle) -> twz_error;
1225}
1226unsafe extern "C-unwind" {
1227 #[doc = " Given a pointer, find the start of the associated object. The returned pointer and the passed pointer p\n are guaranteed to be in the same object, allowing pointer arithmetic."]
1228 pub fn twz_rt_locate_object_start(p: *mut ::core::ffi::c_void) -> *mut ::core::ffi::c_void;
1229}
1230unsafe extern "C-unwind" {
1231 #[doc = " Given a pointer, find the associated object. The returned pointer and the passed pointer p\n are guaranteed to be in the same object, allowing pointer arithmetic."]
1232 pub fn twz_rt_get_object_handle(p: *mut ::core::ffi::c_void) -> object_handle;
1233}
1234unsafe extern "C-unwind" {
1235 #[doc = " Resolve an FOT entry, returning an object handle for the target object with at least valid_len bytes of\n addressable memory."]
1236 pub fn twz_rt_resolve_fot(
1237 handle: *mut object_handle,
1238 idx: u64,
1239 valid_len: usize,
1240 flags: map_flags,
1241 ) -> map_result;
1242}
1243unsafe extern "C-unwind" {
1244 #[doc = " Does the same as twz_rt_resolve_fot but optimizes for local pointers and avoids cloning handles if possible. Returns null on failure\n with no error code. Callers should try the twz_rt_resolve_fot function if this one fails."]
1245 pub fn twz_rt_resolve_fot_local(
1246 start: *mut ::core::ffi::c_void,
1247 idx: u64,
1248 valid_len: usize,
1249 flags: map_flags,
1250 ) -> *mut ::core::ffi::c_void;
1251}
1252unsafe extern "C-unwind" {
1253 #[doc = " Insert the given entry into the FOT, or return the existing entry if it already exists in this object's FOT.\n Returns -1 on failure."]
1254 pub fn twz_rt_insert_fot(
1255 handle: *mut object_handle,
1256 entry: *mut ::core::ffi::c_void,
1257 ) -> u32_result;
1258}
1259unsafe extern "C-unwind" {
1260 pub fn __twz_rt_map_two_objects(
1261 id_1: objid,
1262 flags_1: map_flags,
1263 id_2: objid,
1264 flags_2: map_flags,
1265 res_1: *mut map_result,
1266 res_2: *mut map_result,
1267 );
1268}
1269pub const monotonicity_NonMonotonic: monotonicity = 0;
1270pub const monotonicity_WeakMonotonic: monotonicity = 1;
1271pub const monotonicity_StrongMonotonic: monotonicity = 2;
1272#[doc = " Supported monotonicity levels"]
1273pub type monotonicity = ::core::ffi::c_uint;
1274unsafe extern "C-unwind" {
1275 #[doc = " Get time from the monotonic clock"]
1276 pub fn twz_rt_get_monotonic_time() -> duration;
1277}
1278unsafe extern "C-unwind" {
1279 #[doc = " Get time from the system clock"]
1280 pub fn twz_rt_get_system_time() -> duration;
1281}
1282#[doc = " Information about a loaded dynamic object"]
1283#[repr(C)]
1284#[derive(Debug, Copy, Clone)]
1285pub struct dl_phdr_info {
1286 #[doc = " Load address"]
1287 pub addr: usize,
1288 #[doc = " Pointer to name, as a C string"]
1289 pub name: *const ::core::ffi::c_char,
1290 #[doc = " Pointer to program headers"]
1291 pub phdr: *const ::core::ffi::c_void,
1292 #[doc = " Number of program headers"]
1293 pub phnum: u32,
1294 pub adds: ::core::ffi::c_ulonglong,
1295 pub subs: ::core::ffi::c_ulonglong,
1296 pub tls_modid: usize,
1297 pub tls_data: *mut ::core::ffi::c_void,
1298}
1299#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1300const _: () = {
1301 ["Size of dl_phdr_info"][::core::mem::size_of::<dl_phdr_info>() - 64usize];
1302 ["Alignment of dl_phdr_info"][::core::mem::align_of::<dl_phdr_info>() - 8usize];
1303 ["Offset of field: dl_phdr_info::addr"][::core::mem::offset_of!(dl_phdr_info, addr) - 0usize];
1304 ["Offset of field: dl_phdr_info::name"][::core::mem::offset_of!(dl_phdr_info, name) - 8usize];
1305 ["Offset of field: dl_phdr_info::phdr"][::core::mem::offset_of!(dl_phdr_info, phdr) - 16usize];
1306 ["Offset of field: dl_phdr_info::phnum"]
1307 [::core::mem::offset_of!(dl_phdr_info, phnum) - 24usize];
1308 ["Offset of field: dl_phdr_info::adds"][::core::mem::offset_of!(dl_phdr_info, adds) - 32usize];
1309 ["Offset of field: dl_phdr_info::subs"][::core::mem::offset_of!(dl_phdr_info, subs) - 40usize];
1310 ["Offset of field: dl_phdr_info::tls_modid"]
1311 [::core::mem::offset_of!(dl_phdr_info, tls_modid) - 48usize];
1312 ["Offset of field: dl_phdr_info::tls_data"]
1313 [::core::mem::offset_of!(dl_phdr_info, tls_data) - 56usize];
1314};
1315impl Default for dl_phdr_info {
1316 fn default() -> Self {
1317 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
1318 unsafe {
1319 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1320 s.assume_init()
1321 }
1322 }
1323}
1324#[repr(C)]
1325#[derive(Debug, Copy, Clone)]
1326pub struct link_map {
1327 pub addr: usize,
1328 pub name: *mut ::core::ffi::c_char,
1329 pub ld: *mut ::core::ffi::c_void,
1330 pub next: *mut ::core::ffi::c_void,
1331 pub prev: *mut ::core::ffi::c_void,
1332}
1333#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1334const _: () = {
1335 ["Size of link_map"][::core::mem::size_of::<link_map>() - 40usize];
1336 ["Alignment of link_map"][::core::mem::align_of::<link_map>() - 8usize];
1337 ["Offset of field: link_map::addr"][::core::mem::offset_of!(link_map, addr) - 0usize];
1338 ["Offset of field: link_map::name"][::core::mem::offset_of!(link_map, name) - 8usize];
1339 ["Offset of field: link_map::ld"][::core::mem::offset_of!(link_map, ld) - 16usize];
1340 ["Offset of field: link_map::next"][::core::mem::offset_of!(link_map, next) - 24usize];
1341 ["Offset of field: link_map::prev"][::core::mem::offset_of!(link_map, prev) - 32usize];
1342};
1343impl Default for link_map {
1344 fn default() -> Self {
1345 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
1346 unsafe {
1347 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1348 s.assume_init()
1349 }
1350 }
1351}
1352#[doc = " An ID for a loaded program image (or library)"]
1353pub type loaded_image_id = u32;
1354#[doc = " Information about a loaded program image or library"]
1355#[repr(C)]
1356#[repr(align(16))]
1357#[derive(Debug, Copy, Clone)]
1358pub struct loaded_image {
1359 #[doc = " Object handle"]
1360 pub image_handle: object_handle,
1361 #[doc = " Start of full image"]
1362 pub image_start: *const ::core::ffi::c_void,
1363 #[doc = " Length of full image"]
1364 pub image_len: usize,
1365 #[doc = " The dl_info for this loaded image"]
1366 pub dl_info: dl_phdr_info,
1367 #[doc = " The ID for this loaded image"]
1368 pub id: loaded_image_id,
1369}
1370#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1371const _: () = {
1372 ["Size of loaded_image"][::core::mem::size_of::<loaded_image>() - 144usize];
1373 ["Alignment of loaded_image"][::core::mem::align_of::<loaded_image>() - 16usize];
1374 ["Offset of field: loaded_image::image_handle"]
1375 [::core::mem::offset_of!(loaded_image, image_handle) - 0usize];
1376 ["Offset of field: loaded_image::image_start"]
1377 [::core::mem::offset_of!(loaded_image, image_start) - 48usize];
1378 ["Offset of field: loaded_image::image_len"]
1379 [::core::mem::offset_of!(loaded_image, image_len) - 56usize];
1380 ["Offset of field: loaded_image::dl_info"]
1381 [::core::mem::offset_of!(loaded_image, dl_info) - 64usize];
1382 ["Offset of field: loaded_image::id"][::core::mem::offset_of!(loaded_image, id) - 128usize];
1383};
1384impl Default for loaded_image {
1385 fn default() -> Self {
1386 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
1387 unsafe {
1388 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1389 s.assume_init()
1390 }
1391 }
1392}
1393unsafe extern "C-unwind" {
1394 #[doc = " Get a loaded image from its ID. All IDs for loaded image are sequential, starting from TWZ_RT_EXEID.\n On success, fill out data pointed to by the li argument and return true."]
1395 pub fn twz_rt_get_loaded_image(id: loaded_image_id, li: *mut loaded_image) -> bool;
1396}
1397unsafe extern "C-unwind" {
1398 pub fn twz_rt_iter_phdr(
1399 cb: ::core::option::Option<
1400 unsafe extern "C-unwind" fn(
1401 arg1: *const dl_phdr_info,
1402 size: usize,
1403 data: *mut ::core::ffi::c_void,
1404 ) -> ::core::ffi::c_int,
1405 >,
1406 data: *mut ::core::ffi::c_void,
1407 ) -> ::core::ffi::c_int;
1408}
1409#[doc = " The loaded image ID for the root loaded image (usually the executable)"]
1410pub const TWZ_RT_EXEID: loaded_image_id = 0;
1411#[doc = " Information about the system"]
1412#[repr(C)]
1413#[derive(Debug, Copy, Clone)]
1414pub struct system_info {
1415 #[doc = " Supported monotonicity"]
1416 pub clock_monotonicity: monotonicity,
1417 #[doc = " Number of CPUs (hardware threads)"]
1418 pub available_parallelism: usize,
1419 #[doc = " Page size"]
1420 pub page_size: usize,
1421}
1422#[allow(clippy::unnecessary_operation, clippy::identity_op)]
1423const _: () = {
1424 ["Size of system_info"][::core::mem::size_of::<system_info>() - 24usize];
1425 ["Alignment of system_info"][::core::mem::align_of::<system_info>() - 8usize];
1426 ["Offset of field: system_info::clock_monotonicity"]
1427 [::core::mem::offset_of!(system_info, clock_monotonicity) - 0usize];
1428 ["Offset of field: system_info::available_parallelism"]
1429 [::core::mem::offset_of!(system_info, available_parallelism) - 8usize];
1430 ["Offset of field: system_info::page_size"]
1431 [::core::mem::offset_of!(system_info, page_size) - 16usize];
1432};
1433impl Default for system_info {
1434 fn default() -> Self {
1435 let mut s = ::core::mem::MaybeUninit::<Self>::uninit();
1436 unsafe {
1437 ::core::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
1438 s.assume_init()
1439 }
1440 }
1441}
1442unsafe extern "C-unwind" {
1443 #[doc = " Get system information"]
1444 pub fn twz_rt_get_sysinfo() -> system_info;
1445}
1446#[doc = " Flags to get_random"]
1447pub type get_random_flags = u32;
1448#[doc = " Do not block when collecting random data"]
1449pub const GET_RANDOM_NON_BLOCKING: get_random_flags = 1;
1450unsafe extern "C-unwind" {
1451 #[doc = " Collect up to len bytes of randomness, filling buf. Returns the number of bytes\n of random data actually collected."]
1452 pub fn twz_rt_get_random(
1453 buf: *mut ::core::ffi::c_char,
1454 len: usize,
1455 flags: get_random_flags,
1456 ) -> usize;
1457}
1458pub const version: &[u8; 7] = b"0.99.0\0";
1459#[doc = " Object ID"]
1460pub type __uint128_t = u128;