authorgravatar for shritesh@shritesh.comShritesh Bhattarai <shritesh@shritesh.com> 2019-04-30 21:34:32-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-04-30 22:58:41-04:00
logf53abf40631463a42d640856e3f1613a8334cb14
treefcfb7f52491420f8068b2c55aa53e8a6e08a639b
parentbb0c5f7a2f816709a0ec5af7099057fdfbfad04a

wasi: import all constants and their types


2 files changed, 233 insertions(+), 87 deletions(-)

std/os/wasi.zig-81
......@@ -1,90 +1,9 @@
11pub use @import("wasi/core.zig");
22
3// Based on https://github.com/CraneStation/wasi-sysroot/blob/wasi/libc-bottom-half/headers/public/wasi/core.h
4// and https://github.com/WebAssembly/WASI/blob/master/design/WASI-core.md
5
63pub const STDIN_FILENO = 0;
74pub const STDOUT_FILENO = 1;
85pub const STDERR_FILENO = 2;
96
10pub const ESUCCESS = 0;
11pub const E2BIG = 1;
12pub const EACCES = 2;
13pub const EADDRINUSE = 3;
14pub const EADDRNOTAVAIL = 4;
15pub const EAFNOSUPPORT = 5;
16pub const EAGAIN = 6;
17pub const EALREADY = 7;
18pub const EBADF = 8;
19pub const EBADMSG = 9;
20pub const EBUSY = 10;
21pub const ECANCELED = 11;
22pub const ECHILD = 12;
23pub const ECONNABORTED = 13;
24pub const ECONNREFUSED = 14;
25pub const ECONNRESET = 15;
26pub const EDEADLK = 16;
27pub const EDESTADDRREQ = 17;
28pub const EDOM = 18;
29pub const EDQUOT = 19;
30pub const EEXIST = 20;
31pub const EFAULT = 21;
32pub const EFBIG = 22;
33pub const EHOSTUNREACH = 23;
34pub const EIDRM = 24;
35pub const EILSEQ = 25;
36pub const EINPROGRESS = 26;
37pub const EINTR = 27;
38pub const EINVAL = 28;
39pub const EIO = 29;
40pub const EISCONN = 30;
41pub const EISDIR = 31;
42pub const ELOOP = 32;
43pub const EMFILE = 33;
44pub const EMLINK = 34;
45pub const EMSGSIZE = 35;
46pub const EMULTIHOP = 36;
47pub const ENAMETOOLONG = 37;
48pub const ENETDOWN = 38;
49pub const ENETRESET = 39;
50pub const ENETUNREACH = 40;
51pub const ENFILE = 41;
52pub const ENOBUFS = 42;
53pub const ENODEV = 43;
54pub const ENOENT = 44;
55pub const ENOEXEC = 45;
56pub const ENOLCK = 46;
57pub const ENOLINK = 47;
58pub const ENOMEM = 48;
59pub const ENOMSG = 49;
60pub const ENOPROTOOPT = 50;
61pub const ENOSPC = 51;
62pub const ENOSYS = 52;
63pub const ENOTCONN = 53;
64pub const ENOTDIR = 54;
65pub const ENOTEMPTY = 55;
66pub const ENOTRECOVERABLE = 56;
67pub const ENOTSOCK = 57;
68pub const ENOTSUP = 58;
69pub const ENOTTY = 59;
70pub const ENXIO = 60;
71pub const EOVERFLOW = 61;
72pub const EOWNERDEAD = 62;
73pub const EPERM = 63;
74pub const EPIPE = 64;
75pub const EPROTO = 65;
76pub const EPROTONOSUPPORT = 66;
77pub const EPROTOTYPE = 67;
78pub const ERANGE = 68;
79pub const EROFS = 69;
80pub const ESPIPE = 70;
81pub const ESRCH = 71;
82pub const ESTALE = 72;
83pub const ETIMEDOUT = 73;
84pub const ETXTBSY = 74;
85pub const EXDEV = 75;
86pub const ENOTCAPABLE = 76;
87
887// TODO: implement this like darwin does
898pub fn getErrno(r: usize) usize {
909 const signed_r = @bitCast(isize, r);
std/os/wasi/core.zig+233-6
......@@ -1,21 +1,248 @@
1pub const clockid_t = u32;
2pub const errno_t = u16;
3pub const exitcode_t = u32;
4pub const fd_t = u32;
5pub const signal_t = u8;
6pub const timestamp_t = u64;
1// Based on https://github.com/CraneStation/wasi-sysroot/blob/wasi/libc-bottom-half/headers/public/wasi/core.h
2// and https://github.com/WebAssembly/WASI/blob/master/design/WASI-core.md
3
4pub const advice_t = u8;
5pub const ADVICE_NORMAL: advice_t = 0;
6pub const ADVICE_SEQUENTIAL: advice_t = 1;
7pub const ADVICE_RANDOM: advice_t = 2;
8pub const ADVICE_WILLNEED: advice_t = 3;
9pub const ADVICE_DONTNEED: advice_t = 4;
10pub const ADVICE_NOREUSE: advice_t = 5;
711
812pub const ciovec_t = extern struct {
913 buf: [*]const u8,
1014 buf_len: usize,
1115};
1216
17pub const clockid_t = u32;
1318pub const CLOCK_REALTIME: clockid_t = 0;
1419pub const CLOCK_MONOTONIC: clockid_t = 1;
1520pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2;
1621pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3;
1722
23pub const device_t = u64;
24
25pub const dircookie_t = u64;
26pub const DIRCOOKIE_START: dircookie_t = 0;
27
28pub const errno_t = u16;
29pub const ESUCCESS: errno_t = 0;
30pub const E2BIG: errno_t = 1;
31pub const EACCES: errno_t = 2;
32pub const EADDRINUSE: errno_t = 3;
33pub const EADDRNOTAVAIL: errno_t = 4;
34pub const EAFNOSUPPORT: errno_t = 5;
35pub const EAGAIN: errno_t = 6;
36pub const EALREADY: errno_t = 7;
37pub const EBADF: errno_t = 8;
38pub const EBADMSG: errno_t = 9;
39pub const EBUSY: errno_t = 10;
40pub const ECANCELED: errno_t = 11;
41pub const ECHILD: errno_t = 12;
42pub const ECONNABORTED: errno_t = 13;
43pub const ECONNREFUSED: errno_t = 14;
44pub const ECONNRESET: errno_t = 15;
45pub const EDEADLK: errno_t = 16;
46pub const EDESTADDRREQ: errno_t = 17;
47pub const EDOM: errno_t = 18;
48pub const EDQUOT: errno_t = 19;
49pub const EEXIST: errno_t = 20;
50pub const EFAULT: errno_t = 21;
51pub const EFBIG: errno_t = 22;
52pub const EHOSTUNREACH: errno_t = 23;
53pub const EIDRM: errno_t = 24;
54pub const EILSEQ: errno_t = 25;
55pub const EINPROGRESS: errno_t = 26;
56pub const EINTR: errno_t = 27;
57pub const EINVAL: errno_t = 28;
58pub const EIO: errno_t = 29;
59pub const EISCONN: errno_t = 30;
60pub const EISDIR: errno_t = 31;
61pub const ELOOP: errno_t = 32;
62pub const EMFILE: errno_t = 33;
63pub const EMLINK: errno_t = 34;
64pub const EMSGSIZE: errno_t = 35;
65pub const EMULTIHOP: errno_t = 36;
66pub const ENAMETOOLONG: errno_t = 37;
67pub const ENETDOWN: errno_t = 38;
68pub const ENETRESET: errno_t = 39;
69pub const ENETUNREACH: errno_t = 40;
70pub const ENFILE: errno_t = 41;
71pub const ENOBUFS: errno_t = 42;
72pub const ENODEV: errno_t = 43;
73pub const ENOENT: errno_t = 44;
74pub const ENOEXEC: errno_t = 45;
75pub const ENOLCK: errno_t = 46;
76pub const ENOLINK: errno_t = 47;
77pub const ENOMEM: errno_t = 48;
78pub const ENOMSG: errno_t = 49;
79pub const ENOPROTOOPT: errno_t = 50;
80pub const ENOSPC: errno_t = 51;
81pub const ENOSYS: errno_t = 52;
82pub const ENOTCONN: errno_t = 53;
83pub const ENOTDIR: errno_t = 54;
84pub const ENOTEMPTY: errno_t = 55;
85pub const ENOTRECOVERABLE: errno_t = 56;
86pub const ENOTSOCK: errno_t = 57;
87pub const ENOTSUP: errno_t = 58;
88pub const ENOTTY: errno_t = 59;
89pub const ENXIO: errno_t = 60;
90pub const EOVERFLOW: errno_t = 61;
91pub const EOWNERDEAD: errno_t = 62;
92pub const EPERM: errno_t = 63;
93pub const EPIPE: errno_t = 64;
94pub const EPROTO: errno_t = 65;
95pub const EPROTONOSUPPORT: errno_t = 66;
96pub const EPROTOTYPE: errno_t = 67;
97pub const ERANGE: errno_t = 68;
98pub const EROFS: errno_t = 69;
99pub const ESPIPE: errno_t = 70;
100pub const ESRCH: errno_t = 71;
101pub const ESTALE: errno_t = 72;
102pub const ETIMEDOUT: errno_t = 73;
103pub const ETXTBSY: errno_t = 74;
104pub const EXDEV: errno_t = 75;
105pub const ENOTCAPABLE: errno_t = 76;
106
107pub const eventrwflags_t = u16;
108pub const EVENT_FD_READWRITE_HANGUP: eventrwflags_t = 0x0001;
109
110pub const eventtype_t = u8;
111pub const EVENTTYPE_CLOCK: eventtype_t = 0;
112pub const EVENTTYPE_FD_READ: eventtype_t = 1;
113pub const EVENTTYPE_FD_WRITE: eventtype_t = 2;
114
115pub const exitcode_t = u32;
116
117pub const fd_t = u32;
118
119pub const fdflags_t = u16;
120pub const FDFLAG_APPEND: fdflags_t = 0x0001;
121pub const FDFLAG_DSYNC: fdflags_t = 0x0002;
122pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004;
123pub const FDFLAG_RSYNC: fdflags_t = 0x0008;
124pub const FDFLAG_SYNC: fdflags_t = 0x0010;
125
126pub const filedelta_t = i64;
127
128pub const filesize_t = u64;
129
130pub const filetype_t = u8;
131pub const FILETYPE_UNKNOWN: filetype_t = 0;
132pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1;
133pub const FILETYPE_CHARACTER_DEVICE: filetype_t = 2;
134pub const FILETYPE_DIRECTORY: filetype_t = 3;
135pub const FILETYPE_REGULAR_FILE: filetype_t = 4;
136pub const FILETYPE_SOCKET_DGRAM: filetype_t = 5;
137pub const FILETYPE_SOCKET_STREAM: filetype_t = 6;
138pub const FILETYPE_SYMBOLIC_LINK: filetype_t = 7;
139
140pub const fstflags_t = u16;
141pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001;
142pub const FILESTAT_SET_ATIM_NOW: fstflags_t = 0x0002;
143pub const FILESTAT_SET_MTIM: fstflags_t = 0x0004;
144pub const FILESTAT_SET_MTIM_NOW: fstflags_t = 0x0008;
145
146pub const inode_t = u64;
147
148pub const linkcount_t = u32;
149
150pub const lookupflags_t = u32;
151pub const LOOKUP_SYMLINK_FOLLOW: lookupflags_t = 0x00000001;
152
153pub const oflags_t = u16;
154pub const O_CREAT: oflags_t = 0x0001;
155pub const O_DIRECTORY: oflags_t = 0x0002;
156pub const O_EXCL: oflags_t = 0x0004;
157pub const O_TRUNC: oflags_t = 0x0008;
158
159pub const riflags_t = u16;
160pub const SOCK_RECV_PEEK: riflags_t = 0x0001;
161pub const SOCK_RECV_WAITALL: riflags_t = 0x0002;
162
163pub const rights_t = u64;
164pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001;
165pub const RIGHT_FD_READ: rights_t = 0x0000000000000002;
166pub const RIGHT_FD_SEEK: rights_t = 0x0000000000000004;
167pub const RIGHT_FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;
168pub const RIGHT_FD_SYNC: rights_t = 0x0000000000000010;
169pub const RIGHT_FD_TELL: rights_t = 0x0000000000000020;
170pub const RIGHT_FD_WRITE: rights_t = 0x0000000000000040;
171pub const RIGHT_FD_ADVISE: rights_t = 0x0000000000000080;
172pub const RIGHT_FD_ALLOCATE: rights_t = 0x0000000000000100;
173pub const RIGHT_PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;
174pub const RIGHT_PATH_CREATE_FILE: rights_t = 0x0000000000000400;
175pub const RIGHT_PATH_LINK_SOURCE: rights_t = 0x0000000000000800;
176pub const RIGHT_PATH_LINK_TARGET: rights_t = 0x0000000000001000;
177pub const RIGHT_PATH_OPEN: rights_t = 0x0000000000002000;
178pub const RIGHT_FD_READDIR: rights_t = 0x0000000000004000;
179pub const RIGHT_PATH_READLINK: rights_t = 0x0000000000008000;
180pub const RIGHT_PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;
181pub const RIGHT_PATH_RENAME_TARGET: rights_t = 0x0000000000020000;
182pub const RIGHT_PATH_FILESTAT_GET: rights_t = 0x0000000000040000;
183pub const RIGHT_PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;
184pub const RIGHT_PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;
185pub const RIGHT_FD_FILESTAT_GET: rights_t = 0x0000000000200000;
186pub const RIGHT_FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;
187pub const RIGHT_FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;
188pub const RIGHT_PATH_SYMLINK: rights_t = 0x0000000001000000;
189pub const RIGHT_PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;
190pub const RIGHT_PATH_UNLINK_FILE: rights_t = 0x0000000004000000;
191pub const RIGHT_POLL_FD_READWRITE: rights_t = 0x0000000008000000;
192pub const RIGHT_SOCK_SHUTDOWN: rights_t = 0x0000000010000000;
193
194pub const roflags_t = u16;
195pub const SOCK_RECV_DATA_TRUNCATED: roflags_t = 0x0001;
196
197pub const sdflags_t = u8;
198pub const SHUT_RD: sdflags_t = 0x01;
199pub const SHUT_WR: sdflags_t = 0x02;
200
201pub const siflags_t = u16;
202
203pub const signal_t = u8;
204pub const SIGHUP: signal_t = 1;
205pub const SIGINT: signal_t = 2;
206pub const SIGQUIT: signal_t = 3;
207pub const SIGILL: signal_t = 4;
208pub const SIGTRAP: signal_t = 5;
18209pub const SIGABRT: signal_t = 6;
210pub const SIGBUS: signal_t = 7;
211pub const SIGFPE: signal_t = 8;
212pub const SIGKILL: signal_t = 9;
213pub const SIGUSR1: signal_t = 10;
214pub const SIGSEGV: signal_t = 11;
215pub const SIGUSR2: signal_t = 12;
216pub const SIGPIPE: signal_t = 13;
217pub const SIGALRM: signal_t = 14;
218pub const SIGTERM: signal_t = 15;
219pub const SIGCHLD: signal_t = 16;
220pub const SIGCONT: signal_t = 17;
221pub const SIGSTOP: signal_t = 18;
222pub const SIGTSTP: signal_t = 19;
223pub const SIGTTIN: signal_t = 20;
224pub const SIGTTOU: signal_t = 21;
225pub const SIGURG: signal_t = 22;
226pub const SIGXCPU: signal_t = 23;
227pub const SIGXFSZ: signal_t = 24;
228pub const SIGVTALRM: signal_t = 25;
229pub const SIGPROF: signal_t = 26;
230pub const SIGWINCH: signal_t = 27;
231pub const SIGPOLL: signal_t = 28;
232pub const SIGPWR: signal_t = 29;
233pub const SIGSYS: signal_t = 30;
234
235pub const subclockflags_t = u16;
236pub const SUBSCRIPTION_CLOCK_ABSTIME: subclockflags_t = 0x0001;
237
238pub const timestamp_t = u64;
239
240pub const userdata_t = u64;
241
242pub const whence_t = u8;
243pub const WHENCE_CUR: whence_t = 0;
244pub const WHENCE_END: whence_t = 1;
245pub const WHENCE_SET: whence_t = 2;
19246
20247pub extern "wasi_unstable" fn args_get(argv: [*][*]u8, argv_buf: [*]u8) errno_t;
21248pub extern "wasi_unstable" fn args_sizes_get(argc: *usize, argv_buf_size: *usize) errno_t;