#runtime/core
Xu 0.13.1 API
import: #runtime/core
counts: 185 functions, 0 methods, 1 types, 0 constants, 0 method sets
Standard library package `#runtime/core`.
base64_encode
pub fn base64_encode(src &string, alphabet &string, pad bool) string
Purpose
The alphabet and output size are checked once for the complete conversion. Allocate the destination here so the raw stores only touch fresh storage.
Parameters
src &string- source (read-only borrow; caller keeps the original; type &string)
alphabet &string- alphabet (read-only borrow; caller keeps the original; type &string)
pad bool- pad (bool)
Returns
string — result string
base64_decode
pub fn base64_decode(src &string, alphabet &string) string
Purpose
On malformed input, return the empty descriptor so the caller can report the original structured error. A valid nonempty encoding decodes to >= 1 byte.
Parameters
src &string- source (read-only borrow; caller keeps the original; type &string)
alphabet &string- alphabet (read-only borrow; caller keeps the original; type &string)
Returns
string — result string
task_io_progress
pub fn task_io_progress()
Purpose
Task io progress.
Parameters
No arguments are required.
Returns
This call does not return a value.
task_es_enter
Purpose
Task es enter.
Parameters
No arguments are required.
Returns
This call does not return a value.
task_es_leave
Purpose
Task es leave.
Parameters
No arguments are required.
Returns
This call does not return a value.
task_block
Purpose
The current task cannot proceed: let the others run.
Parameters
No arguments are required.
Returns
This call does not return a value.
task_spawn
pub fn task_spawn(entry int, fn_addr int, exit_addr int, block int)
Purpose
Start fn_addr on a new task. block holds 16 argument words (x0-x7 then the stack words); entry is __xu_task_entry and exit_addr task_exit.
Parameters
entry int- entry (int)
fn_addr int- fn_addr (int)
exit_addr int- exit_addr (int)
block int- block (int)
Returns
This call does not return a value.
task_others
pub fn task_others() bool
Purpose
Whether other tasks exist that could run while this one waits.
Parameters
No arguments are required.
Returns
bool — true or false
sched_epoch
Purpose
Sched epoch.
Parameters
No arguments are required.
Returns
int — a value of this type
task_yield
Purpose
Let the other tasks run without counting this task as blocked (it is waiting for time or I/O, not for another task). Once main has returned it does count: a task only waiting on the outside world must not keep the process alive, as a thread would be killed at exit.
Parameters
No arguments are required.
Returns
This call does not return a value.
chan_ready
pub fn chan_ready(ch int) bool
Purpose
A value is buffered or the channel is closed.
Parameters
ch int- character code (int)
Returns
bool — true or false
task_drain
Purpose
Called when main returns: other tasks run to completion first, until they have all exited or none of them can make progress.
Parameters
No arguments are required.
Returns
This call does not return a value.
task_exit
Purpose
Called by __xu_task_entry when the task function returns.
Parameters
t int- t (int)
Returns
This call does not return a value.
chan_new
pub fn chan_new(cap int) int
Purpose
Chan new.
Parameters
cap int- cap (int)
Returns
int — a value of this type
chan_retain
pub fn chan_retain(ch int)
Purpose
Add a holder to channel ch (0 is no channel).
Parameters
ch int- character code (int)
Returns
This call does not return a value.
chan_release
pub fn chan_release(ch int) int
Purpose
Give up a holder of ch. Returns 1 when it was the last one: the caller then drops the unread elements (chan_take_unread) and calls chan_free.
Parameters
ch int- character code (int)
Returns
int — a value of this type
chan_take_unread
pub fn chan_take_unread(ch int, dst int, esize int) int
Purpose
Move the oldest unread element of ch to dst; 0 when none is left.
Parameters
ch int- character code (int)
dst int- destination (int)
esize int- esize (int)
Returns
int — a value of this type
chan_free
Purpose
Chan free.
Parameters
ch int- character code (int)
Returns
This call does not return a value.
chan_try_send
pub fn chan_try_send(ch int, src int, esize int) int
Purpose
1 when the value was sent, 0 when the send would block.
Parameters
ch int- character code (int)
src int- source (int)
esize int- esize (int)
Returns
int — a value of this type
chan_try_recv
pub fn chan_try_recv(ch int, dst int, esize int) int
Purpose
1 with a value, 2 when the channel is closed and drained (dst zeroed), 0 when the receive would block.
Parameters
ch int- character code (int)
dst int- destination (int)
esize int- esize (int)
Returns
int — a value of this type
chan_send
pub fn chan_send(ch int, src int, esize int)
Purpose
Unbuffered sends complete once a receiver has taken the value.
Parameters
ch int- character code (int)
src int- source (int)
esize int- esize (int)
Returns
This call does not return a value.
chan_recv
pub fn chan_recv(ch int, dst int, esize int) bool
Purpose
Receive into dst; false when the channel is closed and drained.
Parameters
ch int- character code (int)
dst int- destination (int)
esize int- esize (int)
Returns
bool — true or false
chan_close
pub fn chan_close(ch int)
Purpose
Chan close.
Parameters
ch int- character code (int)
Returns
This call does not return a value.
exit_process
pub fn exit_process(code int)
Purpose
Exit process.
Parameters
code int- code (int)
Returns
This call does not return a value.
write_fd
pub fn write_fd(fd int, ptr int, n int) int
Purpose
Write fd.
Parameters
fd int- file descriptor (int)
ptr int- ptr (int)
n int- count, length, or limit (int)
Returns
int — a value of this type
alloc
pub fn alloc(size int) int
Purpose
Zeroed, 16-byte aligned block of at least size bytes.
Parameters
size int- size (int)
Returns
int — a value of this type
free
Purpose
Returns block p from alloc to the heap. p must be live: freeing it twice, or freeing a pointer alloc did not return, is fatal.
Parameters
p int- p (int)
Returns
This call does not return a value.
debug_free_enable
pub fn debug_free_enable()
Purpose
Called first by main in a debug build.
Parameters
No arguments are required.
Returns
This call does not return a value.
mem_zero
pub fn mem_zero(p int, n int)
Purpose
Mem zero.
Parameters
p int- p (int)
n int- count, length, or limit (int)
Returns
This call does not return a value.
mem_copy
pub fn mem_copy(dst int, src int, n int)
Purpose
Mem copy.
Parameters
dst int- destination (int)
src int- source (int)
n int- count, length, or limit (int)
Returns
This call does not return a value.
mem_eq
pub fn mem_eq(a int, b int, n int) bool
Purpose
Mem eq.
Parameters
a int- value (int)
b int- b (int)
n int- count, length, or limit (int)
Returns
bool — true or false
desc_ptr
pub fn desc_ptr(d int) int
Purpose
Desc ptr.
Parameters
d int- d (int)
Returns
int — a value of this type
desc_len
pub fn desc_len(d int) int
Purpose
Desc len.
Parameters
d int- d (int)
Returns
int — a value of this type
desc_reserve
pub fn desc_reserve(d int, need int, esize int)
Purpose
Grow descriptor d so it can hold need elements of esize bytes.
Parameters
d int- d (int)
need int- need (int)
esize int- esize (int)
Returns
This call does not return a value.
slice_push
pub fn slice_push(d int, elem int, esize int)
Purpose
Append the esize bytes at elem to the array described by d.
Parameters
d int- d (int)
elem int- elem (int)
esize int- esize (int)
Returns
This call does not return a value.
bytes_new
pub fn bytes_new(out int, src int, n int)
Purpose
Write a fresh descriptor at out holding a copy of n bytes at src.
Parameters
out int- out (int)
src int- source (int)
n int- count, length, or limit (int)
Returns
This call does not return a value.
str_concat
pub fn str_concat(out int, a int, b int)
Purpose
out = a + b (string concatenation).
Parameters
out int- out (int)
a int- value (int)
b int- b (int)
Returns
This call does not return a value.
string_repeat
pub fn string_repeat(s &string, count int) string
Purpose
Repeat into a single allocation. Copy only from the initialized prefix each destination starts at or after the end of that prefix.
Parameters
s &string- source string (read-only borrow; caller keeps the original; type &string)
count int- count (int)
Returns
string — result string
str_push
pub fn str_push(d int, b int)
Purpose
Append string b. Reserve one byte after the payload for the terminator.
Parameters
d int- d (int)
b int- b (int)
Returns
This call does not return a value.
str_push_byte
pub fn str_push_byte(d int, value int)
Purpose
Append the low byte of value without boxing it in an array element slot.
Parameters
d int- d (int)
value int- value (int)
Returns
This call does not return a value.
str_free
Purpose
Free the buffer of the owned string at d (literals have cap 0).
Parameters
d int- d (int)
Returns
This call does not return a value.
str_ensure_owned
pub fn str_ensure_owned(d int)
Purpose
Copy a literal or non-owned string into a fresh mutable buffer (for s[i] = b).
Parameters
d int- d (int)
Returns
This call does not return a value.
str_eq
pub fn str_eq(a int, b int) bool
Purpose
Str eq.
Parameters
a int- value (int)
b int- b (int)
Returns
bool — true or false
str_less
pub fn str_less(a int, b int) bool
Purpose
Bytewise a < b.
Parameters
a int- value (int)
b int- b (int)
Returns
bool — true or false
str_slice
pub fn str_slice(out int, s int, lo int, hi int)
Purpose
out = s[lo:hi] (bytes copied).
Parameters
out int- out (int)
s int- s (int)
lo int- lo (int)
hi int- hi (int)
Returns
This call does not return a value.
slice_slice
pub fn slice_slice(out int, a int, lo int, hi int, esize int)
Purpose
out = a[lo:hi] for an array of esize-byte elements (elements copied).
Parameters
out int- out (int)
a int- value (int)
lo int- lo (int)
hi int- hi (int)
esize int- esize (int)
Returns
This call does not return a value.
str_bytes
pub fn str_bytes(out int, s int)
Purpose
out = s.bytes: one int per byte.
Parameters
out int- out (int)
s int- s (int)
Returns
This call does not return a value.
str_runes
pub fn str_runes(out int, s int)
Purpose
out = s.runes: code points of strict UTF-8; invalid input panics.
Parameters
out int- out (int)
s int- s (int)
Returns
This call does not return a value.
print_desc
pub fn print_desc(fd int, d int, newline bool)
Purpose
Print desc.
Parameters
fd int- file descriptor (int)
d int- d (int)
newline bool- newline (bool)
Returns
This call does not return a value.
print_int
pub fn print_int(fd int, v int, newline bool)
Purpose
Print int.
Parameters
fd int- file descriptor (int)
v int- value (int)
newline bool- newline (bool)
Returns
This call does not return a value.
print_bool
pub fn print_bool(fd int, b bool, newline bool)
Purpose
Print bool.
Parameters
fd int- file descriptor (int)
b bool- b (bool)
newline bool- newline (bool)
Returns
This call does not return a value.
index_panic
pub fn index_panic(i int, n int)
Purpose
Index panic.
Parameters
i int- index or integer (int)
n int- count, length, or limit (int)
Returns
This call does not return a value.
rt_panic
pub fn rt_panic(kind int)
Purpose
Runtime check failures: 1 index, 2 slice, 3 division by zero, 4 division overflow, 5 invalid utf-8, 6 shared resource cast. Messages and exit code match the product compiler.
Parameters
kind int- kind tag (int)
Returns
This call does not return a value.
slice_check
pub fn slice_check(lo int, hi int, n int)
Purpose
Slice check.
Parameters
lo int- lo (int)
hi int- hi (int)
n int- count, length, or limit (int)
Returns
This call does not return a value.
record_test_failure
pub fn record_test_failure()
Purpose
This is a runtime helper, not a test component. Keep the reserved test_ declaration prefix for user tests so explicit core imports pass preflight.
Parameters
No arguments are required.
Returns
This call does not return a value.
backtrace
Purpose
Return addresses up the frame-pointer chain, as offsets from __xu_start (resolve with the map written by XU_SYMMAP at build time).
Parameters
fd int- file descriptor (int)
Returns
This call does not return a value.
err_from_str
pub fn err_from_str(msg &string) int
Purpose
Error word carrying a copy of message msg.
Parameters
msg &string- message (read-only borrow; caller keeps the original; type &string)
Returns
int — a value of this type
err_msg_copy
pub fn err_msg_copy(out int, box int)
Purpose
out = msg of a runtime-made error box.
Parameters
out int- out (int)
box int- box (int)
Returns
This call does not return a value.
iface_tag_panic
pub fn iface_tag_panic(tag int)
Purpose
A struct@ value whose type id matches no lowered method dispatch case.
Parameters
tag int- tag (int)
Returns
This call does not return a value.
ffi_call
pub fn ffi_call(fp int, block int)
Purpose
Ffi call.
Parameters
fp int- fp (int)
block int- block (int)
Returns
This call does not return a value.
ffi_sym
pub fn ffi_sym(idx int, sym int, libs int) int
Purpose
Address of C symbol sym (NUL-terminated), searched in libs (comma separated link names, possibly empty), cached in slot idx.
Parameters
idx int- idx (int)
sym int- sym (int)
libs int- libs (int)
Returns
int — a value of this type
ffi_flush
Purpose
Flush C stdio at process exit (Xu exits with the raw system call).
Parameters
No arguments are required.
Returns
This call does not return a value.
ffi_cstr
pub fn ffi_cstr(d int) int
Purpose
NUL-terminated heap copy of the string with descriptor d (freed with free).
Parameters
d int- d (int)
Returns
int — a value of this type
ffi_string_from
pub fn ffi_string_from(out int, p int)
Purpose
out (a string descriptor) = copy of the C string p; NULL gives "".
Parameters
out int- out (int)
p int- p (int)
Returns
This call does not return a value.
ffi_closure_alloc
pub fn ffi_closure_alloc(adapter int, code int, env int, stubs_base int) int
Purpose
Ffi closure alloc.
Parameters
adapter int- adapter (int)
code int- code (int)
env int- env (int)
stubs_base int- stubs_base (int)
Returns
int — a value of this type
ffi_closure_take_env
pub fn ffi_closure_take_env(p int, stubs_base int) int
Purpose
Ffi closure take env.
Parameters
p int- p (int)
stubs_base int- stubs_base (int)
Returns
int — a value of this type
float64_bits
pub fn float64_bits(f f64) int
Purpose
Float64 bits.
Parameters
f f64- floating-point value
Returns
int — a value of this type
float64_from_bits
pub fn float64_from_bits(b int) f64
Purpose
Float64 from bits.
Parameters
b int- b (int)
Returns
f64 — a value of this type
print_f64
pub fn print_f64(fd int, f f64, newline bool)
Purpose
Format of the product compiler: sign, truncated integer part, then up to six fraction digits with trailing zeros trimmed. Conversions saturate (fcvtzs), so huge values and infinities print as 9223372036854775807 followed by '/' digits, and NaN prints as 0.
Parameters
fd int- file descriptor (int)
f f64- floating-point value
newline bool- newline (bool)
Returns
This call does not return a value.
fnval_error_panic
pub fn fnval_error_panic(e int)
Purpose
A throwing function called through a function value has no caller that can receive its error.
Parameters
e int- e (int)
Returns
This call does not return a value.
host_read_file
pub fn host_read_file(out int, path int) int
Purpose
Host read file.
Parameters
out int- out (int)
path int- filesystem path (int)
Returns
int — a value of this type
host_write_file
pub fn host_write_file(okp int, path int, data int) int
Purpose
Host write file.
Parameters
okp int- okp (int)
path int- filesystem path (int)
data int- data (int)
Returns
int — a value of this type
host_read_dir
pub fn host_read_dir(out int, path int) int
Purpose
Names in directory order, each followed by a newline; "." and ".." skipped.
Parameters
out int- out (int)
path int- filesystem path (int)
Returns
int — a value of this type
host_stat
pub fn host_stat(out int, path int) int
Purpose
FileInfo{size, is_dir, mode} at out.
Parameters
out int- out (int)
path int- filesystem path (int)
Returns
int — a value of this type
host_mkdir
pub fn host_mkdir(okp int, path int) int
Purpose
Host mkdir.
Parameters
okp int- okp (int)
path int- filesystem path (int)
Returns
int — a value of this type
host_rename
pub fn host_rename(okp int, from int, to int) int
Purpose
Host rename.
Parameters
okp int- okp (int)
from int- from (int)
to int- to (int)
Returns
int — a value of this type
host_remove
pub fn host_remove(okp int, path int) int
Purpose
Removes a file or an empty directory.
Parameters
okp int- okp (int)
path int- filesystem path (int)
Returns
int — a value of this type
host_chmod
pub fn host_chmod(okp int, path int, mode int) int
Purpose
Host chmod.
Parameters
okp int- okp (int)
path int- filesystem path (int)
mode int- mode (int)
Returns
int — a value of this type
host_chdir
pub fn host_chdir(okp int, path int) int
Purpose
Host chdir.
Parameters
okp int- okp (int)
path int- filesystem path (int)
Returns
int — a value of this type
host_symlink
pub fn host_symlink(okp int, target int, link int) int
Purpose
Host symlink.
Parameters
okp int- okp (int)
target int- target (int)
link int- link (int)
Returns
int — a value of this type
host_readlink
pub fn host_readlink(out int, path int) int
Purpose
Host readlink.
Parameters
out int- out (int)
path int- filesystem path (int)
Returns
int — a value of this type
host_os_open
pub fn host_os_open(okp int, path int, mode int) int
Purpose
mode: 0 read, 1 create/truncate, 2 append, 3 exclusive create, 4 lock (create, no truncation), 5 lock an existing file.
Parameters
okp int- okp (int)
path int- filesystem path (int)
mode int- mode (int)
Returns
int — a value of this type
host_fd_read
pub fn host_fd_read(out int, fd int, max int) int
Purpose
Host fd read.
Parameters
out int- out (int)
fd int- file descriptor (int)
max int- maximum (int)
Returns
int — a value of this type
host_fd_write
pub fn host_fd_write(okp int, fd int, data int) int
Purpose
Host fd write.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
data int- data (int)
Returns
int — a value of this type
host_fd_close
pub fn host_fd_close(okp int, fd int) int
Purpose
Host fd close.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
Returns
int — a value of this type
host_fd_seek
pub fn host_fd_seek(okp int, fd int, off int, whence int) int
Purpose
Host fd seek.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
off int- offset (int)
whence int- seek base: 0 start / 1 current / 2 end (int)
Returns
int — a value of this type
host_pipe
pub fn host_pipe(okp int) int
Purpose
ok = (read fd << 32) | write fd.
Parameters
okp int- okp (int)
Returns
int — a value of this type
host_fd_peek_read
pub fn host_fd_peek_read(okp int, fd int) int
Purpose
1 when a read on fd would not block (data, EOF or error), else 0.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
Returns
int — a value of this type
host_random_fill
pub fn host_random_fill(out int, n int) int
Purpose
Host random fill.
Parameters
out int- out (int)
n int- count, length, or limit (int)
Returns
int — a value of this type
host_interface_data
pub fn host_interface_data(out int, name int) int
Purpose
Host interface data.
Parameters
out int- out (int)
name int- name (int)
Returns
int — a value of this type
host_socket
pub fn host_socket(okp int, domain int, typ int, proto int) int
Purpose
Host socket.
Parameters
okp int- okp (int)
domain int- domain (int)
typ int- typ (int)
proto int- proto (int)
Returns
int — a value of this type
host_bind4
pub fn host_bind4(okp int, fd int, a int, b int, c int, d int, port int) int
Purpose
SO_REUSEADDR, then bind.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
a int- value (int)
b int- b (int)
c int- byte or character code (int)
d int- d (int)
port int- port (int)
Returns
int — a value of this type
host_connect4
pub fn host_connect4(okp int, fd int, a int, b int, c int, d int, port int) int
Purpose
Host connect4.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
a int- value (int)
b int- b (int)
c int- byte or character code (int)
d int- d (int)
port int- port (int)
Returns
int — a value of this type
host_bind6
pub fn host_bind6(okp int, fd int, ip int, port int) int
Purpose
Host bind6.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
ip int- ip (int)
port int- port (int)
Returns
int — a value of this type
host_connect6
pub fn host_connect6(okp int, fd int, ip int, port int) int
Purpose
Host connect6.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
ip int- ip (int)
port int- port (int)
Returns
int — a value of this type
host_bind_unix
pub fn host_bind_unix(okp int, fd int, path int) int
Purpose
Host bind unix.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
path int- filesystem path (int)
Returns
int — a value of this type
host_connect_unix
pub fn host_connect_unix(okp int, fd int, path int) int
Purpose
Host connect unix.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
path int- filesystem path (int)
Returns
int — a value of this type
host_listen
pub fn host_listen(okp int, fd int, backlog int) int
Purpose
Host listen.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
backlog int- backlog (int)
Returns
int — a value of this type
host_accept
pub fn host_accept(okp int, fd int) int
Purpose
Host accept.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
Returns
int — a value of this type
host_sendto
pub fn host_sendto(okp int, fd int, addr int, data int) int
Purpose
addr = 4 IPv4 bytes + BE port (6), tagged IPv4 (7), 16 IPv6 bytes + BE port (18), or tagged IPv6 (19).
Parameters
okp int- okp (int)
fd int- file descriptor (int)
addr int- address (int)
data int- data (int)
Returns
int — a value of this type
host_recvfrom
pub fn host_recvfrom(out int, fd int, max int) int
Purpose
Result = tagged datagram packet Tag 4: 1-byte tag (4), 2-byte BE port, 4-byte IPv4, payload. Total header = 7. Tag 6: 1-byte tag (6), 2-byte BE port, 16-byte IPv6, payload. Total header = 19.
Parameters
out int- out (int)
fd int- file descriptor (int)
max int- maximum (int)
Returns
int — a value of this type
host_setsockopt_timeo
pub fn host_setsockopt_timeo(okp int, fd int, ns int) int
Purpose
SO_SNDTIMEO and SO_RCVTIMEO from a relative ns; ns <= 0 clears.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
ns int- ns (int)
Returns
int — a value of this type
host_setsockopt
pub fn host_setsockopt(okp int, fd int, level int, opt int, value int) int
Purpose
Host setsockopt.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
level int- level (int)
opt int- opt (int)
value int- value (int)
Returns
int — a value of this type
host_socket_close
pub fn host_socket_close(okp int, fd int) int
Purpose
Host socket close.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
Returns
int — a value of this type
host_socket_poll
pub fn host_socket_poll(okp int, fd int, events int) int
Purpose
events: 1 read, 4 write. ok = 1 when ready (EOF and errors included).
Parameters
okp int- okp (int)
fd int- file descriptor (int)
events int- events (int)
Returns
int — a value of this type
host_socket_wait
pub fn host_socket_wait(okp int, fd int, events int, timeout_ns int) int
Purpose
events: read 1, write 2. ok = mask of read 1, write 2, error 4, hangup 8. timeout_ns: 0 waits forever, negative polls once.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
events int- events (int)
timeout_ns int- timeout in nanoseconds (int)
Returns
int — a value of this type
host_getsockname
pub fn host_getsockname(out int, fd int) int
Purpose
Host getsockname.
Parameters
out int- out (int)
fd int- file descriptor (int)
Returns
int — a value of this type
host_getpeername
pub fn host_getpeername(out int, fd int) int
Purpose
Host getpeername.
Parameters
out int- out (int)
fd int- file descriptor (int)
Returns
int — a value of this type
host_shutdown
pub fn host_shutdown(okp int, fd int, how int) int
Purpose
Host shutdown.
Parameters
okp int- okp (int)
fd int- file descriptor (int)
how int- how (int)
Returns
int — a value of this type
host_string_from_byte
pub fn host_string_from_byte(out int, b int)
Purpose
Host string from byte.
Parameters
out int- out (int)
b int- b (int)
Returns
This call does not return a value.
host_string_from_bytes
pub fn host_string_from_bytes(out int, arr int, lo int, hi int)
Purpose
Low bytes of the int array at arr[lo:hi]; hi < 0 means arr.len.
Parameters
out int- out (int)
arr int- arr (int)
lo int- lo (int)
hi int- hi (int)
Returns
This call does not return a value.
host_args
pub fn host_args(out int)
Purpose
Host args.
Parameters
out int- out (int)
Returns
This call does not return a value.
host_env_list
pub fn host_env_list(out int)
Purpose
Host env list.
Parameters
out int- out (int)
Returns
This call does not return a value.
host_env_get
pub fn host_env_get(out int, name int)
Purpose
Host env get.
Parameters
out int- out (int)
name int- name (int)
Returns
This call does not return a value.
host_tmp_dir
pub fn host_tmp_dir(out int)
Purpose
Host tmp directory.
Parameters
out int- out (int)
Returns
This call does not return a value.
host_cwd
Purpose
Host cwd.
Parameters
out int- out (int)
Returns
This call does not return a value.
host_host_name
pub fn host_host_name(out int)
Purpose
Host host name.
Parameters
out int- out (int)
Returns
This call does not return a value.
host_pid
Purpose
Host pid.
Parameters
No arguments are required.
Returns
int — a value of this type
host_ppid
Purpose
Host ppid.
Parameters
No arguments are required.
Returns
int — a value of this type
host_uid
Purpose
Host uid.
Parameters
No arguments are required.
Returns
int — a value of this type
host_euid
Purpose
Host euid.
Parameters
No arguments are required.
Returns
int — a value of this type
host_gid
Purpose
Host gid.
Parameters
No arguments are required.
Returns
int — a value of this type
host_egid
Purpose
Host egid.
Parameters
No arguments are required.
Returns
int — a value of this type
host_pagesize
pub fn host_pagesize() int
Purpose
Host pagesize.
Parameters
No arguments are required.
Returns
int — a value of this type
host_now_ns
Purpose
Nanoseconds from the platform's monotonic clock.
Parameters
No arguments are required.
Returns
int — a value of this type
host_wall_time_ns
pub fn host_wall_time_ns() int
Purpose
Host wall time ns.
Parameters
No arguments are required.
Returns
int — a value of this type
host_sleep_ns
pub fn host_sleep_ns(ns int)
Purpose
Host sleep ns.
Parameters
ns int- ns (int)
Returns
This call does not return a value.
host_wait_cancel
pub fn host_wait_cancel(done int, ns int) bool
Purpose
Waits up to ns for cancellation of done: a buffered value or close.
Parameters
done int- done (int)
ns int- ns (int)
Returns
bool — true or false
rt_signal_notify
pub fn rt_signal_notify(c chan int, sig int)
Purpose
Rt signal notify.
Parameters
c chan int- byte or character code (channel; type chan int)
sig int- sig (int)
Returns
This call does not return a value.
rt_signal_stop
pub fn rt_signal_stop(c chan int)
Purpose
Rt signal stop.
Parameters
c chan int- byte or character code (channel; type chan int)
Returns
This call does not return a value.
rt_signal_ignore
pub fn rt_signal_ignore(sig int)
Purpose
Rt signal ignore.
Parameters
sig int- sig (int)
Returns
This call does not return a value.
rt_signal_dispatch
pub fn rt_signal_dispatch(sig int) bool
Purpose
Rt signal dispatch.
Parameters
sig int- sig (int)
Returns
bool — true or false
rt_signal_has_waiters
pub fn rt_signal_has_waiters() bool
Purpose
Rt signal has waiters.
Parameters
No arguments are required.
Returns
bool — true or false
host_system
pub fn host_system(cmd int) int
Purpose
os_system(cmd): wait(2) status of /bin/sh -c cmd.
Parameters
cmd int- cmd (int)
Returns
int — a value of this type
host_exec
pub fn host_exec(path int, blob int, redir int, has_deadline bool, deadline int) int
Purpose
os_exec(path, blob, redir [, cancel, deadline]) -> wait(2) status. blob = dir NUL then each argument NUL-terminated. redir empty inherit stdio [1] path stdout and stderr to the file [2] out [in] 8-byte little-endian stdout (and stdin) fds [3] in 8-byte little-endian stdin fd other the whole string is the stdout file path The parent closes passed fds. Negative results: -2 deadline passed (the child is killed and reaped), -3 process or wait failure.
Parameters
path int- filesystem path (int)
blob int- blob (int)
redir int- redir (int)
has_deadline bool- has_deadline (bool)
deadline int- deadline (int)
Returns
int — a value of this type
host_ui_run
pub fn host_ui_run(path int) int
Purpose
Host ui run.
Parameters
path int- filesystem path (int)
Returns
int — a value of this type
wasi_sys
pub fn wasi_sys(nr int, a int, b int, c int, d int, e int, f int) int
Purpose
Linux generic system call nr on WASI; called by the backend's stub.
Parameters
nr int- nr (int)
a int- value (int)
b int- b (int)
c int- byte or character code (int)
d int- d (int)
e int- e (int)
f int- callback or format string (int)
Returns
int — a value of this type
host_security_store
pub fn host_security_store(out int, name int) int
Purpose
sys_security_store(name): the certificates of system store name, each framed as a little-endian u32 length and the DER bytes.
Parameters
out int- out (int)
name int- name (int)
Returns
int — a value of this type
struct WinSocketWatch
pub struct WinSocketWatch {
pub fd int
pub interest int
pub token int
pub ready int
}
Purpose
Structure encapsulating fd, interest, token, ready.
Public fields
fd int- file descriptor
interest int- field (int)
token int- field (int)
ready int- field (int)
win_wait_sockets
pub fn win_wait_sockets(watches $&[]WinSocketWatch, timeout_ns int) int
Purpose
The caller owns the sockets during the wait. Uses the same interest and readiness bits as host_socket_wait. Negative results are -errno.
Parameters
watches $&[]WinSocketWatch- watches (exclusive borrow; may modify the original; type $&[]WinSocketWatch)
timeout_ns int- timeout in nanoseconds (int)
Returns
int — a value of this type
host_xacp_output_init
pub fn host_xacp_output_init(capacity int) int
Purpose
A capacity of zero queries the control fd without enabling capture.
Parameters
capacity int- capacity (int)
Returns
int — a value of this type
host_xacp_output_read
pub fn host_xacp_output_read(out int, fd int, since int, limit int)
Purpose
Host xacp output read.
Parameters
out int- out (int)
fd int- file descriptor (int)
since int- since (int)
limit int- limit (int)
Returns
This call does not return a value.
type_assert_fail
pub fn type_assert_fail()
Purpose
x as T on a value of another type.
Parameters
No arguments are required.
Returns
This call does not return a value.
assert_fail
pub fn assert_fail(path int, line int, col int, msg int)
Purpose
assert(cond[, msg]) failed at path:line:col; msg is a string address or 0.
Parameters
path int- filesystem path (int)
line int- line (int)
col int- col (int)
msg int- message (int)
Returns
This call does not return a value.
intrin_make_string
pub fn intrin_make_string(out int, n int)
Purpose
make_string(n): n zero bytes; n == 0 is the empty descriptor.
Parameters
out int- out (int)
n int- count, length, or limit (int)
Returns
This call does not return a value.
intrin_make_ints
pub fn intrin_make_ints(out int, n int)
Purpose
make_ints(n): n zero ints.
Parameters
out int- out (int)
n int- count, length, or limit (int)
Returns
This call does not return a value.
intrin_count_byte
pub fn intrin_count_byte(s int, b int) int
Purpose
Intrin count byte.
Parameters
s int- s (int)
b int- b (int)
Returns
int — a value of this type
intrin_find_byte
pub fn intrin_find_byte(s int, b int, from int) int
Purpose
Index of the first byte b at or after from, or -1.
Parameters
s int- s (int)
b int- b (int)
from int- from (int)
Returns
int — a value of this type
string_replace_byte
pub fn string_replace_byte(src &string, old_byte int, new_byte int) string
Purpose
Return an owned copy with every occurrence of old_byte replaced.
Parameters
src &string- source (read-only borrow; caller keeps the original; type &string)
old_byte int- old_byte (int)
new_byte int- new_byte (int)
Returns
string — result string
intrin_split_byte
pub fn intrin_split_byte(out int, s int, b int)
Purpose
split_byte(s, b): the pieces between occurrences of b; "" gives [""].
Parameters
out int- out (int)
s int- s (int)
b int- b (int)
Returns
This call does not return a value.
intrin_join_strings
pub fn intrin_join_strings(out int, arr int, sep int)
Purpose
join_strings(parts, sep).
Parameters
out int- out (int)
arr int- arr (int)
sep int- separator (int)
Returns
This call does not return a value.
intrin_str_bool
pub fn intrin_str_bool(out int, b bool)
Purpose
Intrin str bool.
Parameters
out int- out (int)
b bool- b (bool)
Returns
This call does not return a value.
intrin_assert_fail
pub fn intrin_assert_fail(file int, line int, col int, msg int)
Purpose
"<file>:<line>:<col>: assertion failed[: msg]" on stderr, exit status 1. msg is a string descriptor address or 0.
Parameters
file int- file (int)
line int- line (int)
col int- col (int)
msg int- message (int)
Returns
This call does not return a value.
intrin_atomic_add
pub fn intrin_atomic_add(p int, d int) int
Purpose
Tasks are cooperative on one thread, so plain memory accesses are atomic.
Parameters
p int- p (int)
d int- d (int)
Returns
int — a value of this type
intrin_atomic_cas
pub fn intrin_atomic_cas(p int, old int, new int) bool
Purpose
Intrin atomic cas.
Parameters
p int- p (int)
old int- old value / piece to replace (int)
new int- new value / replacement (int)
Returns
bool — true or false
u64_div
pub fn u64_div(a int, b int) int
Purpose
Unsigned 64-bit division of the bit patterns a / b (b != 0), for u64.
Parameters
a int- value (int)
b int- b (int)
Returns
int — a value of this type
print_u64
pub fn print_u64(fd int, v int, newline bool)
Purpose
Print u64.
Parameters
fd int- file descriptor (int)
v int- value (int)
newline bool- newline (bool)
Returns
This call does not return a value.
intrin_event_set
pub fn intrin_event_set(out int, op int, handle int, fd int, interest int, token int, timeout int) int
Purpose
Intrin event set.
Parameters
out int- out (int)
op int- op (int)
handle int- handle (int)
fd int- file descriptor (int)
interest int- interest (int)
token int- token (int)
timeout int- timeout (int)
Returns
int — a value of this type
map_new
pub fn map_new(kstr int, vsize int, cap int) int
Purpose
kstr: 1 for string keys, 0 for int keys; vsize: value bytes.
Parameters
kstr int- kstr (int)
vsize int- vsize (int)
cap int- cap (int)
Returns
int — a value of this type
map_put_has
pub fn map_put_has(m int, key int, existed_out int) int
Purpose
Value address for key, inserting a zeroed value when it is absent. If existed_out != 0, stores 1 when key already existed and 0 when inserted.
Parameters
m int- m (int)
key int- key (int)
existed_out int- existed_out (int)
Returns
int — a value of this type
map_put
pub fn map_put(m int, key int) int
Purpose
Map put.
Parameters
m int- m (int)
key int- key (int)
Returns
int — a value of this type
map_find_val
pub fn map_find_val(m int, key int) int
Purpose
Value address for key, or 0 when absent.
Parameters
m int- m (int)
key int- key (int)
Returns
int — a value of this type
map_val_ptr
pub fn map_val_ptr(m int, key int) int
Purpose
Value address for key; a missing key ends the program.
Parameters
m int- m (int)
key int- key (int)
Returns
int — a value of this type
map_has
pub fn map_has(m int, key int) bool
Purpose
Map has.
Parameters
m int- m (int)
key int- key (int)
Returns
bool — true or false
map_len
pub fn map_len(m int) int
Purpose
Map len.
Parameters
m int- m (int)
Returns
int — a value of this type
map_delete
pub fn map_delete(m int, key int)
Purpose
Map delete.
Parameters
m int- m (int)
key int- key (int)
Returns
This call does not return a value.
map_free
Purpose
Map free.
Parameters
m int- m (int)
Returns
This call does not return a value.
map_take
pub fn map_take(m int, key int, dst int)
Purpose
Move the value for key to dst and remove the entry; a missing key ends the program.
Parameters
m int- m (int)
key int- key (int)
dst int- destination (int)
Returns
This call does not return a value.
map_next
pub fn map_next(m int, i int) int
Purpose
Index of the first live slot at or after i, or -1.
Parameters
m int- m (int)
i int- index or integer (int)
Returns
int — a value of this type
map_key_at
pub fn map_key_at(m int, i int) int
Purpose
Map key at.
Parameters
m int- m (int)
i int- index or integer (int)
Returns
int — a value of this type
map_val_at
pub fn map_val_at(m int, i int) int
Purpose
Map val at.
Parameters
m int- m (int)
i int- index or integer (int)
Returns
int — a value of this type
md5_hex
pub fn md5_hex(h0 int, h1 int, h2 int, h3 int) string
Purpose
Md5 hex.
Parameters
h0 int- h0 (int)
h1 int- h1 (int)
h2 int- h2 (int)
h3 int- h3 (int)
Returns
string — result string
md5_compress_block
pub fn md5_compress_block(h0 $&int, h1 $&int, h2 $&int, h3 $&int, s &string, off int)
Purpose
Md5 compress block.
Parameters
h0 $&int- h0 (exclusive borrow; may modify the original; type $&int)
h1 $&int- h1 (exclusive borrow; may modify the original; type $&int)
h2 $&int- h2 (exclusive borrow; may modify the original; type $&int)
h3 $&int- h3 (exclusive borrow; may modify the original; type $&int)
s &string- source string (read-only borrow; caller keeps the original; type &string)
off int- offset (int)
Returns
This call does not return a value.
md5_finish_tail
pub fn md5_finish_tail(h0 $&int, h1 $&int, h2 $&int, h3 $&int, s &string, off int, total int) string
Purpose
Md5 finish tail.
Parameters
h0 $&int- h0 (exclusive borrow; may modify the original; type $&int)
h1 $&int- h1 (exclusive borrow; may modify the original; type $&int)
h2 $&int- h2 (exclusive borrow; may modify the original; type $&int)
h3 $&int- h3 (exclusive borrow; may modify the original; type $&int)
s &string- source string (read-only borrow; caller keeps the original; type &string)
off int- offset (int)
total int- total (int)
Returns
string — result string
md5_sum
pub fn md5_sum(s &string) string
Purpose
Md5 digest.
Parameters
s &string- source string (read-only borrow; caller keeps the original; type &string)
Returns
string — result string
sf_add
pub fn sf_add(a int, b int) int
Purpose
Sf add.
Parameters
a int- value (int)
b int- b (int)
Returns
int — a value of this type
sf_sub
pub fn sf_sub(a int, b int) int
Purpose
Sf sub.
Parameters
a int- value (int)
b int- b (int)
Returns
int — a value of this type
sf_mul
pub fn sf_mul(a int, b int) int
Purpose
Sf mul.
Parameters
a int- value (int)
b int- b (int)
Returns
int — a value of this type
sf_div
pub fn sf_div(a int, b int) int
Purpose
Sf div.
Parameters
a int- value (int)
b int- b (int)
Returns
int — a value of this type
sf_eq
pub fn sf_eq(a int, b int) bool
Purpose
Sf eq.
Parameters
a int- value (int)
b int- b (int)
Returns
bool — true or false
sf_lt
pub fn sf_lt(a int, b int) bool
Purpose
Sf lt.
Parameters
a int- value (int)
b int- b (int)
Returns
bool — true or false
sf_le
pub fn sf_le(a int, b int) bool
Purpose
Sf le.
Parameters
a int- value (int)
b int- b (int)
Returns
bool — true or false
sf_from_int
pub fn sf_from_int(x int) int
Purpose
Sf from int.
Parameters
x int- value (int)
Returns
int — a value of this type
sf_to_int
pub fn sf_to_int(a int) int
Purpose
Truncates toward zero, saturating; NaN gives 0.
Parameters
a int- value (int)
Returns
int — a value of this type
sf_div64
pub fn sf_div64(a int, b int) int
Purpose
The hosted division semantics: x / 0 = 0, x % 0 = x, MIN / -1 wraps.
Parameters
a int- value (int)
b int- b (int)
Returns
int — a value of this type
sf_mod64
pub fn sf_mod64(a int, b int) int
Purpose
Sf mod64.
Parameters
a int- value (int)
b int- b (int)
Returns
int — a value of this type