1 //! [wasi-libc](https://github.com/WebAssembly/wasi-libc) definitions. 2 //! 3 //! `wasi-libc` project provides multiple libraries including emulated features, but we list only 4 //! basic features with `libc.a` here. 5 6 use core::iter::Iterator; 7 8 use super::{Send, Sync}; 9 use c_void; 10 11 pub type c_char = i8; 12 pub type c_uchar = u8; 13 pub type c_schar = i8; 14 pub type c_int = i32; 15 pub type c_uint = u32; 16 pub type c_short = i16; 17 pub type c_ushort = u16; 18 pub type c_long = i32; 19 pub type c_ulong = u32; 20 pub type c_longlong = i64; 21 pub type c_ulonglong = u64; 22 pub type intmax_t = i64; 23 pub type uintmax_t = u64; 24 pub type size_t = usize; 25 pub type ssize_t = isize; 26 pub type ptrdiff_t = isize; 27 pub type intptr_t = isize; 28 pub type uintptr_t = usize; 29 pub type off_t = i64; 30 pub type pid_t = i32; 31 pub type clock_t = c_longlong; 32 pub type time_t = c_longlong; 33 pub type c_double = f64; 34 pub type c_float = f32; 35 pub type ino_t = u64; 36 pub type sigset_t = c_uchar; 37 pub type suseconds_t = c_longlong; 38 pub type mode_t = u32; 39 pub type dev_t = u64; 40 pub type uid_t = u32; 41 pub type gid_t = u32; 42 pub type nlink_t = u64; 43 pub type blksize_t = c_long; 44 pub type blkcnt_t = i64; 45 pub type nfds_t = c_ulong; 46 pub type wchar_t = i32; 47 pub type nl_item = c_int; 48 pub type __wasi_rights_t = u64; 49 50 s_no_extra_traits! { 51 #[repr(align(16))] 52 #[allow(missing_debug_implementations)] 53 pub struct max_align_t { 54 priv_: [f64; 4] 55 } 56 } 57 58 #[allow(missing_copy_implementations)] 59 #[cfg_attr(feature = "extra_traits", derive(Debug))] 60 pub enum FILE {} 61 #[allow(missing_copy_implementations)] 62 #[cfg_attr(feature = "extra_traits", derive(Debug))] 63 pub enum DIR {} 64 #[allow(missing_copy_implementations)] 65 #[cfg_attr(feature = "extra_traits", derive(Debug))] 66 pub enum __locale_struct {} 67 68 pub type locale_t = *mut __locale_struct; 69 70 s_paren! { 71 // in wasi-libc clockid_t is const struct __clockid* (where __clockid is an opaque struct), 72 // but that's an implementation detail that we don't want to have to deal with 73 #[repr(transparent)] 74 #[allow(dead_code)] 75 pub struct clockid_t(*const u8); 76 } 77 78 unsafe impl Send for clockid_t {} 79 unsafe impl Sync for clockid_t {} 80 81 s! { 82 #[repr(align(8))] 83 pub struct fpos_t { 84 data: [u8; 16], 85 } 86 87 pub struct tm { 88 pub tm_sec: c_int, 89 pub tm_min: c_int, 90 pub tm_hour: c_int, 91 pub tm_mday: c_int, 92 pub tm_mon: c_int, 93 pub tm_year: c_int, 94 pub tm_wday: c_int, 95 pub tm_yday: c_int, 96 pub tm_isdst: c_int, 97 pub __tm_gmtoff: c_int, 98 pub __tm_zone: *const c_char, 99 pub __tm_nsec: c_int, 100 } 101 102 pub struct timeval { 103 pub tv_sec: time_t, 104 pub tv_usec: suseconds_t, 105 } 106 107 pub struct timespec { 108 pub tv_sec: time_t, 109 pub tv_nsec: c_long, 110 } 111 112 pub struct tms { 113 pub tms_utime: clock_t, 114 pub tms_stime: clock_t, 115 pub tms_cutime: clock_t, 116 pub tms_cstime: clock_t, 117 } 118 119 pub struct itimerspec { 120 pub it_interval: timespec, 121 pub it_value: timespec, 122 } 123 124 pub struct iovec { 125 pub iov_base: *mut c_void, 126 pub iov_len: size_t, 127 } 128 129 pub struct lconv { 130 pub decimal_point: *mut c_char, 131 pub thousands_sep: *mut c_char, 132 pub grouping: *mut c_char, 133 pub int_curr_symbol: *mut c_char, 134 pub currency_symbol: *mut c_char, 135 pub mon_decimal_point: *mut c_char, 136 pub mon_thousands_sep: *mut c_char, 137 pub mon_grouping: *mut c_char, 138 pub positive_sign: *mut c_char, 139 pub negative_sign: *mut c_char, 140 pub int_frac_digits: c_char, 141 pub frac_digits: c_char, 142 pub p_cs_precedes: c_char, 143 pub p_sep_by_space: c_char, 144 pub n_cs_precedes: c_char, 145 pub n_sep_by_space: c_char, 146 pub p_sign_posn: c_char, 147 pub n_sign_posn: c_char, 148 pub int_p_cs_precedes: c_char, 149 pub int_p_sep_by_space: c_char, 150 pub int_n_cs_precedes: c_char, 151 pub int_n_sep_by_space: c_char, 152 pub int_p_sign_posn: c_char, 153 pub int_n_sign_posn: c_char, 154 } 155 156 pub struct pollfd { 157 pub fd: c_int, 158 pub events: c_short, 159 pub revents: c_short, 160 } 161 162 pub struct rusage { 163 pub ru_utime: timeval, 164 pub ru_stime: timeval, 165 } 166 167 pub struct stat { 168 pub st_dev: dev_t, 169 pub st_ino: ino_t, 170 pub st_nlink: nlink_t, 171 pub st_mode: mode_t, 172 pub st_uid: uid_t, 173 pub st_gid: gid_t, 174 __pad0: c_uint, 175 pub st_rdev: dev_t, 176 pub st_size: off_t, 177 pub st_blksize: blksize_t, 178 pub st_blocks: blkcnt_t, 179 pub st_atim: timespec, 180 pub st_mtim: timespec, 181 pub st_ctim: timespec, 182 __reserved: [c_longlong; 3], 183 } 184 185 pub struct fd_set { 186 __nfds: usize, 187 __fds: [c_int; FD_SETSIZE as usize], 188 } 189 } 190 191 // Declare dirent outside of s! so that it doesn't implement Copy, Eq, Hash, 192 // etc., since it contains a flexible array member with a dynamic size. 193 #[repr(C)] 194 #[allow(missing_copy_implementations)] 195 #[cfg_attr(feature = "extra_traits", derive(Debug))] 196 pub struct dirent { 197 pub d_ino: ino_t, 198 pub d_type: c_uchar, 199 /// d_name is declared in WASI libc as a flexible array member, which 200 /// can't be directly expressed in Rust. As an imperfect workaround, 201 /// declare it as a zero-length array instead. 202 pub d_name: [c_char; 0], 203 } 204 205 pub const EXIT_SUCCESS: c_int = 0; 206 pub const EXIT_FAILURE: c_int = 1; 207 pub const STDIN_FILENO: c_int = 0; 208 pub const STDOUT_FILENO: c_int = 1; 209 pub const STDERR_FILENO: c_int = 2; 210 pub const SEEK_SET: c_int = 0; 211 pub const SEEK_CUR: c_int = 1; 212 pub const SEEK_END: c_int = 2; 213 pub const _IOFBF: c_int = 0; 214 pub const _IONBF: c_int = 2; 215 pub const _IOLBF: c_int = 1; 216 pub const F_GETFD: c_int = 1; 217 pub const F_SETFD: c_int = 2; 218 pub const F_GETFL: c_int = 3; 219 pub const F_SETFL: c_int = 4; 220 pub const FD_CLOEXEC: c_int = 1; 221 pub const FD_SETSIZE: size_t = 1024; 222 pub const O_APPEND: c_int = 0x0001; 223 pub const O_DSYNC: c_int = 0x0002; 224 pub const O_NONBLOCK: c_int = 0x0004; 225 pub const O_RSYNC: c_int = 0x0008; 226 pub const O_SYNC: c_int = 0x0010; 227 pub const O_CREAT: c_int = 0x0001 << 12; 228 pub const O_DIRECTORY: c_int = 0x0002 << 12; 229 pub const O_EXCL: c_int = 0x0004 << 12; 230 pub const O_TRUNC: c_int = 0x0008 << 12; 231 pub const O_NOFOLLOW: c_int = 0x01000000; 232 pub const O_EXEC: c_int = 0x02000000; 233 pub const O_RDONLY: c_int = 0x04000000; 234 pub const O_SEARCH: c_int = 0x08000000; 235 pub const O_WRONLY: c_int = 0x10000000; 236 pub const O_CLOEXEC: c_int = 0x0; 237 pub const O_RDWR: c_int = O_WRONLY | O_RDONLY; 238 pub const O_ACCMODE: c_int = O_EXEC | O_RDWR | O_SEARCH; 239 pub const O_NOCTTY: c_int = 0x0; 240 pub const POSIX_FADV_DONTNEED: c_int = 4; 241 pub const POSIX_FADV_NOREUSE: c_int = 5; 242 pub const POSIX_FADV_NORMAL: c_int = 0; 243 pub const POSIX_FADV_RANDOM: c_int = 2; 244 pub const POSIX_FADV_SEQUENTIAL: c_int = 1; 245 pub const POSIX_FADV_WILLNEED: c_int = 3; 246 pub const AT_FDCWD: ::c_int = -2; 247 pub const AT_EACCESS: c_int = 0x0; 248 pub const AT_SYMLINK_NOFOLLOW: c_int = 0x1; 249 pub const AT_SYMLINK_FOLLOW: c_int = 0x2; 250 pub const AT_REMOVEDIR: c_int = 0x4; 251 pub const UTIME_OMIT: c_long = 0xfffffffe; 252 pub const UTIME_NOW: c_long = 0xffffffff; 253 pub const S_IFIFO: mode_t = 0o1_0000; 254 pub const S_IFCHR: mode_t = 0o2_0000; 255 pub const S_IFBLK: mode_t = 0o6_0000; 256 pub const S_IFDIR: mode_t = 0o4_0000; 257 pub const S_IFREG: mode_t = 0o10_0000; 258 pub const S_IFLNK: mode_t = 0o12_0000; 259 pub const S_IFSOCK: mode_t = 0o14_0000; 260 pub const S_IFMT: mode_t = 0o17_0000; 261 pub const S_IRWXO: mode_t = 0o0007; 262 pub const S_IXOTH: mode_t = 0o0001; 263 pub const S_IWOTH: mode_t = 0o0002; 264 pub const S_IROTH: mode_t = 0o0004; 265 pub const S_IRWXG: mode_t = 0o0070; 266 pub const S_IXGRP: mode_t = 0o0010; 267 pub const S_IWGRP: mode_t = 0o0020; 268 pub const S_IRGRP: mode_t = 0o0040; 269 pub const S_IRWXU: mode_t = 0o0700; 270 pub const S_IXUSR: mode_t = 0o0100; 271 pub const S_IWUSR: mode_t = 0o0200; 272 pub const S_IRUSR: mode_t = 0o0400; 273 pub const S_ISVTX: mode_t = 0o1000; 274 pub const S_ISGID: mode_t = 0o2000; 275 pub const S_ISUID: mode_t = 0o4000; 276 pub const DT_UNKNOWN: u8 = 0; 277 pub const DT_BLK: u8 = 1; 278 pub const DT_CHR: u8 = 2; 279 pub const DT_DIR: u8 = 3; 280 pub const DT_REG: u8 = 4; 281 pub const DT_LNK: u8 = 7; 282 pub const FIONREAD: c_int = 1; 283 pub const FIONBIO: c_int = 2; 284 pub const F_OK: ::c_int = 0; 285 pub const R_OK: ::c_int = 4; 286 pub const W_OK: ::c_int = 2; 287 pub const X_OK: ::c_int = 1; 288 pub const POLLIN: ::c_short = 0x1; 289 pub const POLLOUT: ::c_short = 0x2; 290 pub const POLLERR: ::c_short = 0x1000; 291 pub const POLLHUP: ::c_short = 0x2000; 292 pub const POLLNVAL: ::c_short = 0x4000; 293 pub const POLLRDNORM: ::c_short = 0x1; 294 pub const POLLWRNORM: ::c_short = 0x2; 295 296 pub const E2BIG: c_int = 1; 297 pub const EACCES: c_int = 2; 298 pub const EADDRINUSE: c_int = 3; 299 pub const EADDRNOTAVAIL: c_int = 4; 300 pub const EAFNOSUPPORT: c_int = 5; 301 pub const EAGAIN: c_int = 6; 302 pub const EALREADY: c_int = 7; 303 pub const EBADF: c_int = 8; 304 pub const EBADMSG: c_int = 9; 305 pub const EBUSY: c_int = 10; 306 pub const ECANCELED: c_int = 11; 307 pub const ECHILD: c_int = 12; 308 pub const ECONNABORTED: c_int = 13; 309 pub const ECONNREFUSED: c_int = 14; 310 pub const ECONNRESET: c_int = 15; 311 pub const EDEADLK: c_int = 16; 312 pub const EDESTADDRREQ: c_int = 17; 313 pub const EDOM: c_int = 18; 314 pub const EDQUOT: c_int = 19; 315 pub const EEXIST: c_int = 20; 316 pub const EFAULT: c_int = 21; 317 pub const EFBIG: c_int = 22; 318 pub const EHOSTUNREACH: c_int = 23; 319 pub const EIDRM: c_int = 24; 320 pub const EILSEQ: c_int = 25; 321 pub const EINPROGRESS: c_int = 26; 322 pub const EINTR: c_int = 27; 323 pub const EINVAL: c_int = 28; 324 pub const EIO: c_int = 29; 325 pub const EISCONN: c_int = 30; 326 pub const EISDIR: c_int = 31; 327 pub const ELOOP: c_int = 32; 328 pub const EMFILE: c_int = 33; 329 pub const EMLINK: c_int = 34; 330 pub const EMSGSIZE: c_int = 35; 331 pub const EMULTIHOP: c_int = 36; 332 pub const ENAMETOOLONG: c_int = 37; 333 pub const ENETDOWN: c_int = 38; 334 pub const ENETRESET: c_int = 39; 335 pub const ENETUNREACH: c_int = 40; 336 pub const ENFILE: c_int = 41; 337 pub const ENOBUFS: c_int = 42; 338 pub const ENODEV: c_int = 43; 339 pub const ENOENT: c_int = 44; 340 pub const ENOEXEC: c_int = 45; 341 pub const ENOLCK: c_int = 46; 342 pub const ENOLINK: c_int = 47; 343 pub const ENOMEM: c_int = 48; 344 pub const ENOMSG: c_int = 49; 345 pub const ENOPROTOOPT: c_int = 50; 346 pub const ENOSPC: c_int = 51; 347 pub const ENOSYS: c_int = 52; 348 pub const ENOTCONN: c_int = 53; 349 pub const ENOTDIR: c_int = 54; 350 pub const ENOTEMPTY: c_int = 55; 351 pub const ENOTRECOVERABLE: c_int = 56; 352 pub const ENOTSOCK: c_int = 57; 353 pub const ENOTSUP: c_int = 58; 354 pub const ENOTTY: c_int = 59; 355 pub const ENXIO: c_int = 60; 356 pub const EOVERFLOW: c_int = 61; 357 pub const EOWNERDEAD: c_int = 62; 358 pub const EPERM: c_int = 63; 359 pub const EPIPE: c_int = 64; 360 pub const EPROTO: c_int = 65; 361 pub const EPROTONOSUPPORT: c_int = 66; 362 pub const EPROTOTYPE: c_int = 67; 363 pub const ERANGE: c_int = 68; 364 pub const EROFS: c_int = 69; 365 pub const ESPIPE: c_int = 70; 366 pub const ESRCH: c_int = 71; 367 pub const ESTALE: c_int = 72; 368 pub const ETIMEDOUT: c_int = 73; 369 pub const ETXTBSY: c_int = 74; 370 pub const EXDEV: c_int = 75; 371 pub const ENOTCAPABLE: c_int = 76; 372 pub const EOPNOTSUPP: c_int = ENOTSUP; 373 pub const EWOULDBLOCK: c_int = EAGAIN; 374 375 pub const _SC_PAGESIZE: c_int = 30; 376 pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; 377 pub const _SC_IOV_MAX: c_int = 60; 378 pub const _SC_SYMLOOP_MAX: c_int = 173; 379 380 cfg_if! { 381 if #[cfg(libc_ctest)] { 382 // skip these constants when this is active because `ctest` currently 383 // panics on parsing the constants below 384 } else { 385 // `addr_of!(EXTERN_STATIC)` is now safe; remove `unsafe` when MSRV >= 1.82 386 #[allow(unused_unsafe)] 387 pub static CLOCK_MONOTONIC: clockid_t = 388 clockid_t(core::ptr::addr_of!(_CLOCK_MONOTONIC)); 389 #[allow(unused_unsafe)] 390 pub static CLOCK_PROCESS_CPUTIME_ID: clockid_t = 391 clockid_t(core::ptr::addr_of!(_CLOCK_PROCESS_CPUTIME_ID)); 392 #[allow(unused_unsafe)] 393 pub static CLOCK_REALTIME: clockid_t = 394 clockid_t(core::ptr::addr_of!(_CLOCK_REALTIME)); 395 #[allow(unused_unsafe)] 396 pub static CLOCK_THREAD_CPUTIME_ID: clockid_t = 397 clockid_t(core::ptr::addr_of!(_CLOCK_THREAD_CPUTIME_ID)); 398 } 399 } 400 401 pub const ABDAY_1: ::nl_item = 0x20000; 402 pub const ABDAY_2: ::nl_item = 0x20001; 403 pub const ABDAY_3: ::nl_item = 0x20002; 404 pub const ABDAY_4: ::nl_item = 0x20003; 405 pub const ABDAY_5: ::nl_item = 0x20004; 406 pub const ABDAY_6: ::nl_item = 0x20005; 407 pub const ABDAY_7: ::nl_item = 0x20006; 408 409 pub const DAY_1: ::nl_item = 0x20007; 410 pub const DAY_2: ::nl_item = 0x20008; 411 pub const DAY_3: ::nl_item = 0x20009; 412 pub const DAY_4: ::nl_item = 0x2000A; 413 pub const DAY_5: ::nl_item = 0x2000B; 414 pub const DAY_6: ::nl_item = 0x2000C; 415 pub const DAY_7: ::nl_item = 0x2000D; 416 417 pub const ABMON_1: ::nl_item = 0x2000E; 418 pub const ABMON_2: ::nl_item = 0x2000F; 419 pub const ABMON_3: ::nl_item = 0x20010; 420 pub const ABMON_4: ::nl_item = 0x20011; 421 pub const ABMON_5: ::nl_item = 0x20012; 422 pub const ABMON_6: ::nl_item = 0x20013; 423 pub const ABMON_7: ::nl_item = 0x20014; 424 pub const ABMON_8: ::nl_item = 0x20015; 425 pub const ABMON_9: ::nl_item = 0x20016; 426 pub const ABMON_10: ::nl_item = 0x20017; 427 pub const ABMON_11: ::nl_item = 0x20018; 428 pub const ABMON_12: ::nl_item = 0x20019; 429 430 pub const MON_1: ::nl_item = 0x2001A; 431 pub const MON_2: ::nl_item = 0x2001B; 432 pub const MON_3: ::nl_item = 0x2001C; 433 pub const MON_4: ::nl_item = 0x2001D; 434 pub const MON_5: ::nl_item = 0x2001E; 435 pub const MON_6: ::nl_item = 0x2001F; 436 pub const MON_7: ::nl_item = 0x20020; 437 pub const MON_8: ::nl_item = 0x20021; 438 pub const MON_9: ::nl_item = 0x20022; 439 pub const MON_10: ::nl_item = 0x20023; 440 pub const MON_11: ::nl_item = 0x20024; 441 pub const MON_12: ::nl_item = 0x20025; 442 443 pub const AM_STR: ::nl_item = 0x20026; 444 pub const PM_STR: ::nl_item = 0x20027; 445 446 pub const D_T_FMT: ::nl_item = 0x20028; 447 pub const D_FMT: ::nl_item = 0x20029; 448 pub const T_FMT: ::nl_item = 0x2002A; 449 pub const T_FMT_AMPM: ::nl_item = 0x2002B; 450 451 pub const ERA: ::nl_item = 0x2002C; 452 pub const ERA_D_FMT: ::nl_item = 0x2002E; 453 pub const ALT_DIGITS: ::nl_item = 0x2002F; 454 pub const ERA_D_T_FMT: ::nl_item = 0x20030; 455 pub const ERA_T_FMT: ::nl_item = 0x20031; 456 457 pub const CODESET: ::nl_item = 14; 458 pub const CRNCYSTR: ::nl_item = 0x4000F; 459 pub const RADIXCHAR: ::nl_item = 0x10000; 460 pub const THOUSEP: ::nl_item = 0x10001; 461 pub const YESEXPR: ::nl_item = 0x50000; 462 pub const NOEXPR: ::nl_item = 0x50001; 463 pub const YESSTR: ::nl_item = 0x50002; 464 pub const NOSTR: ::nl_item = 0x50003; 465 466 f! { 467 pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool { 468 let set = &*set; 469 let n = set.__nfds; 470 return set.__fds[..n].iter().any(|p| *p == fd) 471 } 472 473 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { 474 let set = &mut *set; 475 let n = set.__nfds; 476 if !set.__fds[..n].iter().any(|p| *p == fd) { 477 set.__nfds = n + 1; 478 set.__fds[n] = fd; 479 } 480 } 481 482 pub fn FD_ZERO(set: *mut fd_set) -> () { 483 (*set).__nfds = 0; 484 return 485 } 486 } 487 488 #[cfg_attr( 489 feature = "rustc-dep-of-std", 490 link( 491 name = "c", 492 kind = "static", 493 modifiers = "-bundle", 494 cfg(target_feature = "crt-static") 495 ) 496 )] 497 #[cfg_attr( 498 feature = "rustc-dep-of-std", 499 link(name = "c", cfg(not(target_feature = "crt-static"))) 500 )] 501 extern "C" { 502 pub fn _Exit(code: c_int) -> !; 503 pub fn _exit(code: c_int) -> !; 504 pub fn abort() -> !; 505 pub fn aligned_alloc(a: size_t, b: size_t) -> *mut c_void; 506 pub fn calloc(amt: size_t, amt2: size_t) -> *mut c_void; 507 pub fn exit(code: c_int) -> !; 508 pub fn free(ptr: *mut c_void); 509 pub fn getenv(s: *const c_char) -> *mut c_char; 510 pub fn malloc(amt: size_t) -> *mut c_void; 511 pub fn malloc_usable_size(ptr: *mut c_void) -> size_t; 512 pub fn sbrk(increment: ::intptr_t) -> *mut ::c_void; 513 pub fn rand() -> c_int; 514 pub fn read(fd: c_int, ptr: *mut c_void, size: size_t) -> ssize_t; 515 pub fn realloc(ptr: *mut c_void, amt: size_t) -> *mut c_void; 516 pub fn setenv(k: *const c_char, v: *const c_char, a: c_int) -> c_int; 517 pub fn unsetenv(k: *const c_char) -> c_int; 518 pub fn clearenv() -> ::c_int; 519 pub fn write(fd: c_int, ptr: *const c_void, size: size_t) -> ssize_t; 520 pub static mut environ: *mut *mut c_char; 521 pub fn fopen(a: *const c_char, b: *const c_char) -> *mut FILE; 522 pub fn freopen(a: *const c_char, b: *const c_char, f: *mut FILE) -> *mut FILE; 523 pub fn fclose(f: *mut FILE) -> c_int; 524 pub fn remove(a: *const c_char) -> c_int; 525 pub fn rename(a: *const c_char, b: *const c_char) -> c_int; 526 pub fn feof(f: *mut FILE) -> c_int; 527 pub fn ferror(f: *mut FILE) -> c_int; 528 pub fn fflush(f: *mut FILE) -> c_int; 529 pub fn clearerr(f: *mut FILE); 530 pub fn fseek(f: *mut FILE, b: c_long, c: c_int) -> c_int; 531 pub fn ftell(f: *mut FILE) -> c_long; 532 pub fn rewind(f: *mut FILE); 533 pub fn fgetpos(f: *mut FILE, pos: *mut fpos_t) -> c_int; 534 pub fn fsetpos(f: *mut FILE, pos: *const fpos_t) -> c_int; 535 pub fn fread(buf: *mut c_void, a: size_t, b: size_t, f: *mut FILE) -> size_t; 536 pub fn fwrite(buf: *const c_void, a: size_t, b: size_t, f: *mut FILE) -> size_t; 537 pub fn fgetc(f: *mut FILE) -> c_int; 538 pub fn getc(f: *mut FILE) -> c_int; 539 pub fn getchar() -> c_int; 540 pub fn ungetc(a: c_int, f: *mut FILE) -> c_int; 541 pub fn fputc(a: c_int, f: *mut FILE) -> c_int; 542 pub fn putc(a: c_int, f: *mut FILE) -> c_int; 543 pub fn putchar(a: c_int) -> c_int; 544 pub fn fputs(a: *const c_char, f: *mut FILE) -> c_int; 545 pub fn puts(a: *const c_char) -> c_int; 546 pub fn perror(a: *const c_char); 547 pub fn srand(a: c_uint); 548 pub fn atexit(a: extern "C" fn()) -> c_int; 549 pub fn at_quick_exit(a: extern "C" fn()) -> c_int; 550 pub fn quick_exit(a: c_int) -> !; 551 pub fn posix_memalign(a: *mut *mut c_void, b: size_t, c: size_t) -> c_int; 552 pub fn rand_r(a: *mut c_uint) -> c_int; 553 pub fn random() -> c_long; 554 pub fn srandom(a: c_uint); 555 pub fn putenv(a: *mut c_char) -> c_int; 556 pub fn clock() -> clock_t; 557 pub fn time(a: *mut time_t) -> time_t; 558 pub fn difftime(a: time_t, b: time_t) -> c_double; 559 pub fn mktime(a: *mut tm) -> time_t; 560 pub fn strftime(a: *mut c_char, b: size_t, c: *const c_char, d: *const tm) -> size_t; 561 pub fn gmtime(a: *const time_t) -> *mut tm; 562 pub fn gmtime_r(a: *const time_t, b: *mut tm) -> *mut tm; 563 pub fn localtime(a: *const time_t) -> *mut tm; 564 pub fn localtime_r(a: *const time_t, b: *mut tm) -> *mut tm; 565 pub fn asctime_r(a: *const tm, b: *mut c_char) -> *mut c_char; 566 pub fn ctime_r(a: *const time_t, b: *mut c_char) -> *mut c_char; 567 568 static _CLOCK_MONOTONIC: u8; 569 static _CLOCK_PROCESS_CPUTIME_ID: u8; 570 static _CLOCK_REALTIME: u8; 571 static _CLOCK_THREAD_CPUTIME_ID: u8; 572 pub fn nanosleep(a: *const timespec, b: *mut timespec) -> c_int; 573 pub fn clock_getres(a: clockid_t, b: *mut timespec) -> c_int; 574 pub fn clock_gettime(a: clockid_t, b: *mut timespec) -> c_int; 575 pub fn clock_nanosleep(a: clockid_t, a2: c_int, b: *const timespec, c: *mut timespec) -> c_int; 576 577 pub fn isalnum(c: c_int) -> c_int; 578 pub fn isalpha(c: c_int) -> c_int; 579 pub fn iscntrl(c: c_int) -> c_int; 580 pub fn isdigit(c: c_int) -> c_int; 581 pub fn isgraph(c: c_int) -> c_int; 582 pub fn islower(c: c_int) -> c_int; 583 pub fn isprint(c: c_int) -> c_int; 584 pub fn ispunct(c: c_int) -> c_int; 585 pub fn isspace(c: c_int) -> c_int; 586 pub fn isupper(c: c_int) -> c_int; 587 pub fn isxdigit(c: c_int) -> c_int; 588 pub fn isblank(c: c_int) -> c_int; 589 pub fn tolower(c: c_int) -> c_int; 590 pub fn toupper(c: c_int) -> c_int; 591 pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; 592 pub fn setbuf(stream: *mut FILE, buf: *mut c_char); 593 pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; 594 pub fn atof(s: *const c_char) -> c_double; 595 pub fn atoi(s: *const c_char) -> c_int; 596 pub fn atol(s: *const c_char) -> c_long; 597 pub fn atoll(s: *const c_char) -> c_longlong; 598 pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double; 599 pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float; 600 pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long; 601 pub fn strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; 602 pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; 603 pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; 604 605 pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; 606 pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; 607 pub fn strcat(s: *mut c_char, ct: *const c_char) -> *mut c_char; 608 pub fn strncat(s: *mut c_char, ct: *const c_char, n: size_t) -> *mut c_char; 609 pub fn strcmp(cs: *const c_char, ct: *const c_char) -> c_int; 610 pub fn strncmp(cs: *const c_char, ct: *const c_char, n: size_t) -> c_int; 611 pub fn strcoll(cs: *const c_char, ct: *const c_char) -> c_int; 612 pub fn strchr(cs: *const c_char, c: c_int) -> *mut c_char; 613 pub fn strrchr(cs: *const c_char, c: c_int) -> *mut c_char; 614 pub fn strspn(cs: *const c_char, ct: *const c_char) -> size_t; 615 pub fn strcspn(cs: *const c_char, ct: *const c_char) -> size_t; 616 pub fn strdup(cs: *const c_char) -> *mut c_char; 617 pub fn strndup(cs: *const c_char, n: size_t) -> *mut c_char; 618 pub fn strpbrk(cs: *const c_char, ct: *const c_char) -> *mut c_char; 619 pub fn strstr(cs: *const c_char, ct: *const c_char) -> *mut c_char; 620 pub fn strcasecmp(s1: *const c_char, s2: *const c_char) -> c_int; 621 pub fn strncasecmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int; 622 pub fn strlen(cs: *const c_char) -> size_t; 623 pub fn strnlen(cs: *const c_char, maxlen: size_t) -> size_t; 624 pub fn strerror(n: c_int) -> *mut c_char; 625 pub fn strtok(s: *mut c_char, t: *const c_char) -> *mut c_char; 626 pub fn strxfrm(s: *mut c_char, ct: *const c_char, n: size_t) -> size_t; 627 628 pub fn memchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; 629 pub fn memcmp(cx: *const c_void, ct: *const c_void, n: size_t) -> c_int; 630 pub fn memcpy(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; 631 pub fn memmove(dest: *mut c_void, src: *const c_void, n: size_t) -> *mut c_void; 632 pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; 633 634 pub fn fprintf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int; 635 pub fn printf(format: *const ::c_char, ...) -> ::c_int; 636 pub fn snprintf(s: *mut ::c_char, n: ::size_t, format: *const ::c_char, ...) -> ::c_int; 637 pub fn sprintf(s: *mut ::c_char, format: *const ::c_char, ...) -> ::c_int; 638 pub fn fscanf(stream: *mut ::FILE, format: *const ::c_char, ...) -> ::c_int; 639 pub fn scanf(format: *const ::c_char, ...) -> ::c_int; 640 pub fn sscanf(s: *const ::c_char, format: *const ::c_char, ...) -> ::c_int; 641 pub fn getchar_unlocked() -> ::c_int; 642 pub fn putchar_unlocked(c: ::c_int) -> ::c_int; 643 644 pub fn shutdown(socket: ::c_int, how: ::c_int) -> ::c_int; 645 pub fn fstat(fildes: ::c_int, buf: *mut stat) -> ::c_int; 646 pub fn mkdir(path: *const c_char, mode: mode_t) -> ::c_int; 647 pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int; 648 pub fn fdopen(fd: ::c_int, mode: *const c_char) -> *mut ::FILE; 649 pub fn fileno(stream: *mut ::FILE) -> ::c_int; 650 pub fn open(path: *const c_char, oflag: ::c_int, ...) -> ::c_int; 651 pub fn creat(path: *const c_char, mode: mode_t) -> ::c_int; 652 pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int; 653 pub fn opendir(dirname: *const c_char) -> *mut ::DIR; 654 pub fn fdopendir(fd: ::c_int) -> *mut ::DIR; 655 pub fn readdir(dirp: *mut ::DIR) -> *mut ::dirent; 656 pub fn closedir(dirp: *mut ::DIR) -> ::c_int; 657 pub fn rewinddir(dirp: *mut ::DIR); 658 pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; 659 pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); 660 pub fn telldir(dirp: *mut ::DIR) -> ::c_long; 661 662 pub fn openat(dirfd: ::c_int, pathname: *const ::c_char, flags: ::c_int, ...) -> ::c_int; 663 pub fn fstatat( 664 dirfd: ::c_int, 665 pathname: *const ::c_char, 666 buf: *mut stat, 667 flags: ::c_int, 668 ) -> ::c_int; 669 pub fn linkat( 670 olddirfd: ::c_int, 671 oldpath: *const ::c_char, 672 newdirfd: ::c_int, 673 newpath: *const ::c_char, 674 flags: ::c_int, 675 ) -> ::c_int; 676 pub fn mkdirat(dirfd: ::c_int, pathname: *const ::c_char, mode: ::mode_t) -> ::c_int; 677 pub fn readlinkat( 678 dirfd: ::c_int, 679 pathname: *const ::c_char, 680 buf: *mut ::c_char, 681 bufsiz: ::size_t, 682 ) -> ::ssize_t; 683 pub fn renameat( 684 olddirfd: ::c_int, 685 oldpath: *const ::c_char, 686 newdirfd: ::c_int, 687 newpath: *const ::c_char, 688 ) -> ::c_int; 689 pub fn symlinkat( 690 target: *const ::c_char, 691 newdirfd: ::c_int, 692 linkpath: *const ::c_char, 693 ) -> ::c_int; 694 pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char, flags: ::c_int) -> ::c_int; 695 696 pub fn access(path: *const c_char, amode: ::c_int) -> ::c_int; 697 pub fn close(fd: ::c_int) -> ::c_int; 698 pub fn fpathconf(filedes: ::c_int, name: ::c_int) -> c_long; 699 pub fn getopt(argc: ::c_int, argv: *const *mut c_char, optstr: *const c_char) -> ::c_int; 700 pub fn isatty(fd: ::c_int) -> ::c_int; 701 pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int; 702 pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t; 703 pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long; 704 pub fn rmdir(path: *const c_char) -> ::c_int; 705 pub fn sleep(secs: ::c_uint) -> ::c_uint; 706 pub fn unlink(c: *const c_char) -> ::c_int; 707 pub fn pread(fd: ::c_int, buf: *mut ::c_void, count: ::size_t, offset: off_t) -> ::ssize_t; 708 pub fn pwrite(fd: ::c_int, buf: *const ::c_void, count: ::size_t, offset: off_t) -> ::ssize_t; 709 710 pub fn lstat(path: *const c_char, buf: *mut stat) -> ::c_int; 711 712 pub fn fsync(fd: ::c_int) -> ::c_int; 713 pub fn fdatasync(fd: ::c_int) -> ::c_int; 714 715 pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int; 716 717 pub fn truncate(path: *const c_char, length: off_t) -> ::c_int; 718 pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int; 719 720 pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int; 721 722 pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int; 723 pub fn times(buf: *mut ::tms) -> ::clock_t; 724 725 pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int; 726 727 pub fn usleep(secs: ::c_uint) -> ::c_int; 728 pub fn send(socket: ::c_int, buf: *const ::c_void, len: ::size_t, flags: ::c_int) -> ::ssize_t; 729 pub fn recv(socket: ::c_int, buf: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::ssize_t; 730 pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int; 731 pub fn setlocale(category: ::c_int, locale: *const ::c_char) -> *mut ::c_char; 732 pub fn localeconv() -> *mut lconv; 733 734 pub fn readlink(path: *const c_char, buf: *mut c_char, bufsz: ::size_t) -> ::ssize_t; 735 736 pub fn timegm(tm: *mut ::tm) -> time_t; 737 738 pub fn sysconf(name: ::c_int) -> ::c_long; 739 740 pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int; 741 742 pub fn fseeko(stream: *mut ::FILE, offset: ::off_t, whence: ::c_int) -> ::c_int; 743 pub fn ftello(stream: *mut ::FILE) -> ::off_t; 744 pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, len: ::off_t) -> ::c_int; 745 746 pub fn strcasestr(cs: *const c_char, ct: *const c_char) -> *mut c_char; 747 pub fn getline(lineptr: *mut *mut c_char, n: *mut size_t, stream: *mut FILE) -> ssize_t; 748 749 pub fn faccessat( 750 dirfd: ::c_int, 751 pathname: *const ::c_char, 752 mode: ::c_int, 753 flags: ::c_int, 754 ) -> ::c_int; 755 pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; 756 pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; 757 pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) 758 -> ::ssize_t; 759 pub fn preadv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t) -> ::ssize_t; 760 pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, advise: ::c_int) -> ::c_int; 761 pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; 762 pub fn utimensat( 763 dirfd: ::c_int, 764 path: *const ::c_char, 765 times: *const ::timespec, 766 flag: ::c_int, 767 ) -> ::c_int; 768 pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; 769 pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void; 770 pub fn abs(i: c_int) -> c_int; 771 pub fn labs(i: c_long) -> c_long; 772 pub fn duplocale(base: ::locale_t) -> ::locale_t; 773 pub fn freelocale(loc: ::locale_t); 774 pub fn newlocale(mask: ::c_int, locale: *const ::c_char, base: ::locale_t) -> ::locale_t; 775 pub fn uselocale(loc: ::locale_t) -> ::locale_t; 776 pub fn sched_yield() -> ::c_int; 777 pub fn getcwd(buf: *mut c_char, size: ::size_t) -> *mut c_char; 778 pub fn chdir(dir: *const c_char) -> ::c_int; 779 780 pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char; 781 pub fn nl_langinfo_l(item: ::nl_item, loc: ::locale_t) -> *mut ::c_char; 782 783 pub fn select( 784 nfds: c_int, 785 readfds: *mut fd_set, 786 writefds: *mut fd_set, 787 errorfds: *mut fd_set, 788 timeout: *const timeval, 789 ) -> c_int; 790 791 pub fn __wasilibc_register_preopened_fd(fd: c_int, path: *const c_char) -> c_int; 792 pub fn __wasilibc_fd_renumber(fd: c_int, newfd: c_int) -> c_int; 793 pub fn __wasilibc_unlinkat(fd: c_int, path: *const c_char) -> c_int; 794 pub fn __wasilibc_rmdirat(fd: c_int, path: *const c_char) -> c_int; 795 pub fn __wasilibc_find_relpath( 796 path: *const c_char, 797 abs_prefix: *mut *const c_char, 798 relative_path: *mut *mut c_char, 799 relative_path_len: usize, 800 ) -> c_int; 801 pub fn __wasilibc_tell(fd: c_int) -> ::off_t; 802 pub fn __wasilibc_nocwd___wasilibc_unlinkat(dirfd: c_int, path: *const c_char) -> c_int; 803 pub fn __wasilibc_nocwd___wasilibc_rmdirat(dirfd: c_int, path: *const c_char) -> c_int; 804 pub fn __wasilibc_nocwd_linkat( 805 olddirfd: c_int, 806 oldpath: *const c_char, 807 newdirfd: c_int, 808 newpath: *const c_char, 809 flags: c_int, 810 ) -> c_int; 811 pub fn __wasilibc_nocwd_symlinkat( 812 target: *const c_char, 813 dirfd: c_int, 814 path: *const c_char, 815 ) -> c_int; 816 pub fn __wasilibc_nocwd_readlinkat( 817 dirfd: c_int, 818 path: *const c_char, 819 buf: *mut c_char, 820 bufsize: usize, 821 ) -> isize; 822 pub fn __wasilibc_nocwd_faccessat( 823 dirfd: c_int, 824 path: *const c_char, 825 mode: c_int, 826 flags: c_int, 827 ) -> c_int; 828 pub fn __wasilibc_nocwd_renameat( 829 olddirfd: c_int, 830 oldpath: *const c_char, 831 newdirfd: c_int, 832 newpath: *const c_char, 833 ) -> c_int; 834 pub fn __wasilibc_nocwd_openat_nomode(dirfd: c_int, path: *const c_char, flags: c_int) 835 -> c_int; 836 pub fn __wasilibc_nocwd_fstatat( 837 dirfd: c_int, 838 path: *const c_char, 839 buf: *mut stat, 840 flags: c_int, 841 ) -> c_int; 842 pub fn __wasilibc_nocwd_mkdirat_nomode(dirfd: c_int, path: *const c_char) -> c_int; 843 pub fn __wasilibc_nocwd_utimensat( 844 dirfd: c_int, 845 path: *const c_char, 846 times: *const ::timespec, 847 flags: c_int, 848 ) -> c_int; 849 pub fn __wasilibc_nocwd_opendirat(dirfd: c_int, path: *const c_char) -> *mut ::DIR; 850 pub fn __wasilibc_access(pathname: *const c_char, mode: c_int, flags: c_int) -> c_int; 851 pub fn __wasilibc_stat(pathname: *const c_char, buf: *mut stat, flags: c_int) -> c_int; 852 pub fn __wasilibc_utimens( 853 pathname: *const c_char, 854 times: *const ::timespec, 855 flags: c_int, 856 ) -> c_int; 857 pub fn __wasilibc_link(oldpath: *const c_char, newpath: *const c_char, flags: c_int) -> c_int; 858 pub fn __wasilibc_link_oldat( 859 olddirfd: c_int, 860 oldpath: *const c_char, 861 newpath: *const c_char, 862 flags: c_int, 863 ) -> c_int; 864 pub fn __wasilibc_link_newat( 865 oldpath: *const c_char, 866 newdirfd: c_int, 867 newpath: *const c_char, 868 flags: c_int, 869 ) -> c_int; 870 pub fn __wasilibc_rename_oldat( 871 olddirfd: c_int, 872 oldpath: *const c_char, 873 newpath: *const c_char, 874 ) -> c_int; 875 pub fn __wasilibc_rename_newat( 876 oldpath: *const c_char, 877 newdirfd: c_int, 878 newpath: *const c_char, 879 ) -> c_int; 880 881 pub fn arc4random() -> u32; 882 pub fn arc4random_buf(a: *mut c_void, b: size_t); 883 pub fn arc4random_uniform(a: u32) -> u32; 884 885 pub fn __errno_location() -> *mut ::c_int; 886 } 887 888 cfg_if! { 889 if #[cfg(target_env = "p2")] { 890 mod p2; 891 pub use self::p2::*; 892 } 893 } 894