pub const __bool_true_false_are_defined: u32 = 1;
pub const true_: u32 = 1;
pub const false_: u32 = 0;
pub type wchar_t = ::core::ffi::c_int;
#[repr(C)]
#[repr(align(16))]
#[derive(Debug, Copy, Clone)]
pub struct max_align_t {
pub __clang_max_align_nonce1: ::core::ffi::c_longlong,
pub __bindgen_padding_0: u64,
pub __clang_max_align_nonce2: u128,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of max_align_t"][::core::mem::size_of::<max_align_t>() - 32usize];
["Alignment of max_align_t"][::core::mem::align_of::<max_align_t>() - 16usize];
["Offset of field: max_align_t::__clang_max_align_nonce1"]
[::core::mem::offset_of!(max_align_t, __clang_max_align_nonce1) - 0usize];
["Offset of field: max_align_t::__clang_max_align_nonce2"]
[::core::mem::offset_of!(max_align_t, __clang_max_align_nonce2) - 16usize];
};
pub type int_least64_t = i64;
pub type uint_least64_t = u64;
pub type int_fast64_t = i64;
pub type uint_fast64_t = u64;
pub type int_least32_t = i32;
pub type uint_least32_t = u32;
pub type int_fast32_t = i32;
pub type uint_fast32_t = u32;
pub type int_least16_t = i16;
pub type uint_least16_t = u16;
pub type int_fast16_t = i16;
pub type uint_fast16_t = u16;
pub type int_least8_t = i8;
pub type uint_least8_t = u8;
pub type int_fast8_t = i8;
pub type uint_fast8_t = u8;
pub type intmax_t = ::core::ffi::c_long;
pub type uintmax_t = ::core::ffi::c_ulong;
#[doc = " Object ID"]
pub type rt_objid = __uint128_t;
#[doc = " Duration, containing seconds and nanoseconds."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct duration {
pub seconds: u64,
pub nanos: u32,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of duration"][::core::mem::size_of::<duration>() - 16usize];
["Alignment of duration"][::core::mem::align_of::<duration>() - 8usize];
["Offset of field: duration::seconds"][::core::mem::offset_of!(duration, seconds) - 0usize];
["Offset of field: duration::nanos"][::core::mem::offset_of!(duration, nanos) - 8usize];
};
#[doc = " Optional duration."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct option_duration {
pub dur: duration,
pub is_some: i32,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of option_duration"][::core::mem::size_of::<option_duration>() - 24usize];
["Alignment of option_duration"][::core::mem::align_of::<option_duration>() - 8usize];
["Offset of field: option_duration::dur"]
[::core::mem::offset_of!(option_duration, dur) - 0usize];
["Offset of field: option_duration::is_some"]
[::core::mem::offset_of!(option_duration, is_some) - 16usize];
};
#[doc = " Allocation flags"]
pub type alloc_flags = u32;
#[doc = " Zero memory during operation"]
pub const ZERO_MEMORY: alloc_flags = 1;
extern "C-unwind" {
#[doc = " Allocate memory, zeroing it first if the flag is set."]
pub fn twz_rt_malloc(sz: usize, align: usize, flags: alloc_flags) -> *mut ::core::ffi::c_void;
}
extern "C-unwind" {
#[doc = " Deallocate memory. If ZERO_MEMORY is set, will clear the memory before freeing."]
pub fn twz_rt_dealloc(
ptr: *mut ::core::ffi::c_void,
sz: usize,
align: usize,
flags: alloc_flags,
);
}
extern "C-unwind" {
#[doc = " Reallocate memory. If ZERO_MEMORY is set, will zero new memory before returning and zero to-be-freed memory before freeing."]
pub fn twz_rt_realloc(
ptr: *mut ::core::ffi::c_void,
sz: usize,
align: usize,
new_size: usize,
flags: alloc_flags,
) -> *mut ::core::ffi::c_void;
}
#[doc = " Exit code type"]
pub type exit_code = i32;
#[doc = " Basic OS information provided to rust libstd"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct basic_aux {
#[doc = " Number of arguments"]
pub argc: usize,
#[doc = " Pointer to args"]
pub args: *mut *mut ::core::ffi::c_char,
#[doc = " Environment pointer"]
pub env: *mut *mut ::core::ffi::c_char,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of basic_aux"][::core::mem::size_of::<basic_aux>() - 24usize];
["Alignment of basic_aux"][::core::mem::align_of::<basic_aux>() - 8usize];
["Offset of field: basic_aux::argc"][::core::mem::offset_of!(basic_aux, argc) - 0usize];
["Offset of field: basic_aux::args"][::core::mem::offset_of!(basic_aux, args) - 8usize];
["Offset of field: basic_aux::env"][::core::mem::offset_of!(basic_aux, env) - 16usize];
};
#[doc = " Return info from rust libstd"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct basic_return {
pub code: exit_code,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of basic_return"][::core::mem::size_of::<basic_return>() - 4usize];
["Alignment of basic_return"][::core::mem::align_of::<basic_return>() - 4usize];
["Offset of field: basic_return::code"][::core::mem::offset_of!(basic_return, code) - 0usize];
};
#[doc = " Init information for compartments"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct comp_init_info {
#[doc = " Fn ptr to _init"]
pub legacy_init: ::core::option::Option<unsafe extern "C-unwind" fn()>,
#[doc = " Pointer to the init array"]
pub init_array: *mut ::core::option::Option<unsafe extern "C-unwind" fn()>,
#[doc = " Length of init array"]
pub init_array_len: usize,
#[doc = " Pointer to compartment config info"]
pub comp_config_info: *mut ::core::ffi::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of comp_init_info"][::core::mem::size_of::<comp_init_info>() - 32usize];
["Alignment of comp_init_info"][::core::mem::align_of::<comp_init_info>() - 8usize];
["Offset of field: comp_init_info::legacy_init"]
[::core::mem::offset_of!(comp_init_info, legacy_init) - 0usize];
["Offset of field: comp_init_info::init_array"]
[::core::mem::offset_of!(comp_init_info, init_array) - 8usize];
["Offset of field: comp_init_info::init_array_len"]
[::core::mem::offset_of!(comp_init_info, init_array_len) - 16usize];
["Offset of field: comp_init_info::comp_config_info"]
[::core::mem::offset_of!(comp_init_info, comp_config_info) - 24usize];
};
#[doc = " Init information for minimal runtime"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct minimal_init_info {
#[doc = " Pointer to args"]
pub args: *mut *mut ::core::ffi::c_char,
#[doc = " Number of args"]
pub argc: usize,
#[doc = " Environment pointer"]
pub envp: *mut *mut ::core::ffi::c_char,
#[doc = " Pointer to program headers"]
pub phdrs: *mut ::core::ffi::c_void,
#[doc = " Number of program headers"]
pub nr_phdrs: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of minimal_init_info"][::core::mem::size_of::<minimal_init_info>() - 40usize];
["Alignment of minimal_init_info"][::core::mem::align_of::<minimal_init_info>() - 8usize];
["Offset of field: minimal_init_info::args"]
[::core::mem::offset_of!(minimal_init_info, args) - 0usize];
["Offset of field: minimal_init_info::argc"]
[::core::mem::offset_of!(minimal_init_info, argc) - 8usize];
["Offset of field: minimal_init_info::envp"]
[::core::mem::offset_of!(minimal_init_info, envp) - 16usize];
["Offset of field: minimal_init_info::phdrs"]
[::core::mem::offset_of!(minimal_init_info, phdrs) - 24usize];
["Offset of field: minimal_init_info::nr_phdrs"]
[::core::mem::offset_of!(minimal_init_info, nr_phdrs) - 32usize];
};
#[doc = " Possible init info types"]
#[repr(C)]
#[derive(Copy, Clone)]
pub union init_info_ptrs {
pub comp: *mut comp_init_info,
pub min: *mut minimal_init_info,
pub monitor: *mut ::core::ffi::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of init_info_ptrs"][::core::mem::size_of::<init_info_ptrs>() - 8usize];
["Alignment of init_info_ptrs"][::core::mem::align_of::<init_info_ptrs>() - 8usize];
["Offset of field: init_info_ptrs::comp"]
[::core::mem::offset_of!(init_info_ptrs, comp) - 0usize];
["Offset of field: init_info_ptrs::min"][::core::mem::offset_of!(init_info_ptrs, min) - 0usize];
["Offset of field: init_info_ptrs::monitor"]
[::core::mem::offset_of!(init_info_ptrs, monitor) - 0usize];
};
#[doc = " Runtime initialization info."]
#[repr(C)]
#[derive(Copy, Clone)]
pub struct runtime_info {
pub flags: i32,
#[doc = " Discrim. for init_info."]
pub kind: i32,
pub init_info: init_info_ptrs,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of runtime_info"][::core::mem::size_of::<runtime_info>() - 16usize];
["Alignment of runtime_info"][::core::mem::align_of::<runtime_info>() - 8usize];
["Offset of field: runtime_info::flags"][::core::mem::offset_of!(runtime_info, flags) - 0usize];
["Offset of field: runtime_info::kind"][::core::mem::offset_of!(runtime_info, kind) - 4usize];
["Offset of field: runtime_info::init_info"]
[::core::mem::offset_of!(runtime_info, init_info) - 8usize];
};
#[doc = " Minimal runtime info"]
pub const RUNTIME_INIT_MIN: i32 = 0;
#[doc = " Info for monitor"]
pub const RUNTIME_INIT_MONITOR: i32 = 1;
#[doc = " Info for compartments"]
pub const RUNTIME_INIT_COMP: i32 = 2;
#[doc = " Optional exit code"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct option_exit_code {
pub is_some: i32,
pub value: exit_code,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of option_exit_code"][::core::mem::size_of::<option_exit_code>() - 8usize];
["Alignment of option_exit_code"][::core::mem::align_of::<option_exit_code>() - 4usize];
["Offset of field: option_exit_code::is_some"]
[::core::mem::offset_of!(option_exit_code, is_some) - 0usize];
["Offset of field: option_exit_code::value"]
[::core::mem::offset_of!(option_exit_code, value) - 4usize];
};
extern "C-unwind" {
#[doc = " Exit with provided code"]
pub fn twz_rt_exit(code: exit_code);
}
extern "C-unwind" {
#[doc = " Abort immediately"]
pub fn twz_rt_abort();
}
extern "C-unwind" {
pub fn twz_rt_pre_main_hook() -> option_exit_code;
}
extern "C-unwind" {
pub fn twz_rt_post_main_hook();
}
extern "C-unwind" {
pub fn twz_rt_runtime_entry(
arg: *const runtime_info,
std_entry: ::core::option::Option<
unsafe extern "C-unwind" fn(arg1: basic_aux) -> basic_return,
>,
);
}
#[doc = " Futex type, based on linux futex."]
pub type futex_word = u32;
extern "C-unwind" {
#[doc = " If *ptr == expected, wait until signal, optionally timing out."]
pub fn twz_rt_futex_wait(ptr: *mut u32, expected: futex_word, timeout: option_duration)
-> bool;
}
extern "C-unwind" {
#[doc = " Wake up up to max threads waiting on ptr. If max is set to FUTEX_WAKE_ALL, wake all threads."]
pub fn twz_rt_futex_wake(ptr: *mut u32, max: i64) -> bool;
}
#[doc = " Wake all threads instead of a maximum number"]
pub const FUTEX_WAKE_ALL: i64 = -1;
extern "C-unwind" {
#[doc = " Yield the thread now."]
pub fn twz_rt_yield_now();
}
extern "C-unwind" {
#[doc = " Set the name of the calling thread."]
pub fn twz_rt_set_name(name: *const ::core::ffi::c_char);
}
extern "C-unwind" {
#[doc = " Sleep the calling thread for specified duration."]
pub fn twz_rt_sleep(dur: duration);
}
#[doc = " TLS index, module ID and offset."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct tls_index {
pub mod_id: usize,
pub offset: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of tls_index"][::core::mem::size_of::<tls_index>() - 16usize];
["Alignment of tls_index"][::core::mem::align_of::<tls_index>() - 8usize];
["Offset of field: tls_index::mod_id"][::core::mem::offset_of!(tls_index, mod_id) - 0usize];
["Offset of field: tls_index::offset"][::core::mem::offset_of!(tls_index, offset) - 8usize];
};
extern "C-unwind" {
#[doc = " Resolve the TLS index and get back the TLS data pointer."]
pub fn twz_rt_tls_get_addr(index: *mut tls_index) -> *mut ::core::ffi::c_void;
}
#[doc = " Runtime-internal ID of a thread"]
pub type thread_id = u32;
#[doc = " Arguments to spawn"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct spawn_args {
#[doc = " Size of stack to allocate"]
pub stack_size: usize,
#[doc = " Starting address"]
pub start: usize,
#[doc = " Starting argument"]
pub arg: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of spawn_args"][::core::mem::size_of::<spawn_args>() - 24usize];
["Alignment of spawn_args"][::core::mem::align_of::<spawn_args>() - 8usize];
["Offset of field: spawn_args::stack_size"]
[::core::mem::offset_of!(spawn_args, stack_size) - 0usize];
["Offset of field: spawn_args::start"][::core::mem::offset_of!(spawn_args, start) - 8usize];
["Offset of field: spawn_args::arg"][::core::mem::offset_of!(spawn_args, arg) - 16usize];
};
pub const spawn_error_Spawn_Success: spawn_error = 0;
pub const spawn_error_Spawn_Other: spawn_error = 1;
pub const spawn_error_Spawn_InvalidArgument: spawn_error = 2;
pub const spawn_error_Spawn_ObjectNotFound: spawn_error = 3;
pub const spawn_error_Spawn_PermissionDenied: spawn_error = 4;
pub const spawn_error_Spawn_KernelError: spawn_error = 5;
#[doc = " Possible spawn errors"]
pub type spawn_error = ::core::ffi::c_uint;
#[doc = " Spawn result."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct spawn_result {
#[doc = " Thread id, if err is set to Success."]
pub id: thread_id,
pub err: spawn_error,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of spawn_result"][::core::mem::size_of::<spawn_result>() - 8usize];
["Alignment of spawn_result"][::core::mem::align_of::<spawn_result>() - 4usize];
["Offset of field: spawn_result::id"][::core::mem::offset_of!(spawn_result, id) - 0usize];
["Offset of field: spawn_result::err"][::core::mem::offset_of!(spawn_result, err) - 4usize];
};
extern "C-unwind" {
#[doc = " Sawn a thread. On success, that thread starts executing concurrently with this function's return."]
pub fn twz_rt_spawn_thread(args: spawn_args) -> spawn_result;
}
pub const join_result_Join_Success: join_result = 0;
pub const join_result_Join_Other: join_result = 1;
pub const join_result_Join_ThreadNotFound: join_result = 2;
pub const join_result_Join_Timeout: join_result = 3;
#[doc = " Possible results of join."]
pub type join_result = ::core::ffi::c_uint;
extern "C-unwind" {
#[doc = " Wait for a thread to exit, optionally timing out."]
pub fn twz_rt_join_thread(id: thread_id, timeout: option_duration) -> join_result;
}
#[doc = " Mapping flags"]
pub type map_flags = u32;
#[doc = " Object handle"]
#[repr(C)]
#[repr(align(16))]
#[derive(Debug, Copy, Clone)]
pub struct object_handle {
#[doc = " ID for this handle"]
pub id: rt_objid,
#[doc = " Pointer to per-runtime info. The first 64-bits of this data must be an atomic u64 value used for reference counting."]
pub runtime_info: *mut ::core::ffi::c_void,
#[doc = " Pointer to start of object data."]
pub start: *mut ::core::ffi::c_void,
#[doc = " Pointer to object meta struct."]
pub meta: *mut ::core::ffi::c_void,
#[doc = " Mapping flags"]
pub map_flags: map_flags,
#[doc = " Number of valid bytes after start pointer for this object handle, in multiples of of LEN_MUL"]
pub valid_len: u32,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of object_handle"][::core::mem::size_of::<object_handle>() - 48usize];
["Alignment of object_handle"][::core::mem::align_of::<object_handle>() - 16usize];
["Offset of field: object_handle::id"][::core::mem::offset_of!(object_handle, id) - 0usize];
["Offset of field: object_handle::runtime_info"]
[::core::mem::offset_of!(object_handle, runtime_info) - 16usize];
["Offset of field: object_handle::start"]
[::core::mem::offset_of!(object_handle, start) - 24usize];
["Offset of field: object_handle::meta"]
[::core::mem::offset_of!(object_handle, meta) - 32usize];
["Offset of field: object_handle::map_flags"]
[::core::mem::offset_of!(object_handle, map_flags) - 40usize];
["Offset of field: object_handle::valid_len"]
[::core::mem::offset_of!(object_handle, valid_len) - 44usize];
};
#[doc = " Multiplier to valid_len."]
pub const LEN_MUL: usize = 4096;
#[doc = " An open descriptor for a runtime file handle."]
pub type descriptor = i32;
#[doc = " Information for opening a file."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct open_info {
#[doc = " File name pointer."]
pub name: *const ::core::ffi::c_char,
#[doc = " Length of file name in bytes."]
pub len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of open_info"][::core::mem::size_of::<open_info>() - 16usize];
["Alignment of open_info"][::core::mem::align_of::<open_info>() - 8usize];
["Offset of field: open_info::name"][::core::mem::offset_of!(open_info, name) - 0usize];
["Offset of field: open_info::len"][::core::mem::offset_of!(open_info, len) - 8usize];
};
#[doc = " Open success."]
pub const open_error_OpenError_Success: open_error = 0;
#[doc = " Other error."]
pub const open_error_OpenError_Other: open_error = 1;
#[doc = " Failed to lookup provided file name."]
pub const open_error_OpenError_LookupFail: open_error = 2;
#[doc = " Permission denied."]
pub const open_error_OpenError_PermissionDenied: open_error = 3;
#[doc = " Argument was invalid."]
pub const open_error_OpenError_InvalidArgument: open_error = 4;
#[doc = " Possible open error conditions."]
pub type open_error = ::core::ffi::c_uint;
#[doc = " Result of open call."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct open_result {
#[doc = " If error is Success, this contains a valid descriptor."]
pub fd: descriptor,
#[doc = " Error code, or success."]
pub error: open_error,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of open_result"][::core::mem::size_of::<open_result>() - 8usize];
["Alignment of open_result"][::core::mem::align_of::<open_result>() - 4usize];
["Offset of field: open_result::fd"][::core::mem::offset_of!(open_result, fd) - 0usize];
["Offset of field: open_result::error"][::core::mem::offset_of!(open_result, error) - 4usize];
};
extern "C-unwind" {
#[doc = " Open a file."]
pub fn twz_rt_fd_open(info: open_info) -> open_result;
}
extern "C-unwind" {
#[doc = " Close a file descriptor. If the file descriptor is invalid\n or already closed, this function does nothing."]
pub fn twz_rt_fd_close(fd: descriptor);
}
#[doc = " Flags a descriptor can have."]
pub type fd_flags = u32;
#[doc = " This file descriptor is a terminal."]
pub const FD_IS_TERMINAL: fd_flags = 1;
#[doc = " Information about a file descriptor."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct fd_info {
#[doc = " Flags for the descriptor."]
pub flags: fd_flags,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of fd_info"][::core::mem::size_of::<fd_info>() - 4usize];
["Alignment of fd_info"][::core::mem::align_of::<fd_info>() - 4usize];
["Offset of field: fd_info::flags"][::core::mem::offset_of!(fd_info, flags) - 0usize];
};
extern "C-unwind" {
#[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."]
pub fn twz_rt_fd_get_info(fd: descriptor, info: *mut fd_info) -> bool;
}
#[doc = " Commands for descriptors."]
pub type fd_cmd = u32;
#[doc = " Duplicate this descriptor. The arg argument is ignored. The ret argument points to a descriptor."]
pub const FD_CMD_DUP: fd_cmd = 1;
#[doc = " Errors for twz_rt_fd_cmd."]
pub type fd_cmd_err = u32;
#[doc = " Success value for twz_rt_fd_cmd."]
pub const FD_CMD_SUCCESS: fd_cmd_err = 0;
extern "C-unwind" {
#[doc = " Perform a command on the descriptor. The arguments arg and ret are interpreted according to\n the command specified."]
pub fn twz_rt_fd_cmd(
fd: descriptor,
cmd: fd_cmd,
arg: *mut ::core::ffi::c_void,
ret: *mut ::core::ffi::c_void,
) -> fd_cmd_err;
}
#[doc = " Success"]
pub const io_error_IoError_Success: io_error = 0;
#[doc = " Other error"]
pub const io_error_IoError_Other: io_error = 1;
#[doc = " Error during seek"]
pub const io_error_IoError_SeekError: io_error = 2;
#[doc = " Invalid descriptor"]
pub const io_error_IoError_InvalidDesc: io_error = 3;
#[doc = " Operation would block, but nonblocking behavior was specified."]
pub const io_error_IoError_WouldBlock: io_error = 4;
#[doc = " Possible IO errors"]
pub type io_error = ::core::ffi::c_uint;
#[doc = " Result of IO operations"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct io_result {
#[doc = " Error value, or success."]
pub error: io_error,
#[doc = " Returned value, only valid if error is set to Success."]
pub value: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of io_result"][::core::mem::size_of::<io_result>() - 16usize];
["Alignment of io_result"][::core::mem::align_of::<io_result>() - 8usize];
["Offset of field: io_result::error"][::core::mem::offset_of!(io_result, error) - 0usize];
["Offset of field: io_result::value"][::core::mem::offset_of!(io_result, value) - 8usize];
};
#[doc = " Type of whence values for seek."]
pub type whence = u32;
#[doc = " Flags for IO operations"]
pub type io_flags = u32;
#[doc = " Non-blocking behavior specified. If the operation would block, return io_result with error set to WouldBlock instead."]
pub const IO_NONBLOCKING: io_flags = 1;
#[doc = " Seek offset from start of file"]
pub const WHENCE_START: whence = 0;
#[doc = " Seek offset from end of file"]
pub const WHENCE_END: whence = 1;
#[doc = " Seek offset from current fd position"]
pub const WHENCE_CURRENT: whence = 2;
#[doc = " Optional offset. If value is FD_POS, use the file descriptor position."]
pub type optional_offset = i64;
pub const FD_POS: optional_offset = -1;
extern "C-unwind" {
#[doc = " Read from a file. May read less than specified len."]
pub fn twz_rt_fd_pread(
fd: descriptor,
offset: optional_offset,
buf: *mut ::core::ffi::c_void,
len: usize,
flags: io_flags,
) -> io_result;
}
extern "C-unwind" {
#[doc = " Write to a file. May write less than specified len."]
pub fn twz_rt_fd_pwrite(
fd: descriptor,
offset: optional_offset,
buf: *const ::core::ffi::c_void,
len: usize,
flags: io_flags,
) -> io_result;
}
extern "C-unwind" {
#[doc = " Seek to a specified point in the file."]
pub fn twz_rt_fd_seek(fd: descriptor, whence: whence, offset: i64) -> io_result;
}
#[doc = " Io vec, a buffer and a len."]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct io_vec {
#[doc = " Pointer to buffer."]
pub buf: *mut ::core::ffi::c_char,
#[doc = " Length of buffer in bytes."]
pub len: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of io_vec"][::core::mem::size_of::<io_vec>() - 16usize];
["Alignment of io_vec"][::core::mem::align_of::<io_vec>() - 8usize];
["Offset of field: io_vec::buf"][::core::mem::offset_of!(io_vec, buf) - 0usize];
["Offset of field: io_vec::len"][::core::mem::offset_of!(io_vec, len) - 8usize];
};
extern "C-unwind" {
#[doc = " Do vectored IO read."]
pub fn twz_rt_fd_preadv(
fd: descriptor,
offset: optional_offset,
iovs: *const io_vec,
nr_iovs: usize,
flags: io_flags,
) -> io_result;
}
extern "C-unwind" {
#[doc = " Do vectored IO write."]
pub fn twz_rt_fd_pwritev(
fd: descriptor,
offset: optional_offset,
iovs: *const io_vec,
nr_iovs: usize,
flags: io_flags,
) -> io_result;
}
pub const map_error_MapError_Success: map_error = 0;
pub const map_error_MapError_Other: map_error = 1;
pub const map_error_MapError_OutOfResources: map_error = 2;
pub const map_error_MapError_NoSuchObject: map_error = 3;
pub const map_error_MapError_PermissionDenied: map_error = 4;
pub const map_error_MapError_InvalidArgument: map_error = 5;
#[doc = " Possible mapping errors"]
pub type map_error = ::core::ffi::c_uint;
#[doc = " Result map_object call"]
#[repr(C)]
#[repr(align(16))]
#[derive(Debug, Copy, Clone)]
pub struct map_result {
#[doc = " Handle, if error is set to Success."]
pub handle: object_handle,
pub error: map_error,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of map_result"][::core::mem::size_of::<map_result>() - 64usize];
["Alignment of map_result"][::core::mem::align_of::<map_result>() - 16usize];
["Offset of field: map_result::handle"][::core::mem::offset_of!(map_result, handle) - 0usize];
["Offset of field: map_result::error"][::core::mem::offset_of!(map_result, error) - 48usize];
};
#[doc = " Map with READ permission."]
pub const MAP_FLAG_R: map_flags = 1;
#[doc = " Map with WRITE permission."]
pub const MAP_FLAG_W: map_flags = 2;
#[doc = " Map with EXEC permission."]
pub const MAP_FLAG_X: map_flags = 4;
extern "C-unwind" {
#[doc = " Map an object with a given ID and flags."]
pub fn twz_rt_map_object(id: rt_objid, flags: map_flags) -> map_result;
}
extern "C-unwind" {
#[doc = " Release an object handle. After calling this, the handle may not be used."]
pub fn twz_rt_release_handle(handle: *mut object_handle);
}
extern "C-unwind" {
pub fn __twz_rt_map_two_objects(
id_1: rt_objid,
flags_1: map_flags,
id_2: rt_objid,
flags_2: map_flags,
res_1: *mut map_result,
res_2: *mut map_result,
);
}
pub const monotonicity_NonMonotonic: monotonicity = 0;
pub const monotonicity_WeakMonotonic: monotonicity = 1;
pub const monotonicity_StrongMonotonic: monotonicity = 2;
#[doc = " Supported monotonicity levels"]
pub type monotonicity = ::core::ffi::c_uint;
extern "C-unwind" {
#[doc = " Get time from the monotonic clock"]
pub fn twz_rt_get_monotonic_time() -> duration;
}
extern "C-unwind" {
#[doc = " Get time from the system clock"]
pub fn twz_rt_get_system_time() -> duration;
}
#[doc = " Information about a loaded dynamic object"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct dl_phdr_info {
#[doc = " Load address"]
pub addr: usize,
#[doc = " Pointer to name, as a C string"]
pub name: *const ::core::ffi::c_char,
#[doc = " Pointer to program headers"]
pub phdr: *const ::core::ffi::c_void,
#[doc = " Number of program headers"]
pub phnum: u32,
pub adds: ::core::ffi::c_ulonglong,
pub subs: ::core::ffi::c_ulonglong,
pub tls_modid: usize,
pub tls_data: *mut ::core::ffi::c_void,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of dl_phdr_info"][::core::mem::size_of::<dl_phdr_info>() - 64usize];
["Alignment of dl_phdr_info"][::core::mem::align_of::<dl_phdr_info>() - 8usize];
["Offset of field: dl_phdr_info::addr"][::core::mem::offset_of!(dl_phdr_info, addr) - 0usize];
["Offset of field: dl_phdr_info::name"][::core::mem::offset_of!(dl_phdr_info, name) - 8usize];
["Offset of field: dl_phdr_info::phdr"][::core::mem::offset_of!(dl_phdr_info, phdr) - 16usize];
["Offset of field: dl_phdr_info::phnum"]
[::core::mem::offset_of!(dl_phdr_info, phnum) - 24usize];
["Offset of field: dl_phdr_info::adds"][::core::mem::offset_of!(dl_phdr_info, adds) - 32usize];
["Offset of field: dl_phdr_info::subs"][::core::mem::offset_of!(dl_phdr_info, subs) - 40usize];
["Offset of field: dl_phdr_info::tls_modid"]
[::core::mem::offset_of!(dl_phdr_info, tls_modid) - 48usize];
["Offset of field: dl_phdr_info::tls_data"]
[::core::mem::offset_of!(dl_phdr_info, tls_data) - 56usize];
};
#[doc = " An ID for a loaded program image (or library)"]
pub type loaded_image_id = u32;
#[doc = " Information about a loaded program image or library"]
#[repr(C)]
#[repr(align(16))]
#[derive(Debug, Copy, Clone)]
pub struct loaded_image {
#[doc = " Object handle"]
pub image_handle: object_handle,
#[doc = " Start of full image"]
pub image_start: *const ::core::ffi::c_void,
#[doc = " Length of full image"]
pub image_len: usize,
#[doc = " The dl_info for this loaded image"]
pub dl_info: dl_phdr_info,
#[doc = " The ID for this loaded image"]
pub id: loaded_image_id,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of loaded_image"][::core::mem::size_of::<loaded_image>() - 144usize];
["Alignment of loaded_image"][::core::mem::align_of::<loaded_image>() - 16usize];
["Offset of field: loaded_image::image_handle"]
[::core::mem::offset_of!(loaded_image, image_handle) - 0usize];
["Offset of field: loaded_image::image_start"]
[::core::mem::offset_of!(loaded_image, image_start) - 48usize];
["Offset of field: loaded_image::image_len"]
[::core::mem::offset_of!(loaded_image, image_len) - 56usize];
["Offset of field: loaded_image::dl_info"]
[::core::mem::offset_of!(loaded_image, dl_info) - 64usize];
["Offset of field: loaded_image::id"][::core::mem::offset_of!(loaded_image, id) - 128usize];
};
extern "C-unwind" {
#[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."]
pub fn twz_rt_get_loaded_image(id: loaded_image_id, li: *mut loaded_image) -> bool;
}
extern "C-unwind" {
pub fn twz_rt_iter_phdr(
cb: ::core::option::Option<
unsafe extern "C-unwind" fn(
arg1: *const dl_phdr_info,
size: usize,
data: *mut ::core::ffi::c_void,
) -> ::core::ffi::c_int,
>,
data: *mut ::core::ffi::c_void,
) -> ::core::ffi::c_int;
}
#[doc = " The loaded image ID for the root loaded image (usually the executable)"]
pub const TWZ_RT_EXEID: loaded_image_id = 0;
#[doc = " Information about the system"]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct system_info {
#[doc = " Supported monotonicity"]
pub clock_monotonicity: monotonicity,
#[doc = " Number of CPUs (hardware threads)"]
pub available_parallelism: usize,
#[doc = " Page size"]
pub page_size: usize,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of system_info"][::core::mem::size_of::<system_info>() - 24usize];
["Alignment of system_info"][::core::mem::align_of::<system_info>() - 8usize];
["Offset of field: system_info::clock_monotonicity"]
[::core::mem::offset_of!(system_info, clock_monotonicity) - 0usize];
["Offset of field: system_info::available_parallelism"]
[::core::mem::offset_of!(system_info, available_parallelism) - 8usize];
["Offset of field: system_info::page_size"]
[::core::mem::offset_of!(system_info, page_size) - 16usize];
};
extern "C-unwind" {
#[doc = " Get system information"]
pub fn twz_rt_get_sysinfo() -> system_info;
}
#[doc = " Flags to get_random"]
pub type get_random_flags = u32;
#[doc = " Do not block when collecting random data"]
pub const GET_RANDOM_NON_BLOCKING: get_random_flags = 1;
extern "C-unwind" {
#[doc = " Collect up to len bytes of randomness, filling buf. Returns the number of bytes\n of random data actually collected."]
pub fn twz_rt_get_random(
buf: *mut ::core::ffi::c_char,
len: usize,
flags: get_random_flags,
) -> usize;
}
pub const version: &[u8; 7] = b"0.99.0\0";
#[doc = " Object ID"]
pub type __uint128_t = u128;