joka.wasip1

The wasip1 module provides types and functions available in WASI preview 1.

Types 47

enumErrno : ushort

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.

success = 0No error occurred. System call completed successfully.
toobig = 1Argument list too long.
acces = 2Permission denied.
addrinuse = 3Address in use.
addrnotavail = 4Address not available.
afnosupport = 5Address family not supported.
again = 6Resource unavailable, or operation would block.
already = 7Connection already in progress.
badf = 8Bad file descriptor.
badmsg = 9Bad message.
busy = 10Device or resource busy.
canceled = 11Operation canceled.
child = 12No child processes.
connaborted = 13Connection aborted.
connrefused = 14Connection refused.
connreset = 15Connection reset.
deadlk = 16Resource deadlock would occur.
destaddrreq = 17Destination address required.
dom = 18Mathematics argument out of domain of function.
dquot = 19Reserved.
exist = 20File exists.
fault = 21Bad address.
fbig = 22File too large.
hostunreach = 23Host is unreachable.
idrm = 24Identifier removed.
ilseq = 25Illegal byte sequence.
inprogress = 26Operation in progress.
intr = 27Interrupted function.
inval = 28Invalid argument.
io = 29I/O error.
isconn = 30Socket is connected.
isdir = 31Is a directory.
loop = 32Too many levels of symbolic links.
mfile = 33File descriptor value too large.
mlink = 34Too many links.
msgsize = 35Message too large.
multihop = 36Reserved.
nametoolong = 37Filename too long.
netdown = 38Network is down.
netreset = 39Connection aborted by network.
netunreach = 40Network unreachable.
nfile = 41Too many files open in system.
nobufs = 42No buffer space available.
nodev = 43No such device.
noent = 44No such file or directory.
noexec = 45Executable file format error.
nolck = 46No locks available.
nolink = 47Reserved.
nomem = 48Not enough space.
nomsg = 49No message of the desired type.
noprotoopt = 50Protocol not available.
nospc = 51No space left on device.
nosys = 52Function not supported.
notconn = 53The socket is not connected.
notdir = 54Not a directory or a symbolic link to a directory.
notempty = 55Directory not empty.
notrecoverable = 56State not recoverable.
notsock = 57Not a socket.
notsup = 58Not supported, or operation not supported on socket.
notty = 59Inappropriate I/O control operation.
nxio = 60No such device or address.
overflow = 61Value too large to be stored in data type.
ownerdead = 62Previous owner died.
perm = 63Operation not permitted.
pipe = 64Broken pipe.
proto = 65Protocol error.
protonosupport = 66Protocol not supported.
prototype = 67Protocol wrong type for socket.
range = 68Result too large.
rofs = 69Read-only file system.
spipe = 70Invalid seek.
srch = 71No such process.
stale = 72Reserved.
timedout = 73Connection timed out.
txtbsy = 74Text file busy.
xdev = 75Cross-device link.
notcapable = 76Extension: Capabilities insufficient.
enumClockId : uint

Identifiers for clocks.

realtime = 0The clock measuring real time. Time value zero corresponds with 1970-01-01T00:00:00Z.
monotonic = 1The store-wide monotonic clock, which is defined as a clock measuring real time, whose value cannot be adjusted and which cannot have negative clock jumps. The epoch of this clock is undefined. The...
processCpuTime = 2The CPU-time clock associated with the current process.
threadCpuTime = 3The CPU-time clock associated with the current thread.
enumEventType : ubyte

Type of a subscription to an event or its occurrence.

clockThe time value of clock subscriptionclock::id has reached timestamp subscriptionclock::timeout.
fdReadFile descriptor subscriptionfdreadwrite::file_descriptor has data available for reading. This event always triggers for regular files.
fdWriteFile descriptor subscriptionfdreadwrite::file_descriptor has capacity available for writing. This event always triggers for regular files.
aliasLookupFlags = uint

Flags determining the method of how paths are resolved.

Flags determining the method of how paths are resolved.

none = 0x0None.
symlinkFollow = 0x1As long as the resolved path corresponds to a symbolic link, it is expanded.
aliasOFlags = ushort

Open flags used by path_open.

Open flags used by path_open.

none = 0x0None.
creat = 0x1Create file if it does not exist.
directory = 0x2Fail if not a directory.
excl = 0x4Fail if file already exists.
trunc = 0x8Truncate file to size 0.
aliasRights = ulong

File descriptor rights, determining which actions may be performed.

File descriptor rights, determining which actions may be performed.

none = 0ULNone.
fdDataSync = 1UL << 0The right to invoke fddatasync. If pathopen is set, includes the right to invoke path_open with FdFlags.dsync.
fdRead = 1UL << 1The right to invoke fdRead and sockrecv. If Rights.fdSeek is set, includes the right to invoke fdpread.
fdSeek = 1UL << 2The right to invoke fd_seek. This flag implies Rights.fdTell.
fdFdStatSetFlags = 1UL << 3The right to invoke fdfdstatset_flags.
fdSync = 1UL << 4The right to invoke fdsync. If pathopen is set, includes the right to invoke path_open with FdFlags.rsync and FdFlags.dsync.
fdTell = 1UL << 5The right to invoke fdseek in such a way that the file offset remains unaltered (i.e., Whence.cur with offset zero), or to invoke fdtell.
fdWrite = 1UL << 6The right to invoke fdWrite and socksend. If Rights.fdSeek is set, includes the right to invoke fdpwrite.
fdAdvise = 1UL << 7The right to invoke fd_advise.
fdAllocate = 1UL << 8The right to invoke fd_allocate.
pathCreateDirectory = 1UL << 9The right to invoke pathcreatedirectory.
pathCreateFile = 1UL << 10If pathopen is set, the right to invoke pathopen with OFlags.creat.
pathLinkSource = 1UL << 11The right to invoke path_link with the file descriptor as the source directory.
pathLinkTarget = 1UL << 12The right to invoke path_link with the file descriptor as the target directory.
pathOpen = 1UL << 13The right to invoke path_open.
fdReadDir = 1UL << 14The right to invoke fdReadDir.
pathReadLink = 1UL << 15The right to invoke path_readlink.
pathRenameSource = 1UL << 16The right to invoke path_rename with the file descriptor as the source directory.
pathRenameTarget = 1UL << 17The right to invoke path_rename with the file descriptor as the target directory.
pathFileStatGet = 1UL << 18The right to invoke pathfilestatget.
pathFileStatSetSize = 1UL << 19The right to change a file's size. If pathopen is set, includes the right to invoke pathopen with OFlags.trunc. Note: there is no function named pathfilestatset_size. This follows POSIX design, whi...
pathFileStatSetTimes = 1UL << 20The right to invoke pathfilestatset_times.
fdFileStatGet = 1UL << 21The right to invoke fdfilestatget.
fdFileStatSetSize = 1UL << 22The right to invoke fdfilestatset_size.
fdFileStatSetTimes = 1UL << 23The right to invoke fdfilestatset_times.
pathSymlink = 1UL << 24The right to invoke path_symlink.
pathRemoveDirectory = 1UL << 25The right to invoke pathremovedirectory.
pathUnlinkFile = 1UL << 26The right to invoke pathunlinkfile.
pollFdReadwrite = 1UL << 27If Rights.fdRead is set, includes the right to invoke polloneoff to subscribe to EventType.fdRead. If Rights.fdWrite is set, includes the right to invoke polloneoff to subscribe to EventType.fdWrite.
sockShutdown = 1UL << 28The right to invoke sock_shutdown.
sockAccept = 1UL << 29The right to invoke sock_accept.
aliasFdFlags = ushort

File descriptor flags.

File descriptor flags.

none = 0x00None.
append = 0x01Append mode: Data written to the file is always appended to the file's end.
dsync = 0x02Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized. This feature is not available on all platforms and therefore path_open and other suc...
nonblock = 0x04Non-blocking mode.
rsync = 0x08Synchronized read I/O operations. This feature is not available on all platforms and therefore path_open and other such functions which accept fdflags may return errno.notsup in the case that this ...
sync = 0x10Write according to synchronized I/O file integrity completion. In addition to synchronizing the data stored in the file, the implementation may also synchronously update the file's metadata. This f...
aliasFstFlags = ushort

Which file time attributes to adjust.

Which file time attributes to adjust.

none = 0x0None.
atime = 0x1Adjust the last data access timestamp to the value stored in FileStat.atime.
atimeNow = 0x2Adjust the last data access timestamp to the time of clock clockid::realtime.
mtime = 0x4Adjust the last data modification timestamp to the value stored in FileStat.mtime.
mtimeNow = 0x8Adjust the last data modification timestamp to the time of clock clockid::realtime.
enumAdvice : ubyte

File or memory access pattern advisory information.

normal = 0The application has no advice to give on its behavior with respect to the specified data.
sequential = 1The application expects to access the specified data sequentially from lower offsets to higher offsets.
random = 2The application expects to access the specified data in a random order.
willneed = 3The application expects to access the specified data in the near future.
dontneed = 4The application expects that it will not access the specified data in the near future.
noreuse = 5The application expects to access the specified data once and then not reuse it thereafter.
enumFileType : ubyte

The type of a file descriptor or file.

unknown = 0The type of the file descriptor or file is unknown or is different from any of the other types specified.
blockDevice = 1The file descriptor or file refers to a block device inode.
characterDevice = 2The file descriptor or file refers to a character device inode.
directory = 3The file descriptor or file refers to a directory inode.
regularFile = 4The file descriptor or file refers to a regular file inode.
socketDgram = 5The file descriptor or file refers to a datagram socket.
socketStream = 6The file descriptor or file refers to a byte-stream socket.
symbolicLink = 7The file refers to a symbolic link inode.
enumWhence : ubyte

The position relative to which to set the offset of the file descriptor.

set = 0Seek relative to start-of-file.
cur = 1Seek relative to current position.
end = 2Seek relative to end-of-file.

The contents of a $prestat when type is preopentype::dir.

Fields
Size nameLen

Information about a pre-opened capability.

structFdStat

File descriptor attributes.

Fields
FdFlags flags
Rights rightsBase
Rights rightsInheriting
structFileStat

File attributes.

Fields
Device dev
Inode ino
LinkCount nlink
TimeStamp atime
TimeStamp mtime
TimeStamp ctime

Flags determining how to interpret the timestamp provided in subscription_clock::timeout.

Flags determining how to interpret the timestamp provided in subscription_clock::timeout.

none = 0x0None.
absTime = 0x1If set, treat the timestamp provided in subscriptionclock::timeout as an absolute timestamp of clock subscriptionclock::id. If clear, treat the timestamp provided in subscriptionclock::timeout rela...

The contents of a subscription when type is eventtype::clock.

Fields
TimeStamp timeout
TimeStamp precision

The contents of a subscription when type is type is eventtype::fd_read or eventtype::fd_write.

Fields
Fd fd

The contents of a subscription.

Fields
ubyte type
Data data

Subscription to an event.

Fields
UserData userData
SubscriptionU contents
aliasEventRwFlags = ushort

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.

none = 0x0None.
fd_readwrite_hangup = 0x1The peer of this socket has closed or disconnected.

The contents of an event when type is eventtype::fd_read or eventtype::fd_write.

Fields
FileSize nbytes
structEvent

An event that occurred.

Fields
UserData userData
Errno error
EventFdReadWrite fdReadWrite
aliasSdFlags = ubyte

Which channels on a socket to shut down.

Which channels on a socket to shut down.

none = 0x0None.
rd = 0x1Disables further receive operations.
wr = 0x2Disables further send operations.
aliasSize = Sz

A size value in bytes.

aliasLinkCount = ulong

Number of hard links to an inode.

aliasUserData = ulong

User-provided value that may be attached to objects that is retained when extracted from the implementation.

aliasInode = ulong

File serial number that is unique within its file system.

aliasDevice = ulong

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.

aliasDirCookie = ulong

A reference to the offset of a directory entry. The value 0 signifies the start of the directory.

aliasFileSize = ulong

Non-negative file size or length of a region within a file.

aliasFileDelta = ulong

Relative offset within a file.

aliasExitCode = uint

Exit code generated by a process when exiting.

aliasFd = uint

A file descriptor handle.

aliasTimeStamp = ulong

Timestamp in nanoseconds.

aliasIovec = ForeignSlice!(ubyte)

A region of memory for scatter/gather reads.

aliastoIovec = toForeignBytesMut

Convert a string to a Iovec.

aliasCiovec = ForeignSlice!(const(ubyte))

A region of memory for scatter/gather writes.

aliastoCiovec = toForeignBytes

Convert a string to a Ciovec.

Functions 43

private fnllvmAttr importName(immutable(char)[] name)
fnErrno 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.
fnErrno argsSizesGet(Size * argc, Size * argvBufSize) @importName("args_sizes_get")Return command-line argument data sizes.
fnErrno 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...
fnErrno 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.
fnErrno 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.
fnErrno environSizesGet(Size * envCount, Size * envBufSize) @importName("environ_sizes_get")Return environment variable data sizes.
fnErrno 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.
fnErrno 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.
fnErrno fdClose(Fd fd) @importName("fd_close")Close a file descriptor. Note: This is similar to close in POSIX.
fnErrno fdDataSync(Fd fd) @importName("fd_datasync")Synchronize the data of a file to disk. Note: This is similar to fdatasync in POSIX.
fnErrno 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.
fnErrno 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.
fnErrno 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.
fnErrno fdFileStatGet(Fd fd, FileStat * fileStat) @importName("fd_filestat_get")Return the attributes of an open file.
fnErrno 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.
fnErrno 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.
fnErrno 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).
fnErrno fdPrestatDirName(Fd fd, ubyte * path, Size pathLen) @importName("fd_prestat_dir_name")Return a description of the given preopened file descriptor.
fnErrno fdPrestatGet(Fd fd, Prestat * outPrestat) @importName("fd_prestat_get")Return a description of the given preopened file descriptor.
fnErrno 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...
fnErrno 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.
fnErrno 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...
fnErrno 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 ...
fnErrno 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.
fnErrno fdSync(Fd fd) @importName("fd_sync")Synchronize the data and metadata of a file to disk. Note: This is similar to fsync in POSIX.
fnErrno 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.
fnErrno 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...
fnErrno pathCreateDirectory(Fd fd, const(char) * path, Size pathLen) @importName("path_create_directory")Create a directory. Note: This is similar to mkdirat in POSIX.
fnErrno 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.
fnErrno 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.
fnErrno 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.
fnErrno 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...
fnErrno 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.
fnErrno 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.
fnErrno 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.
fnErrno 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.
fnErrno 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.
fnErrno 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.
fnnoreturn 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.
fnErrno 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.
fnErrno schedYield() @importName("sched_yield")Temporarily yield execution of the calling thread. Note: This is similar to sched_yield in POSIX.
fnErrno 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

enumvarwasi = llvmAttr("wasm-import-module", "wasi_snapshot_preview1")

The WASI Preview 1 import module.

enumvarstdin = Fd(0)

The "standard error" descriptor number.

enumvarstdout = Fd(1)

The "standard input" descriptor number.

enumvarstderr = Fd(2)

The "standard output" descriptor number.