Platform-specific package target: js_wasm32

Collection Info

View Source
Collection
core
Path
sys/wasm/wasi
Entries
124

Source Files

Constants

5

CLOCK_PROCESS_CPUTIME_ID #

Source
CLOCK_PROCESS_CPUTIME_ID :: clockid_t(2)

CLOCK_THREAD_CPUTIME_ID #

Source
CLOCK_THREAD_CPUTIME_ID :: clockid_t(3)

Types

54

iovec_t #

Source
iovec_t :: []u8

iovec_t :: struct { buf: [^]u8, buf_len: size_t, } ciovec_t :: struct { buf: [^]u8, buf_len: size_t, }

Procedures

65

args_get #

Source
args_get :: proc "contextless" (argv: [^]cstring, argv_buf: [^]u8) -> errno_t ---

* * Read command-line argument data. * The size of the array should match that returned by `args_sizes_get`

args_sizes_get #

Source
args_sizes_get :: proc "contextless" () -> (num_args, size_of_args: uint, err: errno_t) {…}

* * Return command-line argument data sizes. * @return * Returns the number of arguments and the size of the argument string * data, or an error.

clock_res_get #

Source
clock_res_get :: proc "contextless" (id: clockid_t) -> (ts: timestamp_t, err: errno_t) {…}

* * Return the resolution of a clock. * Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks, * return `errno::inval`. * Note: This is similar to `clock_getres` in POSIX. * @return * The resolution of the clock, or an error if one happened.

clock_time_get #

Source
clock_time_get :: proc "contextless" (id: clockid_t, precision: timestamp_t) -> (ts: timestamp_t, err: errno_t) {…}

* * Return the time value of a clock. * Note: This is similar to `clock_gettime` in POSIX. * @return * The time value of the clock.

environ_get #

Source
environ_get :: proc "contextless" (environ: [^]cstring, environ_buf: [^]u8) -> errno_t ---

* * Read environment variable data. * The sizes of the buffers should match that returned by `environ_sizes_get`.

environ_sizes_get #

Source
environ_sizes_get :: proc "contextless" () -> (num_envs, size_of_envs: uint, err: errno_t) {…}

* * Return environment variable data sizes. * @return * Returns the number of environment variable arguments and the size of the * environment variable data.

fd_close #

Source
fd_close :: proc "contextless" (fd: fd_t) -> errno_t ---

* * Close a file descriptor. * Note: This is similar to `close` in POSIX.

fd_datasync #

Source
fd_datasync :: proc "contextless" (fd: fd_t) -> errno_t ---

* * Synchronize the data of a file to disk. * Note: This is similar to `fdatasync` in POSIX.

fd_fdstat_get #

Source
fd_fdstat_get :: proc "contextless" (fd: fd_t) -> (stat: fdstat_t, err: errno_t) {…}

* * Get the attributes of a file descriptor. * Note: This returns similar flags to `fsync(fd, F_GETFL)` in POSIX, as well as additional fields. * @return * The buffer where the file descriptor's attributes are stored.

fd_fdstat_set_flags #

Source
fd_fdstat_set_flags :: proc "contextless" (fd: fd_t, flags: fdflags_t) -> errno_t ---

* * Adjust the flags associated with a file descriptor. * Note: This is similar to `fcntl(fd, F_SETFL, flags)` in POSIX.

fd_fdstat_set_rights #

Source
fd_fdstat_set_rights :: proc "contextless" (fd: fd_t, fs_rights_base: rights_t, fs_rights_inheritin: rights_t) -> errno_t ---

* * Adjust the rights associated with a file descriptor. * This can only be used to remove rights, and returns `errno::notcapable` if called in a way that would attempt to add rights

fd_filestat_get #

Source
fd_filestat_get :: proc "contextless" (fd: fd_t) -> (stat: filestat_t, err: errno_t) {…}

* * Return the attributes of an open file. * @return * The buffer where the file's attributes are stored.

fd_filestat_set_size #

Source
fd_filestat_set_size :: proc "contextless" (fd: fd_t, size: filesize_t) -> errno_t ---

* * Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros. * Note: This is similar to `ftruncate` in POSIX.

fd_pread #

Source
fd_pread :: proc "contextless" (fd: fd_t, iovs: [][]u8, offset: filesize_t) -> (n: uint, err: errno_t) {…}

* * Read from a file descriptor, without using and updating the file descriptor's offset. * Note: This is similar to `preadv` in POSIX. * @return * The number of bytes read.

fd_prestat_dir_name #

Source
fd_prestat_dir_name :: proc "contextless" (fd: fd_t, path: []u8) -> errno_t ---

* * Return a description of the given preopened file descriptor.

fd_prestat_get #

Source
fd_prestat_get :: proc "contextless" (fd: fd_t) -> (desc: prestat_t, err: errno_t) {…}

* * Return a description of the given preopened file descriptor. * @return * The buffer where the description is stored.

fd_pwrite #

Source
fd_pwrite :: proc "contextless" (fd: fd_t, iovs: [][]u8, offset: filesize_t) -> (n: uint, err: errno_t) {…}

* * Write to a file descriptor, without using and updating the file descriptor's offset. * Note: This is similar to `pwritev` in POSIX. * @return * The number of bytes written.

fd_read #

Source
fd_read :: proc "contextless" (fd: fd_t, iovs: [][]u8) -> (n: uint, err: errno_t) {…}

* * Read from a file descriptor. * Note: This is similar to `readv` in POSIX. * @return * The number of bytes read.

fd_readdir #

Source
fd_readdir :: proc "contextless" (fd: fd_t, buf: []u8, cookie: dircookie_t) -> (n: uint, err: errno_t) {…}

* * Read directory entries from a directory. * When successful, the contents of the output buffer consist of a sequence of * directory entries. Each directory entry consists of a `dirent` object, * followed by `dirent::d_namlen` bytes holding the name of the directory * entry. * This function fills the output buffer as much as possible, potentially * truncating the last directory entry. This allows the caller to grow its * read buffer size in case it's too small to fit a single large directory * entry, or skip the oversized directory entry. * @return * The number of bytes stored in the read buffer. If less than the size of the read buffer, the end of the directory has been reached.

fd_renumber #

Source
fd_renumber :: proc "contextless" (fd: fd_t, to: fd_t) -> errno_t ---

* * Atomically replace a file descriptor by renumbering another file descriptor. * Due to the strong focus on thread safety, this environment does not provide * a mechanism to duplicate or renumber a file descriptor to an arbitrary * number, like `dup2()`. This would be prone to race conditions, as an actual * file descriptor with the same number could be allocated by a different * thread at the same time. * This function provides a way to atomically renumber file descriptors, which * would disappear if `dup2()` were to be removed entirely.

fd_seek #

Source
fd_seek :: proc "contextless" (fd: fd_t, offset: filedelta_t, whence: whence_t) -> (new_offset: filesize_t, err: errno_t) {…}

* * Move the offset of a file descriptor. * Note: This is similar to `lseek` in POSIX. * @return * The new offset of the file descriptor, relative to the start of the file.

fd_sync #

Source
fd_sync :: proc "contextless" (f: fd_t) -> errno_t ---

* * Synchronize the data and metadata of a file to disk. * Note: This is similar to `fsync` in POSIX.

fd_tell #

Source
fd_tell :: proc "contextless" (fd: fd_t) -> (offset: filesize_t, err: errno_t) {…}

* * Return the current offset of a file descriptor. * Note: This is similar to `lseek(fd, 0, SEEK_CUR)` in POSIX. * @return * The current offset of the file descriptor, relative to the start of the file.

fd_write #

Source
fd_write :: proc "contextless" (fd: fd_t, iovs: [][]u8) -> (n: uint, err: errno_t) {…}

* * Write to a file descriptor. * Note: This is similar to `writev` in POSIX.

path_create_directory #

Source
path_create_directory :: proc "contextless" (fd: fd_t, path: string) -> errno_t ---

* * Create a directory. * Note: This is similar to `mkdirat` in POSIX.

path_filestat_get #

Source
path_filestat_get :: proc "contextless" (fd: fd_t, flags: lookupflags_t, path: string) -> (offset: filestat_t, err: errno_t) {…}

* * Return the attributes of a file or directory. * Note: This is similar to `stat` in POSIX. * @return * The buffer where the file's attributes are stored.

path_open #

Source
path_open :: proc "contextless" (
	fd:                   fd_t, 
	dirflags:             lookupflags_t, 
	path:                 string, 
	oflags:               oflags_t, 
	fs_rights_base:       rights_t, 
	fs_rights_inheriting: rights_t, 
	fdflags:              fdflags_t, 
) -> (file: fd_t, err: errno_t) {…}

* * Open a file or directory. * The returned file descriptor is not guaranteed to be the lowest-numbered * file descriptor not currently open; it is randomized to prevent * applications from depending on making assumptions about indexes, since this * is error-prone in multi-threaded contexts. The returned file descriptor is * guaranteed to be less than 2**31. * Note: This is similar to `openat` in POSIX. * @return * The file descriptor of the file that has been opened.

path_readlink #

Source
path_readlink :: proc "contextless" (fd: fd_t, path: string, buf: []u8) -> (n: uint, err: errno_t) {…}

* * Read the contents of a symbolic link. * Note: This is similar to `readlinkat` in POSIX. * @return * The number of bytes placed in the buffer.

path_remove_directory #

Source
path_remove_directory :: proc "contextless" (fd: fd_t, path: string) -> errno_t ---

* * Remove a directory. * Return `errno::notempty` if the directory is not empty. * Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX.

path_rename #

Source
path_rename :: proc "contextless" (fd: fd_t, old_path: string, new_fd: fd_t, new_path: string) -> errno_t ---

* * Rename a file or directory. * Note: This is similar to `renameat` in POSIX.

path_symlink #

Source
path_symlink :: proc "contextless" (old_path: string, fd: fd_t, new_path: string) -> errno_t ---

* * Create a symbolic link. * Note: This is similar to `symlinkat` in POSIX.

path_unlink_file #

Source
path_unlink_file :: proc "contextless" (fd: fd_t, path: string) -> errno_t ---

* * Unlink a file. * Return `errno::isdir` if the path refers to a directory. * Note: This is similar to `unlinkat(fd, path, 0)` in POSIX.

poll_oneoff #

Source
poll_oneoff :: proc "contextless" (subscription_in: ^subscription_t, event_out: ^event_t, nsubscriptions: uint) -> (n: uint, err: errno_t) {…}

* * Concurrently poll for the occurrence of a set of events. * @return * The number of events stored.

proc_exit #

Source
proc_exit :: proc "contextless" (rval: exitcode_t) -> ! ---

* * Terminate the process normally. An exit code of 0 indicates successful * termination of the program. The meanings of other values is dependent on * the environment.

proc_raise #

Source
proc_raise :: proc "contextless" (sig: signal_t) -> errno_t ---

* * Send a signal to the process of the calling thread. * Note: This is similar to `raise` in POSIX.

random_get #

Source
random_get :: proc "contextless" (buf: []u8) -> errno_t ---

* * Write high-quality random data into a buffer. * This function blocks when the implementation is unable to immediately * provide sufficient high-quality random data. * This function may execute slowly, so when large mounts of random data are * required, it's advisable to use this function to seed a pseudo-random * number generator, rather than to provide the random data directly.

sched_yield #

Source
sched_yield :: proc "contextless" () -> errno_t ---

* * Temporarily yield execution of the calling thread. * Note: This is similar to `sched_yield` in POSIX.

sock_recv #

Source
sock_recv :: proc "contextless" (fd: fd_t, ri_data: [][]u8, ri_flags: riflags_t) -> (n: uint, flags: roflags_t, err: errno_t) {…}

* * Receive a message from a socket. * Note: This is similar to `recv` in POSIX, though it also supports reading * the data into multiple buffers in the manner of `readv`. * @return * Number of bytes stored in ri_data and message flags.

sock_send #

Source
sock_send :: proc "contextless" (fd: fd_t, si_data: [][]u8, si_flags: siflags_t) -> (n: uint, err: errno_t) {…}

* * Send a message on a socket. * Note: This is similar to `send` in POSIX, though it also supports writing * the data from multiple buffers in the manner of `writev`. * @return * Number of bytes transmitted.

sock_shutdown #

Source
sock_shutdown :: proc "contextless" (fd: fd_t, how: sdflags_t) -> errno_t ---

* * Shut down socket send and receive channels. * Note: This is similar to `shutdown` in POSIX.

wasi_args_sizes_get #

Source
@(link_name="args_sizes_get")
wasi_args_sizes_get :: proc "contextless" (retptr0: ^uint, retptr1: ^uint) -> errno_t ---

wasi_environ_sizes_get #

Source
@(link_name="environ_sizes_get")
wasi_environ_sizes_get :: proc "contextless" (retptr0: ^uint, retptr1: ^uint) -> errno_t ---