1 use super::{Send, Sync};
2 
3 pub use ffi::c_void;
4 
5 pub type c_char = i8;
6 pub type c_uchar = u8;
7 pub type c_schar = i8;
8 pub type c_int = i32;
9 pub type c_uint = u32;
10 pub type c_short = i16;
11 pub type c_ushort = u16;
12 pub type c_long = i32;
13 pub type c_ulong = u32;
14 pub type c_longlong = i64;
15 pub type c_ulonglong = u64;
16 pub type intmax_t = i64;
17 pub type uintmax_t = u64;
18 pub type size_t = usize;
19 pub type ssize_t = isize;
20 pub type ptrdiff_t = isize;
21 pub type intptr_t = isize;
22 pub type uintptr_t = usize;
23 pub type off_t = i64;
24 pub type pid_t = i32;
25 pub type clock_t = c_longlong;
26 pub type time_t = c_longlong;
27 pub type c_double = f64;
28 pub type c_float = f32;
29 pub type ino_t = u64;
30 pub type sigset_t = c_uchar;
31 pub type suseconds_t = c_longlong;
32 pub type mode_t = u32;
33 pub type dev_t = u64;
34 pub type uid_t = u32;
35 pub type gid_t = u32;
36 pub type nlink_t = u64;
37 pub type blksize_t = c_long;
38 pub type blkcnt_t = i64;
39 pub type nfds_t = c_ulong;
40 pub type wchar_t = i32;
41 pub type nl_item = c_int;
42 pub type __wasi_rights_t = u64;
43 
44 s_no_extra_traits! {
45     #[repr(align(16))]
46     #[allow(missing_debug_implementations)]
47     pub struct max_align_t {
48         priv_: [f64; 4]
49     }
50 }
51 
52 #[allow(missing_copy_implementations)]
53 #[cfg_attr(feature = "extra_traits", derive(Debug))]
54 pub enum FILE {}
55 #[allow(missing_copy_implementations)]
56 #[cfg_attr(feature = "extra_traits", derive(Debug))]
57 pub enum DIR {}
58 #[allow(missing_copy_implementations)]
59 #[cfg_attr(feature = "extra_traits", derive(Debug))]
60 pub enum __locale_struct {}
61 
62 pub type locale_t = *mut __locale_struct;
63 
64 s_paren! {
65     // in wasi-libc clockid_t is const struct __clockid* (where __clockid is an opaque struct),
66     // but that's an implementation detail that we don't want to have to deal with
67     #[repr(transparent)]
68     pub struct clockid_t(*const u8);
69 }
70 
71 unsafe impl Send for clockid_t {}
72 unsafe impl Sync for clockid_t {}
73 
74 s! {
75     #[repr(align(8))]
76     pub struct fpos_t {
77         data: [u8; 16],
78     }
79 
80     pub struct tm {
81         pub tm_sec: c_int,
82         pub tm_min: c_int,
83         pub tm_hour: c_int,
84         pub tm_mday: c_int,
85         pub tm_mon: c_int,
86         pub tm_year: c_int,
87         pub tm_wday: c_int,
88         pub tm_yday: c_int,
89         pub tm_isdst: c_int,
90         pub __tm_gmtoff: c_int,
91         pub __tm_zone: *const c_char,
92         pub __tm_nsec: c_int,
93     }
94 
95     pub struct timeval {
96         pub tv_sec: time_t,
97         pub tv_usec: suseconds_t,
98     }
99 
100     pub struct timespec {
101         pub tv_sec: time_t,
102         pub tv_nsec: c_long,
103     }
104 
105     pub struct tms {
106         pub tms_utime: clock_t,
107         pub tms_stime: clock_t,
108         pub tms_cutime: clock_t,
109         pub tms_cstime: clock_t,
110     }
111 
112     pub struct itimerspec {
113         pub it_interval: timespec,
114         pub it_value: timespec,
115     }
116 
117     pub struct iovec {
118         pub iov_base: *mut c_void,
119         pub iov_len: size_t,
120     }
121 
122     pub struct lconv {
123         pub decimal_point: *mut c_char,
124         pub thousands_sep: *mut c_char,
125         pub grouping: *mut c_char,
126         pub int_curr_symbol: *mut c_char,
127         pub currency_symbol: *mut c_char,
128         pub mon_decimal_point: *mut c_char,
129         pub mon_thousands_sep: *mut c_char,
130         pub mon_grouping: *mut c_char,
131         pub positive_sign: *mut c_char,
132         pub negative_sign: *mut c_char,
133         pub int_frac_digits: c_char,
134         pub frac_digits: c_char,
135         pub p_cs_precedes: c_char,
136         pub p_sep_by_space: c_char,
137         pub n_cs_precedes: c_char,
138         pub n_sep_by_space: c_char,
139         pub p_sign_posn: c_char,
140         pub n_sign_posn: c_char,
141         pub int_p_cs_precedes: c_char,
142         pub int_p_sep_by_space: c_char,
143         pub int_n_cs_precedes: c_char,
144         pub int_n_sep_by_space: c_char,
145         pub int_p_sign_posn: c_char,
146         pub int_n_sign_posn: c_char,
147     }
148 
149     pub struct pollfd {
150         pub fd: c_int,
151         pub events: c_short,
152         pub revents: c_short,
153     }
154 
155     pub struct rusage {
156         pub ru_utime: timeval,
157         pub ru_stime: timeval,
158     }
159 
160     pub struct stat {
161         pub st_dev: dev_t,
162         pub st_ino: ino_t,
163         pub st_nlink: nlink_t,
164         pub st_mode: mode_t,
165         pub st_uid: uid_t,
166         pub st_gid: gid_t,
167         __pad0: c_uint,
168         pub st_rdev: dev_t,
169         pub st_size: off_t,
170         pub st_blksize: blksize_t,
171         pub st_blocks: blkcnt_t,
172         pub st_atim: timespec,
173         pub st_mtim: timespec,
174         pub st_ctim: timespec,
175         __reserved: [c_longlong; 3],
176     }
177 }
178 
179 // Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash,
180 // etc., since it contains a flexible array member with a dynamic size.
181 #[repr(C)]
182 #[allow(missing_copy_implementations)]
183 #[cfg_attr(feature = "extra_traits", derive(Debug))]
184 pub struct dirent {
185     pub d_ino: ino_t,
186     pub d_type: c_uchar,
187     /// d_name is declared in WASI libc as a flexible array member, which
188     /// can't be directly expressed in Rust. As an imperfect workaround,
189     /// declare it as a zero-length array instead.
190     pub d_name: [c_char; 0],
191 }
192 
193 pub const EXIT_SUCCESS: c_int = 0;
194 pub const EXIT_FAILURE: c_int = 1;
195 pub const STDIN_FILENO: c_int = 0;
196 pub const STDOUT_FILENO: c_int = 1;
197 pub const STDERR_FILENO: c_int = 2;
198 pub const SEEK_SET: c_int = 0;
199 pub const SEEK_CUR: c_int = 1;
200 pub const SEEK_END: c_int = 2;
201 pub const _IOFBF: c_int = 0;
202 pub const _IONBF: c_int = 2;
203 pub const _IOLBF: c_int = 1;
204 pub const F_GETFD: c_int = 1;
205 pub const F_SETFD: c_int = 2;
206 pub const F_GETFL: c_int = 3;
207 pub const F_SETFL: c_int = 4;
208 pub const FD_CLOEXEC: c_int = 1;
209 pub const FD_SETSIZE: size_t = 1024;
210 pub const O_APPEND: c_int = 0x0001;
211 pub const O_DSYNC: c_int = 0x0002;
212 pub const O_NONBLOCK: c_int = 0x0004;
213 pub const O_RSYNC: c_int = 0x0008;
214 pub const O_SYNC: c_int = 0x0010;
215 pub const O_CREAT: c_int = 0x0001 << 12;
216 pub const O_DIRECTORY: c_int = 0x0002 << 12;
217 pub const O_EXCL: c_int = 0x0004 << 12;
218 pub const O_TRUNC: c_int = 0x0008 << 12;
219 pub const O_NOFOLLOW: c_int = 0x01000000;
220 pub const O_EXEC: c_int = 0x02000000;
221 pub const O_RDONLY: c_int = 0x04000000;
222 pub const O_SEARCH: c_int = 0x08000000;
223 pub const O_WRONLY: c_int = 0x10000000;
224 pub const O_CLOEXEC: c_int = 0x0;
225 pub const O_RDWR: c_int = O_WRONLY | O_RDONLY;
226 pub const O_ACCMODE: c_int = O_EXEC | O_RDWR | O_SEARCH;
227 pub const O_NOCTTY: c_int = 0x0;
228 pub const POSIX_FADV_DONTNEED: c_int = 4;
229 pub const POSIX_FADV_NOREUSE: c_int = 5;
230 pub const POSIX_FADV_NORMAL: c_int = 0;
231 pub const POSIX_FADV_RANDOM: c_int = 2;
232 pub const POSIX_FADV_SEQUENTIAL: c_int = 1;
233 pub const POSIX_FADV_WILLNEED: c_int = 3;
234 pub const AT_FDCWD: ::c_int = -2;
235 pub const AT_EACCESS: c_int = 0x0;
236 pub const AT_SYMLINK_NOFOLLOW: c_int = 0x1;
237 pub const AT_SYMLINK_FOLLOW: c_int = 0x2;
238 pub const AT_REMOVEDIR: c_int = 0x4;
239 pub const UTIME_OMIT: c_long = 0xfffffffe;
240 pub const UTIME_NOW: c_long = 0xffffffff;
241 pub const S_IFIFO: mode_t = 49152;
242 pub const S_IFCHR: mode_t = 8192;
243 pub const S_IFBLK: mode_t = 24576;
244 pub const S_IFDIR: mode_t = 16384;
245 pub const S_IFREG: mode_t = 32768;
246 pub const S_IFLNK: mode_t = 40960;
247 pub const S_IFSOCK: mode_t = 49152;
248 pub const S_IFMT: mode_t = 57344;
249 pub const S_IXOTH: mode_t = 0x1;
250 pub const S_IWOTH: mode_t = 0x2;
251 pub const S_IROTH: mode_t = 0x4;
252 pub const S_IXGRP: mode_t = 0x8;
253 pub const S_IWGRP: mode_t = 0x10;
254 pub const S_IRGRP: mode_t = 0x20;
255 pub const S_IXUSR: mode_t = 0x40;
256 pub const S_IWUSR: mode_t = 0x80;
257 pub const S_IRUSR: mode_t = 0x100;
258 pub const S_ISVTX: mode_t = 0x200;
259 pub const S_ISGID: mode_t = 0x400;
260 pub const S_ISUID: mode_t = 0x800;
261 pub const DT_UNKNOWN: u8 = 0;
262 pub const DT_BLK: u8 = 1;
263 pub const DT_CHR: u8 = 2;
264 pub const DT_DIR: u8 = 3;
265 pub const DT_REG: u8 = 4;
266 pub const DT_LNK: u8 = 7;
267 pub const FIONREAD: c_int = 1;
268 pub const FIONBIO: c_int = 2;
269 pub const F_OK: ::c_int = 0;
270 pub const R_OK: ::c_int = 4;
271 pub const W_OK: ::c_int = 2;
272 pub const X_OK: ::c_int = 1;
273 pub const POLLIN: ::c_short = 0x1;
274 pub const POLLOUT: ::c_short = 0x2;
275 pub const POLLERR: ::c_short = 0x1000;
276 pub const POLLHUP: ::c_short = 0x2000;
277 pub const POLLNVAL: ::c_short = 0x4000;
278 pub const POLLRDNORM: ::c_short = 0x1;
279 pub const POLLWRNORM: ::c_short = 0x2;
280 
281 pub const E2BIG: c_int = 1;
282 pub const EACCES: c_int = 2;
283 pub const EADDRINUSE: c_int = 3;
284 pub const EADDRNOTAVAIL: c_int = 4;
285 pub const EAFNOSUPPORT: c_int = 5;
286 pub const EAGAIN: c_int = 6;
287 pub const EALREADY: c_int = 7;
288 pub const EBADF: c_int = 8;
289 pub const EBADMSG: c_int = 9;
290 pub const EBUSY: c_int = 10;
291 pub const ECANCELED: c_int = 11;
292 pub const ECHILD: c_int = 12;
293 pub const ECONNABORTED: c_int = 13;
294 pub const ECONNREFUSED: c_int = 14;
295 pub const ECONNRESET: c_int = 15;
296 pub const EDEADLK: c_int = 16;
297 pub const EDESTADDRREQ: c_int = 17;
298 pub const EDOM: c_int = 18;
299 pub const EDQUOT: c_int = 19;
300 pub const EEXIST: c_int = 20;
301 pub const EFAULT: c_int = 21;
302 pub const EFBIG: c_int = 22;
303 pub const EHOSTUNREACH: c_int = 23;
304 pub const EIDRM: c_int = 24;
305 pub const EILSEQ: c_int = 25;
306 pub const EINPROGRESS: c_int = 26;
307 pub const EINTR: c_int = 27;
308 pub const EINVAL: c_int = 28;
309 pub const EIO: c_int = 29;
310 pub const EISCONN: c_int = 30;
311 pub const EISDIR: c_int = 31;
312 pub const ELOOP: c_int = 32;
313 pub const EMFILE: c_int = 33;
314 pub const EMLINK: c_int = 34;
315 pub const EMSGSIZE: c_int = 35;
316 pub const EMULTIHOP: c_int = 36;
317 pub const ENAMETOOLONG: c_int = 37;
318 pub const ENETDOWN: c_int = 38;
319 pub const ENETRESET: c_int = 39;
320 pub const ENETUNREACH: c_int = 40;
321 pub const ENFILE: c_int = 41;
322 pub const ENOBUFS: c_int = 42;
323 pub const ENODEV: c_int = 43;
324 pub const ENOENT: c_int = 44;
325 pub const ENOEXEC: c_int = 45;
326 pub const ENOLCK: c_int = 46;
327 pub const ENOLINK: c_int = 47;
328 pub const ENOMEM: c_int = 48;
329 pub const ENOMSG: c_int = 49;
330 pub const ENOPROTOOPT: c_int = 50;
331 pub const ENOSPC: c_int = 51;
332 pub const ENOSYS: c_int = 52;
333 pub const ENOTCONN: c_int = 53;
334 pub const ENOTDIR: c_int = 54;
335 pub const ENOTEMPTY: c_int = 55;
336 pub const ENOTRECOVERABLE: c_int = 56;
337 pub const ENOTSOCK: c_int = 57;
338 pub const ENOTSUP: c_int = 58;
339 pub const ENOTTY: c_int = 59;
340 pub const ENXIO: c_int = 60;
341 pub const EOVERFLOW: c_int = 61;
342 pub const EOWNERDEAD: c_int = 62;
343 pub const EPERM: c_int = 63;
344 pub const EPIPE: c_int = 64;
345 pub const EPROTO: c_int = 65;
346 pub const EPROTONOSUPPORT: c_int = 66;
347 pub const EPROTOTYPE: c_int = 67;
348 pub const ERANGE: c_int = 68;
349 pub const EROFS: c_int = 69;
350 pub const ESPIPE: c_int = 70;
351 pub const ESRCH: c_int = 71;
352 pub const ESTALE: c_int = 72;
353 pub const ETIMEDOUT: c_int = 73;
354 pub const ETXTBSY: c_int = 74;
355 pub const EXDEV: c_int = 75;
356 pub const ENOTCAPABLE: c_int = 76;
357 pub const EOPNOTSUPP: c_int = ENOTSUP;
358 pub const EWOULDBLOCK: c_int = EAGAIN;
359 
360 pub const _SC_PAGESIZE: c_int = 30;
361 pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
362 pub const _SC_IOV_MAX: c_int = 60;
363 pub const _SC_SYMLOOP_MAX: c_int = 173;
364 
365 pub static CLOCK_MONOTONIC: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_MONOTONIC)) };
366 pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t =
367     unsafe { clockid_t(ptr_addr_of!(_CLOCK_PROCESS_CPUTIME_ID)) };
368 pub static CLOCK_REALTIME: clockid_t = unsafe { clockid_t(ptr_addr_of!(_CLOCK_REALTIME)) };
369 pub static CLOCK_THREAD_CPUTIME_ID: clockid_t =
370     unsafe { clockid_t(ptr_addr_of!(_CLOCK_THREAD_CPUTIME_ID)) };
371 
372 pub const ABDAY_1: ::nl_item = 0x20000;
373 pub const ABDAY_2: ::nl_item = 0x20001;
374 pub const ABDAY_3: ::nl_item = 0x20002;
375 pub const ABDAY_4: ::nl_item = 0x20003;
376 pub const ABDAY_5: ::nl_item = 0x20004;
377 pub const ABDAY_6: ::nl_item = 0x20005;
378 pub const ABDAY_7: ::nl_item = 0x20006;
379 
380 pub const DAY_1: ::nl_item = 0x20007;
381 pub const DAY_2: ::nl_item = 0x20008;
382 pub const DAY_3: ::nl_item = 0x20009;
383 pub const DAY_4: ::nl_item = 0x2000A;
384 pub const DAY_5: ::nl_item = 0x2000B;
385 pub const DAY_6: ::nl_item = 0x2000C;
386 pub const DAY_7: ::nl_item = 0x2000D;
387 
388 pub const ABMON_1: ::nl_item = 0x2000E;
389 pub const ABMON_2: ::nl_item = 0x2000F;
390 pub const ABMON_3: ::nl_item = 0x20010;
391 pub const ABMON_4: ::nl_item = 0x20011;
392 pub const ABMON_5: ::nl_item = 0x20012;
393 pub const ABMON_6: ::nl_item = 0x20013;
394 pub const ABMON_7: ::nl_item = 0x20014;
395 pub const ABMON_8: ::nl_item = 0x20015;
396 pub const ABMON_9: ::nl_item = 0x20016;
397 pub const ABMON_10: ::nl_item = 0x20017;
398 pub const ABMON_11: ::nl_item = 0x20018;
399 pub const ABMON_12: ::nl_item = 0x20019;
400 
401 pub const MON_1: ::nl_item = 0x2001A;
402 pub const MON_2: ::nl_item = 0x2001B;
403 pub const MON_3: ::nl_item = 0x2001C;
404 pub const MON_4: ::nl_item = 0x2001D;
405 pub const MON_5: ::nl_item = 0x2001E;
406 pub const MON_6: ::nl_item = 0x2001F;
407 pub const MON_7: ::nl_item = 0x20020;
408 pub const MON_8: ::nl_item = 0x20021;
409 pub const MON_9: ::nl_item = 0x20022;
410 pub const MON_10: ::nl_item = 0x20023;
411 pub const MON_11: ::nl_item = 0x20024;
412 pub const MON_12: ::nl_item = 0x20025;
413 
414 pub const AM_STR: ::nl_item = 0x20026;
415 pub const PM_STR: ::nl_item = 0x20027;
416 
417 pub const D_T_FMT: ::nl_item = 0x20028;
418 pub const D_FMT: ::nl_item = 0x20029;
419 pub const T_FMT: ::nl_item = 0x2002A;
420 pub const T_FMT_AMPM: ::nl_item = 0x2002B;
421 
422 pub const ERA: ::nl_item = 0x2002C;
423 pub const ERA_D_FMT: ::nl_item = 0x2002E;
424 pub const ALT_DIGITS: ::nl_item = 0x2002F;
425 pub const ERA_D_T_FMT: ::nl_item = 0x20030;
426 pub const ERA_T_FMT: ::nl_item = 0x20031;
427 
428 pub const CODESET: ::nl_item = 14;
429 pub const CRNCYSTR: ::nl_item = 0x4000F;
430 pub const RADIXCHAR: ::nl_item = 0x10000;
431 pub const THOUSEP: ::nl_item = 0x10001;
432 pub const YESEXPR: ::nl_item = 0x50000;
433 pub const NOEXPR: ::nl_item = 0x50001;
434 pub const YESSTR: ::nl_item = 0x50002;
435 pub const NOSTR: ::nl_item = 0x50003;
436 
437 #[cfg_attr(
438     feature = "rustc-dep-of-std",
439     link(
440         name = "c",
441         kind = "static",
442         modifiers = "-bundle",
443         cfg(target_feature = "crt-static")
444     )
445 )]
446 #[cfg_attr(
447     feature = "rustc-dep-of-std",
448     link(name = "c", cfg(not(target_feature = "crt-static")))
449 )]
450 extern "C" {
_Exitnull451     pub fn _Exit(code: c_int) -> !;
_exitnull452     pub fn _exit(code: c_int) -> !;
abortnull453     pub fn abort() -> !;
aligned_allocnull454     pub fn aligned_alloc(a: size_t, b: size_t) -> *mut c_void;
callocnull455     pub fn calloc(amt: size_t, amt2: size_t) -> *mut c_void;
exitnull456     pub fn exit(code: c_int) -> !;
freenull457     pub fn free(ptr: *mut c_void);
getenvnull458     pub fn getenv(s: *const c_char) -> *mut c_char;
mallocnull459     pub fn malloc(amt: size_t) -> *mut c_void;
malloc_usable_sizenull460     pub fn malloc_usable_size(ptr: *mut c_void) -> size_t;
sbrknull461     pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void;
randnull462     pub fn rand() -> c_int;
readnull463     pub fn read(fd: c_int, ptr: *mut c_void, size: size_t) -> ssize_t;
reallocnull464     pub fn realloc(ptr: *mut c_void, amt: size_t) -> *mut c_void;
setenvnull465     pub fn setenv(k: *const c_char, v: *const c_char, a: c_int) -> c_int;
unsetenvnull466     pub fn unsetenv(k: *const c_char) -> c_int;
clearenvnull467     pub fn clearenv() -> ::c_int;
writenull468     pub fn write(fd: c_int, ptr: *const c_void, size: size_t) -> ssize_t;
469     pub static mut environ: *mut *mut c_char;
fopennull470     pub fn fopen(a: *const c_char, b: *const c_char) -> *mut FILE;
freopennull471     pub fn freopen(a: *const c_char, b: *const c_char, f: *mut FILE) -> *mut FILE;
fclosenull472     pub fn fclose(f: *mut FILE) -> c_int;
removenull473     pub fn remove(a: *const c_char) -> c_int;
renamenull474     pub fn rename(a: *const c_char, b: *const c_char) -> c_int;
feofnull475     pub fn feof(f: *mut FILE) -> c_int;
ferrornull476     pub fn ferror(f: *mut FILE) -> c_int;
fflushnull477     pub fn fflush(f: *mut FILE) -> c_int;
clearerrnull478     pub fn clearerr(f: *mut FILE);
fseeknull479     pub fn fseek(f: *mut FILE, b: c_long, c: c_int) -> c_int;
ftellnull480     pub fn ftell(f: *mut FILE) -> c_long;
rewindnull481     pub fn rewind(f: *mut FILE);
fgetposnull482     pub fn fgetpos(f: *mut FILE, pos: *mut fpos_t) -> c_int;
fsetposnull483     pub fn fsetpos(f: *mut FILE, pos: *const fpos_t) -> c_int;
freadnull484     pub fn fread(buf: *mut c_void, a: size_t, b: size_t, f: *mut FILE) -> size_t;
fwritenull485     pub fn fwrite(buf: *const c_void, a: size_t, b: size_t, f: *mut FILE) -> size_t;
fgetcnull486     pub fn fgetc(f: *mut FILE) -> c_int;
getcnull487     pub fn getc(f: *mut FILE) -> c_int;
getcharnull488     pub fn getchar() -> c_int;
ungetcnull489     pub fn ungetc(a: c_int, f: *mut FILE) -> c_int;
fputcnull490     pub fn fputc(a: c_int, f: *mut FILE) -> c_int;
putcnull491     pub fn putc(a: c_int, f: *mut FILE) -> c_int;
putcharnull492     pub fn putchar(a: c_int) -> c_int;
fputsnull493     pub fn fputs(a: *const c_char, f: *mut FILE) -> c_int;
putsnull494     pub fn puts(a: *const c_char) -> c_int;
perrornull495     pub fn perror(a: *const c_char);
srandnull496     pub fn srand(a: c_uint);
atexitnull497     pub fn atexit(a: extern "C" fn()) -> c_int;
at_quick_exitnull498     pub fn at_quick_exit(a: extern "C" fn()) -> c_int;
quick_exitnull499     pub fn quick_exit(a: c_int) -> !;
posix_memalignnull500     pub fn posix_memalign(a: *mut *mut c_void, b: size_t, c: size_t) -> c_int;
rand_rnull501     pub fn rand_r(a: *mut c_uint) -> c_int;
randomnull502     pub fn random() -> c_long;
srandomnull503     pub fn srandom(a: c_uint);
putenvnull504     pub fn putenv(a: *mut c_char) -> c_int;
clocknull505     pub fn clock() -> clock_t;
timenull506     pub fn time(a: *mut time_t) -> time_t;
difftimenull507     pub fn difftime(a: time_t, b: time_t) -> c_double;
mktimenull508     pub fn mktime(a: *mut tm) -> time_t;
strftimenull509     pub fn strftime(a: *mut c_char, b: size_t, c: *const c_char, d: *const tm) -> size_t;
gmtimenull510     pub fn gmtime(a: *const time_t) -> *mut tm;
gmtime_rnull511     pub fn gmtime_r(a: *const time_t, b: *mut tm) -> *mut tm;
localtimenull512     pub fn localtime(a: *const time_t) -> *mut tm;
localtime_rnull513     pub fn localtime_r(a: *const time_t, b: *mut tm) -> *mut tm;
asctime_rnull514     pub fn asctime_r(a: *const tm, b: *mut c_char) -> *mut c_char;
ctime_rnull515     pub fn ctime_r(a: *const time_t, b: *mut c_char) -> *mut c_char;
516 
517     static _CLOCK_MONOTONIC: u8;
518     static _CLOCK_PROCESS_CPUTIME_ID: u8;
519     static _CLOCK_REALTIME: u8;
520     static _CLOCK_THREAD_CPUTIME_ID: u8;
nanosleepnull521     pub fn nanosleep(a: *const timespec, b: *mut timespec) -> c_int;
clock_getresnull522     pub fn clock_getres(a: clockid_t, b: *mut timespec) -> c_int;
clock_gettimenull523     pub fn clock_gettime(a: clockid_t, b: *mut timespec) -> c_int;
clock_nanosleepnull524     pub fn clock_nanosleep(a: clockid_t, a2: c_int, b: *const timespec, c: *mut timespec) -> c_int;
525 
isalnumnull526     pub fn isalnum(c: c_int) -> c_int;
isalphanull527     pub fn isalpha(c: c_int) -> c_int;
iscntrlnull528     pub fn iscntrl(c: c_int) -> c_int;
isdigitnull529     pub fn isdigit(c: c_int) -> c_int;
isgraphnull530     pub fn isgraph(c: c_int) -> c_int;
islowernull531     pub fn islower(c: c_int) -> c_int;
isprintnull532     pub fn isprint(c: c_int) -> c_int;
ispunctnull533     pub fn ispunct(c: c_int) -> c_int;
isspacenull534     pub fn isspace(c: c_int) -> c_int;
isuppernull535     pub fn isupper(c: c_int) -> c_int;
isxdigitnull536     pub fn isxdigit(c: c_int) -> c_int;
isblanknull537     pub fn isblank(c: c_int) -> c_int;
tolowernull538     pub fn tolower(c: c_int) -> c_int;
touppernull539     pub fn toupper(c: c_int) -> c_int;
setvbufnull540     pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int;
setbufnull541     pub fn setbuf(stream: *mut FILE, buf: *mut c_char);
fgetsnull542     pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char;
atofnull543     pub fn atof(s: *const c_char) -> c_double;
atoinull544     pub fn atoi(s: *const c_char) -> c_int;
atolnull545     pub fn atol(s: *const c_char) -> c_long;
atollnull546     pub fn atoll(s: *const c_char) -> c_longlong;
strtodnull547     pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
strtofnull548     pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
strtolnull549     pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
strtollnull550     pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong;
strtoulnull551     pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
strtoullnull552     pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong;
553 
strcpynull554     pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char;
strncpynull555     pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char;
strcatnull556     pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char;
strncatnull557     pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char;
strcmpnull558     pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int;
strncmpnull559     pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int;
strcollnull560     pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int;
strchrnull561     pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char;
strrchrnull562     pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char;
strspnnull563     pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t;
strcspnnull564     pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t;
strdupnull565     pub fn strdup(cs: *const c_char) -> *mut c_char;
strndupnull566     pub fn strndup(cs: *const c_char, n: size_t) -> *mut c_char;
strpbrknull567     pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char;
strstrnull568     pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
strcasecmpnull569     pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int;
strncasecmpnull570     pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int;
strlennull571     pub fn strlen(cs: *const c_char) -> size_t;
strnlennull572     pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t;
strerrornull573     pub fn strerror(n: c_int) -> *mut c_char;
strtoknull574     pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char;
strxfrmnull575     pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t;
576 
memchrnull577     pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void;
memcmpnull578     pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int;
memcpynull579     pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
memmovenull580     pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void;
memsetnull581     pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void;
582 
fprintfnull583     pub fn fprintf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
printfnull584     pub fn printf(format: *const ::c_char, ...) -> ::c_int;
snprintfnull585     pub fn snprintf(s: *mut ::c_char, n: ::size_t, format: *const ::c_char, ...) -> ::c_int;
sprintfnull586     pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int;
fscanfnull587     pub fn fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int;
scanfnull588     pub fn scanf(format: *const ::c_char, ...) -> ::c_int;
sscanfnull589     pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int;
getchar_unlockednull590     pub fn getchar_unlocked() -> ::c_int;
putchar_unlockednull591     pub fn putchar_unlocked(c: ::c_int) -> ::c_int;
592 
shutdownnull593     pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int;
fstatnull594     pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int;
mkdirnull595     pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int;
statnull596     pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
fdopennull597     pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE;
filenonull598     pub fn fileno(stream: *mut ::FILE) -> ::c_int;
opennull599     pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int;
creatnull600     pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int;
fcntlnull601     pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
opendirnull602     pub fn opendir(dirname: *const c_char) -> *mut ::DIR;
fdopendirnull603     pub fn fdopendir(fd: ::c_int) -> *mut ::DIR;
readdirnull604     pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent;
closedirnull605     pub fn closedir(dirp: *mut ::DIR) -> ::c_int;
rewinddirnull606     pub fn rewinddir(dirp: *mut ::DIR);
dirfdnull607     pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
seekdirnull608     pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
telldirnull609     pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
610 
openatnull611     pub fn openat(dirfd: ::c_int, pathname: *const ::c_char, flags: ::c_int, ...) -> ::c_int;
fstatatnull612     pub fn fstatat(
613         dirfd: ::c_int,
614         pathname: *const ::c_char,
615         buf: *mut stat,
616         flags: ::c_int,
617     ) -> ::c_int;
linkatnull618     pub fn linkat(
619         olddirfd: ::c_int,
620         oldpath: *const ::c_char,
621         newdirfd: ::c_int,
622         newpath: *const ::c_char,
623         flags: ::c_int,
624     ) -> ::c_int;
mkdiratnull625     pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int;
readlinkatnull626     pub fn readlinkat(
627         dirfd: ::c_int,
628         pathname: *const ::c_char,
629         buf: *mut ::c_char,
630         bufsiz: ::size_t,
631     ) -> ::ssize_t;
renameatnull632     pub fn renameat(
633         olddirfd: ::c_int,
634         oldpath: *const ::c_char,
635         newdirfd: ::c_int,
636         newpath: *const ::c_char,
637     ) -> ::c_int;
symlinkatnull638     pub fn symlinkat(
639         target: *const ::c_char,
640         newdirfd: ::c_int,
641         linkpath: *const ::c_char,
642     ) -> ::c_int;
unlinkatnull643     pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char, flags: ::c_int) -> ::c_int;
644 
accessnull645     pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int;
closenull646     pub fn close(fd: ::c_int) -> ::c_int;
fpathconfnull647     pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long;
getoptnull648     pub fn getopt(argc: ::c_int, argv: *const *mut c_char, optstr: *const c_char) -> ::c_int;
isattynull649     pub fn isatty(fd: ::c_int) -> ::c_int;
linknull650     pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
lseeknull651     pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
pathconfnull652     pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
rmdirnull653     pub fn rmdir(path: *const c_char) -> ::c_int;
sleepnull654     pub fn sleep(secs: ::c_uint) -> ::c_uint;
unlinknull655     pub fn unlink(c: *const c_char) -> ::c_int;
preadnull656     pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, offset: off_t) -> ::ssize_t;
pwritenull657     pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t, offset: off_t) -> ::ssize_t;
658 
lstatnull659     pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int;
660 
fsyncnull661     pub fn fsync(fd: ::c_int) -> ::c_int;
fdatasyncnull662     pub fn fdatasync(fd: ::c_int) -> ::c_int;
663 
symlinknull664     pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int;
665 
truncatenull666     pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
ftruncatenull667     pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
668 
getrusagenull669     pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
670 
gettimeofdaynull671     pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
timesnull672     pub fn times(buf: *mut ::tms) -> ::clock_t;
673 
strerror_rnull674     pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
675 
usleepnull676     pub fn usleep(secs: ::c_uint) -> ::c_int;
sendnull677     pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, flags: ::c_int) -> ::ssize_t;
recvnull678     pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::ssize_t;
pollnull679     pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
setlocalenull680     pub fn setlocale(category: ::c_int, locale: *const ::c_char) -> *mut ::c_char;
localeconvnull681     pub fn localeconv() -> *mut lconv;
682 
readlinknull683     pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: ::size_t) -> ::ssize_t;
684 
timegmnull685     pub fn timegm(tm: *mut ::tm) -> time_t;
686 
sysconfnull687     pub fn sysconf(name: ::c_int) -> ::c_long;
688 
ioctlnull689     pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
690 
fseekonull691     pub fn fseeko(stream: *mut ::FILE, offset: ::off_t, whence: ::c_int) -> ::c_int;
ftellonull692     pub fn ftello(stream: *mut ::FILE) -> ::off_t;
posix_fallocatenull693     pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int;
694 
strcasestrnull695     pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char;
getlinenull696     pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t;
697 
faccessatnull698     pub fn faccessat(
699         dirfd: ::c_int,
700         pathname: *const ::c_char,
701         mode: ::c_int,
702         flags: ::c_int,
703     ) -> ::c_int;
writevnull704     pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
readvnull705     pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t;
pwritevnull706     pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t)
707         -> ::ssize_t;
preadvnull708     pub fn preadv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t;
posix_fadvisenull709     pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int;
futimensnull710     pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
utimensatnull711     pub fn utimensat(
712         dirfd: ::c_int,
713         path: *const ::c_char,
714         times: *const ::timespec,
715         flag: ::c_int,
716     ) -> ::c_int;
getentropynull717     pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
memrchrnull718     pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
absnull719     pub fn abs(i: c_int) -> c_int;
labsnull720     pub fn labs(i: c_long) -> c_long;
duplocalenull721     pub fn duplocale(base: ::locale_t) -> ::locale_t;
freelocalenull722     pub fn freelocale(loc: ::locale_t);
newlocalenull723     pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t;
uselocalenull724     pub fn uselocale(loc: ::locale_t) -> ::locale_t;
sched_yieldnull725     pub fn sched_yield() -> ::c_int;
getcwdnull726     pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char;
chdirnull727     pub fn chdir(dir: *const c_char) -> ::c_int;
728 
nl_langinfonull729     pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
nl_langinfo_lnull730     pub fn nl_langinfo_l(item: ::nl_item, loc: ::locale_t) -> *mut ::c_char;
731 
__wasilibc_register_preopened_fdnull732     pub fn __wasilibc_register_preopened_fd(fd: c_int, path: *const c_char) -> c_int;
__wasilibc_fd_renumbernull733     pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int;
__wasilibc_unlinkatnull734     pub fn __wasilibc_unlinkat(fd: c_int, path: *const c_char) -> c_int;
__wasilibc_rmdiratnull735     pub fn __wasilibc_rmdirat(fd: c_int, path: *const c_char) -> c_int;
__wasilibc_find_relpathnull736     pub fn __wasilibc_find_relpath(
737         path: *const c_char,
738         abs_prefix: *mut *const c_char,
739         relative_path: *mut *mut c_char,
740         relative_path_len: usize,
741     ) -> c_int;
__wasilibc_tellnull742     pub fn __wasilibc_tell(fd: c_int) -> ::off_t;
__wasilibc_nocwd___wasilibc_unlinkatnull743     pub fn __wasilibc_nocwd___wasilibc_unlinkat(dirfd: c_int, path: *const c_char) -> c_int;
__wasilibc_nocwd___wasilibc_rmdiratnull744     pub fn __wasilibc_nocwd___wasilibc_rmdirat(dirfd: c_int, path: *const c_char) -> c_int;
__wasilibc_nocwd_linkatnull745     pub fn __wasilibc_nocwd_linkat(
746         olddirfd: c_int,
747         oldpath: *const c_char,
748         newdirfd: c_int,
749         newpath: *const c_char,
750         flags: c_int,
751     ) -> c_int;
__wasilibc_nocwd_symlinkatnull752     pub fn __wasilibc_nocwd_symlinkat(
753         target: *const c_char,
754         dirfd: c_int,
755         path: *const c_char,
756     ) -> c_int;
__wasilibc_nocwd_readlinkatnull757     pub fn __wasilibc_nocwd_readlinkat(
758         dirfd: c_int,
759         path: *const c_char,
760         buf: *mut c_char,
761         bufsize: usize,
762     ) -> isize;
__wasilibc_nocwd_faccessatnull763     pub fn __wasilibc_nocwd_faccessat(
764         dirfd: c_int,
765         path: *const c_char,
766         mode: c_int,
767         flags: c_int,
768     ) -> c_int;
__wasilibc_nocwd_renameatnull769     pub fn __wasilibc_nocwd_renameat(
770         olddirfd: c_int,
771         oldpath: *const c_char,
772         newdirfd: c_int,
773         newpath: *const c_char,
774     ) -> c_int;
__wasilibc_nocwd_openat_nomodenull775     pub fn __wasilibc_nocwd_openat_nomode(dirfd: c_int, path: *const c_char, flags: c_int)
776         -> c_int;
__wasilibc_nocwd_fstatatnull777     pub fn __wasilibc_nocwd_fstatat(
778         dirfd: c_int,
779         path: *const c_char,
780         buf: *mut stat,
781         flags: c_int,
782     ) -> c_int;
__wasilibc_nocwd_mkdirat_nomodenull783     pub fn __wasilibc_nocwd_mkdirat_nomode(dirfd: c_int, path: *const c_char) -> c_int;
__wasilibc_nocwd_utimensatnull784     pub fn __wasilibc_nocwd_utimensat(
785         dirfd: c_int,
786         path: *const c_char,
787         times: *const ::timespec,
788         flags: c_int,
789     ) -> c_int;
__wasilibc_nocwd_opendiratnull790     pub fn __wasilibc_nocwd_opendirat(dirfd: c_int, path: *const c_char) -> *mut ::DIR;
__wasilibc_accessnull791     pub fn __wasilibc_access(pathname: *const c_char, mode: c_int, flags: c_int) -> c_int;
__wasilibc_statnull792     pub fn __wasilibc_stat(pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int;
__wasilibc_utimensnull793     pub fn __wasilibc_utimens(
794         pathname: *const c_char,
795         times: *const ::timespec,
796         flags: c_int,
797     ) -> c_int;
__wasilibc_linknull798     pub fn __wasilibc_link(oldpath: *const c_char, newpath: *const c_char, flags: c_int) -> c_int;
__wasilibc_link_oldatnull799     pub fn __wasilibc_link_oldat(
800         olddirfd: c_int,
801         oldpath: *const c_char,
802         newpath: *const c_char,
803         flags: c_int,
804     ) -> c_int;
__wasilibc_link_newatnull805     pub fn __wasilibc_link_newat(
806         oldpath: *const c_char,
807         newdirfd: c_int,
808         newpath: *const c_char,
809         flags: c_int,
810     ) -> c_int;
__wasilibc_rename_oldatnull811     pub fn __wasilibc_rename_oldat(
812         olddirfd: c_int,
813         oldpath: *const c_char,
814         newpath: *const c_char,
815     ) -> c_int;
__wasilibc_rename_newatnull816     pub fn __wasilibc_rename_newat(
817         oldpath: *const c_char,
818         newdirfd: c_int,
819         newpath: *const c_char,
820     ) -> c_int;
821 
arc4randomnull822     pub fn arc4random() -> u32;
arc4random_bufnull823     pub fn arc4random_buf(a: *mut c_void, b: size_t);
arc4random_uniformnull824     pub fn arc4random_uniform(a: u32) -> u32;
825 }
826