XU XUv0.13.1
中文

#runtime/core

import: #runtime/core

counts: 185 functions, 0 methods, 1 types, 0 constants, 0 method sets

Standard library package `#runtime/core`.

base64_encode

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub fn task_es_enter()

Purpose

Task es enter.

Parameters

No arguments are required.

Returns

This call does not return a value.

task_es_leave

XuAPI
pub fn task_es_leave()

Purpose

Task es leave.

Parameters

No arguments are required.

Returns

This call does not return a value.

task_block

XuAPI
pub fn 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

XuAPI
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

XuAPI
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

XuAPI
pub fn sched_epoch() int

Purpose

Sched epoch.

Parameters

No arguments are required.

Returns

int — a value of this type

task_yield

XuAPI
pub fn 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

XuAPI
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

XuAPI
pub fn 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

XuAPI
pub fn task_exit(t int)

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

XuAPI
pub fn chan_new(cap int) int

Purpose

Chan new.

Parameters

cap int
cap (int)

Returns

int — a value of this type

chan_retain

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub fn chan_free(ch int)

Purpose

Chan free.

Parameters

ch int
character code (int)

Returns

This call does not return a value.

chan_try_send

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub fn exit_process(code int)

Purpose

Exit process.

Parameters

code int
code (int)

Returns

This call does not return a value.

write_fd

XuAPI
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

XuAPI
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

XuAPI
pub fn free(p int)

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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub fn desc_ptr(d int) int

Purpose

Desc ptr.

Parameters

d int
d (int)

Returns

int — a value of this type

desc_len

XuAPI
pub fn desc_len(d int) int

Purpose

Desc len.

Parameters

d int
d (int)

Returns

int — a value of this type

desc_reserve

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub fn str_free(d int)

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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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.

index_panic

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub fn backtrace(fd int)

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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub fn 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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub fn float64_from_bits(b int) f64

Purpose

Float64 from bits.

Parameters

b int
b (int)

Returns

f64 — a value of this type

fnval_error_panic

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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_os_open

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub fn host_cwd(out int)

Purpose

Host cwd.

Parameters

out int
out (int)

Returns

This call does not return a value.

host_host_name

XuAPI
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

XuAPI
pub fn host_pid() int

Purpose

Host pid.

Parameters

No arguments are required.

Returns

int — a value of this type

host_ppid

XuAPI
pub fn host_ppid() int

Purpose

Host ppid.

Parameters

No arguments are required.

Returns

int — a value of this type

host_uid

XuAPI
pub fn host_uid() int

Purpose

Host uid.

Parameters

No arguments are required.

Returns

int — a value of this type

host_euid

XuAPI
pub fn host_euid() int

Purpose

Host euid.

Parameters

No arguments are required.

Returns

int — a value of this type

host_gid

XuAPI
pub fn host_gid() int

Purpose

Host gid.

Parameters

No arguments are required.

Returns

int — a value of this type

host_egid

XuAPI
pub fn host_egid() int

Purpose

Host egid.

Parameters

No arguments are required.

Returns

int — a value of this type

host_pagesize

XuAPI
pub fn host_pagesize() int

Purpose

Host pagesize.

Parameters

No arguments are required.

Returns

int — a value of this type

host_now_ns

XuAPI
pub fn host_now_ns() int

Purpose

Nanoseconds from the platform's monotonic clock.

Parameters

No arguments are required.

Returns

int — a value of this type

host_wall_time_ns

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub fn rt_signal_has_waiters() bool

Purpose

Rt signal has waiters.

Parameters

No arguments are required.

Returns

bool — true or false

host_system

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

intrin_event_set

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
pub fn map_len(m int) int

Purpose

Map len.

Parameters

m int
m (int)

Returns

int — a value of this type

map_delete

XuAPI
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

XuAPI
pub fn map_free(m int)

Purpose

Map free.

Parameters

m int
m (int)

Returns

This call does not return a value.

map_take

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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

XuAPI
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