Packages

builtin
cbindgen
core
core.alloc
core.alloc.arena
core.alloc.atomic
core.alloc.debug
core.alloc.fixed
core.alloc.gc
core.alloc.heap
core.alloc.log
core.alloc.memwatch
core.alloc.pool
core.alloc.ring
core.arg_parse
core.array
core.avl_tree
core.bucket_array
core.bytes
core.conv
core.crypto
core.crypto.keys
core.doc
core.encoding
core.encoding.base64
core.encoding.csv
core.encoding.hex
core.encoding.json
core.encoding.kdl
core.encoding.osad
core.encoding.protobuf
core.encoding.utf8
core.encoding.xml
core.hash
core.hash.md5
core.hash.sha1
core.hash.sha256
core.heap
core.intrinsics
core.intrinsics.atomics
core.intrinsics.onyx
core.intrinsics.types
core.intrinsics.wasm
core.io
core.iter
core.libc
core.list
core.map
core.math
core.memory
core.misc
core.net
core.os
core.random
core.set
core.slice
core.string
core.sync
core.test
core.thread
core.time
runtime
runtime.info
runtime.platform
runtime.vars
simd

Package

core.libc

AtExit
AtExit :: struct {
    func: i32
    arg: rawptr
}
Dirent
Dirent :: struct {
    ino: u64
    typ: u8
    name: [256] u8
}
Stat
Stat :: struct {
    dev: u64
    ino: u64
    nlink: u64
    mode: u32
    uid: u32
    gid: u32
    pad0: u32
    rdev: u64
    size: i64
    blksize: i32
    pad1: i32
    blocks: i64
    atim: Timespec
    mtim: Timespec
    ctim: Timespec
    reserved0: i64
    reserved1: i64
    reserved2: i64
}
Timespec
Timespec :: struct {
    sec: i64
    nsec: i32
    pad: i32
}
Timeval
Timeval :: struct {
    sec: i64
    usec: i64
}

wasm32-wasi struct timeval.

Tm
Tm :: struct {
    sec: i32
    min: i32
    hour: i32
    mday: i32
    mon: i32
    year: i32
    wday: i32
    yday: i32
    isdst: i32
    gmtoff: i32
    zone: rawptr
    nsec: i32
}

wasm32-wasi struct tm (__struct_tm.h). The first nine fields match time.Timestamp.

i128
i128 :: struct {
    lo: i64
    hi: i64
}
__ashlti3
__ashlti3 :: (ret: &i128, lo: i64, hi: i64, sh: i32) -> void
__cxa_atexit
__cxa_atexit :: (func: i32, arg: rawptr, dso: rawptr) -> i32
__i128_mul_wide
__i128_mul_wide :: (x: u64, y: u64) -> i128
__multi3
__multi3 :: (ret: &i128, a_lo: i64, a_hi: i64, b_lo: i64, b_hi: i64) -> void
abort
abort :: () -> void

C abort. Does not return.

access
access :: (path: rawptr, _mode: i32) -> i32

C access.

arc4random_buf
arc4random_buf :: (buf: rawptr, len: i32) -> void

BSD arc4random_buf.

atexit
atexit :: (func: i32) -> i32

C atexit. func is a wasm function-table index for void ()(void). Recorded beside __cxa_atexit. The list is not walked on exit yet.

atoi
atoi :: (text: rawptr) -> i32

C atoi.

calloc
calloc :: (count: i32, size: i32) -> rawptr

C calloc. The product is checked for overflow. A zero product still allocates.

clock_gettime
clock_gettime :: (clock_id: i32, out: &Timespec) -> i32

C clock_gettime. Clock 1 is monotonic. Every other id, including _CLOCK_REALTIME, is wall time. Seconds come from os.time milliseconds.

close
close :: (fd: i32) -> i32

C close.

closedir
closedir :: (dirp: rawptr) -> i32

C closedir.

free
free :: (ptr: rawptr) -> void

C free. null is ignored.

fstat
fstat :: (fd: i32, out: &Stat) -> i32

C fstat.

getentropy
getentropy :: (buf: rawptr, len: i32) -> i32

C getentropy. Fills buf from the platform random source.

getenv
getenv :: (name: rawptr) -> rawptr

C getenv. The returned string is a malloc copy; missing names return null.

getpid
getpid :: () -> i32

C getpid. This runtime has one process, so the id is 1.

gettimeofday
gettimeofday :: (out: &Timeval, tz: rawptr) -> i32

C gettimeofday. tz is ignored.

gmtime
gmtime :: (timer: rawptr) -> rawptr

C gmtime. timer points at a wasm32 time_t (long long). The result is one reused struct tm.

ldexp
ldexp :: (a: f64, b: i32) -> f64

C ldexp

localtime
localtime :: (timer: rawptr) -> rawptr

C localtime. There is no timezone database, so this matches gmtime and reuses its buffer.

malloc
malloc :: (size: i32) -> rawptr

C malloc. Memory comes from context.allocator. A zero size still returns a unique freeable pointer.

memchr
memchr :: (mem: rawptr, ch: i32, count: i32) -> rawptr

C memchr.

memcmp
memcmp :: (left: rawptr, right: rawptr, count: i32) -> i32

C memcmp. Bytes are compared as unsigned values.

memcpy
memcpy :: (dest: rawptr, src: rawptr, count: i32) -> rawptr

C memcpy. The ranges must not overlap.

memmove
memmove :: (dest: rawptr, src: rawptr, count: i32) -> rawptr

C memmove. Overlapping ranges are safe.

memset
memset :: (dest: rawptr, value: i32, count: i32) -> rawptr

C memset. value is truncated to a byte, matching C.

open
open :: (path: rawptr, flags: i32, mode: i32) -> i32

C open. mode is accepted and ignored. Descriptors start at 3. Flag values are the wasm32-wasi-musl ones (O_RDONLY and so on).

opendir
opendir :: (path: rawptr) -> rawptr

C opendir.

posix_memalign
posix_memalign :: (out: &rawptr, alignment: i32, size: i32) -> i32

C posix_memalign. alignment must be a power of two and at least 4. Returns 0 or an errno value, and also stores that errno.

pow
pow :: (base: f64, exponent: f64) -> f64

C pow for double.

qsort
qsort :: (base: rawptr, count: i32, size: i32, compare: i32) -> void

C qsort. compare is a wasm function-table index, the form Clang passes for an int ()(const void , const void ).

read
read :: (fd: i32, buf: rawptr, count: i32) -> i32

C read. A short read is returned as its byte count. End of file is 0.

readdir
readdir :: (dirp: rawptr) -> rawptr

C readdir. The returned Dirent is reused by the next call.

realloc
realloc :: (ptr: rawptr, size: i32) -> rawptr

C realloc. null allocates, and a non-positive size frees.

sscanf
sscanf :: (text: rawptr, format: rawptr, args: rawptr) -> i32

C sscanf. args is the same wasm32 vararg area as vsnprintf. Returns the number of assigned values.

stat
stat :: (path: rawptr, out: &Stat) -> i32

C stat. out is a wasm32-wasi-musl struct stat.

strchr
strchr :: (text: rawptr, ch: i32) -> rawptr

C strchr. ch is truncated to a byte. A search for 0 returns the terminator.

strcmp
strcmp :: (left: rawptr, right: rawptr) -> i32

C strcmp.

strcpy
strcpy :: (dest: rawptr, src: rawptr) -> rawptr

C strcpy. dest must have room for src and its terminator.

strcspn
strcspn :: (text: rawptr, reject: rawptr) -> i32

C strcspn. Counts the leading bytes that do not appear in reject.

strdup
strdup :: (text: rawptr) -> rawptr

C strdup. The result is allocated with malloc.

strerror
strerror :: (err: i32) -> rawptr

C strerror. The pointer is to a single reused buffer.

strerror_r
strerror_r :: (errnum: i32, buf: rawptr, buflen: i32) -> i32

C strerror_r (XSI). Copies the strerror text into buf. Returns 0, or an errno value when buf cannot hold the text.

strlen
strlen :: (text: rawptr) -> i32

C strlen.

strncmp
strncmp :: (left: rawptr, right: rawptr, count: i32) -> i32

C strncmp. Comparison stops after count bytes or at a null.

strncpy
strncpy :: (dest: rawptr, src: rawptr, count: i32) -> rawptr

C strncpy. Copies at most count bytes and zero-fills the remainder. The result is not terminated when src is longer than count.

strpbrk
strpbrk :: (text: rawptr, accept: rawptr) -> rawptr

C strpbrk. Returns the first byte of text that appears in accept.

strrchr
strrchr :: (text: rawptr, ch: i32) -> rawptr

C strrchr. Returns the last matching byte, including a search for 0.

strspn
strspn :: (text: rawptr, accept: rawptr) -> i32

C strspn. Counts the leading bytes that appear in accept.

strstr
strstr :: (haystack: rawptr, needle: rawptr) -> rawptr

C strstr. An empty needle returns haystack.

strtol
strtol :: (text: rawptr, end: rawptr, base: i32) -> i32

C strtol. The result is a wasm32 long.

strtoul
strtoul :: (text: rawptr, end: rawptr, base: i32) -> i32

C strtoul. The result is a wasm32 unsigned long stored in an i32.

time
time :: (out: rawptr) -> i64

C time. Returns seconds since the Unix epoch. out may be null.

tolower
tolower :: (ch: i32) -> i32

C tolower for a byte. Values outside A-Z are unchanged.

vsnprintf
vsnprintf :: (dest: rawptr, size: i32, format: rawptr, args: rawptr) -> i32

C vsnprintf. args points at the wasm32 vararg area: i32 values are packed, and i64 / double values are aligned to 8. Returns the length that would have been written, not counting the terminator.