joka.wasip1
The wasip1 module provides types and functions available in WASI preview 1.
Types 47
Error codes returned by functions. Not all of these error codes are returned by the functions provided by this API; some are used in higher-level library layers, and others are provided merely for alignment with POSIX.
Identifiers for clocks.
Type of a subscription to an event or its occurrence.
Flags determining the method of how paths are resolved.
Flags determining the method of how paths are resolved.
Open flags used by path_open.
Open flags used by path_open.
File descriptor rights, determining which actions may be performed.
File descriptor rights, determining which actions may be performed.
File descriptor flags.
File descriptor flags.
Which file time attributes to adjust.
Which file time attributes to adjust.
File or memory access pattern advisory information.
The type of a file descriptor or file.
The position relative to which to set the offset of the file descriptor.
The contents of a $prestat when type is preopentype::dir.
Size nameLenInformation about a pre-opened capability.
Flags determining how to interpret the timestamp provided in subscription_clock::timeout.
Flags determining how to interpret the timestamp provided in subscription_clock::timeout.
The contents of a subscription when type is eventtype::clock.
The contents of a subscription when type is type is eventtype::fd_read or eventtype::fd_write.
Fd fdThe contents of a subscription.
ubyte typeData dataSubscription to an event.
The state of the file descriptor subscribed to with eventtype::fd_read or eventtype::fd_write.
The state of the file descriptor subscribed to with eventtype::fd_read or eventtype::fd_write.
The contents of an event when type is eventtype::fd_read or eventtype::fd_write.
An event that occurred.
Which channels on a socket to shut down.
Which channels on a socket to shut down.
Number of hard links to an inode.
User-provided value that may be attached to objects that is retained when extracted from the implementation.
File serial number that is unique within its file system.
Identifier for a device containing a file system. Can be used in combination with inode to uniquely identify a file or directory in the filesystem.
A reference to the offset of a directory entry. The value 0 signifies the start of the directory.
Non-negative file size or length of a region within a file.
Relative offset within a file.
Exit code generated by a process when exiting.
A file descriptor handle.
Timestamp in nanoseconds.
A region of memory for scatter/gather reads.
Convert a string to a Iovec.
A region of memory for scatter/gather writes.
Convert a string to a Ciovec.
Functions 43
Errno argsGet(ubyte * * argv, ubyte * argvBuf) @importName("args_get")Read command-line argument data. The size of the array should match that returned by argssizesget. Each argument is expected to be \0 terminated.Errno argsSizesGet(Size * argc, Size * argvBufSize) @importName("args_sizes_get")Return command-line argument data sizes.Errno clockResGet(ClockId clockId, TimeStamp * time) @importName("clock_res_get")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 i...Errno clockTimeGet(ClockId clockId, TimeStamp precision, TimeStamp * time) @importName("clock_time_get")Return the time value of a clock. Note: This is similar to clock_gettime in POSIX.Errno environGet(ubyte * * environ, ubyte * environBuf) @importName("environ_get")Read environment variable data. The sizes of the buffers should match that returned by environsizesget. Key/value pairs are expected to be joined with =s, and terminated with \0s.Errno environSizesGet(Size * envCount, Size * envBufSize) @importName("environ_sizes_get")Return environment variable data sizes.Errno fdAdvise(Fd fd, FileSize offset, FileSize len, Advice advice) @importName("fd_advise")Provide file advisory information on a file descriptor. Note: This is similar to posix_fadvise in POSIX.Errno fdAllocate(Fd fd, FileSize offset, FileSize len) @importName("fd_allocate")Force the allocation of space in a file. Note: This is similar to posix_fallocate in POSIX.Errno fdClose(Fd fd) @importName("fd_close")Close a file descriptor. Note: This is similar to close in POSIX.Errno fdDataSync(Fd fd) @importName("fd_datasync")Synchronize the data of a file to disk. Note: This is similar to fdatasync in POSIX.Errno fdFdStatGet(Fd fd, FdStat * fdStat) @importName("fd_fdstat_get")Get the attributes of a file descriptor. Note: This returns similar flags to fcntl(fd, F_GETFL) in POSIX, as well as additional fields.Errno fdFdStatSetFlags(Fd fd, FdFlags flags) @importName("fd_fdstat_set_flags")Adjust the flags associated with a file descriptor. Note: This is similar to fcntl(fd, F_SETFL, flags) in POSIX.Errno fdFdStatSetRights(Fd fd, Rights rightsBase, Rights rightsInheriting) @importName("fd_fdstat_set_rights")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.Errno fdFileStatGet(Fd fd, FileStat * fileStat) @importName("fd_filestat_get")Return the attributes of an open file.Errno fdFileStatSetSize(Fd fd, FileSize size) @importName("fd_filestat_set_size")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.Errno fdFileStatSetTimes(Fd fd, TimeStamp atime, TimeStamp mtime, FstFlags fstFlags) @importName("fd_filestat_set_times")Adjust the timestamps of an open file or directory. Note: This is similar to futimens in POSIX.Errno fdPread(Fd fd, Iovec * iovs, Size iovsLen, FileSize offset, Size * outSize) @importName("fd_pread")Read from a file descriptor, without using and updating the file descriptor's offset. Note: This is similar to preadv in Linux (and other Unix-es).Errno fdPrestatDirName(Fd fd, ubyte * path, Size pathLen) @importName("fd_prestat_dir_name")Return a description of the given preopened file descriptor.Errno fdPrestatGet(Fd fd, Prestat * outPrestat) @importName("fd_prestat_get")Return a description of the given preopened file descriptor.Errno fdPwrite(Fd fd, const(Ciovec) * iovs, Size iovsLen, FileSize offset, Size * outSize) @importName("fd_pwrite")Write to a file descriptor, without using and updating the file descriptor's offset. Note: This is similar to pwritev in Linux (and other Unix-es). Like Linux (and other Unix-es), any calls of pwri...Errno fdRead(Fd fd, Iovec * iovs, Size iovsLen, Size * nread) @importName("fd_read")Read from a file descriptor. Note: This is similar to readv in POSIX.Errno fdReadDir(Fd fd, ubyte * buf, Size bufLen, DirCookie cookie, Size * nread) @importName("fd_readdir")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...Errno fdRenumber(Fd fd, Fd to) @importName("fd_renumber")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 ...Errno fdSeek(Fd fd, FileDelta offset, Whence whence, FileSize * outOffset) @importName("fd_seek")Move the offset of a file descriptor. Note: This is similar to lseek in POSIX.Errno fdSync(Fd fd) @importName("fd_sync")Synchronize the data and metadata of a file to disk. Note: This is similar to fsync in POSIX.Errno fdTell(Fd fd, FileSize * outOffset) @importName("fd_tell")Return the current offset of a file descriptor. Note: This is similar to lseek(fd, 0, SEEK_CUR) in POSIX.Errno fdWrite(Fd fd, const(Ciovec) * iovs, Size iovsLen, Size * nwritten) @importName("fd_write")Write to a file descriptor. Note: This is similar to writev in POSIX. Like POSIX, any calls of write (and other functions to read or write) for a regular file by other threads in the WASI process s...Errno pathCreateDirectory(Fd fd, const(char) * path, Size pathLen) @importName("path_create_directory")Create a directory. Note: This is similar to mkdirat in POSIX.Errno pathFileStatGet(Fd fd, LookupFlags flags, const(char) * path, Size pathLen, FileStat * fileStatOut) @importName("path_filestat_get")Return the attributes of a file or directory. Note: This is similar to stat in POSIX.Errno pathFileStatSetTimes(Fd fd, LookupFlags flags, const(char) * path, Size pathLen, TimeStamp atime, TimeStamp mtime, FstFlags fstFlags) @importName("path_filestat_set_times")Adjust the timestamps of a file or directory. Note: This is similar to utimensat in POSIX.Errno pathLink(Fd fd, LookupFlags oldFlags, const(char) * oldPath, Size oldPathLen, Fd newFd, const(char) * newPath, Size newPathLen) @importName("path_link")Create a hard link. Note: This is similar to linkat in POSIX.Errno pathOpen(
Fd fd,
LookupFlags dirFlags,
const(char) * path,
Size pathLen,
OFlags oFlags,
Rights rightsBase,
Rights rightsInheriting,
FdFlags fdFlags,
Fd * openedFd,
) @importName("path_open")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 mak...Errno pathReadLink(Fd fd, const(char) * path, Size pathLen, ubyte * buf, Size size, Size * outSize) @importName("path_readlink")Read the contents of a symbolic link. Note: This is similar to readlinkat in POSIX.Errno pathRemoveDirectory(Fd fd, const(char) * path, Size pathLen) @importName("path_remove_directory")Remove a directory. Return errno::notempty if the directory is not empty. Note: This is similar to unlinkat(fd, path, AT_REMOVEDIR) in POSIX.Errno pathRename(Fd fd, const(char) * oldPath, Size oldPathLen, Fd newFd, const(char) * newPath, Size newPathLen) @importName("path_rename")Rename a file or directory. Note: This is similar to renameat in POSIX.Errno pathSymlink(const(char) * oldPath, Size oldPathLen, Fd fd, const(char) * newPath, Size newPathLen) @importName("path_symlink")Create a symbolic link. Note: This is similar to symlinkat in POSIX.Errno pathUnlinkFile(Fd fd, const(char) * path, Size pathLen) @importName("path_unlink_file")Unlink a file. Return errno::isdir if the path refers to a directory. Note: This is similar to unlinkat(fd, path, 0) in POSIX.Errno pollOneoff(const(Subscription) * input, Event * output, Size nsubscriptions, Sz * outSize) @importName("poll_oneoff")Concurrently poll for the occurrence of a set of events. If nsubscriptions is 0, returns errno::inval.noreturn procExit(ExitCode code) @importName("proc_exit")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.Errno randomGet(ubyte * buf, Size bufLen) @importName("random_get")Write high-quality random data into a buffer. This function blocks when the implementation is unable to immediately provide sufficient high-quality random data.Errno schedYield() @importName("sched_yield")Temporarily yield execution of the calling thread. Note: This is similar to sched_yield in POSIX.Errno sockShutdown(Fd fd, SdFlags how) @importName("sock_shutdown")Shut down socket send and receive channels. Note: This is similar to shutdown in POSIX.Variables 4
wasi = llvmAttr("wasm-import-module", "wasi_snapshot_preview1")The WASI Preview 1 import module.
stdin = Fd(0)The "standard error" descriptor number.
stdout = Fd(1)The "standard input" descriptor number.
stderr = Fd(2)The "standard output" descriptor number.