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 01:32:15 +01:00
type uintptr = usize ;
type size = usize ;
2019-03-27 22:05:14 +01:00
/** Read command-line argument data. */
2019-03-28 01:32:15 +01:00
export declare function args_get ( argv : uintptr , argv_buf : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Return command-line argument data sizes. */
2019-03-28 01:32:15 +01:00
export declare function args_sizes_get ( argc : uintptr , argv_buf_size_ptr : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Return the resolution of a clock. */
2019-03-28 01:32:15 +01:00
export declare function clock_res_get ( clock : clockid , resolution : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Return the time value of a clock. */
2019-03-28 01:32:15 +01:00
export declare function clock_time_get ( clock : clockid , precision : timestamp , time : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Read environment variable data. */
2019-03-28 01:32:15 +01:00
export declare function environ_get ( environ : uintptr , environ_buf : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Return command-line argument data sizes. */
2019-03-28 01:32:15 +01:00
export declare function environ_sizes_get ( environ_count : uintptr , environ_buf_size : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Provide file advisory information on a file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_advise ( fd : fd , offset : filesize , len : filesize , advice : advice ) : errno ;
2019-03-27 22:05:14 +01:00
/** Provide file advisory information on a file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_allocate ( fd : fd , offset : filesize , len : filesize ) : errno ;
2019-03-27 22:05:14 +01:00
/** Close a file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_close ( fd : fd ) : errno ;
2019-03-27 22:05:14 +01:00
/** Synchronize the data of a file to disk. */
2019-03-28 01:32:15 +01:00
export declare function fd_datasync ( fd : fd ) : errno ;
2019-03-27 22:05:14 +01:00
/** Get the attributes of a file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_fdstat_get ( fd : fd , buf : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Adjust the flags associated with a file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_fdstat_set_flags ( fd : fd , flags : fdflags ) : errno ;
2019-03-27 22:05:14 +01:00
/** Adjust the rights associated with a file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_fdstat_set_rights ( fd : fd , fs_rights_base : rights , fs_rights_inheriting : rights ) : errno ;
2019-03-27 22:05:14 +01:00
/** Return the attributes of an open file. */
2019-03-28 01:32:15 +01:00
export declare function fd_filestat_get ( fd : fd , buf : uintptr ) : 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 01:32:15 +01:00
export declare function fd_filestat_set_size ( fd : fd , size : filesize ) : errno ;
2019-03-27 22:05:14 +01:00
/** Adjust the timestamps of an open file or directory. */
2019-03-28 01:32:15 +01:00
export declare function fd_filestat_set_times ( fd : fd , st_atim : timestamp , st_mtim : timestamp , 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 01:32:15 +01:00
export declare function fd_pread ( fd : fd , iovs : uintptr , iovs_len : size , offset : filesize , nread : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Return a description of the given preopened file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_prestat_get ( fd : fd , buf : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Return a description of the given preopened file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_prestat_dir_name ( fd : fd , path : uintptr , path_len : size ) : 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 01:32:15 +01:00
export declare function fd_pwrite ( fd : fd , iovs : uintptr , iovs_len : size , offset : filesize , nwritten : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Read from a file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_read ( fd : fd , iovs : uintptr , iovs_len : size , nread : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Read directory entries from a directory. */
2019-03-28 01:32:15 +01:00
export declare function fd_readdir ( fd : fd , buf : uintptr , buf_len : size , cookie : dircookie , buf_used : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Atomically replace a file descriptor by renumbering another file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_renumber ( from : fd , to : fd ) : errno ;
2019-03-27 22:05:14 +01:00
/** Move the offset of a file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_seek ( fd : fd , offset : filedelta , whence : whence , newoffset : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Synchronize the data and metadata of a file to disk. */
2019-03-28 01:32:15 +01:00
export declare function fd_sync ( fd : fd ) : errno ;
2019-03-27 22:05:14 +01:00
/** Return the current offset of a file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_tell ( fd : fd , newoffset : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Write to a file descriptor. */
2019-03-28 01:32:15 +01:00
export declare function fd_write ( fd : fd , iovs : uintptr , iovs_len : size , nwritten : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/* Create a directory. */
2019-03-28 01:32:15 +01:00
export declare function path_create_directory ( fd : fd , path : uintptr , path_len : size ) : errno ;
2019-03-27 22:05:14 +01:00
/** Return the attributes of a file or directory. */
2019-03-28 01:32:15 +01:00
export declare function path_filestat_get ( fd : fd , flags : lookupflags , path : uintptr , path_len : size , buf : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Adjust the timestamps of a file or directory. */
2019-03-28 01:32:15 +01:00
export declare function path_filestat_set_times ( fd : fd , flags : lookupflags , path : uintptr , path_len : size , st_atim : timestamp , st_mtim : timestamp , fstflags : fstflags ) : errno ;
2019-03-27 22:05:14 +01:00
/** Create a hard link. */
2019-03-28 01:32:15 +01:00
export declare function path_link ( fd0 : fd , flags0 : lookupflags , path0 : uintptr , path_len0 : size , fd1 : fd , path1 : uintptr , path_len : size ) : errno ;
2019-03-27 22:05:14 +01:00
/** Open a file or directory. */
2019-03-28 01:32:15 +01:00
export declare function path_open ( dirfd : fd , dirflags : lookupflags , path : uintptr , path_len : size , oflags : oflags , fs_rights_base : rights , fs_rights_inheriting : rights , fs_flags : fdflags , fd : fd ) : errno ;
2019-03-27 22:05:14 +01:00
/** Read the contents of a symbolic link. */
2019-03-28 01:32:15 +01:00
export declare function path_readlink ( fd : fd , path : uintptr , path_len : size , buf : uintptr , buf_len : size , buf_used : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Remove a directory. */
2019-03-28 01:32:15 +01:00
export declare function path_remove_directory ( fd : fd , path : uintptr , path_len : size ) : errno ;
2019-03-27 22:05:14 +01:00
/** Rename a file or directory. */
2019-03-28 01:32:15 +01:00
export declare function path_rename ( fd0 : fd , path0 : uintptr , path_len0 : size , fd1 : fd , path1 : uintptr , path_len1 : size ) : errno ;
2019-03-27 22:05:14 +01:00
/** Create a symbolic link. */
2019-03-28 01:32:15 +01:00
export declare function path_symlink ( path0 : uintptr , path_len0 : size , fd : fd , path1 : uintptr , path_len1 : size ) : errno ;
2019-03-27 22:05:14 +01:00
/** Unlink a file. */
2019-03-28 01:32:15 +01:00
export declare function path_unlink_file ( fd : fd , path : uintptr , path_len : size ) : errno ;
2019-03-27 22:05:14 +01:00
/** Concurrently poll for the occurrence of a set of events. */
2019-03-28 01:32:15 +01:00
export declare function poll_oneoff ( in_ : uintptr , out : uintptr , nsubscriptions : size , nevents : uintptr ) : 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. */
export declare function proc_exit ( rval : u32 ) : void ;
/** Send a signal to the process of the calling thread. */
export declare function proc_raise ( sig : signal ) : errno ;
/** Write high-quality random data into a buffer. */
2019-03-28 01:32:15 +01:00
export declare function random_get ( buf : uintptr , buf_len : size ) : 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 01:32:15 +01:00
export declare function sock_recv ( sock : fd , ri_data : uintptr , ri_data_len : size , ri_flags : riflags , ro_datalen : uintptr , ro_flags : roflags ) : errno ;
2019-03-27 22:05:14 +01:00
/** Send a message on a socket. */
2019-03-28 01:32:15 +01:00
export declare function sock_send ( sock : fd , si_data : uintptr , si_data_len : size , si_flags : siflags , so_datalen : uintptr ) : errno ;
2019-03-27 22:05:14 +01:00
/** Shut down socket send and receive channels. */
2019-03-28 01:32:15 +01:00
export declare function sock_shutdown ( sock : fd , 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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const SUCCESS : errno = 0 ;
2019-03-27 22:05:14 +01:00
/** Argument list too long. */
2019-03-28 01:32:15 +01:00
@inline export const TOOBIG : errno = 1 ;
2019-03-27 22:05:14 +01:00
/** Permission denied. */
2019-03-28 01:32:15 +01:00
@inline export const ACCES : errno = 2 ;
2019-03-27 22:05:14 +01:00
/** Address in use. */
2019-03-28 01:32:15 +01:00
@inline export const ADDRINUSE : errno = 3 ;
2019-03-27 22:05:14 +01:00
/** Address not available. */
2019-03-28 01:32:15 +01:00
@inline export const ADDRNOTAVAIL : errno = 4 ;
2019-03-27 22:05:14 +01:00
/** Address family not supported. */
2019-03-28 01:32:15 +01:00
@inline export const AFNOSUPPORT : errno = 5 ;
2019-03-27 22:05:14 +01:00
/** Resource unavailable, or operation would block. */
2019-03-28 01:32:15 +01:00
@inline export const AGAIN : errno = 6 ;
2019-03-27 22:05:14 +01:00
/** Connection already in progress. */
2019-03-28 01:32:15 +01:00
@inline export const ALREADY : errno = 7 ;
2019-03-27 22:05:14 +01:00
/** Bad file descriptor. */
2019-03-28 01:32:15 +01:00
@inline export const BADF : errno = 8 ;
2019-03-27 22:05:14 +01:00
/** Bad message. */
2019-03-28 01:32:15 +01:00
@inline export const BADMSG : errno = 9 ;
2019-03-27 22:05:14 +01:00
/** Device or resource busy. */
2019-03-28 01:32:15 +01:00
@inline export const BUSY : errno = 10 ;
2019-03-27 22:05:14 +01:00
/** Operation canceled. */
2019-03-28 01:32:15 +01:00
@inline export const CANCELED : errno = 11 ;
2019-03-27 22:05:14 +01:00
/** No child processes. */
2019-03-28 01:32:15 +01:00
@inline export const CHILD : errno = 12 ;
2019-03-27 22:05:14 +01:00
/** Connection aborted. */
2019-03-28 01:32:15 +01:00
@inline export const CONNABORTED : errno = 13 ;
2019-03-27 22:05:14 +01:00
/** Connection refused. */
2019-03-28 01:32:15 +01:00
@inline export const CONNREFUSED : errno = 14 ;
2019-03-27 22:05:14 +01:00
/** Connection reset. */
2019-03-28 01:32:15 +01:00
@inline export const CONNRESET : errno = 15 ;
2019-03-27 22:05:14 +01:00
/** Resource deadlock would occur. */
2019-03-28 01:32:15 +01:00
@inline export const DEADLK : errno = 16 ;
2019-03-27 22:05:14 +01:00
/** Destination address required. */
2019-03-28 01:32:15 +01:00
@inline export const DESTADDRREQ : errno = 17 ;
2019-03-27 22:05:14 +01:00
/** Mathematics argument out of domain of function. */
2019-03-28 01:32:15 +01:00
@inline export const DOM : errno = 18 ;
2019-03-27 22:05:14 +01:00
/** Reserved. */
2019-03-28 01:32:15 +01:00
@inline export const DQUOT : errno = 19 ;
2019-03-27 22:05:14 +01:00
/** File exists. */
2019-03-28 01:32:15 +01:00
@inline export const EXIST : errno = 20 ;
2019-03-27 22:05:14 +01:00
/** Bad address. */
2019-03-28 01:32:15 +01:00
@inline export const FAULT : errno = 21 ;
2019-03-27 22:05:14 +01:00
/** File too large. */
2019-03-28 01:32:15 +01:00
@inline export const FBIG : errno = 22 ;
2019-03-27 22:05:14 +01:00
/** Host is unreachable. */
2019-03-28 01:32:15 +01:00
@inline export const HOSTUNREACH : errno = 23 ;
2019-03-27 22:05:14 +01:00
/** Identifier removed. */
2019-03-28 01:32:15 +01:00
@inline export const IDRM : errno = 24 ;
2019-03-27 22:05:14 +01:00
/** Illegal byte sequence. */
2019-03-28 01:32:15 +01:00
@inline export const ILSEQ : errno = 25 ;
2019-03-27 22:05:14 +01:00
/** Operation in progress. */
2019-03-28 01:32:15 +01:00
@inline export const INPROGRESS : errno = 26 ;
2019-03-27 22:05:14 +01:00
/** Interrupted function. */
2019-03-28 01:32:15 +01:00
@inline export const INTR : errno = 27 ;
2019-03-27 22:05:14 +01:00
/** Invalid argument. */
2019-03-28 01:32:15 +01:00
@inline export const INVAL : errno = 28 ;
2019-03-27 22:05:14 +01:00
/** I/O error. */
2019-03-28 01:32:15 +01:00
@inline export const IO : errno = 29 ;
2019-03-27 22:05:14 +01:00
/** Socket is connected. */
2019-03-28 01:32:15 +01:00
@inline export const ISCONN : errno = 30 ;
2019-03-27 22:05:14 +01:00
/** Is a directory. */
2019-03-28 01:32:15 +01:00
@inline export const ISDIR : errno = 31 ;
2019-03-27 22:05:14 +01:00
/** Too many levels of symbolic links. */
2019-03-28 01:32:15 +01:00
@inline export const LOOP : errno = 32 ;
2019-03-27 22:05:14 +01:00
/** File descriptor value too large. */
2019-03-28 01:32:15 +01:00
@inline export const MFILE : errno = 33 ;
2019-03-27 22:05:14 +01:00
/** Too many links. */
2019-03-28 01:32:15 +01:00
@inline export const MLINK : errno = 34 ;
2019-03-27 22:05:14 +01:00
/** Message too large. */
2019-03-28 01:32:15 +01:00
@inline export const MSGSIZE : errno = 35 ;
2019-03-27 22:05:14 +01:00
/** Reserved. */
2019-03-28 01:32:15 +01:00
@inline export const MULTIHOP : errno = 36 ;
2019-03-27 22:05:14 +01:00
/** Filename too long. */
2019-03-28 01:32:15 +01:00
@inline export const NAMETOOLONG : errno = 37 ;
2019-03-27 22:05:14 +01:00
/** Network is down. */
2019-03-28 01:32:15 +01:00
@inline export const NETDOWN : errno = 38 ;
2019-03-27 22:05:14 +01:00
/** Connection aborted by network. */
2019-03-28 01:32:15 +01:00
@inline export const NETRESET : errno = 39 ;
2019-03-27 22:05:14 +01:00
/** Network unreachable. */
2019-03-28 01:32:15 +01:00
@inline export const NETUNREACH : errno = 40 ;
2019-03-27 22:05:14 +01:00
/** Too many files open in system. */
2019-03-28 01:32:15 +01:00
@inline export const NFILE : errno = 41 ;
2019-03-27 22:05:14 +01:00
/** No buffer space available. */
2019-03-28 01:32:15 +01:00
@inline export const NOBUFS : errno = 42 ;
2019-03-27 22:05:14 +01:00
/** No such device. */
2019-03-28 01:32:15 +01:00
@inline export const NODEV : errno = 43 ;
2019-03-27 22:05:14 +01:00
/** No such file or directory. */
2019-03-28 01:32:15 +01:00
@inline export const NOENT : errno = 44 ;
2019-03-27 22:05:14 +01:00
/** Executable file format error. */
2019-03-28 01:32:15 +01:00
@inline export const NOEXEC : errno = 45 ;
2019-03-27 22:05:14 +01:00
/** No locks available. */
2019-03-28 01:32:15 +01:00
@inline export const NOLCK : errno = 46 ;
2019-03-27 22:05:14 +01:00
/** Reserved. */
2019-03-28 01:32:15 +01:00
@inline export const NOLINK : errno = 47 ;
2019-03-27 22:05:14 +01:00
/** Not enough space. */
2019-03-28 01:32:15 +01:00
@inline export const NOMEM : errno = 48 ;
2019-03-27 22:05:14 +01:00
/** No message of the desired type. */
2019-03-28 01:32:15 +01:00
@inline export const NOMSG : errno = 49 ;
2019-03-27 22:05:14 +01:00
/** Protocol not available. */
2019-03-28 01:32:15 +01:00
@inline export const NOPROTOOPT : errno = 50 ;
2019-03-27 22:05:14 +01:00
/** No space left on device. */
2019-03-28 01:32:15 +01:00
@inline export const NOSPC : errno = 51 ;
2019-03-27 22:05:14 +01:00
/** Function not supported. */
2019-03-28 01:32:15 +01:00
@inline export const NOSYS : errno = 52 ;
2019-03-27 22:05:14 +01:00
/** The socket is not connected. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const NOTDIR : errno = 54 ;
2019-03-27 22:05:14 +01:00
/** Directory not empty. */
2019-03-28 01:32:15 +01:00
@inline export const NOTEMPTY : errno = 55 ;
2019-03-27 22:05:14 +01:00
/** State not recoverable. */
2019-03-28 01:32:15 +01:00
@inline export const NOTRECOVERABLE : errno = 56 ;
2019-03-27 22:05:14 +01:00
/** Not a socket. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const NOTSUP : errno = 58 ;
2019-03-27 22:05:14 +01:00
/** Inappropriate I/O control operation. */
2019-03-28 01:32:15 +01:00
@inline export const NOTTY : errno = 59 ;
2019-03-27 22:05:14 +01:00
/** No such device or address. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const OVERFLOW : errno = 61 ;
2019-03-27 22:05:14 +01:00
/** Previous owner died. */
2019-03-28 01:32:15 +01:00
@inline export const OWNERDEAD : errno = 62 ;
2019-03-27 22:05:14 +01:00
/** Operation not permitted. */
2019-03-28 01:32:15 +01:00
@inline export const PERM : errno = 63 ;
2019-03-27 22:05:14 +01:00
/** Broken pipe. */
2019-03-28 01:32:15 +01:00
@inline export const PIPE : errno = 64 ;
2019-03-27 22:05:14 +01:00
/** Protocol error. */
2019-03-28 01:32:15 +01:00
@inline export const PROTO : errno = 65 ;
2019-03-27 22:05:14 +01:00
/** Protocol not supported. */
2019-03-28 01:32:15 +01:00
@inline export const PROTONOSUPPORT : errno = 66 ;
2019-03-27 22:05:14 +01:00
/** Protocol wrong type for socket. */
2019-03-28 01:32:15 +01:00
@inline export const PROTOTYPE : errno = 67 ;
2019-03-27 22:05:14 +01:00
/** Result too large. */
2019-03-28 01:32:15 +01:00
@inline export const RANGE : errno = 68 ;
2019-03-27 22:05:14 +01:00
/** Read-only file system. */
2019-03-28 01:32:15 +01:00
@inline export const ROFS : errno = 69 ;
2019-03-27 22:05:14 +01:00
/** Invalid seek. */
2019-03-28 01:32:15 +01:00
@inline export const SPIPE : errno = 70 ;
2019-03-27 22:05:14 +01:00
/** No such process. */
2019-03-28 01:32:15 +01:00
@inline export const SRCH : errno = 71 ;
2019-03-27 22:05:14 +01:00
/** Reserved. */
2019-03-28 01:32:15 +01:00
@inline export const STALE : errno = 72 ;
2019-03-27 22:05:14 +01:00
/** Connection timed out. */
2019-03-28 01:32:15 +01:00
@inline export const TIMEDOUT : errno = 73 ;
2019-03-27 22:05:14 +01:00
/** Text file busy. */
2019-03-28 01:32:15 +01:00
@inline export const TXTBSY : errno = 74 ;
2019-03-27 22:05:14 +01:00
/** Cross-device link. */
2019-03-28 01:32:15 +01:00
@inline export const XDEV : errno = 75 ;
2019-03-27 22:05:14 +01:00
/** Extension: Capabilities insufficient. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const CLOCK : eventtype = 0 ;
2019-03-27 22:05:14 +01:00
/** File descriptor has data available for reading. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const DSYNC : fdflags = 2 ;
2019-03-27 22:05:14 +01:00
/** Non-blocking mode. */
2019-03-28 01:32:15 +01:00
@inline export const NONBLOCK : fdflags = 4 ;
2019-03-27 22:05:14 +01:00
/** Synchronized read I/O operations. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:33:25 +01:00
@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 01:33:25 +01:00
@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 01:33:25 +01:00
@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 01:33:25 +01:00
@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 01:32:15 +01:00
buf : uintptr ;
2019-03-27 22:05:14 +01:00
/** The length of the buffer to be filled. */
2019-03-28 01:32:15 +01:00
buf_len : size ;
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 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const CREAT : oflags = 1 ;
2019-03-27 22:05:14 +01:00
/** Fail if not a directory. */
2019-03-28 01:32:15 +01:00
@inline export const DIRECTORY : oflags = 2 ;
2019-03-27 22:05:14 +01:00
/** Fail if file already exists. */
2019-03-28 01:32:15 +01:00
@inline export const EXCL : oflags = 4 ;
2019-03-27 22:05:14 +01:00
/** Truncate file to size 0. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const FD_WRITE : rights = 64 ;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_advise`. */
2019-03-28 01:32:15 +01:00
@inline export const FD_ADVISE : rights = 128 ;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_allocate`. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const PATH_OPEN : rights = 8192 ;
2019-03-27 22:05:14 +01:00
/** The right to invoke `fd_readdir`. */
2019-03-28 01:32:15 +01:00
@inline export const FD_READDIR : rights = 16384 ;
2019-03-27 22:05:14 +01:00
/** The right to invoke `path_readlink`. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const RD : sdflags = 1 ;
2019-03-27 22:05:14 +01:00
/** Disables further send operations. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const HUP : signal = 1 ;
2019-03-27 22:05:14 +01:00
/** Terminate interrupt signal. */
2019-03-28 01:32:15 +01:00
@inline export const INT : signal = 2 ;
2019-03-27 22:05:14 +01:00
/** Terminal quit signal. */
2019-03-28 01:32:15 +01:00
@inline export const QUIT : signal = 3 ;
2019-03-27 22:05:14 +01:00
/** Illegal instruction. */
2019-03-28 01:32:15 +01:00
@inline export const ILL : signal = 4 ;
2019-03-27 22:05:14 +01:00
/** Trace/breakpoint trap. */
2019-03-28 01:32:15 +01:00
@inline export const TRAP : signal = 5 ;
2019-03-27 22:05:14 +01:00
/** Process abort signal. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const BUS : signal = 7 ;
2019-03-27 22:05:14 +01:00
/** Erroneous arithmetic operation. */
2019-03-28 01:32:15 +01:00
@inline export const FPE : signal = 8 ;
2019-03-27 22:05:14 +01:00
/** Kill. */
2019-03-28 01:32:15 +01:00
@inline export const KILL : signal = 9 ;
2019-03-27 22:05:14 +01:00
/** User-defined signal 1. */
2019-03-28 01:32:15 +01:00
@inline export const USR1 : signal = 10 ;
2019-03-27 22:05:14 +01:00
/** Invalid memory reference. */
2019-03-28 01:32:15 +01:00
@inline export const SEGV : signal = 11 ;
2019-03-27 22:05:14 +01:00
/** User-defined signal 2. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const PIPE : signal = 13 ;
2019-03-27 22:05:14 +01:00
/** Alarm clock. */
2019-03-28 01:32:15 +01:00
@inline export const ALRM : signal = 14 ;
2019-03-27 22:05:14 +01:00
/** Termination signal. */
2019-03-28 01:32:15 +01:00
@inline export const TERM : signal = 15 ;
2019-03-27 22:05:14 +01:00
/** Child process terminated, stopped, or continued. */
2019-03-28 01:32:15 +01:00
@inline export const CHLD : signal = 16 ;
2019-03-27 22:05:14 +01:00
/** Continue executing, if stopped. */
2019-03-28 01:32:15 +01:00
@inline export const CONT : signal = 17 ;
2019-03-27 22:05:14 +01:00
/** Stop executing. */
2019-03-28 01:32:15 +01:00
@inline export const STOP : signal = 18 ;
2019-03-27 22:05:14 +01:00
/** Terminal stop signal. */
2019-03-28 01:32:15 +01:00
@inline export const TSTP : signal = 19 ;
2019-03-27 22:05:14 +01:00
/** Background process attempting read. */
2019-03-28 01:32:15 +01:00
@inline export const TTIN : signal = 20 ;
2019-03-27 22:05:14 +01:00
/** Background process attempting write. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const URG : signal = 22 ;
2019-03-27 22:05:14 +01:00
/** CPU time limit exceeded. */
2019-03-28 01:32:15 +01:00
@inline export const XCPU : signal = 23 ;
2019-03-27 22:05:14 +01:00
/** File size limit exceeded. */
2019-03-28 01:32:15 +01:00
@inline export const XFSZ : signal = 24 ;
2019-03-27 22:05:14 +01:00
/** Virtual timer expired. */
2019-03-28 01:32:15 +01:00
@inline export const VTALRM : signal = 25 ;
@inline export const PROF : signal = 26 ;
@inline export const WINCH : signal = 27 ;
@inline export const POLL : signal = 28 ;
@inline export const PWR : signal = 29 ;
2019-03-27 22:05:14 +01:00
/** Bad system call. */
2019-03-28 01:32:15 +01:00
@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 01:32:15 +01:00
@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 01:32:15 +01:00
@inline export const CUR : whence = 0 ;
2019-03-27 22:05:14 +01:00
/** Seek relative to end-of-file. */
2019-03-28 01:32:15 +01:00
@inline export const END : whence = 1 ;
2019-03-27 22:05:14 +01:00
/** Seek relative to start-of-file. */
2019-03-28 01:32:15 +01:00
@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 ;