1 use crate::prelude::*; 2 3 pub type wchar_t = i32; 4 5 pub type blkcnt_t = c_ulong; 6 pub type blksize_t = c_long; 7 pub type clock_t = c_long; 8 pub type clockid_t = c_int; 9 pub type dev_t = c_long; 10 pub type fsblkcnt_t = c_ulong; 11 pub type fsfilcnt_t = c_ulong; 12 pub type ino_t = c_ulonglong; 13 pub type mode_t = c_int; 14 pub type nfds_t = c_ulong; 15 pub type nlink_t = c_ulong; 16 pub type off_t = c_longlong; 17 pub type pthread_t = *mut c_void; 18 // Must be usize due to library/std/sys_common/thread_local.rs, 19 // should technically be *mut c_void 20 pub type pthread_key_t = usize; 21 pub type rlim_t = c_ulonglong; 22 pub type sa_family_t = u16; 23 pub type sem_t = *mut c_void; 24 pub type sigset_t = c_ulonglong; 25 pub type socklen_t = u32; 26 pub type speed_t = u32; 27 pub type suseconds_t = c_int; 28 pub type tcflag_t = u32; 29 pub type time_t = c_longlong; 30 pub type id_t = c_uint; 31 pub type pid_t = usize; 32 pub type uid_t = u32; 33 pub type gid_t = u32; 34 35 #[cfg_attr(feature = "extra_traits", derive(Debug))] 36 pub enum timezone {} 37 impl Copy for timezone {} 38 impl Clone for timezone { clone(&self) -> timezone39 fn clone(&self) -> timezone { 40 *self 41 } 42 } 43 44 s_no_extra_traits! { 45 #[repr(C)] 46 pub struct utsname { 47 pub sysname: [c_char; UTSLENGTH], 48 pub nodename: [c_char; UTSLENGTH], 49 pub release: [c_char; UTSLENGTH], 50 pub version: [c_char; UTSLENGTH], 51 pub machine: [c_char; UTSLENGTH], 52 pub domainname: [c_char; UTSLENGTH], 53 } 54 55 pub struct dirent { 56 pub d_ino: crate::ino_t, 57 pub d_off: off_t, 58 pub d_reclen: c_ushort, 59 pub d_type: c_uchar, 60 pub d_name: [c_char; 256], 61 } 62 63 pub struct sockaddr_un { 64 pub sun_family: crate::sa_family_t, 65 pub sun_path: [c_char; 108], 66 } 67 68 pub struct sockaddr_storage { 69 pub ss_family: crate::sa_family_t, 70 __ss_padding: [u8; 128 - mem::size_of::<sa_family_t>() - mem::size_of::<c_ulong>()], 71 __ss_align: c_ulong, 72 } 73 } 74 75 s! { 76 pub struct addrinfo { 77 pub ai_flags: c_int, 78 pub ai_family: c_int, 79 pub ai_socktype: c_int, 80 pub ai_protocol: c_int, 81 pub ai_addrlen: size_t, 82 pub ai_canonname: *mut c_char, 83 pub ai_addr: *mut crate::sockaddr, 84 pub ai_next: *mut crate::addrinfo, 85 } 86 87 pub struct Dl_info { 88 pub dli_fname: *const c_char, 89 pub dli_fbase: *mut c_void, 90 pub dli_sname: *const c_char, 91 pub dli_saddr: *mut c_void, 92 } 93 94 pub struct epoll_event { 95 pub events: u32, 96 pub u64: u64, 97 pub _pad: u64, 98 } 99 100 pub struct fd_set { 101 fds_bits: [c_ulong; crate::FD_SETSIZE as usize / ULONG_SIZE], 102 } 103 104 pub struct in_addr { 105 pub s_addr: crate::in_addr_t, 106 } 107 108 pub struct ip_mreq { 109 pub imr_multiaddr: crate::in_addr, 110 pub imr_interface: crate::in_addr, 111 } 112 113 pub struct lconv { 114 pub currency_symbol: *const c_char, 115 pub decimal_point: *const c_char, 116 pub frac_digits: c_char, 117 pub grouping: *const c_char, 118 pub int_curr_symbol: *const c_char, 119 pub int_frac_digits: c_char, 120 pub mon_decimal_point: *const c_char, 121 pub mon_grouping: *const c_char, 122 pub mon_thousands_sep: *const c_char, 123 pub negative_sign: *const c_char, 124 pub n_cs_precedes: c_char, 125 pub n_sep_by_space: c_char, 126 pub n_sign_posn: c_char, 127 pub positive_sign: *const c_char, 128 pub p_cs_precedes: c_char, 129 pub p_sep_by_space: c_char, 130 pub p_sign_posn: c_char, 131 pub thousands_sep: *const c_char, 132 } 133 134 pub struct msghdr { 135 pub msg_name: *mut c_void, 136 pub msg_namelen: crate::socklen_t, 137 pub msg_iov: *mut crate::iovec, 138 pub msg_iovlen: size_t, 139 pub msg_control: *mut c_void, 140 pub msg_controllen: size_t, 141 pub msg_flags: c_int, 142 } 143 144 pub struct cmsghdr { 145 pub cmsg_len: size_t, 146 pub cmsg_level: c_int, 147 pub cmsg_type: c_int, 148 } 149 150 pub struct passwd { 151 pub pw_name: *mut c_char, 152 pub pw_passwd: *mut c_char, 153 pub pw_uid: crate::uid_t, 154 pub pw_gid: crate::gid_t, 155 pub pw_gecos: *mut c_char, 156 pub pw_dir: *mut c_char, 157 pub pw_shell: *mut c_char, 158 } 159 160 // FIXME(1.0): This should not implement `PartialEq` 161 #[allow(unpredictable_function_pointer_comparisons)] 162 pub struct sigaction { 163 pub sa_sigaction: crate::sighandler_t, 164 pub sa_flags: c_ulong, 165 pub sa_restorer: Option<extern "C" fn()>, 166 pub sa_mask: crate::sigset_t, 167 } 168 169 pub struct siginfo_t { 170 pub si_signo: c_int, 171 pub si_errno: c_int, 172 pub si_code: c_int, 173 _pad: [c_int; 29], 174 _align: [usize; 0], 175 } 176 177 pub struct sockaddr { 178 pub sa_family: crate::sa_family_t, 179 pub sa_data: [c_char; 14], 180 } 181 182 pub struct sockaddr_in { 183 pub sin_family: crate::sa_family_t, 184 pub sin_port: crate::in_port_t, 185 pub sin_addr: crate::in_addr, 186 pub sin_zero: [c_char; 8], 187 } 188 189 pub struct sockaddr_in6 { 190 pub sin6_family: crate::sa_family_t, 191 pub sin6_port: crate::in_port_t, 192 pub sin6_flowinfo: u32, 193 pub sin6_addr: crate::in6_addr, 194 pub sin6_scope_id: u32, 195 } 196 197 pub struct stat { 198 pub st_dev: crate::dev_t, 199 pub st_ino: crate::ino_t, 200 pub st_nlink: crate::nlink_t, 201 pub st_mode: mode_t, 202 pub st_uid: crate::uid_t, 203 pub st_gid: crate::gid_t, 204 pub st_rdev: crate::dev_t, 205 pub st_size: off_t, 206 pub st_blksize: crate::blksize_t, 207 pub st_blocks: crate::blkcnt_t, 208 pub st_atime: crate::time_t, 209 pub st_atime_nsec: c_long, 210 pub st_mtime: crate::time_t, 211 pub st_mtime_nsec: c_long, 212 pub st_ctime: crate::time_t, 213 pub st_ctime_nsec: c_long, 214 _pad: [c_char; 24], 215 } 216 217 pub struct statvfs { 218 pub f_bsize: c_ulong, 219 pub f_frsize: c_ulong, 220 pub f_blocks: crate::fsblkcnt_t, 221 pub f_bfree: crate::fsblkcnt_t, 222 pub f_bavail: crate::fsblkcnt_t, 223 pub f_files: crate::fsfilcnt_t, 224 pub f_ffree: crate::fsfilcnt_t, 225 pub f_favail: crate::fsfilcnt_t, 226 pub f_fsid: c_ulong, 227 pub f_flag: c_ulong, 228 pub f_namemax: c_ulong, 229 } 230 231 pub struct termios { 232 pub c_iflag: crate::tcflag_t, 233 pub c_oflag: crate::tcflag_t, 234 pub c_cflag: crate::tcflag_t, 235 pub c_lflag: crate::tcflag_t, 236 pub c_line: crate::cc_t, 237 pub c_cc: [crate::cc_t; crate::NCCS], 238 pub c_ispeed: crate::speed_t, 239 pub c_ospeed: crate::speed_t, 240 } 241 242 pub struct tm { 243 pub tm_sec: c_int, 244 pub tm_min: c_int, 245 pub tm_hour: c_int, 246 pub tm_mday: c_int, 247 pub tm_mon: c_int, 248 pub tm_year: c_int, 249 pub tm_wday: c_int, 250 pub tm_yday: c_int, 251 pub tm_isdst: c_int, 252 pub tm_gmtoff: c_long, 253 pub tm_zone: *const c_char, 254 } 255 256 pub struct ucred { 257 pub pid: pid_t, 258 pub uid: uid_t, 259 pub gid: gid_t, 260 } 261 262 #[cfg_attr(target_pointer_width = "32", repr(C, align(4)))] 263 #[cfg_attr(target_pointer_width = "64", repr(C, align(8)))] 264 pub struct pthread_attr_t { 265 bytes: [u8; _PTHREAD_ATTR_SIZE], 266 } 267 #[repr(C)] 268 #[repr(align(4))] 269 pub struct pthread_barrier_t { 270 bytes: [u8; _PTHREAD_BARRIER_SIZE], 271 } 272 #[repr(C)] 273 #[repr(align(4))] 274 pub struct pthread_barrierattr_t { 275 bytes: [u8; _PTHREAD_BARRIERATTR_SIZE], 276 } 277 #[repr(C)] 278 #[repr(align(4))] 279 pub struct pthread_mutex_t { 280 bytes: [u8; _PTHREAD_MUTEX_SIZE], 281 } 282 #[repr(C)] 283 #[repr(align(4))] 284 pub struct pthread_rwlock_t { 285 bytes: [u8; _PTHREAD_RWLOCK_SIZE], 286 } 287 #[repr(C)] 288 #[repr(align(4))] 289 pub struct pthread_mutexattr_t { 290 bytes: [u8; _PTHREAD_MUTEXATTR_SIZE], 291 } 292 #[repr(C)] 293 #[repr(align(1))] 294 pub struct pthread_rwlockattr_t { 295 bytes: [u8; _PTHREAD_RWLOCKATTR_SIZE], 296 } 297 #[repr(C)] 298 #[repr(align(4))] 299 pub struct pthread_cond_t { 300 bytes: [u8; _PTHREAD_COND_SIZE], 301 } 302 #[repr(C)] 303 #[repr(align(4))] 304 pub struct pthread_condattr_t { 305 bytes: [u8; _PTHREAD_CONDATTR_SIZE], 306 } 307 #[repr(C)] 308 #[repr(align(4))] 309 pub struct pthread_once_t { 310 bytes: [u8; _PTHREAD_ONCE_SIZE], 311 } 312 #[repr(C)] 313 #[repr(align(4))] 314 pub struct pthread_spinlock_t { 315 bytes: [u8; _PTHREAD_SPINLOCK_SIZE], 316 } 317 } 318 const _PTHREAD_ATTR_SIZE: usize = 32; 319 const _PTHREAD_RWLOCKATTR_SIZE: usize = 1; 320 const _PTHREAD_RWLOCK_SIZE: usize = 4; 321 const _PTHREAD_BARRIER_SIZE: usize = 24; 322 const _PTHREAD_BARRIERATTR_SIZE: usize = 4; 323 const _PTHREAD_CONDATTR_SIZE: usize = 8; 324 const _PTHREAD_COND_SIZE: usize = 8; 325 const _PTHREAD_MUTEX_SIZE: usize = 12; 326 const _PTHREAD_MUTEXATTR_SIZE: usize = 20; 327 const _PTHREAD_ONCE_SIZE: usize = 4; 328 const _PTHREAD_SPINLOCK_SIZE: usize = 4; 329 330 pub const UTSLENGTH: usize = 65; 331 332 // intentionally not public, only used for fd_set 333 cfg_if! { 334 if #[cfg(target_pointer_width = "32")] { 335 const ULONG_SIZE: usize = 32; 336 } else if #[cfg(target_pointer_width = "64")] { 337 const ULONG_SIZE: usize = 64; 338 } else { 339 // Unknown target_pointer_width 340 } 341 } 342 343 // limits.h 344 pub const PATH_MAX: c_int = 4096; 345 346 // fcntl.h 347 pub const F_GETLK: c_int = 5; 348 pub const F_SETLK: c_int = 6; 349 pub const F_SETLKW: c_int = 7; 350 pub const F_ULOCK: c_int = 0; 351 pub const F_LOCK: c_int = 1; 352 pub const F_TLOCK: c_int = 2; 353 pub const F_TEST: c_int = 3; 354 355 // FIXME(redox): relibc { 356 pub const RTLD_DEFAULT: *mut c_void = 0i64 as *mut c_void; 357 // } 358 359 // dlfcn.h 360 pub const RTLD_LAZY: c_int = 0x0001; 361 pub const RTLD_NOW: c_int = 0x0002; 362 pub const RTLD_GLOBAL: c_int = 0x0100; 363 pub const RTLD_LOCAL: c_int = 0x0000; 364 365 // errno.h 366 pub const EPERM: c_int = 1; /* Operation not permitted */ 367 pub const ENOENT: c_int = 2; /* No such file or directory */ 368 pub const ESRCH: c_int = 3; /* No such process */ 369 pub const EINTR: c_int = 4; /* Interrupted system call */ 370 pub const EIO: c_int = 5; /* I/O error */ 371 pub const ENXIO: c_int = 6; /* No such device or address */ 372 pub const E2BIG: c_int = 7; /* Argument list too long */ 373 pub const ENOEXEC: c_int = 8; /* Exec format error */ 374 pub const EBADF: c_int = 9; /* Bad file number */ 375 pub const ECHILD: c_int = 10; /* No child processes */ 376 pub const EAGAIN: c_int = 11; /* Try again */ 377 pub const ENOMEM: c_int = 12; /* Out of memory */ 378 pub const EACCES: c_int = 13; /* Permission denied */ 379 pub const EFAULT: c_int = 14; /* Bad address */ 380 pub const ENOTBLK: c_int = 15; /* Block device required */ 381 pub const EBUSY: c_int = 16; /* Device or resource busy */ 382 pub const EEXIST: c_int = 17; /* File exists */ 383 pub const EXDEV: c_int = 18; /* Cross-device link */ 384 pub const ENODEV: c_int = 19; /* No such device */ 385 pub const ENOTDIR: c_int = 20; /* Not a directory */ 386 pub const EISDIR: c_int = 21; /* Is a directory */ 387 pub const EINVAL: c_int = 22; /* Invalid argument */ 388 pub const ENFILE: c_int = 23; /* File table overflow */ 389 pub const EMFILE: c_int = 24; /* Too many open files */ 390 pub const ENOTTY: c_int = 25; /* Not a typewriter */ 391 pub const ETXTBSY: c_int = 26; /* Text file busy */ 392 pub const EFBIG: c_int = 27; /* File too large */ 393 pub const ENOSPC: c_int = 28; /* No space left on device */ 394 pub const ESPIPE: c_int = 29; /* Illegal seek */ 395 pub const EROFS: c_int = 30; /* Read-only file system */ 396 pub const EMLINK: c_int = 31; /* Too many links */ 397 pub const EPIPE: c_int = 32; /* Broken pipe */ 398 pub const EDOM: c_int = 33; /* Math argument out of domain of func */ 399 pub const ERANGE: c_int = 34; /* Math result not representable */ 400 pub const EDEADLK: c_int = 35; /* Resource deadlock would occur */ 401 pub const ENAMETOOLONG: c_int = 36; /* File name too long */ 402 pub const ENOLCK: c_int = 37; /* No record locks available */ 403 pub const ENOSYS: c_int = 38; /* Function not implemented */ 404 pub const ENOTEMPTY: c_int = 39; /* Directory not empty */ 405 pub const ELOOP: c_int = 40; /* Too many symbolic links encountered */ 406 pub const EWOULDBLOCK: c_int = 41; /* Operation would block */ 407 pub const ENOMSG: c_int = 42; /* No message of desired type */ 408 pub const EIDRM: c_int = 43; /* Identifier removed */ 409 pub const ECHRNG: c_int = 44; /* Channel number out of range */ 410 pub const EL2NSYNC: c_int = 45; /* Level 2 not synchronized */ 411 pub const EL3HLT: c_int = 46; /* Level 3 halted */ 412 pub const EL3RST: c_int = 47; /* Level 3 reset */ 413 pub const ELNRNG: c_int = 48; /* Link number out of range */ 414 pub const EUNATCH: c_int = 49; /* Protocol driver not attached */ 415 pub const ENOCSI: c_int = 50; /* No CSI structure available */ 416 pub const EL2HLT: c_int = 51; /* Level 2 halted */ 417 pub const EBADE: c_int = 52; /* Invalid exchange */ 418 pub const EBADR: c_int = 53; /* Invalid request descriptor */ 419 pub const EXFULL: c_int = 54; /* Exchange full */ 420 pub const ENOANO: c_int = 55; /* No anode */ 421 pub const EBADRQC: c_int = 56; /* Invalid request code */ 422 pub const EBADSLT: c_int = 57; /* Invalid slot */ 423 pub const EDEADLOCK: c_int = 58; /* Resource deadlock would occur */ 424 pub const EBFONT: c_int = 59; /* Bad font file format */ 425 pub const ENOSTR: c_int = 60; /* Device not a stream */ 426 pub const ENODATA: c_int = 61; /* No data available */ 427 pub const ETIME: c_int = 62; /* Timer expired */ 428 pub const ENOSR: c_int = 63; /* Out of streams resources */ 429 pub const ENONET: c_int = 64; /* Machine is not on the network */ 430 pub const ENOPKG: c_int = 65; /* Package not installed */ 431 pub const EREMOTE: c_int = 66; /* Object is remote */ 432 pub const ENOLINK: c_int = 67; /* Link has been severed */ 433 pub const EADV: c_int = 68; /* Advertise error */ 434 pub const ESRMNT: c_int = 69; /* Srmount error */ 435 pub const ECOMM: c_int = 70; /* Communication error on send */ 436 pub const EPROTO: c_int = 71; /* Protocol error */ 437 pub const EMULTIHOP: c_int = 72; /* Multihop attempted */ 438 pub const EDOTDOT: c_int = 73; /* RFS specific error */ 439 pub const EBADMSG: c_int = 74; /* Not a data message */ 440 pub const EOVERFLOW: c_int = 75; /* Value too large for defined data type */ 441 pub const ENOTUNIQ: c_int = 76; /* Name not unique on network */ 442 pub const EBADFD: c_int = 77; /* File descriptor in bad state */ 443 pub const EREMCHG: c_int = 78; /* Remote address changed */ 444 pub const ELIBACC: c_int = 79; /* Can not access a needed shared library */ 445 pub const ELIBBAD: c_int = 80; /* Accessing a corrupted shared library */ 446 pub const ELIBSCN: c_int = 81; /* .lib section in a.out corrupted */ 447 /* Attempting to link in too many shared libraries */ 448 pub const ELIBMAX: c_int = 82; 449 pub const ELIBEXEC: c_int = 83; /* Cannot exec a shared library directly */ 450 pub const EILSEQ: c_int = 84; /* Illegal byte sequence */ 451 /* Interrupted system call should be restarted */ 452 pub const ERESTART: c_int = 85; 453 pub const ESTRPIPE: c_int = 86; /* Streams pipe error */ 454 pub const EUSERS: c_int = 87; /* Too many users */ 455 pub const ENOTSOCK: c_int = 88; /* Socket operation on non-socket */ 456 pub const EDESTADDRREQ: c_int = 89; /* Destination address required */ 457 pub const EMSGSIZE: c_int = 90; /* Message too long */ 458 pub const EPROTOTYPE: c_int = 91; /* Protocol wrong type for socket */ 459 pub const ENOPROTOOPT: c_int = 92; /* Protocol not available */ 460 pub const EPROTONOSUPPORT: c_int = 93; /* Protocol not supported */ 461 pub const ESOCKTNOSUPPORT: c_int = 94; /* Socket type not supported */ 462 /* Operation not supported on transport endpoint */ 463 pub const EOPNOTSUPP: c_int = 95; 464 pub const ENOTSUP: c_int = EOPNOTSUPP; 465 pub const EPFNOSUPPORT: c_int = 96; /* Protocol family not supported */ 466 /* Address family not supported by protocol */ 467 pub const EAFNOSUPPORT: c_int = 97; 468 pub const EADDRINUSE: c_int = 98; /* Address already in use */ 469 pub const EADDRNOTAVAIL: c_int = 99; /* Cannot assign requested address */ 470 pub const ENETDOWN: c_int = 100; /* Network is down */ 471 pub const ENETUNREACH: c_int = 101; /* Network is unreachable */ 472 /* Network dropped connection because of reset */ 473 pub const ENETRESET: c_int = 102; 474 pub const ECONNABORTED: c_int = 103; /* Software caused connection abort */ 475 pub const ECONNRESET: c_int = 104; /* Connection reset by peer */ 476 pub const ENOBUFS: c_int = 105; /* No buffer space available */ 477 pub const EISCONN: c_int = 106; /* Transport endpoint is already connected */ 478 pub const ENOTCONN: c_int = 107; /* Transport endpoint is not connected */ 479 /* Cannot send after transport endpoint shutdown */ 480 pub const ESHUTDOWN: c_int = 108; 481 pub const ETOOMANYREFS: c_int = 109; /* Too many references: cannot splice */ 482 pub const ETIMEDOUT: c_int = 110; /* Connection timed out */ 483 pub const ECONNREFUSED: c_int = 111; /* Connection refused */ 484 pub const EHOSTDOWN: c_int = 112; /* Host is down */ 485 pub const EHOSTUNREACH: c_int = 113; /* No route to host */ 486 pub const EALREADY: c_int = 114; /* Operation already in progress */ 487 pub const EINPROGRESS: c_int = 115; /* Operation now in progress */ 488 pub const ESTALE: c_int = 116; /* Stale NFS file handle */ 489 pub const EUCLEAN: c_int = 117; /* Structure needs cleaning */ 490 pub const ENOTNAM: c_int = 118; /* Not a XENIX named type file */ 491 pub const ENAVAIL: c_int = 119; /* No XENIX semaphores available */ 492 pub const EISNAM: c_int = 120; /* Is a named type file */ 493 pub const EREMOTEIO: c_int = 121; /* Remote I/O error */ 494 pub const EDQUOT: c_int = 122; /* Quota exceeded */ 495 pub const ENOMEDIUM: c_int = 123; /* No medium found */ 496 pub const EMEDIUMTYPE: c_int = 124; /* Wrong medium type */ 497 pub const ECANCELED: c_int = 125; /* Operation Canceled */ 498 pub const ENOKEY: c_int = 126; /* Required key not available */ 499 pub const EKEYEXPIRED: c_int = 127; /* Key has expired */ 500 pub const EKEYREVOKED: c_int = 128; /* Key has been revoked */ 501 pub const EKEYREJECTED: c_int = 129; /* Key was rejected by service */ 502 pub const EOWNERDEAD: c_int = 130; /* Owner died */ 503 pub const ENOTRECOVERABLE: c_int = 131; /* State not recoverable */ 504 505 // fcntl.h 506 pub const F_DUPFD: c_int = 0; 507 pub const F_GETFD: c_int = 1; 508 pub const F_SETFD: c_int = 2; 509 pub const F_GETFL: c_int = 3; 510 pub const F_SETFL: c_int = 4; 511 // FIXME(redox): relibc { 512 pub const F_DUPFD_CLOEXEC: c_int = crate::F_DUPFD; 513 // } 514 pub const FD_CLOEXEC: c_int = 0x0100_0000; 515 pub const O_RDONLY: c_int = 0x0001_0000; 516 pub const O_WRONLY: c_int = 0x0002_0000; 517 pub const O_RDWR: c_int = 0x0003_0000; 518 pub const O_ACCMODE: c_int = 0x0003_0000; 519 pub const O_NONBLOCK: c_int = 0x0004_0000; 520 pub const O_APPEND: c_int = 0x0008_0000; 521 pub const O_SHLOCK: c_int = 0x0010_0000; 522 pub const O_EXLOCK: c_int = 0x0020_0000; 523 pub const O_ASYNC: c_int = 0x0040_0000; 524 pub const O_FSYNC: c_int = 0x0080_0000; 525 pub const O_CLOEXEC: c_int = 0x0100_0000; 526 pub const O_CREAT: c_int = 0x0200_0000; 527 pub const O_TRUNC: c_int = 0x0400_0000; 528 pub const O_EXCL: c_int = 0x0800_0000; 529 pub const O_DIRECTORY: c_int = 0x1000_0000; 530 pub const O_PATH: c_int = 0x2000_0000; 531 pub const O_SYMLINK: c_int = 0x4000_0000; 532 // Negative to allow it to be used as int 533 // FIXME(redox): Fix negative values missing from includes 534 pub const O_NOFOLLOW: c_int = -0x8000_0000; 535 536 // locale.h 537 pub const LC_ALL: c_int = 0; 538 pub const LC_COLLATE: c_int = 1; 539 pub const LC_CTYPE: c_int = 2; 540 pub const LC_MESSAGES: c_int = 3; 541 pub const LC_MONETARY: c_int = 4; 542 pub const LC_NUMERIC: c_int = 5; 543 pub const LC_TIME: c_int = 6; 544 545 // netdb.h 546 pub const AI_PASSIVE: c_int = 0x0001; 547 pub const AI_CANONNAME: c_int = 0x0002; 548 pub const AI_NUMERICHOST: c_int = 0x0004; 549 pub const AI_V4MAPPED: c_int = 0x0008; 550 pub const AI_ALL: c_int = 0x0010; 551 pub const AI_ADDRCONFIG: c_int = 0x0020; 552 pub const AI_NUMERICSERV: c_int = 0x0400; 553 pub const EAI_BADFLAGS: c_int = -1; 554 pub const EAI_NONAME: c_int = -2; 555 pub const EAI_AGAIN: c_int = -3; 556 pub const EAI_FAIL: c_int = -4; 557 pub const EAI_NODATA: c_int = -5; 558 pub const EAI_FAMILY: c_int = -6; 559 pub const EAI_SOCKTYPE: c_int = -7; 560 pub const EAI_SERVICE: c_int = -8; 561 pub const EAI_ADDRFAMILY: c_int = -9; 562 pub const EAI_MEMORY: c_int = -10; 563 pub const EAI_SYSTEM: c_int = -11; 564 pub const EAI_OVERFLOW: c_int = -12; 565 pub const NI_MAXHOST: c_int = 1025; 566 pub const NI_MAXSERV: c_int = 32; 567 pub const NI_NUMERICHOST: c_int = 0x0001; 568 pub const NI_NUMERICSERV: c_int = 0x0002; 569 pub const NI_NOFQDN: c_int = 0x0004; 570 pub const NI_NAMEREQD: c_int = 0x0008; 571 pub const NI_DGRAM: c_int = 0x0010; 572 573 // netinet/in.h 574 // FIXME(redox): relibc { 575 pub const IP_TTL: c_int = 2; 576 pub const IPV6_UNICAST_HOPS: c_int = 16; 577 pub const IPV6_MULTICAST_IF: c_int = 17; 578 pub const IPV6_MULTICAST_HOPS: c_int = 18; 579 pub const IPV6_MULTICAST_LOOP: c_int = 19; 580 pub const IPV6_ADD_MEMBERSHIP: c_int = 20; 581 pub const IPV6_DROP_MEMBERSHIP: c_int = 21; 582 pub const IPV6_V6ONLY: c_int = 26; 583 pub const IP_MULTICAST_IF: c_int = 32; 584 pub const IP_MULTICAST_TTL: c_int = 33; 585 pub const IP_MULTICAST_LOOP: c_int = 34; 586 pub const IP_ADD_MEMBERSHIP: c_int = 35; 587 pub const IP_DROP_MEMBERSHIP: c_int = 36; 588 pub const IP_TOS: c_int = 1; 589 pub const IP_RECVTOS: c_int = 2; 590 pub const IPPROTO_IGMP: c_int = 2; 591 pub const IPPROTO_PUP: c_int = 12; 592 pub const IPPROTO_IDP: c_int = 22; 593 pub const IPPROTO_RAW: c_int = 255; 594 pub const IPPROTO_MAX: c_int = 255; 595 // } 596 597 // netinet/tcp.h 598 pub const TCP_NODELAY: c_int = 1; 599 // FIXME(redox): relibc { 600 pub const TCP_KEEPIDLE: c_int = 1; 601 // } 602 603 // poll.h 604 pub const POLLIN: c_short = 0x001; 605 pub const POLLPRI: c_short = 0x002; 606 pub const POLLOUT: c_short = 0x004; 607 pub const POLLERR: c_short = 0x008; 608 pub const POLLHUP: c_short = 0x010; 609 pub const POLLNVAL: c_short = 0x020; 610 pub const POLLRDNORM: c_short = 0x040; 611 pub const POLLRDBAND: c_short = 0x080; 612 pub const POLLWRNORM: c_short = 0x100; 613 pub const POLLWRBAND: c_short = 0x200; 614 615 // pthread.h 616 pub const PTHREAD_MUTEX_NORMAL: c_int = 0; 617 pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; 618 pub const PTHREAD_MUTEX_INITIALIZER: crate::pthread_mutex_t = crate::pthread_mutex_t { 619 bytes: [0; _PTHREAD_MUTEX_SIZE], 620 }; 621 pub const PTHREAD_COND_INITIALIZER: crate::pthread_cond_t = crate::pthread_cond_t { 622 bytes: [0; _PTHREAD_COND_SIZE], 623 }; 624 pub const PTHREAD_RWLOCK_INITIALIZER: crate::pthread_rwlock_t = crate::pthread_rwlock_t { 625 bytes: [0; _PTHREAD_RWLOCK_SIZE], 626 }; 627 pub const PTHREAD_STACK_MIN: size_t = 4096; 628 629 // signal.h 630 pub const SIG_BLOCK: c_int = 0; 631 pub const SIG_UNBLOCK: c_int = 1; 632 pub const SIG_SETMASK: c_int = 2; 633 pub const SIGHUP: c_int = 1; 634 pub const SIGINT: c_int = 2; 635 pub const SIGQUIT: c_int = 3; 636 pub const SIGILL: c_int = 4; 637 pub const SIGTRAP: c_int = 5; 638 pub const SIGABRT: c_int = 6; 639 pub const SIGBUS: c_int = 7; 640 pub const SIGFPE: c_int = 8; 641 pub const SIGKILL: c_int = 9; 642 pub const SIGUSR1: c_int = 10; 643 pub const SIGSEGV: c_int = 11; 644 pub const SIGUSR2: c_int = 12; 645 pub const SIGPIPE: c_int = 13; 646 pub const SIGALRM: c_int = 14; 647 pub const SIGTERM: c_int = 15; 648 pub const SIGSTKFLT: c_int = 16; 649 pub const SIGCHLD: c_int = 17; 650 pub const SIGCONT: c_int = 18; 651 pub const SIGSTOP: c_int = 19; 652 pub const SIGTSTP: c_int = 20; 653 pub const SIGTTIN: c_int = 21; 654 pub const SIGTTOU: c_int = 22; 655 pub const SIGURG: c_int = 23; 656 pub const SIGXCPU: c_int = 24; 657 pub const SIGXFSZ: c_int = 25; 658 pub const SIGVTALRM: c_int = 26; 659 pub const SIGPROF: c_int = 27; 660 pub const SIGWINCH: c_int = 28; 661 pub const SIGIO: c_int = 29; 662 pub const SIGPWR: c_int = 30; 663 pub const SIGSYS: c_int = 31; 664 pub const NSIG: c_int = 32; 665 666 pub const SA_NOCLDWAIT: c_ulong = 0x0000_0002; 667 pub const SA_RESTORER: c_ulong = 0x0000_0004; // FIXME(redox): remove after relibc removes it 668 pub const SA_SIGINFO: c_ulong = 0x0200_0000; 669 pub const SA_ONSTACK: c_ulong = 0x0400_0000; 670 pub const SA_RESTART: c_ulong = 0x0800_0000; 671 pub const SA_NODEFER: c_ulong = 0x1000_0000; 672 pub const SA_RESETHAND: c_ulong = 0x2000_0000; 673 pub const SA_NOCLDSTOP: c_ulong = 0x4000_0000; 674 675 // sys/file.h 676 pub const LOCK_SH: c_int = 1; 677 pub const LOCK_EX: c_int = 2; 678 pub const LOCK_NB: c_int = 4; 679 pub const LOCK_UN: c_int = 8; 680 681 // sys/epoll.h 682 pub const EPOLL_CLOEXEC: c_int = 0x0100_0000; 683 pub const EPOLL_CTL_ADD: c_int = 1; 684 pub const EPOLL_CTL_DEL: c_int = 2; 685 pub const EPOLL_CTL_MOD: c_int = 3; 686 pub const EPOLLIN: c_int = 0x001; 687 pub const EPOLLPRI: c_int = 0x002; 688 pub const EPOLLOUT: c_int = 0x004; 689 pub const EPOLLERR: c_int = 0x008; 690 pub const EPOLLHUP: c_int = 0x010; 691 pub const EPOLLNVAL: c_int = 0x020; 692 pub const EPOLLRDNORM: c_int = 0x040; 693 pub const EPOLLRDBAND: c_int = 0x080; 694 pub const EPOLLWRNORM: c_int = 0x100; 695 pub const EPOLLWRBAND: c_int = 0x200; 696 pub const EPOLLMSG: c_int = 0x400; 697 pub const EPOLLRDHUP: c_int = 0x2000; 698 pub const EPOLLEXCLUSIVE: c_int = 1 << 28; 699 pub const EPOLLWAKEUP: c_int = 1 << 29; 700 pub const EPOLLONESHOT: c_int = 1 << 30; 701 pub const EPOLLET: c_int = 1 << 31; 702 703 // sys/stat.h 704 pub const S_IFMT: c_int = 0o17_0000; 705 pub const S_IFDIR: c_int = 0o4_0000; 706 pub const S_IFCHR: c_int = 0o2_0000; 707 pub const S_IFBLK: c_int = 0o6_0000; 708 pub const S_IFREG: c_int = 0o10_0000; 709 pub const S_IFIFO: c_int = 0o1_0000; 710 pub const S_IFLNK: c_int = 0o12_0000; 711 pub const S_IFSOCK: c_int = 0o14_0000; 712 pub const S_IRWXU: c_int = 0o0700; 713 pub const S_IRUSR: c_int = 0o0400; 714 pub const S_IWUSR: c_int = 0o0200; 715 pub const S_IXUSR: c_int = 0o0100; 716 pub const S_IRWXG: c_int = 0o0070; 717 pub const S_IRGRP: c_int = 0o0040; 718 pub const S_IWGRP: c_int = 0o0020; 719 pub const S_IXGRP: c_int = 0o0010; 720 pub const S_IRWXO: c_int = 0o0007; 721 pub const S_IROTH: c_int = 0o0004; 722 pub const S_IWOTH: c_int = 0o0002; 723 pub const S_IXOTH: c_int = 0o0001; 724 725 // stdlib.h 726 pub const EXIT_SUCCESS: c_int = 0; 727 pub const EXIT_FAILURE: c_int = 1; 728 729 // sys/ioctl.h 730 // FIXME(redox): relibc { 731 pub const FIONREAD: c_ulong = 0x541B; 732 pub const FIONBIO: c_ulong = 0x5421; 733 pub const FIOCLEX: c_ulong = 0x5451; 734 // } 735 pub const TCGETS: c_ulong = 0x5401; 736 pub const TCSETS: c_ulong = 0x5402; 737 pub const TCFLSH: c_ulong = 0x540B; 738 pub const TIOCSCTTY: c_ulong = 0x540E; 739 pub const TIOCGPGRP: c_ulong = 0x540F; 740 pub const TIOCSPGRP: c_ulong = 0x5410; 741 pub const TIOCGWINSZ: c_ulong = 0x5413; 742 pub const TIOCSWINSZ: c_ulong = 0x5414; 743 744 // sys/mman.h 745 pub const PROT_NONE: c_int = 0x0000; 746 pub const PROT_READ: c_int = 0x0004; 747 pub const PROT_WRITE: c_int = 0x0002; 748 pub const PROT_EXEC: c_int = 0x0001; 749 750 pub const MADV_NORMAL: c_int = 0; 751 pub const MADV_RANDOM: c_int = 1; 752 pub const MADV_SEQUENTIAL: c_int = 2; 753 pub const MADV_WILLNEED: c_int = 3; 754 pub const MADV_DONTNEED: c_int = 4; 755 756 pub const MAP_SHARED: c_int = 0x0001; 757 pub const MAP_PRIVATE: c_int = 0x0002; 758 pub const MAP_ANON: c_int = 0x0020; 759 pub const MAP_ANONYMOUS: c_int = MAP_ANON; 760 pub const MAP_FIXED: c_int = 0x0010; 761 pub const MAP_FAILED: *mut c_void = !0 as _; 762 763 pub const MS_ASYNC: c_int = 0x0001; 764 pub const MS_INVALIDATE: c_int = 0x0002; 765 pub const MS_SYNC: c_int = 0x0004; 766 767 // sys/select.h 768 pub const FD_SETSIZE: usize = 1024; 769 770 // sys/socket.h 771 pub const AF_INET: c_int = 2; 772 pub const AF_INET6: c_int = 10; 773 pub const AF_UNIX: c_int = 1; 774 pub const AF_UNSPEC: c_int = 0; 775 pub const PF_INET: c_int = 2; 776 pub const PF_INET6: c_int = 10; 777 pub const PF_UNIX: c_int = 1; 778 pub const PF_UNSPEC: c_int = 0; 779 pub const MSG_CTRUNC: c_int = 8; 780 pub const MSG_DONTROUTE: c_int = 4; 781 pub const MSG_EOR: c_int = 128; 782 pub const MSG_OOB: c_int = 1; 783 pub const MSG_PEEK: c_int = 2; 784 pub const MSG_TRUNC: c_int = 32; 785 pub const MSG_DONTWAIT: c_int = 64; 786 pub const MSG_WAITALL: c_int = 256; 787 pub const SCM_RIGHTS: c_int = 1; 788 pub const SHUT_RD: c_int = 0; 789 pub const SHUT_WR: c_int = 1; 790 pub const SHUT_RDWR: c_int = 2; 791 pub const SO_DEBUG: c_int = 1; 792 pub const SO_REUSEADDR: c_int = 2; 793 pub const SO_TYPE: c_int = 3; 794 pub const SO_ERROR: c_int = 4; 795 pub const SO_DONTROUTE: c_int = 5; 796 pub const SO_BROADCAST: c_int = 6; 797 pub const SO_SNDBUF: c_int = 7; 798 pub const SO_RCVBUF: c_int = 8; 799 pub const SO_KEEPALIVE: c_int = 9; 800 pub const SO_OOBINLINE: c_int = 10; 801 pub const SO_NO_CHECK: c_int = 11; 802 pub const SO_PRIORITY: c_int = 12; 803 pub const SO_LINGER: c_int = 13; 804 pub const SO_BSDCOMPAT: c_int = 14; 805 pub const SO_REUSEPORT: c_int = 15; 806 pub const SO_PASSCRED: c_int = 16; 807 pub const SO_PEERCRED: c_int = 17; 808 pub const SO_RCVLOWAT: c_int = 18; 809 pub const SO_SNDLOWAT: c_int = 19; 810 pub const SO_RCVTIMEO: c_int = 20; 811 pub const SO_SNDTIMEO: c_int = 21; 812 pub const SO_ACCEPTCONN: c_int = 30; 813 pub const SO_PEERSEC: c_int = 31; 814 pub const SO_SNDBUFFORCE: c_int = 32; 815 pub const SO_RCVBUFFORCE: c_int = 33; 816 pub const SO_PROTOCOL: c_int = 38; 817 pub const SO_DOMAIN: c_int = 39; 818 pub const SOCK_STREAM: c_int = 1; 819 pub const SOCK_DGRAM: c_int = 2; 820 pub const SOCK_RAW: c_int = 3; 821 pub const SOCK_NONBLOCK: c_int = 0o4_000; 822 pub const SOCK_CLOEXEC: c_int = 0o2_000_000; 823 pub const SOCK_SEQPACKET: c_int = 5; 824 pub const SOL_SOCKET: c_int = 1; 825 pub const SOMAXCONN: c_int = 128; 826 827 // sys/termios.h 828 pub const VEOF: usize = 0; 829 pub const VEOL: usize = 1; 830 pub const VEOL2: usize = 2; 831 pub const VERASE: usize = 3; 832 pub const VWERASE: usize = 4; 833 pub const VKILL: usize = 5; 834 pub const VREPRINT: usize = 6; 835 pub const VSWTC: usize = 7; 836 pub const VINTR: usize = 8; 837 pub const VQUIT: usize = 9; 838 pub const VSUSP: usize = 10; 839 pub const VSTART: usize = 12; 840 pub const VSTOP: usize = 13; 841 pub const VLNEXT: usize = 14; 842 pub const VDISCARD: usize = 15; 843 pub const VMIN: usize = 16; 844 pub const VTIME: usize = 17; 845 pub const NCCS: usize = 32; 846 847 pub const IGNBRK: crate::tcflag_t = 0o000_001; 848 pub const BRKINT: crate::tcflag_t = 0o000_002; 849 pub const IGNPAR: crate::tcflag_t = 0o000_004; 850 pub const PARMRK: crate::tcflag_t = 0o000_010; 851 pub const INPCK: crate::tcflag_t = 0o000_020; 852 pub const ISTRIP: crate::tcflag_t = 0o000_040; 853 pub const INLCR: crate::tcflag_t = 0o000_100; 854 pub const IGNCR: crate::tcflag_t = 0o000_200; 855 pub const ICRNL: crate::tcflag_t = 0o000_400; 856 pub const IXON: crate::tcflag_t = 0o001_000; 857 pub const IXOFF: crate::tcflag_t = 0o002_000; 858 859 pub const OPOST: crate::tcflag_t = 0o000_001; 860 pub const ONLCR: crate::tcflag_t = 0o000_002; 861 pub const OLCUC: crate::tcflag_t = 0o000_004; 862 pub const OCRNL: crate::tcflag_t = 0o000_010; 863 pub const ONOCR: crate::tcflag_t = 0o000_020; 864 pub const ONLRET: crate::tcflag_t = 0o000_040; 865 pub const OFILL: crate::tcflag_t = 0o0000_100; 866 pub const OFDEL: crate::tcflag_t = 0o0000_200; 867 868 pub const B0: speed_t = 0o000_000; 869 pub const B50: speed_t = 0o000_001; 870 pub const B75: speed_t = 0o000_002; 871 pub const B110: speed_t = 0o000_003; 872 pub const B134: speed_t = 0o000_004; 873 pub const B150: speed_t = 0o000_005; 874 pub const B200: speed_t = 0o000_006; 875 pub const B300: speed_t = 0o000_007; 876 pub const B600: speed_t = 0o000_010; 877 pub const B1200: speed_t = 0o000_011; 878 pub const B1800: speed_t = 0o000_012; 879 pub const B2400: speed_t = 0o000_013; 880 pub const B4800: speed_t = 0o000_014; 881 pub const B9600: speed_t = 0o000_015; 882 pub const B19200: speed_t = 0o000_016; 883 pub const B38400: speed_t = 0o000_017; 884 885 pub const B57600: speed_t = 0o0_020; 886 pub const B115200: speed_t = 0o0_021; 887 pub const B230400: speed_t = 0o0_022; 888 pub const B460800: speed_t = 0o0_023; 889 pub const B500000: speed_t = 0o0_024; 890 pub const B576000: speed_t = 0o0_025; 891 pub const B921600: speed_t = 0o0_026; 892 pub const B1000000: speed_t = 0o0_027; 893 pub const B1152000: speed_t = 0o0_030; 894 pub const B1500000: speed_t = 0o0_031; 895 pub const B2000000: speed_t = 0o0_032; 896 pub const B2500000: speed_t = 0o0_033; 897 pub const B3000000: speed_t = 0o0_034; 898 pub const B3500000: speed_t = 0o0_035; 899 pub const B4000000: speed_t = 0o0_036; 900 901 pub const CSIZE: crate::tcflag_t = 0o001_400; 902 pub const CS5: crate::tcflag_t = 0o000_000; 903 pub const CS6: crate::tcflag_t = 0o000_400; 904 pub const CS7: crate::tcflag_t = 0o001_000; 905 pub const CS8: crate::tcflag_t = 0o001_400; 906 907 pub const CSTOPB: crate::tcflag_t = 0o002_000; 908 pub const CREAD: crate::tcflag_t = 0o004_000; 909 pub const PARENB: crate::tcflag_t = 0o010_000; 910 pub const PARODD: crate::tcflag_t = 0o020_000; 911 pub const HUPCL: crate::tcflag_t = 0o040_000; 912 913 pub const CLOCAL: crate::tcflag_t = 0o0100000; 914 915 pub const ISIG: crate::tcflag_t = 0x0000_0080; 916 pub const ICANON: crate::tcflag_t = 0x0000_0100; 917 pub const ECHO: crate::tcflag_t = 0x0000_0008; 918 pub const ECHOE: crate::tcflag_t = 0x0000_0002; 919 pub const ECHOK: crate::tcflag_t = 0x0000_0004; 920 pub const ECHONL: crate::tcflag_t = 0x0000_0010; 921 pub const NOFLSH: crate::tcflag_t = 0x8000_0000; 922 pub const TOSTOP: crate::tcflag_t = 0x0040_0000; 923 pub const IEXTEN: crate::tcflag_t = 0x0000_0400; 924 925 pub const TCOOFF: c_int = 0; 926 pub const TCOON: c_int = 1; 927 pub const TCIOFF: c_int = 2; 928 pub const TCION: c_int = 3; 929 930 pub const TCIFLUSH: c_int = 0; 931 pub const TCOFLUSH: c_int = 1; 932 pub const TCIOFLUSH: c_int = 2; 933 934 pub const TCSANOW: c_int = 0; 935 pub const TCSADRAIN: c_int = 1; 936 pub const TCSAFLUSH: c_int = 2; 937 938 // sys/wait.h 939 pub const WNOHANG: c_int = 1; 940 pub const WUNTRACED: c_int = 2; 941 942 pub const WSTOPPED: c_int = 2; 943 pub const WEXITED: c_int = 4; 944 pub const WCONTINUED: c_int = 8; 945 pub const WNOWAIT: c_int = 0x0100_0000; 946 947 pub const __WNOTHREAD: c_int = 0x2000_0000; 948 pub const __WALL: c_int = 0x4000_0000; 949 #[allow(overflowing_literals)] 950 pub const __WCLONE: c_int = 0x8000_0000; 951 952 // time.h 953 pub const CLOCK_REALTIME: c_int = 1; 954 pub const CLOCK_MONOTONIC: c_int = 4; 955 pub const CLOCK_PROCESS_CPUTIME_ID: crate::clockid_t = 2; 956 pub const CLOCKS_PER_SEC: crate::clock_t = 1_000_000; 957 958 // unistd.h 959 // POSIX.1 { 960 pub const _SC_ARG_MAX: c_int = 0; 961 pub const _SC_CHILD_MAX: c_int = 1; 962 pub const _SC_CLK_TCK: c_int = 2; 963 pub const _SC_NGROUPS_MAX: c_int = 3; 964 pub const _SC_OPEN_MAX: c_int = 4; 965 pub const _SC_STREAM_MAX: c_int = 5; 966 pub const _SC_TZNAME_MAX: c_int = 6; 967 // ... 968 pub const _SC_VERSION: c_int = 29; 969 pub const _SC_PAGESIZE: c_int = 30; 970 pub const _SC_PAGE_SIZE: c_int = 30; 971 // ... 972 pub const _SC_RE_DUP_MAX: c_int = 44; 973 // ... 974 pub const _SC_LOGIN_NAME_MAX: c_int = 71; 975 pub const _SC_TTY_NAME_MAX: c_int = 72; 976 // ... 977 pub const _SC_SYMLOOP_MAX: c_int = 173; 978 // ... 979 pub const _SC_HOST_NAME_MAX: c_int = 180; 980 // } POSIX.1 981 982 pub const F_OK: c_int = 0; 983 pub const R_OK: c_int = 4; 984 pub const W_OK: c_int = 2; 985 pub const X_OK: c_int = 1; 986 987 pub const SEEK_SET: c_int = 0; 988 pub const SEEK_CUR: c_int = 1; 989 pub const SEEK_END: c_int = 2; 990 pub const STDIN_FILENO: c_int = 0; 991 pub const STDOUT_FILENO: c_int = 1; 992 pub const STDERR_FILENO: c_int = 2; 993 994 pub const _PC_LINK_MAX: c_int = 0; 995 pub const _PC_MAX_CANON: c_int = 1; 996 pub const _PC_MAX_INPUT: c_int = 2; 997 pub const _PC_NAME_MAX: c_int = 3; 998 pub const _PC_PATH_MAX: c_int = 4; 999 pub const _PC_PIPE_BUF: c_int = 5; 1000 pub const _PC_CHOWN_RESTRICTED: c_int = 6; 1001 pub const _PC_NO_TRUNC: c_int = 7; 1002 pub const _PC_VDISABLE: c_int = 8; 1003 pub const _PC_SYNC_IO: c_int = 9; 1004 pub const _PC_ASYNC_IO: c_int = 10; 1005 pub const _PC_PRIO_IO: c_int = 11; 1006 pub const _PC_SOCK_MAXBUF: c_int = 12; 1007 pub const _PC_FILESIZEBITS: c_int = 13; 1008 pub const _PC_REC_INCR_XFER_SIZE: c_int = 14; 1009 pub const _PC_REC_MAX_XFER_SIZE: c_int = 15; 1010 pub const _PC_REC_MIN_XFER_SIZE: c_int = 16; 1011 pub const _PC_REC_XFER_ALIGN: c_int = 17; 1012 pub const _PC_ALLOC_SIZE_MIN: c_int = 18; 1013 pub const _PC_SYMLINK_MAX: c_int = 19; 1014 pub const _PC_2_SYMLINKS: c_int = 20; 1015 1016 pub const PRIO_PROCESS: c_int = 0; 1017 pub const PRIO_PGRP: c_int = 1; 1018 pub const PRIO_USER: c_int = 2; 1019 1020 f! { 1021 //sys/socket.h 1022 pub {const} fn CMSG_ALIGN(len: size_t) -> size_t { 1023 (len + mem::size_of::<size_t>() - 1) & !(mem::size_of::<size_t>() - 1) 1024 } 1025 pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { 1026 (CMSG_ALIGN(mem::size_of::<cmsghdr>()) + length as usize) as c_uint 1027 } 1028 pub {const} fn CMSG_SPACE(len: c_uint) -> c_uint { 1029 (CMSG_ALIGN(len as size_t) + CMSG_ALIGN(mem::size_of::<cmsghdr>())) as c_uint 1030 } 1031 1032 // wait.h 1033 pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { 1034 let fd = fd as usize; 1035 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; 1036 (*set).fds_bits[fd / size] &= !(1 << (fd % size)); 1037 return; 1038 } 1039 1040 pub fn FD_ISSET(fd: c_int, set: *const fd_set) -> bool { 1041 let fd = fd as usize; 1042 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; 1043 return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0; 1044 } 1045 1046 pub fn FD_SET(fd: c_int, set: *mut fd_set) -> () { 1047 let fd = fd as usize; 1048 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; 1049 (*set).fds_bits[fd / size] |= 1 << (fd % size); 1050 return; 1051 } 1052 1053 pub fn FD_ZERO(set: *mut fd_set) -> () { 1054 for slot in (*set).fds_bits.iter_mut() { 1055 *slot = 0; 1056 } 1057 } 1058 } 1059 1060 safe_f! { 1061 pub {const} fn WIFSTOPPED(status: c_int) -> bool { 1062 (status & 0xff) == 0x7f 1063 } 1064 1065 pub {const} fn WSTOPSIG(status: c_int) -> c_int { 1066 (status >> 8) & 0xff 1067 } 1068 1069 pub {const} fn WIFCONTINUED(status: c_int) -> bool { 1070 status == 0xffff 1071 } 1072 1073 pub {const} fn WIFSIGNALED(status: c_int) -> bool { 1074 ((status & 0x7f) + 1) as i8 >= 2 1075 } 1076 1077 pub {const} fn WTERMSIG(status: c_int) -> c_int { 1078 status & 0x7f 1079 } 1080 1081 pub {const} fn WIFEXITED(status: c_int) -> bool { 1082 (status & 0x7f) == 0 1083 } 1084 1085 pub {const} fn WEXITSTATUS(status: c_int) -> c_int { 1086 (status >> 8) & 0xff 1087 } 1088 1089 pub {const} fn WCOREDUMP(status: c_int) -> bool { 1090 (status & 0x80) != 0 1091 } 1092 } 1093 1094 extern "C" { 1095 // errno.h __errno_location() -> *mut c_int1096 pub fn __errno_location() -> *mut c_int; strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int1097 pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int; 1098 1099 // unistd.h pipe2(fds: *mut c_int, flags: c_int) -> c_int1100 pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int; getdtablesize() -> c_int1101 pub fn getdtablesize() -> c_int; 1102 1103 // grp.h getgrent() -> *mut crate::group1104 pub fn getgrent() -> *mut crate::group; setgrent()1105 pub fn setgrent(); endgrent()1106 pub fn endgrent(); getgrgid(gid: crate::gid_t) -> *mut crate::group1107 pub fn getgrgid(gid: crate::gid_t) -> *mut crate::group; getgrgid_r( gid: crate::gid_t, grp: *mut crate::group, buf: *mut c_char, buflen: size_t, result: *mut *mut crate::group, ) -> c_int1108 pub fn getgrgid_r( 1109 gid: crate::gid_t, 1110 grp: *mut crate::group, 1111 buf: *mut c_char, 1112 buflen: size_t, 1113 result: *mut *mut crate::group, 1114 ) -> c_int; getgrnam(name: *const c_char) -> *mut crate::group1115 pub fn getgrnam(name: *const c_char) -> *mut crate::group; getgrnam_r( name: *const c_char, grp: *mut crate::group, buf: *mut c_char, buflen: size_t, result: *mut *mut crate::group, ) -> c_int1116 pub fn getgrnam_r( 1117 name: *const c_char, 1118 grp: *mut crate::group, 1119 buf: *mut c_char, 1120 buflen: size_t, 1121 result: *mut *mut crate::group, 1122 ) -> c_int; getgrouplist( user: *const c_char, group: crate::gid_t, groups: *mut crate::gid_t, ngroups: *mut c_int, ) -> c_int1123 pub fn getgrouplist( 1124 user: *const c_char, 1125 group: crate::gid_t, 1126 groups: *mut crate::gid_t, 1127 ngroups: *mut c_int, 1128 ) -> c_int; 1129 1130 // malloc.h memalign(align: size_t, size: size_t) -> *mut c_void1131 pub fn memalign(align: size_t, size: size_t) -> *mut c_void; 1132 1133 // netdb.h getnameinfo( addr: *const crate::sockaddr, addrlen: crate::socklen_t, host: *mut c_char, hostlen: crate::socklen_t, serv: *mut c_char, servlen: crate::socklen_t, flags: c_int, ) -> c_int1134 pub fn getnameinfo( 1135 addr: *const crate::sockaddr, 1136 addrlen: crate::socklen_t, 1137 host: *mut c_char, 1138 hostlen: crate::socklen_t, 1139 serv: *mut c_char, 1140 servlen: crate::socklen_t, 1141 flags: c_int, 1142 ) -> c_int; 1143 1144 // pthread.h pthread_atfork( prepare: Option<unsafe extern "C" fn()>, parent: Option<unsafe extern "C" fn()>, child: Option<unsafe extern "C" fn()>, ) -> c_int1145 pub fn pthread_atfork( 1146 prepare: Option<unsafe extern "C" fn()>, 1147 parent: Option<unsafe extern "C" fn()>, 1148 child: Option<unsafe extern "C" fn()>, 1149 ) -> c_int; pthread_create( tid: *mut crate::pthread_t, attr: *const crate::pthread_attr_t, start: extern "C" fn(*mut c_void) -> *mut c_void, arg: *mut c_void, ) -> c_int1150 pub fn pthread_create( 1151 tid: *mut crate::pthread_t, 1152 attr: *const crate::pthread_attr_t, 1153 start: extern "C" fn(*mut c_void) -> *mut c_void, 1154 arg: *mut c_void, 1155 ) -> c_int; pthread_condattr_setclock( attr: *mut pthread_condattr_t, clock_id: crate::clockid_t, ) -> c_int1156 pub fn pthread_condattr_setclock( 1157 attr: *mut pthread_condattr_t, 1158 clock_id: crate::clockid_t, 1159 ) -> c_int; 1160 1161 //pty.h openpty( amaster: *mut c_int, aslave: *mut c_int, name: *mut c_char, termp: *const termios, winp: *const crate::winsize, ) -> c_int1162 pub fn openpty( 1163 amaster: *mut c_int, 1164 aslave: *mut c_int, 1165 name: *mut c_char, 1166 termp: *const termios, 1167 winp: *const crate::winsize, 1168 ) -> c_int; 1169 1170 // pwd.h getpwent() -> *mut passwd1171 pub fn getpwent() -> *mut passwd; setpwent()1172 pub fn setpwent(); endpwent()1173 pub fn endpwent(); getpwnam_r( name: *const c_char, pwd: *mut passwd, buf: *mut c_char, buflen: size_t, result: *mut *mut passwd, ) -> c_int1174 pub fn getpwnam_r( 1175 name: *const c_char, 1176 pwd: *mut passwd, 1177 buf: *mut c_char, 1178 buflen: size_t, 1179 result: *mut *mut passwd, 1180 ) -> c_int; getpwuid_r( uid: crate::uid_t, pwd: *mut passwd, buf: *mut c_char, buflen: size_t, result: *mut *mut passwd, ) -> c_int1181 pub fn getpwuid_r( 1182 uid: crate::uid_t, 1183 pwd: *mut passwd, 1184 buf: *mut c_char, 1185 buflen: size_t, 1186 result: *mut *mut passwd, 1187 ) -> c_int; 1188 1189 // signal.h pthread_sigmask( how: c_int, set: *const crate::sigset_t, oldset: *mut crate::sigset_t, ) -> c_int1190 pub fn pthread_sigmask( 1191 how: c_int, 1192 set: *const crate::sigset_t, 1193 oldset: *mut crate::sigset_t, 1194 ) -> c_int; pthread_cancel(thread: crate::pthread_t) -> c_int1195 pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int1196 pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; sigtimedwait( set: *const sigset_t, sig: *mut siginfo_t, timeout: *const crate::timespec, ) -> c_int1197 pub fn sigtimedwait( 1198 set: *const sigset_t, 1199 sig: *mut siginfo_t, 1200 timeout: *const crate::timespec, 1201 ) -> c_int; sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int1202 pub fn sigwait(set: *const sigset_t, sig: *mut c_int) -> c_int; 1203 1204 // stdlib.h getsubopt( optionp: *mut *mut c_char, tokens: *const *mut c_char, valuep: *mut *mut c_char, ) -> c_int1205 pub fn getsubopt( 1206 optionp: *mut *mut c_char, 1207 tokens: *const *mut c_char, 1208 valuep: *mut *mut c_char, 1209 ) -> c_int; reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void1210 pub fn reallocarray(ptr: *mut c_void, nmemb: size_t, size: size_t) -> *mut c_void; 1211 1212 // string.h explicit_bzero(p: *mut c_void, len: size_t)1213 pub fn explicit_bzero(p: *mut c_void, len: size_t); strlcat(dst: *mut c_char, src: *const c_char, siz: size_t) -> size_t1214 pub fn strlcat(dst: *mut c_char, src: *const c_char, siz: size_t) -> size_t; strlcpy(dst: *mut c_char, src: *const c_char, siz: size_t) -> size_t1215 pub fn strlcpy(dst: *mut c_char, src: *const c_char, siz: size_t) -> size_t; 1216 1217 // sys/epoll.h epoll_create(size: c_int) -> c_int1218 pub fn epoll_create(size: c_int) -> c_int; epoll_create1(flags: c_int) -> c_int1219 pub fn epoll_create1(flags: c_int) -> c_int; epoll_wait( epfd: c_int, events: *mut crate::epoll_event, maxevents: c_int, timeout: c_int, ) -> c_int1220 pub fn epoll_wait( 1221 epfd: c_int, 1222 events: *mut crate::epoll_event, 1223 maxevents: c_int, 1224 timeout: c_int, 1225 ) -> c_int; epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int1226 pub fn epoll_ctl(epfd: c_int, op: c_int, fd: c_int, event: *mut crate::epoll_event) -> c_int; 1227 1228 // sys/ioctl.h ioctl(fd: c_int, request: c_ulong, ...) -> c_int1229 pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int; 1230 1231 // sys/mman.h madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int1232 pub fn madvise(addr: *mut c_void, len: size_t, advice: c_int) -> c_int; msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int1233 pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int1234 pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int1235 pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; shm_unlink(name: *const c_char) -> c_int1236 pub fn shm_unlink(name: *const c_char) -> c_int; 1237 1238 // sys/resource.h getpriority(which: c_int, who: crate::id_t) -> c_int1239 pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int1240 pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int1241 pub fn getrlimit(resource: c_int, rlim: *mut crate::rlimit) -> c_int; setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int1242 pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; 1243 1244 // sys/socket.h CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar1245 pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar; CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr1246 pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr; CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr1247 pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr; bind( socket: c_int, address: *const crate::sockaddr, address_len: crate::socklen_t, ) -> c_int1248 pub fn bind( 1249 socket: c_int, 1250 address: *const crate::sockaddr, 1251 address_len: crate::socklen_t, 1252 ) -> c_int; recvfrom( socket: c_int, buf: *mut c_void, len: size_t, flags: c_int, addr: *mut crate::sockaddr, addrlen: *mut crate::socklen_t, ) -> ssize_t1253 pub fn recvfrom( 1254 socket: c_int, 1255 buf: *mut c_void, 1256 len: size_t, 1257 flags: c_int, 1258 addr: *mut crate::sockaddr, 1259 addrlen: *mut crate::socklen_t, 1260 ) -> ssize_t; recvmsg(socket: c_int, msg: *mut msghdr, flags: c_int) -> ssize_t1261 pub fn recvmsg(socket: c_int, msg: *mut msghdr, flags: c_int) -> ssize_t; sendmsg(socket: c_int, msg: *const msghdr, flags: c_int) -> ssize_t1262 pub fn sendmsg(socket: c_int, msg: *const msghdr, flags: c_int) -> ssize_t; 1263 1264 // sys/stat.h futimens(fd: c_int, times: *const crate::timespec) -> c_int1265 pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; 1266 1267 // sys/uio.h preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t1268 pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t1269 pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t1270 pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t1271 pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; 1272 1273 // sys/utsname.h uname(utsname: *mut utsname) -> c_int1274 pub fn uname(utsname: *mut utsname) -> c_int; 1275 1276 // time.h gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int1277 pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut crate::timezone) -> c_int; clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int1278 pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; 1279 1280 // utmp.h login_tty(fd: c_int) -> c_int1281 pub fn login_tty(fd: c_int) -> c_int; 1282 } 1283 1284 cfg_if! { 1285 if #[cfg(feature = "extra_traits")] { 1286 impl PartialEq for dirent { 1287 fn eq(&self, other: &dirent) -> bool { 1288 self.d_ino == other.d_ino 1289 && self.d_off == other.d_off 1290 && self.d_reclen == other.d_reclen 1291 && self.d_type == other.d_type 1292 && self 1293 .d_name 1294 .iter() 1295 .zip(other.d_name.iter()) 1296 .all(|(a, b)| a == b) 1297 } 1298 } 1299 1300 impl Eq for dirent {} 1301 1302 impl hash::Hash for dirent { 1303 fn hash<H: hash::Hasher>(&self, state: &mut H) { 1304 self.d_ino.hash(state); 1305 self.d_off.hash(state); 1306 self.d_reclen.hash(state); 1307 self.d_type.hash(state); 1308 self.d_name.hash(state); 1309 } 1310 } 1311 1312 impl PartialEq for sockaddr_un { 1313 fn eq(&self, other: &sockaddr_un) -> bool { 1314 self.sun_family == other.sun_family 1315 && self 1316 .sun_path 1317 .iter() 1318 .zip(other.sun_path.iter()) 1319 .all(|(a, b)| a == b) 1320 } 1321 } 1322 1323 impl Eq for sockaddr_un {} 1324 1325 impl hash::Hash for sockaddr_un { 1326 fn hash<H: hash::Hasher>(&self, state: &mut H) { 1327 self.sun_family.hash(state); 1328 self.sun_path.hash(state); 1329 } 1330 } 1331 1332 impl PartialEq for sockaddr_storage { 1333 fn eq(&self, other: &sockaddr_storage) -> bool { 1334 self.ss_family == other.ss_family 1335 && self.__ss_align == self.__ss_align 1336 && self 1337 .__ss_padding 1338 .iter() 1339 .zip(other.__ss_padding.iter()) 1340 .all(|(a, b)| a == b) 1341 } 1342 } 1343 1344 impl Eq for sockaddr_storage {} 1345 1346 impl hash::Hash for sockaddr_storage { 1347 fn hash<H: hash::Hasher>(&self, state: &mut H) { 1348 self.ss_family.hash(state); 1349 self.__ss_padding.hash(state); 1350 self.__ss_align.hash(state); 1351 } 1352 } 1353 1354 impl PartialEq for utsname { 1355 fn eq(&self, other: &utsname) -> bool { 1356 self.sysname 1357 .iter() 1358 .zip(other.sysname.iter()) 1359 .all(|(a, b)| a == b) 1360 && self 1361 .nodename 1362 .iter() 1363 .zip(other.nodename.iter()) 1364 .all(|(a, b)| a == b) 1365 && self 1366 .release 1367 .iter() 1368 .zip(other.release.iter()) 1369 .all(|(a, b)| a == b) 1370 && self 1371 .version 1372 .iter() 1373 .zip(other.version.iter()) 1374 .all(|(a, b)| a == b) 1375 && self 1376 .machine 1377 .iter() 1378 .zip(other.machine.iter()) 1379 .all(|(a, b)| a == b) 1380 && self 1381 .domainname 1382 .iter() 1383 .zip(other.domainname.iter()) 1384 .all(|(a, b)| a == b) 1385 } 1386 } 1387 1388 impl Eq for utsname {} 1389 1390 impl hash::Hash for utsname { 1391 fn hash<H: hash::Hasher>(&self, state: &mut H) { 1392 self.sysname.hash(state); 1393 self.nodename.hash(state); 1394 self.release.hash(state); 1395 self.version.hash(state); 1396 self.machine.hash(state); 1397 self.domainname.hash(state); 1398 } 1399 } 1400 } 1401 } 1402