Package
core.libc
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
}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.
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.
calloc :: (count: i32, size: i32) -> rawptr C calloc. The product is checked for overflow. A zero product still allocates.
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.
getentropy :: (buf: rawptr, len: i32) -> i32 C getentropy. Fills buf from the platform random source.
getenv :: (name: rawptr) -> rawptr C getenv. The returned string is a malloc copy; missing names return null.
gmtime :: (timer: rawptr) -> rawptr C gmtime. timer points at a wasm32 time_t (long long). The result is one reused struct tm.
localtime :: (timer: rawptr) -> rawptr C localtime. There is no timezone database, so this matches gmtime and reuses its buffer.
malloc :: (size: i32) -> rawptr C malloc. Memory comes from context.allocator. A zero size still returns a unique freeable pointer.
memcmp :: (left: rawptr, right: rawptr, count: i32) -> i32 C memcmp. Bytes are compared as unsigned values.
memcpy :: (dest: rawptr, src: rawptr, count: i32) -> rawptr C memcpy. The ranges must not overlap.
memmove :: (dest: rawptr, src: rawptr, count: i32) -> rawptr C memmove. Overlapping ranges are safe.
memset :: (dest: rawptr, value: i32, count: i32) -> rawptr C memset. value is truncated to a byte, matching C.
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).
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.
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 :: (fd: i32, buf: rawptr, count: i32) -> i32 C read. A short read is returned as its byte count. End of file is 0.
readdir :: (dirp: rawptr) -> rawptr C readdir. The returned Dirent is reused by the next call.
realloc :: (ptr: rawptr, size: i32) -> rawptr C realloc. null allocates, and a non-positive size frees.
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.
strchr :: (text: rawptr, ch: i32) -> rawptr C strchr. ch is truncated to a byte. A search for 0 returns the terminator.
strcpy :: (dest: rawptr, src: rawptr) -> rawptr C strcpy. dest must have room for src and its terminator.
strcspn :: (text: rawptr, reject: rawptr) -> i32 C strcspn. Counts the leading bytes that do not appear in reject.
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.
strncmp :: (left: rawptr, right: rawptr, count: i32) -> i32 C strncmp. Comparison stops after count bytes or at a null.
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 :: (text: rawptr, accept: rawptr) -> rawptr C strpbrk. Returns the first byte of text that appears in accept.
strrchr :: (text: rawptr, ch: i32) -> rawptr C strrchr. Returns the last matching byte, including a search for 0.
strspn :: (text: rawptr, accept: rawptr) -> i32 C strspn. Counts the leading bytes that appear in accept.
strstr :: (haystack: rawptr, needle: rawptr) -> rawptr C strstr. An empty needle returns haystack.
strtol :: (text: rawptr, end: rawptr, base: i32) -> i32 C strtol. The result is a wasm32 long.
strtoul :: (text: rawptr, end: rawptr, base: i32) -> i32 C strtoul. The result is a wasm32 unsigned long stored in an i32.