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