| ... | @@ -0,0 +1,1450 @@ |
| 1 | // SPDX-License-Identifier: MIT |
| 2 | // Copyright (c) 2015-2020 Zig Contributors |
| 3 | // This file is part of [zig](https://ziglang.org/), which is MIT licensed. |
| 4 | // The MIT license requires this copyright notice to be included in all copies |
| 5 | // and substantial portions of the software. |
| 6 | const std = @import("../../std.zig"); |
| 7 | const maxInt = std.math.maxInt; |
| 8 | |
| 9 | pub const fd_t = c_int; |
| 10 | pub const pid_t = c_int; |
| 11 | pub const uid_t = u32; |
| 12 | pub const gid_t = u32; |
| 13 | pub const mode_t = c_uint; |
| 14 | |
| 15 | pub const socklen_t = u32; |
| 16 | |
| 17 | /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. |
| 18 | pub const Kevent = extern struct { |
| 19 | ident: usize, |
| 20 | filter: i16, |
| 21 | flags: u16, |
| 22 | fflags: u32, |
| 23 | data: i64, |
| 24 | udata: usize, |
| 25 | // TODO ext |
| 26 | }; |
| 27 | |
| 28 | // Modes and flags for dlopen() |
| 29 | // include/dlfcn.h |
| 30 | |
| 31 | pub const POLLIN = 0x0001; |
| 32 | pub const POLLERR = 0x0004; |
| 33 | pub const POLLNVAL = 0x1000; |
| 34 | pub const POLLHUP = 0x0080; |
| 35 | |
| 36 | /// Bind function calls lazily. |
| 37 | pub const RTLD_LAZY = 1; |
| 38 | |
| 39 | /// Bind function calls immediately. |
| 40 | pub const RTLD_NOW = 2; |
| 41 | |
| 42 | pub const RTLD_MODEMASK = 0x3; |
| 43 | |
| 44 | /// Make symbols globally available. |
| 45 | pub const RTLD_GLOBAL = 0x100; |
| 46 | |
| 47 | /// Opposite of RTLD_GLOBAL, and the default. |
| 48 | pub const RTLD_LOCAL = 0; |
| 49 | |
| 50 | /// Trace loaded objects and exit. |
| 51 | pub const RTLD_TRACE = 0x200; |
| 52 | |
| 53 | /// Do not remove members. |
| 54 | pub const RTLD_NODELETE = 0x01000; |
| 55 | |
| 56 | /// Do not load if not already loaded. |
| 57 | pub const RTLD_NOLOAD = 0x02000; |
| 58 | |
| 59 | pub const dl_phdr_info = extern struct { |
| 60 | dlpi_addr: usize, |
| 61 | dlpi_name: ?[*:0]const u8, |
| 62 | dlpi_phdr: [*]std.elf.Phdr, |
| 63 | dlpi_phnum: u16, |
| 64 | }; |
| 65 | |
| 66 | pub const Flock = extern struct { |
| 67 | l_start: off_t, |
| 68 | l_len: off_t, |
| 69 | l_pid: pid_t, |
| 70 | l_type: i16, |
| 71 | l_whence: i16, |
| 72 | l_sysid: i32, |
| 73 | __unused: [4]u8, |
| 74 | }; |
| 75 | |
| 76 | pub const msghdr = extern struct { |
| 77 | /// optional address |
| 78 | msg_name: ?*sockaddr, |
| 79 | |
| 80 | /// size of address |
| 81 | msg_namelen: socklen_t, |
| 82 | |
| 83 | /// scatter/gather array |
| 84 | msg_iov: [*]iovec, |
| 85 | |
| 86 | /// # elements in msg_iov |
| 87 | msg_iovlen: i32, |
| 88 | |
| 89 | /// ancillary data |
| 90 | msg_control: ?*c_void, |
| 91 | |
| 92 | /// ancillary data buffer len |
| 93 | msg_controllen: socklen_t, |
| 94 | |
| 95 | /// flags on received message |
| 96 | msg_flags: i32, |
| 97 | }; |
| 98 | |
| 99 | pub const msghdr_const = extern struct { |
| 100 | /// optional address |
| 101 | msg_name: ?*const sockaddr, |
| 102 | |
| 103 | /// size of address |
| 104 | msg_namelen: socklen_t, |
| 105 | |
| 106 | /// scatter/gather array |
| 107 | msg_iov: [*]iovec_const, |
| 108 | |
| 109 | /// # elements in msg_iov |
| 110 | msg_iovlen: i32, |
| 111 | |
| 112 | /// ancillary data |
| 113 | msg_control: ?*c_void, |
| 114 | |
| 115 | /// ancillary data buffer len |
| 116 | msg_controllen: socklen_t, |
| 117 | |
| 118 | /// flags on received message |
| 119 | msg_flags: i32, |
| 120 | }; |
| 121 | |
| 122 | pub const off_t = i64; |
| 123 | pub const ino_t = u64; |
| 124 | |
| 125 | pub const nfds_t = u32; |
| 126 | |
| 127 | pub const pollfd = extern struct { |
| 128 | fd: i32, |
| 129 | events: i16, |
| 130 | revents: i16, |
| 131 | }; |
| 132 | |
| 133 | pub const libc_stat = extern struct { |
| 134 | dev: i32, |
| 135 | ino: u64, |
| 136 | mode: u32, |
| 137 | nlink: i32, |
| 138 | uid: i32, |
| 139 | gid: i32, |
| 140 | size: i64, |
| 141 | rdev: i32, |
| 142 | blksize: i32, |
| 143 | atim: timespec, |
| 144 | mtim: timespec, |
| 145 | ctim: timespec, |
| 146 | crtim: timespec, |
| 147 | st_type: u32, |
| 148 | blocks: i64, |
| 149 | |
| 150 | pub fn atime(self: @This()) timespec { |
| 151 | return self.atim; |
| 152 | } |
| 153 | pub fn mtime(self: @This()) timespec { |
| 154 | return self.mtim; |
| 155 | } |
| 156 | pub fn ctime(self: @This()) timespec { |
| 157 | return self.ctim; |
| 158 | } |
| 159 | pub fn crtime(self: @This()) timespec { |
| 160 | return self.crtim; |
| 161 | } |
| 162 | }; |
| 163 | |
| 164 | pub const timespec = extern struct { |
| 165 | tv_sec: isize, |
| 166 | tv_nsec: isize, |
| 167 | }; |
| 168 | |
| 169 | pub const dirent = extern struct { |
| 170 | d_dev: i32, |
| 171 | d_pdev: i32, |
| 172 | d_ino: i64, |
| 173 | d_pino: i64, |
| 174 | d_reclen: u16, |
| 175 | d_name: [256]u8, |
| 176 | |
| 177 | pub fn reclen(self: dirent) u16 { |
| 178 | return self.d_reclen; |
| 179 | } |
| 180 | }; |
| 181 | |
| 182 | pub const image_info = extern struct { |
| 183 | id: u32, //image_id |
| 184 | type: u32, // image_type |
| 185 | sequence: i32, |
| 186 | init_order: i32, |
| 187 | init_routine: *c_void, |
| 188 | term_routine: *c_void, |
| 189 | device: i32, |
| 190 | node: i32, |
| 191 | name: [1024]u8, |
| 192 | text: *c_void, |
| 193 | data: *c_void, |
| 194 | text_size: i32, |
| 195 | data_size: i32, |
| 196 | api_version: i32, |
| 197 | abi: i32, |
| 198 | }; |
| 199 | |
| 200 | pub const system_info = extern struct { |
| 201 | boot_time: i64, |
| 202 | cpu_count: u32, |
| 203 | max_pages: u64, |
| 204 | used_pages: u64, |
| 205 | cached_pages: u64, |
| 206 | block_cache_pages: u64, |
| 207 | ignored_pages: u64, |
| 208 | needed_memory: u64, |
| 209 | free_memory: u64, |
| 210 | max_swap_pages: u64, |
| 211 | free_swap_pages: u64, |
| 212 | page_faults: u32, |
| 213 | max_sems: u32, |
| 214 | used_sems: u32, |
| 215 | max_ports: u32, |
| 216 | used_ports: u32, |
| 217 | max_threads: u32, |
| 218 | used_threads: u32, |
| 219 | max_teams: u32, |
| 220 | used_teams: u32, |
| 221 | kernel_name: [256]u8, |
| 222 | kernel_build_date: [32]u8, |
| 223 | kernel_build_time: [32]u8, |
| 224 | kernel_version: i64, |
| 225 | abi: u32, |
| 226 | }; |
| 227 | |
| 228 | pub const in_port_t = u16; |
| 229 | pub const sa_family_t = u8; |
| 230 | |
| 231 | pub const sockaddr = extern struct { |
| 232 | /// total length |
| 233 | len: u8, |
| 234 | |
| 235 | /// address family |
| 236 | family: sa_family_t, |
| 237 | |
| 238 | /// actually longer; address value |
| 239 | data: [14]u8, |
| 240 | }; |
| 241 | |
| 242 | pub const sockaddr_in = extern struct { |
| 243 | len: u8 = @sizeOf(sockaddr_in), |
| 244 | family: sa_family_t = AF_INET, |
| 245 | port: in_port_t, |
| 246 | addr: u32, |
| 247 | zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 }, |
| 248 | }; |
| 249 | |
| 250 | pub const sockaddr_in6 = extern struct { |
| 251 | len: u8 = @sizeOf(sockaddr_in6), |
| 252 | family: sa_family_t = AF_INET6, |
| 253 | port: in_port_t, |
| 254 | flowinfo: u32, |
| 255 | addr: [16]u8, |
| 256 | scope_id: u32, |
| 257 | }; |
| 258 | |
| 259 | pub const sockaddr_un = extern struct { |
| 260 | len: u8 = @sizeOf(sockaddr_un), |
| 261 | family: sa_family_t = AF_UNIX, |
| 262 | path: [104]u8, |
| 263 | }; |
| 264 | |
| 265 | pub const CTL_KERN = 1; |
| 266 | pub const CTL_DEBUG = 5; |
| 267 | |
| 268 | pub const KERN_PROC = 14; // struct: process entries |
| 269 | pub const KERN_PROC_PATHNAME = 12; // path to executable |
| 270 | |
| 271 | pub const PATH_MAX = 1024; |
| 272 | |
| 273 | pub const STDIN_FILENO = 0; |
| 274 | pub const STDOUT_FILENO = 1; |
| 275 | pub const STDERR_FILENO = 2; |
| 276 | |
| 277 | pub const PROT_NONE = 0; |
| 278 | pub const PROT_READ = 1; |
| 279 | pub const PROT_WRITE = 2; |
| 280 | pub const PROT_EXEC = 4; |
| 281 | |
| 282 | pub const CLOCK_REALTIME = 0; |
| 283 | pub const CLOCK_VIRTUAL = 1; |
| 284 | pub const CLOCK_PROF = 2; |
| 285 | pub const CLOCK_MONOTONIC = 4; |
| 286 | pub const CLOCK_UPTIME = 5; |
| 287 | pub const CLOCK_UPTIME_PRECISE = 7; |
| 288 | pub const CLOCK_UPTIME_FAST = 8; |
| 289 | pub const CLOCK_REALTIME_PRECISE = 9; |
| 290 | pub const CLOCK_REALTIME_FAST = 10; |
| 291 | pub const CLOCK_MONOTONIC_PRECISE = 11; |
| 292 | pub const CLOCK_MONOTONIC_FAST = 12; |
| 293 | pub const CLOCK_SECOND = 13; |
| 294 | pub const CLOCK_THREAD_CPUTIME_ID = 14; |
| 295 | pub const CLOCK_PROCESS_CPUTIME_ID = 15; |
| 296 | |
| 297 | pub const MAP_FAILED = @intToPtr(*c_void, maxInt(usize)); |
| 298 | pub const MAP_SHARED = 0x0001; |
| 299 | pub const MAP_PRIVATE = 0x0002; |
| 300 | pub const MAP_FIXED = 0x0010; |
| 301 | pub const MAP_STACK = 0x0400; |
| 302 | pub const MAP_NOSYNC = 0x0800; |
| 303 | pub const MAP_ANON = 0x1000; |
| 304 | pub const MAP_ANONYMOUS = MAP_ANON; |
| 305 | pub const MAP_FILE = 0; |
| 306 | |
| 307 | pub const MAP_GUARD = 0x00002000; |
| 308 | pub const MAP_EXCL = 0x00004000; |
| 309 | pub const MAP_NOCORE = 0x00020000; |
| 310 | pub const MAP_PREFAULT_READ = 0x00040000; |
| 311 | pub const MAP_32BIT = 0x00080000; |
| 312 | |
| 313 | pub const WNOHANG = 1; |
| 314 | pub const WUNTRACED = 2; |
| 315 | pub const WSTOPPED = WUNTRACED; |
| 316 | pub const WCONTINUED = 4; |
| 317 | pub const WNOWAIT = 8; |
| 318 | pub const WEXITED = 16; |
| 319 | pub const WTRAPPED = 32; |
| 320 | |
| 321 | pub const SA_ONSTACK = 0x0001; |
| 322 | pub const SA_RESTART = 0x0002; |
| 323 | pub const SA_RESETHAND = 0x0004; |
| 324 | pub const SA_NOCLDSTOP = 0x0008; |
| 325 | pub const SA_NODEFER = 0x0010; |
| 326 | pub const SA_NOCLDWAIT = 0x0020; |
| 327 | pub const SA_SIGINFO = 0x0040; |
| 328 | |
| 329 | pub const SIGHUP = 1; |
| 330 | pub const SIGINT = 2; |
| 331 | pub const SIGQUIT = 3; |
| 332 | pub const SIGILL = 4; |
| 333 | pub const SIGTRAP = 5; |
| 334 | pub const SIGABRT = 6; |
| 335 | pub const SIGIOT = SIGABRT; |
| 336 | pub const SIGEMT = 7; |
| 337 | pub const SIGFPE = 8; |
| 338 | pub const SIGKILL = 9; |
| 339 | pub const SIGBUS = 10; |
| 340 | pub const SIGSEGV = 11; |
| 341 | pub const SIGSYS = 12; |
| 342 | pub const SIGPIPE = 13; |
| 343 | pub const SIGALRM = 14; |
| 344 | pub const SIGTERM = 15; |
| 345 | pub const SIGURG = 16; |
| 346 | pub const SIGSTOP = 17; |
| 347 | pub const SIGTSTP = 18; |
| 348 | pub const SIGCONT = 19; |
| 349 | pub const SIGCHLD = 20; |
| 350 | pub const SIGTTIN = 21; |
| 351 | pub const SIGTTOU = 22; |
| 352 | pub const SIGIO = 23; |
| 353 | pub const SIGXCPU = 24; |
| 354 | pub const SIGXFSZ = 25; |
| 355 | pub const SIGVTALRM = 26; |
| 356 | pub const SIGPROF = 27; |
| 357 | pub const SIGWINCH = 28; |
| 358 | pub const SIGINFO = 29; |
| 359 | pub const SIGUSR1 = 30; |
| 360 | pub const SIGUSR2 = 31; |
| 361 | pub const SIGTHR = 32; |
| 362 | pub const SIGLWP = SIGTHR; |
| 363 | pub const SIGLIBRT = 33; |
| 364 | |
| 365 | pub const SIGRTMIN = 65; |
| 366 | pub const SIGRTMAX = 126; |
| 367 | |
| 368 | // access function |
| 369 | pub const F_OK = 0; // test for existence of file |
| 370 | pub const X_OK = 1; // test for execute or search permission |
| 371 | pub const W_OK = 2; // test for write permission |
| 372 | pub const R_OK = 4; // test for read permission |
| 373 | |
| 374 | pub const O_RDONLY = 0x0000; |
| 375 | pub const O_WRONLY = 0x0001; |
| 376 | pub const O_RDWR = 0x0002; |
| 377 | pub const O_ACCMODE = 0x0003; |
| 378 | |
| 379 | pub const O_SHLOCK = 0x0010; |
| 380 | pub const O_EXLOCK = 0x0020; |
| 381 | |
| 382 | pub const O_CREAT = 0x0200; |
| 383 | pub const O_EXCL = 0x0800; |
| 384 | pub const O_NOCTTY = 0x8000; |
| 385 | pub const O_TRUNC = 0x0400; |
| 386 | pub const O_APPEND = 0x0008; |
| 387 | pub const O_NONBLOCK = 0x0004; |
| 388 | pub const O_DSYNC = 0o10000; |
| 389 | pub const O_SYNC = 0x0080; |
| 390 | pub const O_RSYNC = 0o4010000; |
| 391 | pub const O_DIRECTORY = 0x20000; |
| 392 | pub const O_NOFOLLOW = 0x0100; |
| 393 | pub const O_CLOEXEC = 0x00100000; |
| 394 | |
| 395 | pub const O_ASYNC = 0x0040; |
| 396 | pub const O_DIRECT = 0x00010000; |
| 397 | pub const O_NOATIME = 0o1000000; |
| 398 | pub const O_PATH = 0o10000000; |
| 399 | pub const O_TMPFILE = 0o20200000; |
| 400 | pub const O_NDELAY = O_NONBLOCK; |
| 401 | |
| 402 | pub const F_DUPFD = 0; |
| 403 | pub const F_GETFD = 1; |
| 404 | pub const F_SETFD = 2; |
| 405 | pub const F_GETFL = 3; |
| 406 | pub const F_SETFL = 4; |
| 407 | |
| 408 | pub const F_GETOWN = 5; |
| 409 | pub const F_SETOWN = 6; |
| 410 | |
| 411 | pub const F_GETLK = 11; |
| 412 | pub const F_SETLK = 12; |
| 413 | pub const F_SETLKW = 13; |
| 414 | |
| 415 | pub const F_RDLCK = 1; |
| 416 | pub const F_WRLCK = 3; |
| 417 | pub const F_UNLCK = 2; |
| 418 | |
| 419 | pub const LOCK_SH = 1; |
| 420 | pub const LOCK_EX = 2; |
| 421 | pub const LOCK_UN = 8; |
| 422 | pub const LOCK_NB = 4; |
| 423 | |
| 424 | pub const F_SETOWN_EX = 15; |
| 425 | pub const F_GETOWN_EX = 16; |
| 426 | |
| 427 | pub const F_GETOWNER_UIDS = 17; |
| 428 | |
| 429 | pub const FD_CLOEXEC = 1; |
| 430 | |
| 431 | pub const SEEK_SET = 0; |
| 432 | pub const SEEK_CUR = 1; |
| 433 | pub const SEEK_END = 2; |
| 434 | |
| 435 | pub const SIG_BLOCK = 1; |
| 436 | pub const SIG_UNBLOCK = 2; |
| 437 | pub const SIG_SETMASK = 3; |
| 438 | |
| 439 | pub const SOCK_STREAM = 1; |
| 440 | pub const SOCK_DGRAM = 2; |
| 441 | pub const SOCK_RAW = 3; |
| 442 | pub const SOCK_RDM = 4; |
| 443 | pub const SOCK_SEQPACKET = 5; |
| 444 | |
| 445 | pub const SOCK_CLOEXEC = 0x10000000; |
| 446 | pub const SOCK_NONBLOCK = 0x20000000; |
| 447 | |
| 448 | pub const SO_DEBUG = 0x00000001; |
| 449 | pub const SO_ACCEPTCONN = 0x00000002; |
| 450 | pub const SO_REUSEADDR = 0x00000004; |
| 451 | pub const SO_KEEPALIVE = 0x00000008; |
| 452 | pub const SO_DONTROUTE = 0x00000010; |
| 453 | pub const SO_BROADCAST = 0x00000020; |
| 454 | pub const SO_USELOOPBACK = 0x00000040; |
| 455 | pub const SO_LINGER = 0x00000080; |
| 456 | pub const SO_OOBINLINE = 0x00000100; |
| 457 | pub const SO_REUSEPORT = 0x00000200; |
| 458 | pub const SO_TIMESTAMP = 0x00000400; |
| 459 | pub const SO_NOSIGPIPE = 0x00000800; |
| 460 | pub const SO_ACCEPTFILTER = 0x00001000; |
| 461 | pub const SO_BINTIME = 0x00002000; |
| 462 | pub const SO_NO_OFFLOAD = 0x00004000; |
| 463 | pub const SO_NO_DDP = 0x00008000; |
| 464 | pub const SO_REUSEPORT_LB = 0x00010000; |
| 465 | |
| 466 | pub const SO_SNDBUF = 0x1001; |
| 467 | pub const SO_RCVBUF = 0x1002; |
| 468 | pub const SO_SNDLOWAT = 0x1003; |
| 469 | pub const SO_RCVLOWAT = 0x1004; |
| 470 | pub const SO_SNDTIMEO = 0x1005; |
| 471 | pub const SO_RCVTIMEO = 0x1006; |
| 472 | pub const SO_ERROR = 0x1007; |
| 473 | pub const SO_TYPE = 0x1008; |
| 474 | pub const SO_LABEL = 0x1009; |
| 475 | pub const SO_PEERLABEL = 0x1010; |
| 476 | pub const SO_LISTENQLIMIT = 0x1011; |
| 477 | pub const SO_LISTENQLEN = 0x1012; |
| 478 | pub const SO_LISTENINCQLEN = 0x1013; |
| 479 | pub const SO_SETFIB = 0x1014; |
| 480 | pub const SO_USER_COOKIE = 0x1015; |
| 481 | pub const SO_PROTOCOL = 0x1016; |
| 482 | pub const SO_PROTOTYPE = SO_PROTOCOL; |
| 483 | pub const SO_TS_CLOCK = 0x1017; |
| 484 | pub const SO_MAX_PACING_RATE = 0x1018; |
| 485 | pub const SO_DOMAIN = 0x1019; |
| 486 | |
| 487 | pub const SOL_SOCKET = 0xffff; |
| 488 | |
| 489 | pub const PF_UNSPEC = AF_UNSPEC; |
| 490 | pub const PF_LOCAL = AF_LOCAL; |
| 491 | pub const PF_UNIX = PF_LOCAL; |
| 492 | pub const PF_INET = AF_INET; |
| 493 | pub const PF_IMPLINK = AF_IMPLINK; |
| 494 | pub const PF_PUP = AF_PUP; |
| 495 | pub const PF_CHAOS = AF_CHAOS; |
| 496 | pub const PF_NETBIOS = AF_NETBIOS; |
| 497 | pub const PF_ISO = AF_ISO; |
| 498 | pub const PF_OSI = AF_ISO; |
| 499 | pub const PF_ECMA = AF_ECMA; |
| 500 | pub const PF_DATAKIT = AF_DATAKIT; |
| 501 | pub const PF_CCITT = AF_CCITT; |
| 502 | pub const PF_DECnet = AF_DECnet; |
| 503 | pub const PF_DLI = AF_DLI; |
| 504 | pub const PF_LAT = AF_LAT; |
| 505 | pub const PF_HYLINK = AF_HYLINK; |
| 506 | pub const PF_APPLETALK = AF_APPLETALK; |
| 507 | pub const PF_ROUTE = AF_ROUTE; |
| 508 | pub const PF_LINK = AF_LINK; |
| 509 | pub const PF_XTP = pseudo_AF_XTP; |
| 510 | pub const PF_COIP = AF_COIP; |
| 511 | pub const PF_CNT = AF_CNT; |
| 512 | pub const PF_SIP = AF_SIP; |
| 513 | pub const PF_IPX = AF_IPX; |
| 514 | pub const PF_RTIP = pseudo_AF_RTIP; |
| 515 | pub const PF_PIP = psuedo_AF_PIP; |
| 516 | pub const PF_ISDN = AF_ISDN; |
| 517 | pub const PF_KEY = pseudo_AF_KEY; |
| 518 | pub const PF_INET6 = pseudo_AF_INET6; |
| 519 | pub const PF_NATM = AF_NATM; |
| 520 | pub const PF_ATM = AF_ATM; |
| 521 | pub const PF_NETGRAPH = AF_NETGRAPH; |
| 522 | pub const PF_SLOW = AF_SLOW; |
| 523 | pub const PF_SCLUSTER = AF_SCLUSTER; |
| 524 | pub const PF_ARP = AF_ARP; |
| 525 | pub const PF_BLUETOOTH = AF_BLUETOOTH; |
| 526 | pub const PF_IEEE80211 = AF_IEEE80211; |
| 527 | pub const PF_INET_SDP = AF_INET_SDP; |
| 528 | pub const PF_INET6_SDP = AF_INET6_SDP; |
| 529 | pub const PF_MAX = AF_MAX; |
| 530 | |
| 531 | pub const AF_UNSPEC = 0; |
| 532 | pub const AF_UNIX = 1; |
| 533 | pub const AF_LOCAL = AF_UNIX; |
| 534 | pub const AF_FILE = AF_LOCAL; |
| 535 | pub const AF_INET = 2; |
| 536 | pub const AF_IMPLINK = 3; |
| 537 | pub const AF_PUP = 4; |
| 538 | pub const AF_CHAOS = 5; |
| 539 | pub const AF_NETBIOS = 6; |
| 540 | pub const AF_ISO = 7; |
| 541 | pub const AF_OSI = AF_ISO; |
| 542 | pub const AF_ECMA = 8; |
| 543 | pub const AF_DATAKIT = 9; |
| 544 | pub const AF_CCITT = 10; |
| 545 | pub const AF_SNA = 11; |
| 546 | pub const AF_DECnet = 12; |
| 547 | pub const AF_DLI = 13; |
| 548 | pub const AF_LAT = 14; |
| 549 | pub const AF_HYLINK = 15; |
| 550 | pub const AF_APPLETALK = 16; |
| 551 | pub const AF_ROUTE = 17; |
| 552 | pub const AF_LINK = 18; |
| 553 | pub const pseudo_AF_XTP = 19; |
| 554 | pub const AF_COIP = 20; |
| 555 | pub const AF_CNT = 21; |
| 556 | pub const pseudo_AF_RTIP = 22; |
| 557 | pub const AF_IPX = 23; |
| 558 | pub const AF_SIP = 24; |
| 559 | pub const pseudo_AF_PIP = 25; |
| 560 | pub const AF_ISDN = 26; |
| 561 | pub const AF_E164 = AF_ISDN; |
| 562 | pub const pseudo_AF_KEY = 27; |
| 563 | pub const AF_INET6 = 28; |
| 564 | pub const AF_NATM = 29; |
| 565 | pub const AF_ATM = 30; |
| 566 | pub const pseudo_AF_HDRCMPLT = 31; |
| 567 | pub const AF_NETGRAPH = 32; |
| 568 | pub const AF_SLOW = 33; |
| 569 | pub const AF_SCLUSTER = 34; |
| 570 | pub const AF_ARP = 35; |
| 571 | pub const AF_BLUETOOTH = 36; |
| 572 | pub const AF_IEEE80211 = 37; |
| 573 | pub const AF_INET_SDP = 40; |
| 574 | pub const AF_INET6_SDP = 42; |
| 575 | pub const AF_MAX = 42; |
| 576 | |
| 577 | pub const DT_UNKNOWN = 0; |
| 578 | pub const DT_FIFO = 1; |
| 579 | pub const DT_CHR = 2; |
| 580 | pub const DT_DIR = 4; |
| 581 | pub const DT_BLK = 6; |
| 582 | pub const DT_REG = 8; |
| 583 | pub const DT_LNK = 10; |
| 584 | pub const DT_SOCK = 12; |
| 585 | pub const DT_WHT = 14; |
| 586 | |
| 587 | /// add event to kq (implies enable) |
| 588 | pub const EV_ADD = 0x0001; |
| 589 | |
| 590 | /// delete event from kq |
| 591 | pub const EV_DELETE = 0x0002; |
| 592 | |
| 593 | /// enable event |
| 594 | pub const EV_ENABLE = 0x0004; |
| 595 | |
| 596 | /// disable event (not reported) |
| 597 | pub const EV_DISABLE = 0x0008; |
| 598 | |
| 599 | /// only report one occurrence |
| 600 | pub const EV_ONESHOT = 0x0010; |
| 601 | |
| 602 | /// clear event state after reporting |
| 603 | pub const EV_CLEAR = 0x0020; |
| 604 | |
| 605 | /// force immediate event output |
| 606 | /// ... with or without EV_ERROR |
| 607 | /// ... use KEVENT_FLAG_ERROR_EVENTS |
| 608 | /// on syscalls supporting flags |
| 609 | pub const EV_RECEIPT = 0x0040; |
| 610 | |
| 611 | /// disable event after reporting |
| 612 | pub const EV_DISPATCH = 0x0080; |
| 613 | |
| 614 | pub const EVFILT_READ = -1; |
| 615 | pub const EVFILT_WRITE = -2; |
| 616 | |
| 617 | /// attached to aio requests |
| 618 | pub const EVFILT_AIO = -3; |
| 619 | |
| 620 | /// attached to vnodes |
| 621 | pub const EVFILT_VNODE = -4; |
| 622 | |
| 623 | /// attached to struct proc |
| 624 | pub const EVFILT_PROC = -5; |
| 625 | |
| 626 | /// attached to struct proc |
| 627 | pub const EVFILT_SIGNAL = -6; |
| 628 | |
| 629 | /// timers |
| 630 | pub const EVFILT_TIMER = -7; |
| 631 | |
| 632 | /// Process descriptors |
| 633 | pub const EVFILT_PROCDESC = -8; |
| 634 | |
| 635 | /// Filesystem events |
| 636 | pub const EVFILT_FS = -9; |
| 637 | |
| 638 | pub const EVFILT_LIO = -10; |
| 639 | |
| 640 | /// User events |
| 641 | pub const EVFILT_USER = -11; |
| 642 | |
| 643 | /// Sendfile events |
| 644 | pub const EVFILT_SENDFILE = -12; |
| 645 | |
| 646 | pub const EVFILT_EMPTY = -13; |
| 647 | |
| 648 | /// On input, NOTE_TRIGGER causes the event to be triggered for output. |
| 649 | pub const NOTE_TRIGGER = 0x01000000; |
| 650 | |
| 651 | /// ignore input fflags |
| 652 | pub const NOTE_FFNOP = 0x00000000; |
| 653 | |
| 654 | /// and fflags |
| 655 | pub const NOTE_FFAND = 0x40000000; |
| 656 | |
| 657 | /// or fflags |
| 658 | pub const NOTE_FFOR = 0x80000000; |
| 659 | |
| 660 | /// copy fflags |
| 661 | pub const NOTE_FFCOPY = 0xc0000000; |
| 662 | |
| 663 | /// mask for operations |
| 664 | pub const NOTE_FFCTRLMASK = 0xc0000000; |
| 665 | pub const NOTE_FFLAGSMASK = 0x00ffffff; |
| 666 | |
| 667 | /// low water mark |
| 668 | pub const NOTE_LOWAT = 0x00000001; |
| 669 | |
| 670 | /// behave like poll() |
| 671 | pub const NOTE_FILE_POLL = 0x00000002; |
| 672 | |
| 673 | /// vnode was removed |
| 674 | pub const NOTE_DELETE = 0x00000001; |
| 675 | |
| 676 | /// data contents changed |
| 677 | pub const NOTE_WRITE = 0x00000002; |
| 678 | |
| 679 | /// size increased |
| 680 | pub const NOTE_EXTEND = 0x00000004; |
| 681 | |
| 682 | /// attributes changed |
| 683 | pub const NOTE_ATTRIB = 0x00000008; |
| 684 | |
| 685 | /// link count changed |
| 686 | pub const NOTE_LINK = 0x00000010; |
| 687 | |
| 688 | /// vnode was renamed |
| 689 | pub const NOTE_RENAME = 0x00000020; |
| 690 | |
| 691 | /// vnode access was revoked |
| 692 | pub const NOTE_REVOKE = 0x00000040; |
| 693 | |
| 694 | /// vnode was opened |
| 695 | pub const NOTE_OPEN = 0x00000080; |
| 696 | |
| 697 | /// file closed, fd did not allow write |
| 698 | pub const NOTE_CLOSE = 0x00000100; |
| 699 | |
| 700 | /// file closed, fd did allow write |
| 701 | pub const NOTE_CLOSE_WRITE = 0x00000200; |
| 702 | |
| 703 | /// file was read |
| 704 | pub const NOTE_READ = 0x00000400; |
| 705 | |
| 706 | /// process exited |
| 707 | pub const NOTE_EXIT = 0x80000000; |
| 708 | |
| 709 | /// process forked |
| 710 | pub const NOTE_FORK = 0x40000000; |
| 711 | |
| 712 | /// process exec'd |
| 713 | pub const NOTE_EXEC = 0x20000000; |
| 714 | |
| 715 | /// mask for signal & exit status |
| 716 | pub const NOTE_PDATAMASK = 0x000fffff; |
| 717 | pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK); |
| 718 | |
| 719 | /// data is seconds |
| 720 | pub const NOTE_SECONDS = 0x00000001; |
| 721 | |
| 722 | /// data is milliseconds |
| 723 | pub const NOTE_MSECONDS = 0x00000002; |
| 724 | |
| 725 | /// data is microseconds |
| 726 | pub const NOTE_USECONDS = 0x00000004; |
| 727 | |
| 728 | /// data is nanoseconds |
| 729 | pub const NOTE_NSECONDS = 0x00000008; |
| 730 | |
| 731 | /// timeout is absolute |
| 732 | pub const NOTE_ABSTIME = 0x00000010; |
| 733 | |
| 734 | pub const TIOCEXCL = 0x2000740d; |
| 735 | pub const TIOCNXCL = 0x2000740e; |
| 736 | pub const TIOCSCTTY = 0x20007461; |
| 737 | pub const TIOCGPGRP = 0x40047477; |
| 738 | pub const TIOCSPGRP = 0x80047476; |
| 739 | pub const TIOCOUTQ = 0x40047473; |
| 740 | pub const TIOCSTI = 0x80017472; |
| 741 | pub const TIOCGWINSZ = 0x40087468; |
| 742 | pub const TIOCSWINSZ = 0x80087467; |
| 743 | pub const TIOCMGET = 0x4004746a; |
| 744 | pub const TIOCMBIS = 0x8004746c; |
| 745 | pub const TIOCMBIC = 0x8004746b; |
| 746 | pub const TIOCMSET = 0x8004746d; |
| 747 | pub const FIONREAD = 0x4004667f; |
| 748 | pub const TIOCCONS = 0x80047462; |
| 749 | pub const TIOCPKT = 0x80047470; |
| 750 | pub const FIONBIO = 0x8004667e; |
| 751 | pub const TIOCNOTTY = 0x20007471; |
| 752 | pub const TIOCSETD = 0x8004741b; |
| 753 | pub const TIOCGETD = 0x4004741a; |
| 754 | pub const TIOCSBRK = 0x2000747b; |
| 755 | pub const TIOCCBRK = 0x2000747a; |
| 756 | pub const TIOCGSID = 0x40047463; |
| 757 | pub const TIOCGPTN = 0x4004740f; |
| 758 | pub const TIOCSIG = 0x2004745f; |
| 759 | |
| 760 | pub fn WEXITSTATUS(s: u32) u32 { |
| 761 | return (s & 0xff00) >> 8; |
| 762 | } |
| 763 | pub fn WTERMSIG(s: u32) u32 { |
| 764 | return s & 0x7f; |
| 765 | } |
| 766 | pub fn WSTOPSIG(s: u32) u32 { |
| 767 | return WEXITSTATUS(s); |
| 768 | } |
| 769 | pub fn WIFEXITED(s: u32) bool { |
| 770 | return WTERMSIG(s) == 0; |
| 771 | } |
| 772 | pub fn WIFSTOPPED(s: u32) bool { |
| 773 | return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00; |
| 774 | } |
| 775 | pub fn WIFSIGNALED(s: u32) bool { |
| 776 | return (s & 0xffff) -% 1 < 0xff; |
| 777 | } |
| 778 | |
| 779 | pub const winsize = extern struct { |
| 780 | ws_row: u16, |
| 781 | ws_col: u16, |
| 782 | ws_xpixel: u16, |
| 783 | ws_ypixel: u16, |
| 784 | }; |
| 785 | |
| 786 | const NSIG = 32; |
| 787 | |
| 788 | pub const SIG_ERR = @intToPtr(fn (i32) callconv(.C) void, maxInt(usize)); |
| 789 | pub const SIG_DFL = @intToPtr(fn (i32) callconv(.C) void, 0); |
| 790 | pub const SIG_IGN = @intToPtr(fn (i32) callconv(.C) void, 1); |
| 791 | |
| 792 | /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. |
| 793 | pub const Sigaction = extern struct { |
| 794 | /// signal handler |
| 795 | __sigaction_u: extern union { |
| 796 | __sa_handler: fn (i32) callconv(.C) void, |
| 797 | __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void, |
| 798 | }, |
| 799 | |
| 800 | /// see signal options |
| 801 | sa_flags: u32, |
| 802 | |
| 803 | /// signal mask to apply |
| 804 | sa_mask: sigset_t, |
| 805 | }; |
| 806 | |
| 807 | pub const _SIG_WORDS = 4; |
| 808 | pub const _SIG_MAXSIG = 128; |
| 809 | |
| 810 | pub inline fn _SIG_IDX(sig: usize) usize { |
| 811 | return sig - 1; |
| 812 | } |
| 813 | pub inline fn _SIG_WORD(sig: usize) usize { |
| 814 | return_SIG_IDX(sig) >> 5; |
| 815 | } |
| 816 | pub inline fn _SIG_BIT(sig: usize) usize { |
| 817 | return 1 << (_SIG_IDX(sig) & 31); |
| 818 | } |
| 819 | pub inline fn _SIG_VALID(sig: usize) usize { |
| 820 | return sig <= _SIG_MAXSIG and sig > 0; |
| 821 | } |
| 822 | |
| 823 | pub const sigset_t = extern struct { |
| 824 | __bits: [_SIG_WORDS]u32, |
| 825 | }; |
| 826 | |
| 827 | pub const EPERM = 1; // Operation not permitted |
| 828 | pub const ENOENT = 2; // No such file or directory |
| 829 | pub const ESRCH = 3; // No such process |
| 830 | pub const EINTR = 4; // Interrupted system call |
| 831 | pub const EIO = 5; // Input/output error |
| 832 | pub const ENXIO = 6; // Device not configured |
| 833 | pub const E2BIG = 7; // Argument list too long |
| 834 | pub const ENOEXEC = 8; // Exec format error |
| 835 | pub const EBADF = 9; // Bad file descriptor |
| 836 | pub const ECHILD = 10; // No child processes |
| 837 | pub const EDEADLK = 11; // Resource deadlock avoided |
| 838 | // 11 was EAGAIN |
| 839 | pub const ENOMEM = 12; // Cannot allocate memory |
| 840 | pub const EACCES = 13; // Permission denied |
| 841 | pub const EFAULT = 14; // Bad address |
| 842 | pub const ENOTBLK = 15; // Block device required |
| 843 | pub const EBUSY = 16; // Device busy |
| 844 | pub const EEXIST = 17; // File exists |
| 845 | pub const EXDEV = 18; // Cross-device link |
| 846 | pub const ENODEV = 19; // Operation not supported by device |
| 847 | pub const ENOTDIR = 20; // Not a directory |
| 848 | pub const EISDIR = 21; // Is a directory |
| 849 | pub const EINVAL = 22; // Invalid argument |
| 850 | pub const ENFILE = 23; // Too many open files in system |
| 851 | pub const EMFILE = 24; // Too many open files |
| 852 | pub const ENOTTY = 25; // Inappropriate ioctl for device |
| 853 | pub const ETXTBSY = 26; // Text file busy |
| 854 | pub const EFBIG = 27; // File too large |
| 855 | pub const ENOSPC = 28; // No space left on device |
| 856 | pub const ESPIPE = 29; // Illegal seek |
| 857 | pub const EROFS = 30; // Read-only filesystem |
| 858 | pub const EMLINK = 31; // Too many links |
| 859 | pub const EPIPE = 32; // Broken pipe |
| 860 | |
| 861 | // math software |
| 862 | pub const EDOM = 33; // Numerical argument out of domain |
| 863 | pub const ERANGE = 34; // Result too large |
| 864 | |
| 865 | // non-blocking and interrupt i/o |
| 866 | pub const EAGAIN = 35; // Resource temporarily unavailable |
| 867 | pub const EWOULDBLOCK = EAGAIN; // Operation would block |
| 868 | pub const EINPROGRESS = 36; // Operation now in progress |
| 869 | pub const EALREADY = 37; // Operation already in progress |
| 870 | |
| 871 | // ipc/network software -- argument errors |
| 872 | pub const ENOTSOCK = 38; // Socket operation on non-socket |
| 873 | pub const EDESTADDRREQ = 39; // Destination address required |
| 874 | pub const EMSGSIZE = 40; // Message too long |
| 875 | pub const EPROTOTYPE = 41; // Protocol wrong type for socket |
| 876 | pub const ENOPROTOOPT = 42; // Protocol not available |
| 877 | pub const EPROTONOSUPPORT = 43; // Protocol not supported |
| 878 | pub const ESOCKTNOSUPPORT = 44; // Socket type not supported |
| 879 | pub const EOPNOTSUPP = 45; // Operation not supported |
| 880 | pub const ENOTSUP = EOPNOTSUPP; // Operation not supported |
| 881 | pub const EPFNOSUPPORT = 46; // Protocol family not supported |
| 882 | pub const EAFNOSUPPORT = 47; // Address family not supported by protocol family |
| 883 | pub const EADDRINUSE = 48; // Address already in use |
| 884 | pub const EADDRNOTAVAIL = 49; // Can't assign requested address |
| 885 | |
| 886 | // ipc/network software -- operational errors |
| 887 | pub const ENETDOWN = 50; // Network is down |
| 888 | pub const ENETUNREACH = 51; // Network is unreachable |
| 889 | pub const ENETRESET = 52; // Network dropped connection on reset |
| 890 | pub const ECONNABORTED = 53; // Software caused connection abort |
| 891 | pub const ECONNRESET = 54; // Connection reset by peer |
| 892 | pub const ENOBUFS = 55; // No buffer space available |
| 893 | pub const EISCONN = 56; // Socket is already connected |
| 894 | pub const ENOTCONN = 57; // Socket is not connected |
| 895 | pub const ESHUTDOWN = 58; // Can't send after socket shutdown |
| 896 | pub const ETOOMANYREFS = 59; // Too many references: can't splice |
| 897 | pub const ETIMEDOUT = 60; // Operation timed out |
| 898 | pub const ECONNREFUSED = 61; // Connection refused |
| 899 | |
| 900 | pub const ELOOP = 62; // Too many levels of symbolic links |
| 901 | pub const ENAMETOOLONG = 63; // File name too long |
| 902 | |
| 903 | // should be rearranged |
| 904 | pub const EHOSTDOWN = 64; // Host is down |
| 905 | pub const EHOSTUNREACH = 65; // No route to host |
| 906 | pub const ENOTEMPTY = 66; // Directory not empty |
| 907 | |
| 908 | // quotas & mush |
| 909 | pub const EPROCLIM = 67; // Too many processes |
| 910 | pub const EUSERS = 68; // Too many users |
| 911 | pub const EDQUOT = 69; // Disc quota exceeded |
| 912 | |
| 913 | // Network File System |
| 914 | pub const ESTALE = 70; // Stale NFS file handle |
| 915 | pub const EREMOTE = 71; // Too many levels of remote in path |
| 916 | pub const EBADRPC = 72; // RPC struct is bad |
| 917 | pub const ERPCMISMATCH = 73; // RPC version wrong |
| 918 | pub const EPROGUNAVAIL = 74; // RPC prog. not avail |
| 919 | pub const EPROGMISMATCH = 75; // Program version wrong |
| 920 | pub const EPROCUNAVAIL = 76; // Bad procedure for program |
| 921 | |
| 922 | pub const ENOLCK = 77; // No locks available |
| 923 | pub const ENOSYS = 78; // Function not implemented |
| 924 | |
| 925 | pub const EFTYPE = 79; // Inappropriate file type or format |
| 926 | pub const EAUTH = 80; // Authentication error |
| 927 | pub const ENEEDAUTH = 81; // Need authenticator |
| 928 | pub const EIDRM = 82; // Identifier removed |
| 929 | pub const ENOMSG = 83; // No message of desired type |
| 930 | pub const EOVERFLOW = 84; // Value too large to be stored in data type |
| 931 | pub const ECANCELED = 85; // Operation canceled |
| 932 | pub const EILSEQ = 86; // Illegal byte sequence |
| 933 | pub const ENOATTR = 87; // Attribute not found |
| 934 | |
| 935 | pub const EDOOFUS = 88; // Programming error |
| 936 | |
| 937 | pub const EBADMSG = 89; // Bad message |
| 938 | pub const EMULTIHOP = 90; // Multihop attempted |
| 939 | pub const ENOLINK = 91; // Link has been severed |
| 940 | pub const EPROTO = 92; // Protocol error |
| 941 | |
| 942 | pub const ENOTCAPABLE = 93; // Capabilities insufficient |
| 943 | pub const ECAPMODE = 94; // Not permitted in capability mode |
| 944 | pub const ENOTRECOVERABLE = 95; // State not recoverable |
| 945 | pub const EOWNERDEAD = 96; // Previous owner died |
| 946 | |
| 947 | pub const ELAST = 96; // Must be equal largest errno |
| 948 | |
| 949 | pub const MINSIGSTKSZ = switch (builtin.arch) { |
| 950 | .i386, .x86_64 => 2048, |
| 951 | .arm, .aarch64 => 4096, |
| 952 | else => @compileError("MINSIGSTKSZ not defined for this architecture"), |
| 953 | }; |
| 954 | pub const SIGSTKSZ = MINSIGSTKSZ + 32768; |
| 955 | |
| 956 | pub const SS_ONSTACK = 1; |
| 957 | pub const SS_DISABLE = 4; |
| 958 | |
| 959 | pub const stack_t = extern struct { |
| 960 | ss_sp: [*]u8, |
| 961 | ss_size: isize, |
| 962 | ss_flags: i32, |
| 963 | }; |
| 964 | |
| 965 | pub const S_IFMT = 0o170000; |
| 966 | |
| 967 | pub const S_IFIFO = 0o010000; |
| 968 | pub const S_IFCHR = 0o020000; |
| 969 | pub const S_IFDIR = 0o040000; |
| 970 | pub const S_IFBLK = 0o060000; |
| 971 | pub const S_IFREG = 0o100000; |
| 972 | pub const S_IFLNK = 0o120000; |
| 973 | pub const S_IFSOCK = 0o140000; |
| 974 | pub const S_IFWHT = 0o160000; |
| 975 | |
| 976 | pub const S_ISUID = 0o4000; |
| 977 | pub const S_ISGID = 0o2000; |
| 978 | pub const S_ISVTX = 0o1000; |
| 979 | pub const S_IRWXU = 0o700; |
| 980 | pub const S_IRUSR = 0o400; |
| 981 | pub const S_IWUSR = 0o200; |
| 982 | pub const S_IXUSR = 0o100; |
| 983 | pub const S_IRWXG = 0o070; |
| 984 | pub const S_IRGRP = 0o040; |
| 985 | pub const S_IWGRP = 0o020; |
| 986 | pub const S_IXGRP = 0o010; |
| 987 | pub const S_IRWXO = 0o007; |
| 988 | pub const S_IROTH = 0o004; |
| 989 | pub const S_IWOTH = 0o002; |
| 990 | pub const S_IXOTH = 0o001; |
| 991 | |
| 992 | pub fn S_ISFIFO(m: u32) bool { |
| 993 | return m & S_IFMT == S_IFIFO; |
| 994 | } |
| 995 | |
| 996 | pub fn S_ISCHR(m: u32) bool { |
| 997 | return m & S_IFMT == S_IFCHR; |
| 998 | } |
| 999 | |
| 1000 | pub fn S_ISDIR(m: u32) bool { |
| 1001 | return m & S_IFMT == S_IFDIR; |
| 1002 | } |
| 1003 | |
| 1004 | pub fn S_ISBLK(m: u32) bool { |
| 1005 | return m & S_IFMT == S_IFBLK; |
| 1006 | } |
| 1007 | |
| 1008 | pub fn S_ISREG(m: u32) bool { |
| 1009 | return m & S_IFMT == S_IFREG; |
| 1010 | } |
| 1011 | |
| 1012 | pub fn S_ISLNK(m: u32) bool { |
| 1013 | return m & S_IFMT == S_IFLNK; |
| 1014 | } |
| 1015 | |
| 1016 | pub fn S_ISSOCK(m: u32) bool { |
| 1017 | return m & S_IFMT == S_IFSOCK; |
| 1018 | } |
| 1019 | |
| 1020 | pub fn S_IWHT(m: u32) bool { |
| 1021 | return m & S_IFMT == S_IFWHT; |
| 1022 | } |
| 1023 | |
| 1024 | pub const HOST_NAME_MAX = 255; |
| 1025 | |
| 1026 | /// Magic value that specify the use of the current working directory |
| 1027 | /// to determine the target of relative file paths in the openat() and |
| 1028 | /// similar syscalls. |
| 1029 | pub const AT_FDCWD = -100; |
| 1030 | |
| 1031 | /// Check access using effective user and group ID |
| 1032 | pub const AT_EACCESS = 0x0100; |
| 1033 | |
| 1034 | /// Do not follow symbolic links |
| 1035 | pub const AT_SYMLINK_NOFOLLOW = 0x0200; |
| 1036 | |
| 1037 | /// Follow symbolic link |
| 1038 | pub const AT_SYMLINK_FOLLOW = 0x0400; |
| 1039 | |
| 1040 | /// Remove directory instead of file |
| 1041 | pub const AT_REMOVEDIR = 0x0800; |
| 1042 | |
| 1043 | pub const addrinfo = extern struct { |
| 1044 | flags: i32, |
| 1045 | family: i32, |
| 1046 | socktype: i32, |
| 1047 | protocol: i32, |
| 1048 | addrlen: socklen_t, |
| 1049 | canonname: ?[*:0]u8, |
| 1050 | addr: ?*sockaddr, |
| 1051 | next: ?*addrinfo, |
| 1052 | }; |
| 1053 | |
| 1054 | /// Fail if not under dirfd |
| 1055 | pub const AT_BENEATH = 0x1000; |
| 1056 | |
| 1057 | /// dummy for IP |
| 1058 | pub const IPPROTO_IP = 0; |
| 1059 | |
| 1060 | /// control message protocol |
| 1061 | pub const IPPROTO_ICMP = 1; |
| 1062 | |
| 1063 | /// tcp |
| 1064 | pub const IPPROTO_TCP = 6; |
| 1065 | |
| 1066 | /// user datagram protocol |
| 1067 | pub const IPPROTO_UDP = 17; |
| 1068 | |
| 1069 | /// IP6 header |
| 1070 | pub const IPPROTO_IPV6 = 41; |
| 1071 | |
| 1072 | /// raw IP packet |
| 1073 | pub const IPPROTO_RAW = 255; |
| 1074 | |
| 1075 | /// IP6 hop-by-hop options |
| 1076 | pub const IPPROTO_HOPOPTS = 0; |
| 1077 | |
| 1078 | /// group mgmt protocol |
| 1079 | pub const IPPROTO_IGMP = 2; |
| 1080 | |
| 1081 | /// gateway^2 (deprecated) |
| 1082 | pub const IPPROTO_GGP = 3; |
| 1083 | |
| 1084 | /// IPv4 encapsulation |
| 1085 | pub const IPPROTO_IPV4 = 4; |
| 1086 | |
| 1087 | /// for compatibility |
| 1088 | pub const IPPROTO_IPIP = IPPROTO_IPV4; |
| 1089 | |
| 1090 | /// Stream protocol II |
| 1091 | pub const IPPROTO_ST = 7; |
| 1092 | |
| 1093 | /// exterior gateway protocol |
| 1094 | pub const IPPROTO_EGP = 8; |
| 1095 | |
| 1096 | /// private interior gateway |
| 1097 | pub const IPPROTO_PIGP = 9; |
| 1098 | |
| 1099 | /// BBN RCC Monitoring |
| 1100 | pub const IPPROTO_RCCMON = 10; |
| 1101 | |
| 1102 | /// network voice protocol |
| 1103 | pub const IPPROTO_NVPII = 11; |
| 1104 | |
| 1105 | /// pup |
| 1106 | pub const IPPROTO_PUP = 12; |
| 1107 | |
| 1108 | /// Argus |
| 1109 | pub const IPPROTO_ARGUS = 13; |
| 1110 | |
| 1111 | /// EMCON |
| 1112 | pub const IPPROTO_EMCON = 14; |
| 1113 | |
| 1114 | /// Cross Net Debugger |
| 1115 | pub const IPPROTO_XNET = 15; |
| 1116 | |
| 1117 | /// Chaos |
| 1118 | pub const IPPROTO_CHAOS = 16; |
| 1119 | |
| 1120 | /// Multiplexing |
| 1121 | pub const IPPROTO_MUX = 18; |
| 1122 | |
| 1123 | /// DCN Measurement Subsystems |
| 1124 | pub const IPPROTO_MEAS = 19; |
| 1125 | |
| 1126 | /// Host Monitoring |
| 1127 | pub const IPPROTO_HMP = 20; |
| 1128 | |
| 1129 | /// Packet Radio Measurement |
| 1130 | pub const IPPROTO_PRM = 21; |
| 1131 | |
| 1132 | /// xns idp |
| 1133 | pub const IPPROTO_IDP = 22; |
| 1134 | |
| 1135 | /// Trunk-1 |
| 1136 | pub const IPPROTO_TRUNK1 = 23; |
| 1137 | |
| 1138 | /// Trunk-2 |
| 1139 | pub const IPPROTO_TRUNK2 = 24; |
| 1140 | |
| 1141 | /// Leaf-1 |
| 1142 | pub const IPPROTO_LEAF1 = 25; |
| 1143 | |
| 1144 | /// Leaf-2 |
| 1145 | pub const IPPROTO_LEAF2 = 26; |
| 1146 | |
| 1147 | /// Reliable Data |
| 1148 | pub const IPPROTO_RDP = 27; |
| 1149 | |
| 1150 | /// Reliable Transaction |
| 1151 | pub const IPPROTO_IRTP = 28; |
| 1152 | |
| 1153 | /// tp-4 w/ class negotiation |
| 1154 | pub const IPPROTO_TP = 29; |
| 1155 | |
| 1156 | /// Bulk Data Transfer |
| 1157 | pub const IPPROTO_BLT = 30; |
| 1158 | |
| 1159 | /// Network Services |
| 1160 | pub const IPPROTO_NSP = 31; |
| 1161 | |
| 1162 | /// Merit Internodal |
| 1163 | pub const IPPROTO_INP = 32; |
| 1164 | |
| 1165 | /// Datagram Congestion Control Protocol |
| 1166 | pub const IPPROTO_DCCP = 33; |
| 1167 | |
| 1168 | /// Third Party Connect |
| 1169 | pub const IPPROTO_3PC = 34; |
| 1170 | |
| 1171 | /// InterDomain Policy Routing |
| 1172 | pub const IPPROTO_IDPR = 35; |
| 1173 | |
| 1174 | /// XTP |
| 1175 | pub const IPPROTO_XTP = 36; |
| 1176 | |
| 1177 | /// Datagram Delivery |
| 1178 | pub const IPPROTO_DDP = 37; |
| 1179 | |
| 1180 | /// Control Message Transport |
| 1181 | pub const IPPROTO_CMTP = 38; |
| 1182 | |
| 1183 | /// TP++ Transport |
| 1184 | pub const IPPROTO_TPXX = 39; |
| 1185 | |
| 1186 | /// IL transport protocol |
| 1187 | pub const IPPROTO_IL = 40; |
| 1188 | |
| 1189 | /// Source Demand Routing |
| 1190 | pub const IPPROTO_SDRP = 42; |
| 1191 | |
| 1192 | /// IP6 routing header |
| 1193 | pub const IPPROTO_ROUTING = 43; |
| 1194 | |
| 1195 | /// IP6 fragmentation header |
| 1196 | pub const IPPROTO_FRAGMENT = 44; |
| 1197 | |
| 1198 | /// InterDomain Routing |
| 1199 | pub const IPPROTO_IDRP = 45; |
| 1200 | |
| 1201 | /// resource reservation |
| 1202 | pub const IPPROTO_RSVP = 46; |
| 1203 | |
| 1204 | /// General Routing Encap. |
| 1205 | pub const IPPROTO_GRE = 47; |
| 1206 | |
| 1207 | /// Mobile Host Routing |
| 1208 | pub const IPPROTO_MHRP = 48; |
| 1209 | |
| 1210 | /// BHA |
| 1211 | pub const IPPROTO_BHA = 49; |
| 1212 | |
| 1213 | /// IP6 Encap Sec. Payload |
| 1214 | pub const IPPROTO_ESP = 50; |
| 1215 | |
| 1216 | /// IP6 Auth Header |
| 1217 | pub const IPPROTO_AH = 51; |
| 1218 | |
| 1219 | /// Integ. Net Layer Security |
| 1220 | pub const IPPROTO_INLSP = 52; |
| 1221 | |
| 1222 | /// IP with encryption |
| 1223 | pub const IPPROTO_SWIPE = 53; |
| 1224 | |
| 1225 | /// Next Hop Resolution |
| 1226 | pub const IPPROTO_NHRP = 54; |
| 1227 | |
| 1228 | /// IP Mobility |
| 1229 | pub const IPPROTO_MOBILE = 55; |
| 1230 | |
| 1231 | /// Transport Layer Security |
| 1232 | pub const IPPROTO_TLSP = 56; |
| 1233 | |
| 1234 | /// SKIP |
| 1235 | pub const IPPROTO_SKIP = 57; |
| 1236 | |
| 1237 | /// ICMP6 |
| 1238 | pub const IPPROTO_ICMPV6 = 58; |
| 1239 | |
| 1240 | /// IP6 no next header |
| 1241 | pub const IPPROTO_NONE = 59; |
| 1242 | |
| 1243 | /// IP6 destination option |
| 1244 | pub const IPPROTO_DSTOPTS = 60; |
| 1245 | |
| 1246 | /// any host internal protocol |
| 1247 | pub const IPPROTO_AHIP = 61; |
| 1248 | |
| 1249 | /// CFTP |
| 1250 | pub const IPPROTO_CFTP = 62; |
| 1251 | |
| 1252 | /// "hello" routing protocol |
| 1253 | pub const IPPROTO_HELLO = 63; |
| 1254 | |
| 1255 | /// SATNET/Backroom EXPAK |
| 1256 | pub const IPPROTO_SATEXPAK = 64; |
| 1257 | |
| 1258 | /// Kryptolan |
| 1259 | pub const IPPROTO_KRYPTOLAN = 65; |
| 1260 | |
| 1261 | /// Remote Virtual Disk |
| 1262 | pub const IPPROTO_RVD = 66; |
| 1263 | |
| 1264 | /// Pluribus Packet Core |
| 1265 | pub const IPPROTO_IPPC = 67; |
| 1266 | |
| 1267 | /// Any distributed FS |
| 1268 | pub const IPPROTO_ADFS = 68; |
| 1269 | |
| 1270 | /// Satnet Monitoring |
| 1271 | pub const IPPROTO_SATMON = 69; |
| 1272 | |
| 1273 | /// VISA Protocol |
| 1274 | pub const IPPROTO_VISA = 70; |
| 1275 | |
| 1276 | /// Packet Core Utility |
| 1277 | pub const IPPROTO_IPCV = 71; |
| 1278 | |
| 1279 | /// Comp. Prot. Net. Executive |
| 1280 | pub const IPPROTO_CPNX = 72; |
| 1281 | |
| 1282 | /// Comp. Prot. HeartBeat |
| 1283 | pub const IPPROTO_CPHB = 73; |
| 1284 | |
| 1285 | /// Wang Span Network |
| 1286 | pub const IPPROTO_WSN = 74; |
| 1287 | |
| 1288 | /// Packet Video Protocol |
| 1289 | pub const IPPROTO_PVP = 75; |
| 1290 | |
| 1291 | /// BackRoom SATNET Monitoring |
| 1292 | pub const IPPROTO_BRSATMON = 76; |
| 1293 | |
| 1294 | /// Sun net disk proto (temp.) |
| 1295 | pub const IPPROTO_ND = 77; |
| 1296 | |
| 1297 | /// WIDEBAND Monitoring |
| 1298 | pub const IPPROTO_WBMON = 78; |
| 1299 | |
| 1300 | /// WIDEBAND EXPAK |
| 1301 | pub const IPPROTO_WBEXPAK = 79; |
| 1302 | |
| 1303 | /// ISO cnlp |
| 1304 | pub const IPPROTO_EON = 80; |
| 1305 | |
| 1306 | /// VMTP |
| 1307 | pub const IPPROTO_VMTP = 81; |
| 1308 | |
| 1309 | /// Secure VMTP |
| 1310 | pub const IPPROTO_SVMTP = 82; |
| 1311 | |
| 1312 | /// Banyon VINES |
| 1313 | pub const IPPROTO_VINES = 83; |
| 1314 | |
| 1315 | /// TTP |
| 1316 | pub const IPPROTO_TTP = 84; |
| 1317 | |
| 1318 | /// NSFNET-IGP |
| 1319 | pub const IPPROTO_IGP = 85; |
| 1320 | |
| 1321 | /// dissimilar gateway prot. |
| 1322 | pub const IPPROTO_DGP = 86; |
| 1323 | |
| 1324 | /// TCF |
| 1325 | pub const IPPROTO_TCF = 87; |
| 1326 | |
| 1327 | /// Cisco/GXS IGRP |
| 1328 | pub const IPPROTO_IGRP = 88; |
| 1329 | |
| 1330 | /// OSPFIGP |
| 1331 | pub const IPPROTO_OSPFIGP = 89; |
| 1332 | |
| 1333 | /// Strite RPC protocol |
| 1334 | pub const IPPROTO_SRPC = 90; |
| 1335 | |
| 1336 | /// Locus Address Resoloution |
| 1337 | pub const IPPROTO_LARP = 91; |
| 1338 | |
| 1339 | /// Multicast Transport |
| 1340 | pub const IPPROTO_MTP = 92; |
| 1341 | |
| 1342 | /// AX.25 Frames |
| 1343 | pub const IPPROTO_AX25 = 93; |
| 1344 | |
| 1345 | /// IP encapsulated in IP |
| 1346 | pub const IPPROTO_IPEIP = 94; |
| 1347 | |
| 1348 | /// Mobile Int.ing control |
| 1349 | pub const IPPROTO_MICP = 95; |
| 1350 | |
| 1351 | /// Semaphore Comm. security |
| 1352 | pub const IPPROTO_SCCSP = 96; |
| 1353 | |
| 1354 | /// Ethernet IP encapsulation |
| 1355 | pub const IPPROTO_ETHERIP = 97; |
| 1356 | |
| 1357 | /// encapsulation header |
| 1358 | pub const IPPROTO_ENCAP = 98; |
| 1359 | |
| 1360 | /// any private encr. scheme |
| 1361 | pub const IPPROTO_APES = 99; |
| 1362 | |
| 1363 | /// GMTP |
| 1364 | pub const IPPROTO_GMTP = 100; |
| 1365 | |
| 1366 | /// payload compression (IPComp) |
| 1367 | pub const IPPROTO_IPCOMP = 108; |
| 1368 | |
| 1369 | /// SCTP |
| 1370 | pub const IPPROTO_SCTP = 132; |
| 1371 | |
| 1372 | /// IPv6 Mobility Header |
| 1373 | pub const IPPROTO_MH = 135; |
| 1374 | |
| 1375 | /// UDP-Lite |
| 1376 | pub const IPPROTO_UDPLITE = 136; |
| 1377 | |
| 1378 | /// IP6 Host Identity Protocol |
| 1379 | pub const IPPROTO_HIP = 139; |
| 1380 | |
| 1381 | /// IP6 Shim6 Protocol |
| 1382 | pub const IPPROTO_SHIM6 = 140; |
| 1383 | |
| 1384 | /// Protocol Independent Mcast |
| 1385 | pub const IPPROTO_PIM = 103; |
| 1386 | |
| 1387 | /// CARP |
| 1388 | pub const IPPROTO_CARP = 112; |
| 1389 | |
| 1390 | /// PGM |
| 1391 | pub const IPPROTO_PGM = 113; |
| 1392 | |
| 1393 | /// MPLS-in-IP |
| 1394 | pub const IPPROTO_MPLS = 137; |
| 1395 | |
| 1396 | /// PFSYNC |
| 1397 | pub const IPPROTO_PFSYNC = 240; |
| 1398 | |
| 1399 | /// Reserved |
| 1400 | pub const IPPROTO_RESERVED_253 = 253; |
| 1401 | |
| 1402 | /// Reserved |
| 1403 | pub const IPPROTO_RESERVED_254 = 254; |
| 1404 | |
| 1405 | pub const rlimit_resource = extern enum(c_int) { |
| 1406 | CPU = 0, |
| 1407 | FSIZE = 1, |
| 1408 | DATA = 2, |
| 1409 | STACK = 3, |
| 1410 | CORE = 4, |
| 1411 | RSS = 5, |
| 1412 | MEMLOCK = 6, |
| 1413 | NPROC = 7, |
| 1414 | NOFILE = 8, |
| 1415 | SBSIZE = 9, |
| 1416 | VMEM = 10, |
| 1417 | AS = 10, |
| 1418 | NPTS = 11, |
| 1419 | SWAP = 12, |
| 1420 | KQUEUES = 13, |
| 1421 | UMTXP = 14, |
| 1422 | |
| 1423 | _, |
| 1424 | }; |
| 1425 | |
| 1426 | pub const rlim_t = i64; |
| 1427 | |
| 1428 | /// No limit |
| 1429 | pub const RLIM_INFINITY: rlim_t = (1 << 63) - 1; |
| 1430 | |
| 1431 | pub const RLIM_SAVED_MAX = RLIM_INFINITY; |
| 1432 | pub const RLIM_SAVED_CUR = RLIM_INFINITY; |
| 1433 | |
| 1434 | pub const rlimit = extern struct { |
| 1435 | /// Soft limit |
| 1436 | cur: rlim_t, |
| 1437 | /// Hard limit |
| 1438 | max: rlim_t, |
| 1439 | }; |
| 1440 | |
| 1441 | pub const SHUT_RD = 0; |
| 1442 | pub const SHUT_WR = 1; |
| 1443 | pub const SHUT_RDWR = 2; |
| 1444 | |
| 1445 | // TODO fill out if needed |
| 1446 | pub const directory_which = extern enum(c_int) { |
| 1447 | B_USER_SETTINGS_DIRECTORY = 0xbbe, |
| 1448 | |
| 1449 | _, |
| 1450 | }; |