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