assemblyscript/std/assembly/bindings/wasi_unstable.ts

1432 lines
45 KiB
TypeScript
Raw Normal View History

2019-03-28 01:36:11 +01:00
// see: https://wasi.dev
2019-03-27 22:05:14 +01:00
/* tslint:disable:max-line-length */
2019-03-28 12:40:03 +01:00
// helper types to be more explicit
type char = u8;
type ptr<T> = usize; // pointers are usize'd
type struct<T> = T; // struct are references already
2019-03-28 01:32:15 +01:00
2019-03-27 22:05:14 +01:00
/** Read command-line argument data. */
2019-03-28 12:40:03 +01:00
export declare function args_get(
/** Input: Pointer to a buffer to write the argument pointers. */
argv: ptr<ptr<char>>,
/** Input: Pointer to a buffer to write the argument string data. */
argv_buf: ptr<char>
): errno;
2019-03-27 22:05:14 +01:00
/** Return command-line argument data sizes. */
2019-03-28 12:40:03 +01:00
export declare function args_sizes_get(
/** Output: Number of arguments. */
argc: ptr<usize>,
/** Output: Size of the argument string data. */
argv_buf_size: ptr<usize>
): errno;
2019-03-27 22:05:14 +01:00
/** Return the resolution of a clock. */
2019-03-28 12:40:03 +01:00
export declare function clock_res_get(
/** Input: The clock for which to return the resolution. */
clock: clockid,
/** Output: The resolution of the clock. */
resolution: ptr<timestamp>
): errno;
2019-03-27 22:05:14 +01:00
/** Return the time value of a clock. */
2019-03-28 12:40:03 +01:00
export declare function clock_time_get(
/** Input: Cock for which to return the time. */
clock: clockid,
/** Input: Maximum lag (exclusive) that the returned time value may have, compared to its actual value. */
precision: timestamp,
/** Output: Time value of the clock. */
time: ptr<timestamp>
): errno;
2019-03-27 22:05:14 +01:00
/** Read environment variable data. */
2019-03-28 12:40:03 +01:00
export declare function environ_get(
/** Input: Pointer to a buffer to write the environment variable pointers. */
environ: ptr<usize>,
/** Input: Pointer to a buffer to write the environment variable string data. */
environ_buf: usize
): errno;
2019-03-27 22:05:14 +01:00
/** Return command-line argument data sizes. */
2019-03-28 12:40:03 +01:00
export declare function environ_sizes_get(
/** Output: The number of environment variables. */
environ_count: ptr<usize>,
/** Output: The size of the environment variable string data. */
environ_buf_size: ptr<usize>
): errno;
2019-03-27 22:05:14 +01:00
/** Provide file advisory information on a file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_advise(
/** Input: The file descriptor for the file for which to provide file advisory information. */
fd: fd,
/** Input: The offset within the file to which the advisory applies. */
offset: filesize,
/** Input: The length of the region to which the advisory applies. */
len: filesize,
/** Input: The advice. */
advice: advice
): errno;
2019-03-27 22:05:14 +01:00
/** Provide file advisory information on a file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_allocate(
/** Input: The file descriptor for the file in which to allocate space. */
fd: fd,
/** Input: The offset at which to start the allocation. */
offset: filesize,
/** Input: The length of the area that is allocated. */
len: filesize
): errno;
2019-03-27 22:05:14 +01:00
/** Close a file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_close(
/** Input: The file descriptor to close. */
fd: fd
): errno;
2019-03-27 22:05:14 +01:00
/** Synchronize the data of a file to disk. */
2019-03-28 12:40:03 +01:00
export declare function fd_datasync(
/** Input: The file descriptor of the file to synchronize to disk. */
fd: fd
): errno;
2019-03-27 22:05:14 +01:00
/** Get the attributes of a file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_fdstat_get(
/** Input: The file descriptor to inspect. */
fd: fd,
/** Input: The buffer where the file descriptor's attributes are stored. */
buf: struct<fdstat>
): errno;
2019-03-27 22:05:14 +01:00
/** Adjust the flags associated with a file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_fdstat_set_flags(
/** Input: The file descriptor to operate on. */
fd: fd,
/** Input: The desired values of the file descriptor flags. */
flags: fdflags
): errno;
2019-03-27 22:05:14 +01:00
/** Adjust the rights associated with a file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_fdstat_set_rights(
/** Input: The file descriptor to operate on. */
fd: fd,
/** Input: The desired rights of the file descriptor. */
fs_rights_base: rights,
/** Input: The desired rights of the file descriptor. */
fs_rights_inheriting: rights
): errno;
2019-03-27 22:05:14 +01:00
/** Return the attributes of an open file. */
2019-03-28 12:40:03 +01:00
export declare function fd_filestat_get(
/** Input: The file descriptor to inspect. */
fd: fd,
/** Input: The buffer where the file's attributes are stored. */
buf: struct<filestat>
): errno;
2019-03-27 22:05:14 +01:00
/** Adjust the size of an open file. If this increases the file's size, the extra bytes are filled with zeros. */
2019-03-28 12:40:03 +01:00
export declare function fd_filestat_set_size(
/** Input: A file descriptor for the file to adjust. */
fd: fd,
/** Input: The desired file size. */
size: filesize
): errno;
2019-03-27 22:05:14 +01:00
/** Adjust the timestamps of an open file or directory. */
2019-03-28 12:40:03 +01:00
export declare function fd_filestat_set_times(
/** Input: The file descriptor to operate on. */
fd: fd,
/** Input: The desired values of the data access timestamp. */
st_atim: timestamp,
/** Input: The desired values of the data modification timestamp. */
st_mtim: timestamp,
/** Input: A bitmask indicating which timestamps to adjust. */
fstflags: fstflags
): errno;
2019-03-27 22:05:14 +01:00
/** Read from a file descriptor, without using and updating the file descriptor's offset. */
2019-03-28 12:40:03 +01:00
export declare function fd_pread(
/** Input: The file descriptor from which to read data. */
fd: fd,
/** Input: List of scatter/gather vectors in which to store data. */
iovs: ptr<struct<iovec>>,
/** Input: Length of the list of scatter/gather vectors in which to store data. */
iovs_len: usize,
/** Input: The offset within the file at which to read. */
offset: filesize,
/** Output: The number of bytes read. */
nread: ptr<usize>
): errno;
2019-03-27 22:05:14 +01:00
/** Return a description of the given preopened file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_prestat_get(
/** Input: The file descriptor about which to retrieve information. */
fd: fd,
/** Input: The buffer where the description is stored. */
buf: usize // TODO: struct<prestat>
): errno;
2019-03-27 22:05:14 +01:00
/** Return a description of the given preopened file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_prestat_dir_name(
/** Input: The file descriptor about which to retrieve information. */
fd: fd,
/** Input: Buffer into which to write the preopened directory name. */
path: ptr<char>,
/** Input: Length of the buffer into which to write the preopened directory name. */
path_len: usize
): errno;
2019-03-27 22:05:14 +01:00
/** Write to a file descriptor, without using and updating the file descriptor's offset. */
2019-03-28 12:40:03 +01:00
export declare function fd_pwrite(
/** Input: The file descriptor to which to write data. */
fd: fd,
/** Input: List of scatter/gather vectors from which to retrieve data. */
iovs: ptr<struct<iovec>>,
/** Input: Length of the list of scatter/gather vectors from which to retrieve data. */
iovs_len: usize,
/** Input: The offset within the file at which to write. */
offset: filesize,
/** Output: The number of bytes written. */
nwritten: ptr<usize>
): errno;
2019-03-27 22:05:14 +01:00
/** Read from a file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_read(
/** Input: The file descriptor from which to read data. */
fd: fd,
/** Input: List of scatter/gather vectors to which to store data. */
iovs: ptr<struct<iovec>>,
/** Input: Length of the list of scatter/gather vectors to which to store data. */
iovs_len: usize,
/** Output: The number of bytes read. */
nread: ptr<usize>
): errno;
2019-03-27 22:05:14 +01:00
/** Read directory entries from a directory. */
2019-03-28 12:40:03 +01:00
export declare function fd_readdir(
/** Input: Directory from which to read the directory entries. */
fd: fd,
/** Input: Buffer where directory entries are stored. */
buf: ptr<struct<dirent>>,
/** Input: Length of the buffer where directory entries are stored. */
buf_len: usize,
/** Input: Location within the directory to start reading. */
cookie: dircookie,
/** Output: 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. */
buf_used: ptr<usize>
): errno;
2019-03-27 22:05:14 +01:00
/** Atomically replace a file descriptor by renumbering another file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_renumber(
/** Input: The file descriptor to renumber. */
from: fd,
/** Input: The file descriptor to overwrite. */
to: fd
): errno;
2019-03-27 22:05:14 +01:00
/** Move the offset of a file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_seek(
/** Input: The file descriptor to operate on. */
fd: fd,
/** Input: The number of bytes to move. */
offset: filedelta,
/** Input: The base from which the offset is relative. */
whence: whence,
/** Output: The new offset of the file descriptor, relative to the start of the file. */
newoffset: ptr<filesize>
): errno;
2019-03-27 22:05:14 +01:00
/** Synchronize the data and metadata of a file to disk. */
2019-03-28 12:40:03 +01:00
export declare function fd_sync(
/** Input: The file descriptor of the file containing the data and metadata to synchronize to disk. */
fd: fd
): errno;
2019-03-27 22:05:14 +01:00
/** Return the current offset of a file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_tell(
/** Input: The file descriptor to inspect. */
fd: fd,
/** Output: The current offset of the file descriptor, relative to the start of the file. */
newoffset: ptr<filesize>
): errno;
2019-03-27 22:05:14 +01:00
/** Write to a file descriptor. */
2019-03-28 12:40:03 +01:00
export declare function fd_write(
/** Input: The file descriptor to which to write data. */
fd: fd,
/** Input: List of scatter/gather vectors from which to retrieve data. */
iovs: ptr<struct<iovec>>,
/** Input: List of scatter/gather vectors from which to retrieve data. */
iovs_len: usize,
/** Output: The number of bytes written. */
nwritten: ptr<usize>
): errno;
2019-03-27 22:05:14 +01:00
/* Create a directory. */
2019-03-28 12:40:03 +01:00
export declare function path_create_directory(
/** Input: The working directory at which the resolution of the path starts. */
fd: fd,
/** Input: The path at which to create the directory. */
path: ptr<char>,
/** Input: The path at which to create the directory. */
path_len: usize
): errno;
2019-03-27 22:05:14 +01:00
/** Return the attributes of a file or directory. */
2019-03-28 12:40:03 +01:00
export declare function path_filestat_get(
/** Input: The working directory at which the resolution of the path starts. */
fd: fd,
/** Input: Flags determining the method of how the path is resolved. */
flags: lookupflags,
/** Input: The path of the file or directory to inspect. */
path: ptr<char>,
/** Input: The path of the file or directory to inspect. */
path_len: usize,
/** Input: The buffer where the file's attributes are stored. */
buf: struct<filestat>
): errno;
2019-03-27 22:05:14 +01:00
/** Adjust the timestamps of a file or directory. */
2019-03-28 12:40:03 +01:00
export declare function path_filestat_set_times(
/** Input: The working directory at which the resolution of the path starts. */
fd: fd,
/** Input: Flags determining the method of how the path is resolved. */
flags: lookupflags,
/** Input: The path of the file or directory to operate on. */
path: ptr<char>,
/** Input: The path of the file or directory to operate on. */
path_len: usize,
/** Input: The desired values of the data access timestamp. */
st_atim: timestamp,
/** Input: The desired values of the data modification timestamp. */
st_mtim: timestamp,
/** Input: A bitmask indicating which timestamps to adjust. */
fstflags: fstflags
): errno;
2019-03-27 22:05:14 +01:00
/** Create a hard link. */
2019-03-28 12:40:03 +01:00
export declare function path_link(
/** Input: The working directory at which the resolution of the old path starts. */
old_fd: fd,
/** Input: Flags determining the method of how the path is resolved. */
old_flags: lookupflags,
/** Input: The source path from which to link. */
old_path: ptr<char>,
/** Input: The source path from which to link. */
old_path_len: usize,
/** Input: The working directory at which the resolution of the new path starts. */
new_fd: fd,
/** Input: The destination path at which to create the hard link. */
new_path: ptr<char>,
/** Input: The length of the destination path at which to create the hard link. */
new_path_len: usize
): errno;
2019-03-27 22:05:14 +01:00
/** Open a file or directory. */
2019-03-28 12:40:03 +01:00
export declare function path_open(
/** Input: The working directory at which the resolution of the path starts. */
dirfd: fd,
/** Input: Flags determining the method of how the path is resolved. */
dirflags: lookupflags,
/** Input: The path of the file or directory to open. */
path: ptr<char>,
/** Input: The length of the path of the file or directory to open. */
path_len: usize,
/** Input: The method by which to open the file. */
oflags: oflags,
/** Input: The initial base rights that apply to operations using the file descriptor itself. */
fs_rights_base: rights,
/** Input: The initial inheriting rights that apply to file descriptors derived from it. */
fs_rights_inheriting: rights,
/** Input: The initial flags of the file descriptor. */
fs_flags: fdflags,
/** Output: The file descriptor of the file that has been opened. */
fd: ptr<fd>
): errno;
2019-03-27 22:05:14 +01:00
/** Read the contents of a symbolic link. */
2019-03-28 12:40:03 +01:00
export declare function path_readlink(
/** Input: The working directory at which the resolution of the path starts. */
fd: fd,
/** Input: The path of the symbolic link from which to read. */
path: ptr<char>,
/** Input: The length of the path of the symbolic link from which to read. */
path_len: usize,
/** Input: The buffer to which to write the contents of the symbolic link. */
buf: ptr<char>,
/** Input: The length of the buffer to which to write the contents of the symbolic link. */
buf_len: usize,
/** Output: The number of bytes placed in the buffer. */
buf_used: ptr<usize>
): errno;
2019-03-27 22:05:14 +01:00
/** Remove a directory. */
2019-03-28 12:40:03 +01:00
export declare function path_remove_directory(
/** Input: The working directory at which the resolution of the path starts. */
fd: fd,
/** Input: The path to a directory to remove. */
path: ptr<char>,
/** Input: The length of the path to a directory to remove. */
path_len: usize
): errno;
2019-03-27 22:05:14 +01:00
/** Rename a file or directory. */
2019-03-28 12:40:03 +01:00
export declare function path_rename(
/** Input: The working directory at which the resolution of the old path starts. */
old_fd: fd,
/** Input: The source path of the file or directory to rename. */
old_path: ptr<char>,
/** Input: The length of the source path of the file or directory to rename. */
old_path_len: usize,
/** Input: The working directory at which the resolution of the new path starts. */
new_fd: fd,
/** Input: The destination path to which to rename the file or directory. */
new_path: ptr<char>,
/** Input: The length of the destination path to which to rename the file or directory. */
new_path_len: usize
): errno;
2019-03-27 22:05:14 +01:00
/** Create a symbolic link. */
2019-03-28 12:40:03 +01:00
export declare function path_symlink(
/** Input: The contents of the symbolic link. */
old_path: ptr<char>,
/** Input: The length of the contents of the symbolic link. */
old_path_len: usize,
/** Input: The working directory at which the resolution of the path starts. */
fd: fd,
/** Input: The destination path at which to create the symbolic link. */
new_path: ptr<char>,
/** Input: The length of the destination path at which to create the symbolic link. */
new_path_len: usize
): errno;
2019-03-27 22:05:14 +01:00
/** Unlink a file. */
2019-03-28 12:40:03 +01:00
export declare function path_unlink_file(
/** Input: The working directory at which the resolution of the path starts. */
fd: fd,
/** Input: The path to a file to unlink. */
path: ptr<char>,
/** Input: The length of the path to a file to unlink. */
path_len: usize
): errno;
2019-03-27 22:05:14 +01:00
/** Concurrently poll for the occurrence of a set of events. */
2019-03-28 12:40:03 +01:00
export declare function poll_oneoff(
/** Input: The events to which to subscribe. */
in_: ptr<struct<subscription>>,
/** Input: The events that have occurred. */
out: ptr<struct<event>>,
/** Input: Both the number of subscriptions and events. */
nsubscriptions: usize,
/** Output: The number of events stored. */
nevents: ptr<usize>
): errno;
2019-03-27 22:05:14 +01:00
/** 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. */
2019-03-28 12:40:03 +01:00
export declare function proc_exit(
/** Input: The exit code returned by the process. */
rval: u32
): void;
2019-03-27 22:05:14 +01:00
/** Send a signal to the process of the calling thread. */
2019-03-28 12:40:03 +01:00
export declare function proc_raise(
/** Input: The signal condition to trigger. */
sig: signal
): errno;
2019-03-27 22:05:14 +01:00
/** Write high-quality random data into a buffer. */
2019-03-28 12:40:03 +01:00
export declare function random_get(
/** Input: The buffer to fill with random data. */
buf: usize,
/** Input: The length of the buffer to fill with random data. */
buf_len: usize
): errno;
2019-03-27 22:05:14 +01:00
/** Temporarily yield execution of the calling thread. */
export declare function sched_yield(): errno;
/** Receive a message from a socket. */
2019-03-28 12:40:03 +01:00
export declare function sock_recv(
/** Input: The socket on which to receive data. */
sock: fd,
/** Input: List of scatter/gather vectors to which to store data. */
ri_data: ptr<struct<iovec>>,
/** Input: The length of the list of scatter/gather vectors to which to store data. */
ri_data_len: usize,
/** Input: Message flags. */
ri_flags: riflags,
/** Output: Number of bytes stored in `ri_data`. */
ro_datalen: ptr<usize>,
/** Output: Message flags. */
ro_flags: ptr<roflags>
): errno;
2019-03-27 22:05:14 +01:00
/** Send a message on a socket. */
2019-03-28 12:40:03 +01:00
export declare function sock_send(
/** Input: The socket on which to send data. */
sock: fd,
/** Input: List of scatter/gather vectors to which to retrieve data */
si_data: ptr<struct<iovec>>,
/** Input: The length of the list of scatter/gather vectors to which to retrieve data */
si_data_len: usize,
/** Input: Message flags. */
si_flags: siflags,
/** Output: Number of bytes transmitted. */
so_datalen: ptr<usize>
): errno;
2019-03-27 22:05:14 +01:00
/** Shut down socket send and receive channels. */
2019-03-28 12:40:03 +01:00
export declare function sock_shutdown(
/** Input: The socket on which to shutdown channels. */
sock: fd,
/** Input: Which channels on the socket to shut down. */
how: sdflags
): errno;
2019-03-27 22:05:14 +01:00
// === Types ======================================================================================
/** File or memory access pattern advisory information. */
2019-03-28 01:32:15 +01:00
export namespace advice {
2019-03-27 22:05:14 +01:00
/** The application has no advice to give on its behavior with respect to the specified data. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NORMAL: advice = 0;
2019-03-27 22:05:14 +01:00
/** The application expects to access the specified data sequentially from lower offsets to higher offsets. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SEQUENTIAL : advice = 1;
2019-03-27 22:05:14 +01:00
/** The application expects to access the specified data in a random order. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const RANDOM: advice = 2;
2019-03-27 22:05:14 +01:00
/** The application expects to access the specified data in the near future. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const WILLNEED: advice = 3;
2019-03-27 22:05:14 +01:00
/** The application expects that it will not access the specified data in the near future. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const DONTNEED: advice = 4;
2019-03-27 22:05:14 +01:00
/** The application expects to access the specified data once and then not reuse it thereafter. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOREUSE: advice = 5;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type advice = u8;
2019-03-27 22:05:14 +01:00
/** Identifiers for clocks. */
2019-03-28 01:32:15 +01:00
export namespace clockid {
2019-03-27 22:05:14 +01:00
/** The clock measuring real time. Time value zero corresponds with 1970-01-01T00:00:00Z. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const REALTIME: clockid = 0;
2019-03-27 22:05:14 +01:00
/** The store-wide monotonic clock. Absolute value has no meaning. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const MONOTONIC: clockid = 1;
2019-03-27 22:05:14 +01:00
/** The CPU-time clock associated with the current process. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PROCESS_CPUTIME_ID: clockid = 2;
2019-03-27 22:05:14 +01:00
/** The CPU-time clock associated with the current thread. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const THREAD_CPUTIME_ID: clockid = 3;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type clockid = u32;
2019-03-27 22:05:14 +01:00
/** 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. */
2019-03-28 01:32:15 +01:00
export type device = u64;
2019-03-27 22:05:14 +01:00
/** A reference to the offset of a directory entry. */
2019-03-28 01:32:15 +01:00
export type dircookie = u64;
2019-03-27 22:05:14 +01:00
/** A directory entry. */
@unmanaged export class dirent {
/** The offset of the next directory entry stored in this directory. */
2019-03-28 01:32:15 +01:00
next: dircookie;
2019-03-27 22:05:14 +01:00
/** The serial number of the file referred to by this directory entry. */
2019-03-28 01:32:15 +01:00
ino: inode;
2019-03-27 22:05:14 +01:00
/** The length of the name of the directory entry. */
2019-03-27 23:25:46 +01:00
namlen: u32;
2019-03-27 22:05:14 +01:00
/** The type of the file referred to by this directory entry. */
2019-03-28 01:32:15 +01:00
type: filetype;
2019-03-27 23:23:53 +01:00
private __padding0: u16;
2019-03-27 22:05:14 +01:00
}
/** Error codes returned by functions. */
2019-03-28 01:32:15 +01:00
export namespace errno {
2019-03-27 22:05:14 +01:00
/** No error occurred. System call completed successfully. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SUCCESS: errno = 0;
2019-03-27 22:05:14 +01:00
/** Argument list too long. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const TOOBIG: errno = 1;
2019-03-27 22:05:14 +01:00
/** Permission denied. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const ACCES: errno = 2;
2019-03-27 22:05:14 +01:00
/** Address in use. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const ADDRINUSE: errno = 3;
2019-03-27 22:05:14 +01:00
/** Address not available. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const ADDRNOTAVAIL: errno = 4;
2019-03-27 22:05:14 +01:00
/** Address family not supported. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const AFNOSUPPORT: errno = 5;
2019-03-27 22:05:14 +01:00
/** Resource unavailable, or operation would block. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const AGAIN: errno = 6;
2019-03-27 22:05:14 +01:00
/** Connection already in progress. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const ALREADY: errno = 7;
2019-03-27 22:05:14 +01:00
/** Bad file descriptor. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const BADF: errno = 8;
2019-03-27 22:05:14 +01:00
/** Bad message. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const BADMSG: errno = 9;
2019-03-27 22:05:14 +01:00
/** Device or resource busy. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const BUSY: errno = 10;
2019-03-27 22:05:14 +01:00
/** Operation canceled. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const CANCELED: errno = 11;
2019-03-27 22:05:14 +01:00
/** No child processes. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const CHILD: errno = 12;
2019-03-27 22:05:14 +01:00
/** Connection aborted. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const CONNABORTED: errno = 13;
2019-03-27 22:05:14 +01:00
/** Connection refused. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const CONNREFUSED: errno = 14;
2019-03-27 22:05:14 +01:00
/** Connection reset. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const CONNRESET: errno = 15;
2019-03-27 22:05:14 +01:00
/** Resource deadlock would occur. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const DEADLK: errno = 16;
2019-03-27 22:05:14 +01:00
/** Destination address required. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const DESTADDRREQ: errno = 17;
2019-03-27 22:05:14 +01:00
/** Mathematics argument out of domain of function. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const DOM: errno = 18;
2019-03-27 22:05:14 +01:00
/** Reserved. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const DQUOT: errno = 19;
2019-03-27 22:05:14 +01:00
/** File exists. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const EXIST: errno = 20;
2019-03-27 22:05:14 +01:00
/** Bad address. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FAULT: errno = 21;
2019-03-27 22:05:14 +01:00
/** File too large. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FBIG: errno = 22;
2019-03-27 22:05:14 +01:00
/** Host is unreachable. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const HOSTUNREACH: errno = 23;
2019-03-27 22:05:14 +01:00
/** Identifier removed. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const IDRM: errno = 24;
2019-03-27 22:05:14 +01:00
/** Illegal byte sequence. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const ILSEQ: errno = 25;
2019-03-27 22:05:14 +01:00
/** Operation in progress. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const INPROGRESS: errno = 26;
2019-03-27 22:05:14 +01:00
/** Interrupted function. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const INTR: errno = 27;
2019-03-27 22:05:14 +01:00
/** Invalid argument. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const INVAL: errno = 28;
2019-03-27 22:05:14 +01:00
/** I/O error. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const IO: errno = 29;
2019-03-27 22:05:14 +01:00
/** Socket is connected. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const ISCONN: errno = 30;
2019-03-27 22:05:14 +01:00
/** Is a directory. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const ISDIR: errno = 31;
2019-03-27 22:05:14 +01:00
/** Too many levels of symbolic links. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const LOOP: errno = 32;
2019-03-27 22:05:14 +01:00
/** File descriptor value too large. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const MFILE: errno = 33;
2019-03-27 22:05:14 +01:00
/** Too many links. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const MLINK: errno = 34;
2019-03-27 22:05:14 +01:00
/** Message too large. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const MSGSIZE: errno = 35;
2019-03-27 22:05:14 +01:00
/** Reserved. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const MULTIHOP: errno = 36;
2019-03-27 22:05:14 +01:00
/** Filename too long. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NAMETOOLONG: errno = 37;
2019-03-27 22:05:14 +01:00
/** Network is down. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NETDOWN: errno = 38;
2019-03-27 22:05:14 +01:00
/** Connection aborted by network. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NETRESET: errno = 39;
2019-03-27 22:05:14 +01:00
/** Network unreachable. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NETUNREACH: errno = 40;
2019-03-27 22:05:14 +01:00
/** Too many files open in system. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NFILE: errno = 41;
2019-03-27 22:05:14 +01:00
/** No buffer space available. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOBUFS: errno = 42;
2019-03-27 22:05:14 +01:00
/** No such device. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NODEV: errno = 43;
2019-03-27 22:05:14 +01:00
/** No such file or directory. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOENT: errno = 44;
2019-03-27 22:05:14 +01:00
/** Executable file format error. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOEXEC: errno = 45;
2019-03-27 22:05:14 +01:00
/** No locks available. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOLCK: errno = 46;
2019-03-27 22:05:14 +01:00
/** Reserved. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOLINK: errno = 47;
2019-03-27 22:05:14 +01:00
/** Not enough space. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOMEM: errno = 48;
2019-03-27 22:05:14 +01:00
/** No message of the desired type. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOMSG: errno = 49;
2019-03-27 22:05:14 +01:00
/** Protocol not available. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOPROTOOPT: errno = 50;
2019-03-27 22:05:14 +01:00
/** No space left on device. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOSPC: errno = 51;
2019-03-27 22:05:14 +01:00
/** Function not supported. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOSYS: errno = 52;
2019-03-27 22:05:14 +01:00
/** The socket is not connected. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOTCONN: errno = 53;
2019-03-27 22:05:14 +01:00
/** Not a directory or a symbolic link to a directory. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOTDIR: errno = 54;
2019-03-27 22:05:14 +01:00
/** Directory not empty. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOTEMPTY: errno = 55;
2019-03-27 22:05:14 +01:00
/** State not recoverable. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOTRECOVERABLE: errno = 56;
2019-03-27 22:05:14 +01:00
/** Not a socket. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOTSOCK: errno = 57;
2019-03-27 22:05:14 +01:00
/** Not supported, or operation not supported on socket. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOTSUP: errno = 58;
2019-03-27 22:05:14 +01:00
/** Inappropriate I/O control operation. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOTTY: errno = 59;
2019-03-27 22:05:14 +01:00
/** No such device or address. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NXIO: errno = 60;
2019-03-27 22:05:14 +01:00
/** Value too large to be stored in data type. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const OVERFLOW: errno = 61;
2019-03-27 22:05:14 +01:00
/** Previous owner died. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const OWNERDEAD: errno = 62;
2019-03-27 22:05:14 +01:00
/** Operation not permitted. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PERM: errno = 63;
2019-03-27 22:05:14 +01:00
/** Broken pipe. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PIPE: errno = 64;
2019-03-27 22:05:14 +01:00
/** Protocol error. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PROTO: errno = 65;
2019-03-27 22:05:14 +01:00
/** Protocol not supported. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PROTONOSUPPORT: errno = 66;
2019-03-27 22:05:14 +01:00
/** Protocol wrong type for socket. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PROTOTYPE: errno = 67;
2019-03-27 22:05:14 +01:00
/** Result too large. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const RANGE: errno = 68;
2019-03-27 22:05:14 +01:00
/** Read-only file system. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const ROFS: errno = 69;
2019-03-27 22:05:14 +01:00
/** Invalid seek. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SPIPE: errno = 70;
2019-03-27 22:05:14 +01:00
/** No such process. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SRCH: errno = 71;
2019-03-27 22:05:14 +01:00
/** Reserved. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const STALE: errno = 72;
2019-03-27 22:05:14 +01:00
/** Connection timed out. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const TIMEDOUT: errno = 73;
2019-03-27 22:05:14 +01:00
/** Text file busy. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const TXTBSY: errno = 74;
2019-03-27 22:05:14 +01:00
/** Cross-device link. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const XDEV: errno = 75;
2019-03-27 22:05:14 +01:00
/** Extension: Capabilities insufficient. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NOTCAPABLE: errno = 76;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type errno = u16;
2019-03-27 22:05:14 +01:00
/** An event that occurred. */
2019-03-27 23:23:53 +01:00
@unmanaged export abstract class event {
/** User-provided value that got attached to `subscription#userdata`. */
2019-03-28 01:32:15 +01:00
userdata: userdata;
2019-03-27 23:23:53 +01:00
/** If non-zero, an error that occurred while processing the subscription request. */
2019-03-28 01:32:15 +01:00
error: errno;
2019-03-27 23:23:53 +01:00
/* The type of the event that occurred. */
2019-03-28 01:32:15 +01:00
type: eventtype;
2019-03-27 23:23:53 +01:00
private __padding0: u16;
2019-03-27 22:05:14 +01:00
}
/** An event that occurred when type is `eventtype.FD_READ` or `eventtype.FD_WRITE`. */
@unmanaged export class rwevent extends event {
2019-03-27 23:23:53 +01:00
/* The number of bytes available for reading or writing. */
2019-03-28 01:32:15 +01:00
nbytes: filesize;
2019-03-27 23:23:53 +01:00
/* The state of the file descriptor. */
2019-03-28 01:32:15 +01:00
flags: eventrwflags;
2019-03-27 23:23:53 +01:00
private __padding1: u32;
2019-03-27 22:05:14 +01:00
}
/** The state of the file descriptor subscribed to with `eventtype.FD_READ` or `eventtype.FD_WRITE`. */
2019-03-28 01:32:15 +01:00
export namespace eventrwflags {
2019-03-27 22:05:14 +01:00
/** The peer of this socket has closed or disconnected. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const HANGUP: eventrwflags = 1;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type eventrwflags = u16;
2019-03-27 22:05:14 +01:00
/** Type of a subscription to an event or its occurrence. */
2019-03-28 01:32:15 +01:00
export namespace eventtype {
2019-03-27 22:05:14 +01:00
/** The time value of clock has reached the timestamp. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const CLOCK: eventtype = 0;
2019-03-27 22:05:14 +01:00
/** File descriptor has data available for reading. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_READ: eventtype = 1;
2019-03-27 22:05:14 +01:00
/** File descriptor has capacity available for writing */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_WRITE: eventtype = 2;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type eventtype = u8;
2019-03-27 22:05:14 +01:00
/** Exit code generated by a process when exiting. */
2019-03-28 01:32:15 +01:00
export type exitcode = u32;
2019-03-27 22:05:14 +01:00
/** A file descriptor number. */
2019-03-28 01:32:15 +01:00
export type fd = u32;
2019-03-27 22:05:14 +01:00
/** File descriptor flags. */
2019-03-28 01:32:15 +01:00
export namespace fdflags {
2019-03-27 22:05:14 +01:00
/** Append mode: Data written to the file is always appended to the file's end. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const APPEND: fdflags = 1;
2019-03-27 22:05:14 +01:00
/** Write according to synchronized I/O data integrity completion. Only the data stored in the file is synchronized. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const DSYNC: fdflags = 2;
2019-03-27 22:05:14 +01:00
/** Non-blocking mode. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const NONBLOCK: fdflags = 4;
2019-03-27 22:05:14 +01:00
/** Synchronized read I/O operations. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const RSYNC: fdflags = 8;
2019-03-27 22:05:14 +01:00
/** Write according to synchronized I/O file integrity completion. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SYNC: fdflags = 16;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type fdflags = u16;
2019-03-27 22:05:14 +01:00
/** File descriptor attributes. */
@unmanaged export class fdstat {
/** File type. */
2019-03-28 01:32:15 +01:00
filetype: filetype;
2019-03-27 22:05:14 +01:00
/** File descriptor flags. */
2019-03-28 01:32:15 +01:00
flags: fdflags;
2019-03-27 22:05:14 +01:00
/** Rights that apply to this file descriptor. */
2019-03-28 01:32:15 +01:00
rights_base: rights;
2019-03-27 22:05:14 +01:00
/** Maximum set of rights that may be installed on new file descriptors that are created through this file descriptor, e.g., through `path_open`. */
2019-03-28 01:32:15 +01:00
rights_inheriting: rights;
2019-03-27 22:05:14 +01:00
}
/** Relative offset within a file. */
2019-03-28 01:32:15 +01:00
export type filedelta = i64;
2019-03-27 22:05:14 +01:00
/** Non-negative file size or length of a region within a file. */
2019-03-28 01:32:15 +01:00
export type filesize = u64;
2019-03-27 22:05:14 +01:00
/** File attributes. */
@unmanaged export class filestat {
/** Device ID of device containing the file. */
2019-03-28 01:32:15 +01:00
dev: device;
2019-03-27 22:05:14 +01:00
/** File serial number. */
2019-03-28 01:32:15 +01:00
ino: inode;
2019-03-27 22:05:14 +01:00
/** File type. */
2019-03-28 01:32:15 +01:00
filetype: filetype;
2019-03-27 22:05:14 +01:00
/** Number of hard links to the file. */
2019-03-28 01:32:15 +01:00
nlink: linkcount;
2019-03-27 22:05:14 +01:00
/** For regular files, the file size in bytes. For symbolic links, the length in bytes of the pathname contained in the symbolic link. */
2019-03-28 01:32:15 +01:00
size: filesize;
2019-03-27 22:05:14 +01:00
/** Last data access timestamp. */
2019-03-28 01:32:15 +01:00
atim: timestamp;
2019-03-27 22:05:14 +01:00
/** Last data modification timestamp. */
2019-03-28 01:32:15 +01:00
mtim: timestamp;
2019-03-27 22:05:14 +01:00
/** Last file status change timestamp. */
2019-03-28 01:32:15 +01:00
ctim: timestamp;
2019-03-27 22:05:14 +01:00
}
/** The type of a file descriptor or file. */
2019-03-28 01:32:15 +01:00
export namespace filetype {
2019-03-27 22:05:14 +01:00
/** The type of the file descriptor or file is unknown or is different from any of the other types specified. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const UNKNOWN: filetype = 0;
2019-03-27 22:05:14 +01:00
/** The file descriptor or file refers to a block device inode. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const BLOCK_DEVICE: filetype = 1;
2019-03-27 22:05:14 +01:00
/** The file descriptor or file refers to a character device inode. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const CHARACTER_DEVICE: filetype = 2;
2019-03-27 22:05:14 +01:00
/** The file descriptor or file refers to a directory inode. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const DIRECTORY: filetype = 3;
2019-03-27 22:05:14 +01:00
/** The file descriptor or file refers to a regular file inode. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const REGULAR_FILE: filetype = 4;
2019-03-27 22:05:14 +01:00
/** The file descriptor or file refers to a datagram socket. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SOCKET_DGRAM: filetype = 5;
2019-03-27 22:05:14 +01:00
/** The file descriptor or file refers to a byte-stream socket. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SOCKET_STREAM: filetype = 6;
2019-03-27 22:05:14 +01:00
/** The file refers to a symbolic link inode. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SYMBOLIC_LINK: filetype = 7;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type filetype = u8;
2019-03-27 22:05:14 +01:00
/** Which file time attributes to adjust. */
2019-03-28 01:32:15 +01:00
export namespace fstflags {
2019-03-27 22:05:14 +01:00
/** Adjust the last data access timestamp to the value stored in `filestat#st_atim`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SET_ATIM: fstflags = 1;
2019-03-27 22:05:14 +01:00
/** Adjust the last data access timestamp to the time of clock `clockid.REALTIME`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SET_ATIM_NOW: fstflags = 2;
2019-03-27 22:05:14 +01:00
/** Adjust the last data modification timestamp to the value stored in `filestat#st_mtim`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SET_MTIM: fstflags = 4;
2019-03-27 22:05:14 +01:00
/** Adjust the last data modification timestamp to the time of clock `clockid.REALTIME`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SET_MTIM_NOW: fstflags = 8;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type fstflags = u16;
2019-03-27 22:05:14 +01:00
/** File serial number that is unique within its file system. */
2019-03-28 01:32:15 +01:00
export type inode = u64;
2019-03-27 22:05:14 +01:00
/** A region of memory for scatter/gather reads. */
@unmanaged export class iovec {
/** The address of the buffer to be filled. */
2019-03-28 12:40:03 +01:00
buf: usize;
2019-03-27 22:05:14 +01:00
/** The length of the buffer to be filled. */
2019-03-28 12:40:03 +01:00
buf_len: usize;
2019-03-27 22:05:14 +01:00
}
/** Number of hard links to an inode. */
2019-03-28 01:32:15 +01:00
export type linkcount = u32;
2019-03-27 22:05:14 +01:00
/** Flags determining the method of how paths are resolved. */
2019-03-28 01:32:15 +01:00
export namespace lookupflags {
2019-03-27 22:05:14 +01:00
/** As long as the resolved path corresponds to a symbolic link, it is expanded. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SYMLINK_FOLLOW: lookupflags = 1;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type lookupflags = u32;
2019-03-27 22:05:14 +01:00
/** Open flags. */
2019-03-28 01:32:15 +01:00
export namespace oflags {
2019-03-27 22:05:14 +01:00
/** Create file if it does not exist. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const CREAT: oflags = 1;
2019-03-27 22:05:14 +01:00
/** Fail if not a directory. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const DIRECTORY: oflags = 2;
2019-03-27 22:05:14 +01:00
/** Fail if file already exists. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const EXCL: oflags = 4;
2019-03-27 22:05:14 +01:00
/** Truncate file to size 0. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const TRUNC: oflags = 8;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type oflags = u16;
2019-03-27 22:05:14 +01:00
/** Flags provided to `sock_recv`. */
2019-03-28 01:32:15 +01:00
export namespace riflags {
2019-03-27 22:05:14 +01:00
/** Returns the message without removing it from the socket's receive queue. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PEEK: riflags = 1;
2019-03-27 22:05:14 +01:00
/** On byte-stream sockets, block until the full amount of data can be returned. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const WAITALL: riflags = 2;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type riflags = u16;
2019-03-27 22:05:14 +01:00
/** File descriptor rights, determining which actions may be performed. */
2019-03-28 01:32:15 +01:00
export namespace rights {
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_datasync`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_DATASYNC: rights = 1;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_read` and `sock_recv`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_READ: rights = 2;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_seek`. This flag implies `rights.FD_TELL`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_SEEK: rights = 4;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_fdstat_set_flags`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_FDSTAT_SET_FLAGS: rights = 8;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_sync`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_SYNC: rights = 16;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_seek` in such a way that the file offset remains unaltered (i.e., `whence.CUR` with offset zero), or to invoke `fd_tell`). */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_TELL: rights = 32;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_write` and `sock_send`. If `rights.FD_SEEK` is set, includes the right to invoke `fd_pwrite`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_WRITE: rights = 64;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_advise`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_ADVISE: rights = 128;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_allocate`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_ALLOCATE: rights = 256;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_create_directory`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_CREATE_DIRECTORY: rights = 512;
2019-03-27 22:05:14 +01:00
/** If `rights.PATH_OPEN` is set, the right to invoke `path_open` with `oflags.CREAT`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_CREATE_FILE: rights = 1024;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_link` with the file descriptor as the source directory. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_LINK_SOURCE: rights = 2048;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_link` with the file descriptor as the target directory. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_LINK_TARGET: rights = 4096;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_open`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_OPEN: rights = 8192;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_readdir`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_READDIR: rights = 16384;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_readlink`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_READLINK: rights = 32768;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_rename` with the file descriptor as the source directory. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_RENAME_SOURCE: rights = 65536;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_rename` with the file descriptor as the target directory. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_RENAME_TARGET: rights = 131072;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_filestat_get`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_FILESTAT_GET: rights = 262144;
2019-03-27 22:05:14 +01:00
/** The right to change a file's size (there is no `path_filestat_set_size`). If `rights.PATH_OPEN` is set, includes the right to invoke `path_open` with `oflags.TRUNC`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_FILESTAT_SET_SIZE: rights = 524288;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_filestat_set_times`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_FILESTAT_SET_TIMES: rights = 1048576;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_filestat_get`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_FILESTAT_GET: rights = 2097152;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_filestat_set_size`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_FILESTAT_SET_SIZE: rights = 4194304;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_filestat_set_times`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FD_FILESTAT_SET_TIMES: rights = 8388608;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_symlink`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const RIGHT_PATH_SYMLINK: rights = 16777216;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_remove_directory`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_REMOVE_DIRECTORY: rights = 33554432;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_unlink_file`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PATH_UNLINK_FILE: rights = 67108864;
2019-03-27 22:05:14 +01:00
/** If `rights.FD_READ` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype.FD_READ`. If `rights.FD_WRITE` is set, includes the right to invoke `poll_oneoff` to subscribe to `eventtype.FD_WRITE`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const POLL_FD_READWRITE: rights = 134217728;
2019-03-27 22:05:14 +01:00
/** The right to invoke `sock_shutdown`. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SOCK_SHUTDOWN: rights = 268435456;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type rights = u64;
2019-03-27 22:05:14 +01:00
/** Flags returned by `sock_recv`. */
2019-03-28 01:32:15 +01:00
export namespace roflags {
2019-03-27 22:05:14 +01:00
/** Message data has been truncated. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const DATA_TRUNCATED: roflags = 1;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type roflags = u16;
2019-03-27 22:05:14 +01:00
/** Which channels on a socket to shut down. */
2019-03-28 01:32:15 +01:00
export namespace sdflags {
2019-03-27 22:05:14 +01:00
/** Disables further receive operations. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const RD: sdflags = 1;
2019-03-27 22:05:14 +01:00
/** Disables further send operations. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const WR: sdflags = 2;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type sdflags = u8;
2019-03-27 22:05:14 +01:00
/** Flags provided to `sock_send`. */
2019-03-28 01:32:15 +01:00
export namespace siflags {
2019-03-27 22:05:14 +01:00
// As there are currently no flags defined, it must be set to zero.
}
2019-03-28 01:32:15 +01:00
export type siflags = u16;
2019-03-27 22:05:14 +01:00
/** Signal condition. */
2019-03-28 01:32:15 +01:00
export namespace signal {
2019-03-27 22:05:14 +01:00
/** Hangup. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const HUP: signal = 1;
2019-03-27 22:05:14 +01:00
/** Terminate interrupt signal. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const INT: signal = 2;
2019-03-27 22:05:14 +01:00
/** Terminal quit signal. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const QUIT: signal = 3;
2019-03-27 22:05:14 +01:00
/** Illegal instruction. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const ILL: signal = 4;
2019-03-27 22:05:14 +01:00
/** Trace/breakpoint trap. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const TRAP: signal = 5;
2019-03-27 22:05:14 +01:00
/** Process abort signal. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const ABRT: signal = 6;
2019-03-27 22:05:14 +01:00
/** Access to an undefined portion of a memory object. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const BUS: signal = 7;
2019-03-27 22:05:14 +01:00
/** Erroneous arithmetic operation. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const FPE: signal = 8;
2019-03-27 22:05:14 +01:00
/** Kill. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const KILL: signal = 9;
2019-03-27 22:05:14 +01:00
/** User-defined signal 1. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const USR1: signal = 10;
2019-03-27 22:05:14 +01:00
/** Invalid memory reference. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SEGV: signal = 11;
2019-03-27 22:05:14 +01:00
/** User-defined signal 2. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const USR2: signal = 12;
2019-03-27 22:05:14 +01:00
/** Write on a pipe with no one to read it. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const PIPE: signal = 13;
2019-03-27 22:05:14 +01:00
/** Alarm clock. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const ALRM: signal = 14;
2019-03-27 22:05:14 +01:00
/** Termination signal. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const TERM: signal = 15;
2019-03-27 22:05:14 +01:00
/** Child process terminated, stopped, or continued. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const CHLD: signal = 16;
2019-03-27 22:05:14 +01:00
/** Continue executing, if stopped. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const CONT: signal = 17;
2019-03-27 22:05:14 +01:00
/** Stop executing. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const STOP: signal = 18;
2019-03-27 22:05:14 +01:00
/** Terminal stop signal. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const TSTP: signal = 19;
2019-03-27 22:05:14 +01:00
/** Background process attempting read. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const TTIN: signal = 20;
2019-03-27 22:05:14 +01:00
/** Background process attempting write. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const TTOU: signal = 21;
2019-03-27 22:05:14 +01:00
/** High bandwidth data is available at a socket. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const URG: signal = 22;
2019-03-27 22:05:14 +01:00
/** CPU time limit exceeded. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const XCPU: signal = 23;
2019-03-27 22:05:14 +01:00
/** File size limit exceeded. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const XFSZ: signal = 24;
2019-03-27 22:05:14 +01:00
/** Virtual timer expired. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const VTALRM: signal = 25;
// @ts-ignore: decorator
@inline
export const PROF: signal = 26;
// @ts-ignore: decorator
@inline
export const WINCH: signal = 27;
// @ts-ignore: decorator
@inline
export const POLL: signal = 28;
// @ts-ignore: decorator
@inline
export const PWR: signal = 29;
2019-03-27 22:05:14 +01:00
/** Bad system call. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SYS: signal = 30;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type signal = u8;
2019-03-27 22:05:14 +01:00
/** Flags determining how to interpret the timestamp provided in `subscription_t::u.clock.timeout. */
2019-03-28 01:32:15 +01:00
export namespace subclockflags {
2019-03-27 22:05:14 +01:00
/** If set, treat the timestamp provided in `clocksubscription` as an absolute timestamp. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const ABSTIME: subclockflags = 1;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type subclockflags = u16;
2019-03-27 22:05:14 +01:00
/** Subscription to an event. */
2019-03-27 23:23:53 +01:00
@unmanaged export abstract class subscription {
2019-03-27 22:05:14 +01:00
/** User-provided value that is attached to the subscription. */
2019-03-28 01:32:15 +01:00
userdata: userdata;
2019-03-27 22:05:14 +01:00
/** The type of the event to which to subscribe. */
2019-03-28 01:32:15 +01:00
type: eventtype;
2019-03-27 23:23:53 +01:00
private __padding0: u32;
2019-03-27 22:05:14 +01:00
}
/* Subscription to an event of type `eventtype.CLOCK`.**/
@unmanaged export class clocksubscription extends subscription {
/** The user-defined unique identifier of the clock. */
2019-03-28 01:32:15 +01:00
identifier: userdata;
2019-03-27 22:05:14 +01:00
/** The clock against which to compare the timestamp. */
2019-03-28 01:32:15 +01:00
clock_id: clockid;
2019-03-27 22:05:14 +01:00
/** The absolute or relative timestamp. */
2019-03-28 01:32:15 +01:00
timeout: timestamp;
2019-03-27 22:05:14 +01:00
/** The amount of time that the implementation may wait additionally to coalesce with other events. */
2019-03-28 01:32:15 +01:00
precision: timestamp;
2019-03-27 22:05:14 +01:00
/** Flags specifying whether the timeout is absolute or relative. */
2019-03-28 01:32:15 +01:00
flags: subclockflags;
2019-03-27 23:23:53 +01:00
private __padding1: u32;
2019-03-27 22:05:14 +01:00
}
/* Subscription to an event of type `eventtype.FD_READ` or `eventtype.FD_WRITE`.**/
@unmanaged export class fdsubscription extends subscription {
/** The file descriptor on which to wait for it to become ready for reading or writing. */
2019-03-28 01:32:15 +01:00
fd: fd;
2019-03-27 22:05:14 +01:00
}
/** Timestamp in nanoseconds. */
2019-03-28 01:32:15 +01:00
export type timestamp = u64;
2019-03-27 22:05:14 +01:00
/** User-provided value that may be attached to objects that is retained when extracted from the implementation. */
2019-03-28 01:32:15 +01:00
export type userdata = u64;
2019-03-27 22:05:14 +01:00
/** The position relative to which to set the offset of the file descriptor. */
2019-03-28 01:32:15 +01:00
export namespace whence {
2019-03-27 22:05:14 +01:00
/** Seek relative to current position. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const CUR: whence = 0;
2019-03-27 22:05:14 +01:00
/** Seek relative to end-of-file. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const END: whence = 1;
2019-03-27 22:05:14 +01:00
/** Seek relative to start-of-file. */
2019-03-28 12:40:03 +01:00
// @ts-ignore: decorator
@inline
export const SET: whence = 2;
2019-03-27 22:05:14 +01:00
}
2019-03-28 01:32:15 +01:00
export type whence = u8;