mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +00:00
1353 lines
34 KiB
Zig
1353 lines
34 KiB
Zig
const std = @import("../std.zig");
|
|
const maxInt = std.math.maxInt;
|
|
const builtin = @import("builtin");
|
|
|
|
extern "c" fn __errno() *c_int;
|
|
pub const _errno = __errno;
|
|
|
|
pub const dl_iterate_phdr_callback = fn (info: *dl_phdr_info, size: usize, data: ?*c_void) callconv(.C) c_int;
|
|
pub extern "c" fn dl_iterate_phdr(callback: dl_iterate_phdr_callback, data: ?*c_void) c_int;
|
|
|
|
pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
|
|
|
|
pub extern "c" fn getthrid() pid_t;
|
|
pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int;
|
|
|
|
pub extern "c" fn getdents(fd: c_int, buf_ptr: [*]u8, nbytes: usize) usize;
|
|
pub extern "c" fn sigaltstack(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
|
|
|
|
pub const pthread_mutex_t = extern struct {
|
|
inner: ?*c_void = null,
|
|
};
|
|
pub const pthread_cond_t = extern struct {
|
|
inner: ?*c_void = null,
|
|
};
|
|
pub const pthread_rwlock_t = extern struct {
|
|
ptr: ?*c_void = null,
|
|
};
|
|
pub const pthread_spinlock_t = extern struct {
|
|
inner: ?*c_void = null,
|
|
};
|
|
pub const pthread_attr_t = extern struct {
|
|
inner: ?*c_void = null,
|
|
};
|
|
pub const pthread_key_t = c_int;
|
|
|
|
pub const sem_t = ?*opaque {};
|
|
|
|
pub extern "c" fn posix_memalign(memptr: *?*c_void, alignment: usize, size: usize) c_int;
|
|
|
|
pub extern "c" fn pledge(promises: ?[*:0]const u8, execpromises: ?[*:0]const u8) c_int;
|
|
pub extern "c" fn unveil(path: ?[*:0]const u8, permissions: ?[*:0]const u8) c_int;
|
|
|
|
pub extern "c" fn pthread_set_name_np(thread: std.c.pthread_t, name: [*:0]const u8) void;
|
|
pub extern "c" fn pthread_get_name_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) void;
|
|
|
|
pub const blkcnt_t = i64;
|
|
pub const blksize_t = i32;
|
|
pub const clock_t = i64;
|
|
pub const dev_t = i32;
|
|
pub const fd_t = c_int;
|
|
pub const gid_t = u32;
|
|
pub const ino_t = u64;
|
|
pub const mode_t = u32;
|
|
pub const nlink_t = u32;
|
|
pub const off_t = i64;
|
|
pub const pid_t = i32;
|
|
pub const socklen_t = u32;
|
|
pub const time_t = i64;
|
|
pub const uid_t = u32;
|
|
|
|
/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
|
|
pub const Kevent = extern struct {
|
|
ident: usize,
|
|
filter: c_short,
|
|
flags: u16,
|
|
fflags: c_uint,
|
|
data: i64,
|
|
udata: usize,
|
|
};
|
|
|
|
// Modes and flags for dlopen()
|
|
// include/dlfcn.h
|
|
|
|
pub const RTLD = struct {
|
|
/// Bind function calls lazily.
|
|
pub const LAZY = 1;
|
|
/// Bind function calls immediately.
|
|
pub const NOW = 2;
|
|
/// Make symbols globally available.
|
|
pub const GLOBAL = 0x100;
|
|
/// Opposite of GLOBAL, and the default.
|
|
pub const LOCAL = 0x000;
|
|
/// Trace loaded objects and exit.
|
|
pub const TRACE = 0x200;
|
|
};
|
|
|
|
pub const dl_phdr_info = extern struct {
|
|
dlpi_addr: std.elf.Addr,
|
|
dlpi_name: ?[*:0]const u8,
|
|
dlpi_phdr: [*]std.elf.Phdr,
|
|
dlpi_phnum: std.elf.Half,
|
|
};
|
|
|
|
pub const Flock = extern struct {
|
|
l_start: off_t,
|
|
l_len: off_t,
|
|
l_pid: pid_t,
|
|
l_type: c_short,
|
|
l_whence: c_short,
|
|
};
|
|
|
|
pub const addrinfo = extern struct {
|
|
flags: c_int,
|
|
family: c_int,
|
|
socktype: c_int,
|
|
protocol: c_int,
|
|
addrlen: socklen_t,
|
|
addr: ?*sockaddr,
|
|
canonname: ?[*:0]u8,
|
|
next: ?*addrinfo,
|
|
};
|
|
|
|
pub const EAI = enum(c_int) {
|
|
/// address family for hostname not supported
|
|
ADDRFAMILY = -9,
|
|
|
|
/// name could not be resolved at this time
|
|
AGAIN = -3,
|
|
|
|
/// flags parameter had an invalid value
|
|
BADFLAGS = -1,
|
|
|
|
/// non-recoverable failure in name resolution
|
|
FAIL = -4,
|
|
|
|
/// address family not recognized
|
|
FAMILY = -6,
|
|
|
|
/// memory allocation failure
|
|
MEMORY = -10,
|
|
|
|
/// no address associated with hostname
|
|
NODATA = -5,
|
|
|
|
/// name does not resolve
|
|
NONAME = -2,
|
|
|
|
/// service not recognized for socket type
|
|
SERVICE = -8,
|
|
|
|
/// intended socket type was not recognized
|
|
SOCKTYPE = -7,
|
|
|
|
/// system error returned in errno
|
|
SYSTEM = -11,
|
|
|
|
/// invalid value for hints
|
|
BADHINTS = -12,
|
|
|
|
/// resolved protocol is unknown
|
|
PROTOCOL = -13,
|
|
|
|
/// argument buffer overflow
|
|
OVERFLOW = -14,
|
|
|
|
_,
|
|
};
|
|
|
|
pub const EAI_MAX = 15;
|
|
|
|
pub const msghdr = extern struct {
|
|
/// optional address
|
|
msg_name: ?*sockaddr,
|
|
|
|
/// size of address
|
|
msg_namelen: socklen_t,
|
|
|
|
/// scatter/gather array
|
|
msg_iov: [*]iovec,
|
|
|
|
/// # elements in msg_iov
|
|
msg_iovlen: c_uint,
|
|
|
|
/// ancillary data
|
|
msg_control: ?*c_void,
|
|
|
|
/// ancillary data buffer len
|
|
msg_controllen: socklen_t,
|
|
|
|
/// flags on received message
|
|
msg_flags: c_int,
|
|
};
|
|
|
|
pub const msghdr_const = extern struct {
|
|
/// optional address
|
|
msg_name: ?*const sockaddr,
|
|
|
|
/// size of address
|
|
msg_namelen: socklen_t,
|
|
|
|
/// scatter/gather array
|
|
msg_iov: [*]iovec_const,
|
|
|
|
/// # elements in msg_iov
|
|
msg_iovlen: c_uint,
|
|
|
|
/// ancillary data
|
|
msg_control: ?*c_void,
|
|
|
|
/// ancillary data buffer len
|
|
msg_controllen: socklen_t,
|
|
|
|
/// flags on received message
|
|
msg_flags: c_int,
|
|
};
|
|
|
|
pub const Stat = extern struct {
|
|
mode: mode_t,
|
|
dev: dev_t,
|
|
ino: ino_t,
|
|
nlink: nlink_t,
|
|
uid: uid_t,
|
|
gid: gid_t,
|
|
rdev: dev_t,
|
|
atim: timespec,
|
|
mtim: timespec,
|
|
ctim: timespec,
|
|
size: off_t,
|
|
blocks: blkcnt_t,
|
|
blksize: blksize_t,
|
|
flags: u32,
|
|
gen: u32,
|
|
birthtim: timespec,
|
|
|
|
pub fn atime(self: @This()) timespec {
|
|
return self.atim;
|
|
}
|
|
|
|
pub fn mtime(self: @This()) timespec {
|
|
return self.mtim;
|
|
}
|
|
|
|
pub fn ctime(self: @This()) timespec {
|
|
return self.ctim;
|
|
}
|
|
};
|
|
|
|
pub const timespec = extern struct {
|
|
tv_sec: time_t,
|
|
tv_nsec: c_long,
|
|
};
|
|
|
|
pub const timeval = extern struct {
|
|
tv_sec: time_t,
|
|
tv_usec: c_long,
|
|
};
|
|
|
|
pub const timezone = extern struct {
|
|
tz_minuteswest: c_int,
|
|
tz_dsttime: c_int,
|
|
};
|
|
|
|
pub const MAXNAMLEN = 255;
|
|
|
|
pub const dirent = extern struct {
|
|
d_fileno: ino_t,
|
|
d_off: off_t,
|
|
d_reclen: u16,
|
|
d_type: u8,
|
|
d_namlen: u8,
|
|
__d_padding: [4]u8,
|
|
d_name: [MAXNAMLEN + 1]u8,
|
|
|
|
pub fn reclen(self: dirent) u16 {
|
|
return self.d_reclen;
|
|
}
|
|
};
|
|
|
|
pub const in_port_t = u16;
|
|
pub const sa_family_t = u8;
|
|
|
|
pub const sockaddr = extern struct {
|
|
/// total length
|
|
len: u8,
|
|
/// address family
|
|
family: sa_family_t,
|
|
/// actually longer; address value
|
|
data: [14]u8,
|
|
|
|
pub const storage = std.x.os.Socket.Address.Native.Storage;
|
|
|
|
pub const in = extern struct {
|
|
len: u8 = @sizeOf(in),
|
|
family: sa_family_t = AF.INET,
|
|
port: in_port_t,
|
|
addr: u32,
|
|
zero: [8]u8 = [8]u8{ 0, 0, 0, 0, 0, 0, 0, 0 },
|
|
};
|
|
|
|
pub const in6 = extern struct {
|
|
len: u8 = @sizeOf(in6),
|
|
family: sa_family_t = AF.INET6,
|
|
port: in_port_t,
|
|
flowinfo: u32,
|
|
addr: [16]u8,
|
|
scope_id: u32,
|
|
};
|
|
|
|
/// Definitions for UNIX IPC domain.
|
|
pub const un = extern struct {
|
|
/// total sockaddr length
|
|
len: u8 = @sizeOf(un),
|
|
|
|
family: sa_family_t = AF.LOCAL,
|
|
|
|
/// path name
|
|
path: [104]u8,
|
|
};
|
|
};
|
|
|
|
pub const AI = struct {
|
|
/// get address to use bind()
|
|
pub const PASSIVE = 1;
|
|
/// fill ai_canonname
|
|
pub const CANONNAME = 2;
|
|
/// prevent host name resolution
|
|
pub const NUMERICHOST = 4;
|
|
/// prevent service name resolution
|
|
pub const NUMERICSERV = 16;
|
|
/// only if any address is assigned
|
|
pub const ADDRCONFIG = 64;
|
|
};
|
|
|
|
pub const PATH_MAX = 1024;
|
|
pub const IOV_MAX = 1024;
|
|
|
|
pub const STDIN_FILENO = 0;
|
|
pub const STDOUT_FILENO = 1;
|
|
pub const STDERR_FILENO = 2;
|
|
|
|
pub const PROT_NONE = 0;
|
|
pub const PROT_READ = 1;
|
|
pub const PROT_WRITE = 2;
|
|
pub const PROT_EXEC = 4;
|
|
|
|
pub const CLOCK = struct {
|
|
pub const REALTIME = 0;
|
|
pub const PROCESS_CPUTIME_ID = 2;
|
|
pub const MONOTONIC = 3;
|
|
pub const THREAD_CPUTIME_ID = 4;
|
|
};
|
|
|
|
pub const MAP = struct {
|
|
pub const FAILED = @intToPtr(*c_void, maxInt(usize));
|
|
pub const SHARED = 0x0001;
|
|
pub const PRIVATE = 0x0002;
|
|
pub const FIXED = 0x0010;
|
|
pub const RENAME = 0;
|
|
pub const NORESERVE = 0;
|
|
pub const INHERIT = 0;
|
|
pub const HASSEMAPHORE = 0;
|
|
pub const TRYFIXED = 0;
|
|
|
|
pub const FILE = 0;
|
|
pub const ANON = 0x1000;
|
|
pub const ANONYMOUS = ANON;
|
|
pub const STACK = 0x4000;
|
|
pub const CONCEAL = 0x8000;
|
|
};
|
|
pub const WNOHANG = 1;
|
|
pub const WUNTRACED = 2;
|
|
pub const WCONTINUED = 8;
|
|
|
|
pub const SA_ONSTACK = 0x0001;
|
|
pub const SA_RESTART = 0x0002;
|
|
pub const SA_RESETHAND = 0x0004;
|
|
pub const SA_NOCLDSTOP = 0x0008;
|
|
pub const SA_NODEFER = 0x0010;
|
|
pub const SA_NOCLDWAIT = 0x0020;
|
|
pub const SA_SIGINFO = 0x0040;
|
|
|
|
pub const SIGHUP = 1;
|
|
pub const SIGINT = 2;
|
|
pub const SIGQUIT = 3;
|
|
pub const SIGILL = 4;
|
|
pub const SIGTRAP = 5;
|
|
pub const SIGABRT = 6;
|
|
pub const SIGIOT = SIGABRT;
|
|
pub const SIGEMT = 7;
|
|
pub const SIGFPE = 8;
|
|
pub const SIGKILL = 9;
|
|
pub const SIGBUS = 10;
|
|
pub const SIGSEGV = 11;
|
|
pub const SIGSYS = 12;
|
|
pub const SIGPIPE = 13;
|
|
pub const SIGALRM = 14;
|
|
pub const SIGTERM = 15;
|
|
pub const SIGURG = 16;
|
|
pub const SIGSTOP = 17;
|
|
pub const SIGTSTP = 18;
|
|
pub const SIGCONT = 19;
|
|
pub const SIGCHLD = 20;
|
|
pub const SIGTTIN = 21;
|
|
pub const SIGTTOU = 22;
|
|
pub const SIGIO = 23;
|
|
pub const SIGXCPU = 24;
|
|
pub const SIGXFSZ = 25;
|
|
pub const SIGVTALRM = 26;
|
|
pub const SIGPROF = 27;
|
|
pub const SIGWINCH = 28;
|
|
pub const SIGINFO = 29;
|
|
pub const SIGUSR1 = 30;
|
|
pub const SIGUSR2 = 31;
|
|
pub const SIGPWR = 32;
|
|
|
|
// access function
|
|
pub const F_OK = 0; // test for existence of file
|
|
pub const X_OK = 1; // test for execute or search permission
|
|
pub const W_OK = 2; // test for write permission
|
|
pub const R_OK = 4; // test for read permission
|
|
|
|
/// open for reading only
|
|
pub const O_RDONLY = 0x00000000;
|
|
|
|
/// open for writing only
|
|
pub const O_WRONLY = 0x00000001;
|
|
|
|
/// open for reading and writing
|
|
pub const O_RDWR = 0x00000002;
|
|
|
|
/// mask for above modes
|
|
pub const O_ACCMODE = 0x00000003;
|
|
|
|
/// no delay
|
|
pub const O_NONBLOCK = 0x00000004;
|
|
|
|
/// set append mode
|
|
pub const O_APPEND = 0x00000008;
|
|
|
|
/// open with shared file lock
|
|
pub const O_SHLOCK = 0x00000010;
|
|
|
|
/// open with exclusive file lock
|
|
pub const O_EXLOCK = 0x00000020;
|
|
|
|
/// signal pgrp when data ready
|
|
pub const O_ASYNC = 0x00000040;
|
|
|
|
/// synchronous writes
|
|
pub const O_SYNC = 0x00000080;
|
|
|
|
/// don't follow symlinks on the last
|
|
pub const O_NOFOLLOW = 0x00000100;
|
|
|
|
/// create if nonexistent
|
|
pub const O_CREAT = 0x00000200;
|
|
|
|
/// truncate to zero length
|
|
pub const O_TRUNC = 0x00000400;
|
|
|
|
/// error if already exists
|
|
pub const O_EXCL = 0x00000800;
|
|
|
|
/// don't assign controlling terminal
|
|
pub const O_NOCTTY = 0x00008000;
|
|
|
|
/// write: I/O data completion
|
|
pub const O_DSYNC = O_SYNC;
|
|
|
|
/// read: I/O completion as for write
|
|
pub const O_RSYNC = O_SYNC;
|
|
|
|
/// fail if not a directory
|
|
pub const O_DIRECTORY = 0x20000;
|
|
|
|
/// set close on exec
|
|
pub const O_CLOEXEC = 0x10000;
|
|
|
|
pub const F_DUPFD = 0;
|
|
pub const F_GETFD = 1;
|
|
pub const F_SETFD = 2;
|
|
pub const F_GETFL = 3;
|
|
pub const F_SETFL = 4;
|
|
|
|
pub const F_GETOWN = 5;
|
|
pub const F_SETOWN = 6;
|
|
|
|
pub const F_GETLK = 7;
|
|
pub const F_SETLK = 8;
|
|
pub const F_SETLKW = 9;
|
|
|
|
pub const F_RDLCK = 1;
|
|
pub const F_UNLCK = 2;
|
|
pub const F_WRLCK = 3;
|
|
|
|
pub const LOCK = struct {
|
|
pub const SH = 0x01;
|
|
pub const EX = 0x02;
|
|
pub const NB = 0x04;
|
|
pub const UN = 0x08;
|
|
};
|
|
|
|
pub const FD_CLOEXEC = 1;
|
|
|
|
pub const SEEK_SET = 0;
|
|
pub const SEEK_CUR = 1;
|
|
pub const SEEK_END = 2;
|
|
|
|
pub const SIG_BLOCK = 1;
|
|
pub const SIG_UNBLOCK = 2;
|
|
pub const SIG_SETMASK = 3;
|
|
|
|
pub const SOCK = struct {
|
|
pub const STREAM = 1;
|
|
pub const DGRAM = 2;
|
|
pub const RAW = 3;
|
|
pub const RDM = 4;
|
|
pub const SEQPACKET = 5;
|
|
|
|
pub const CLOEXEC = 0x8000;
|
|
pub const NONBLOCK = 0x4000;
|
|
};
|
|
|
|
pub const SO = struct {
|
|
pub const DEBUG = 0x0001;
|
|
pub const ACCEPTCONN = 0x0002;
|
|
pub const REUSEADDR = 0x0004;
|
|
pub const KEEPALIVE = 0x0008;
|
|
pub const DONTROUTE = 0x0010;
|
|
pub const BROADCAST = 0x0020;
|
|
pub const USELOOPBACK = 0x0040;
|
|
pub const LINGER = 0x0080;
|
|
pub const OOBINLINE = 0x0100;
|
|
pub const REUSEPORT = 0x0200;
|
|
pub const TIMESTAMP = 0x0800;
|
|
pub const BINDANY = 0x1000;
|
|
pub const ZEROIZE = 0x2000;
|
|
pub const SNDBUF = 0x1001;
|
|
pub const RCVBUF = 0x1002;
|
|
pub const SNDLOWAT = 0x1003;
|
|
pub const RCVLOWAT = 0x1004;
|
|
pub const SNDTIMEO = 0x1005;
|
|
pub const RCVTIMEO = 0x1006;
|
|
pub const ERROR = 0x1007;
|
|
pub const TYPE = 0x1008;
|
|
pub const NETPROC = 0x1020;
|
|
pub const RTABLE = 0x1021;
|
|
pub const PEERCRED = 0x1022;
|
|
pub const SPLICE = 0x1023;
|
|
pub const DOMAIN = 0x1024;
|
|
pub const PROTOCOL = 0x1025;
|
|
};
|
|
|
|
pub const SOL = struct {
|
|
pub const SOCKET = 0xffff;
|
|
};
|
|
|
|
pub const PF = struct {
|
|
pub const UNSPEC = AF.UNSPEC;
|
|
pub const LOCAL = AF.LOCAL;
|
|
pub const UNIX = AF.UNIX;
|
|
pub const INET = AF.INET;
|
|
pub const APPLETALK = AF.APPLETALK;
|
|
pub const INET6 = AF.INET6;
|
|
pub const DECnet = AF.DECnet;
|
|
pub const KEY = AF.KEY;
|
|
pub const ROUTE = AF.ROUTE;
|
|
pub const SNA = AF.SNA;
|
|
pub const MPLS = AF.MPLS;
|
|
pub const BLUETOOTH = AF.BLUETOOTH;
|
|
pub const ISDN = AF.ISDN;
|
|
pub const MAX = AF.MAX;
|
|
};
|
|
|
|
pub const AF = struct {
|
|
pub const UNSPEC = 0;
|
|
pub const UNIX = 1;
|
|
pub const LOCAL = UNIX;
|
|
pub const INET = 2;
|
|
pub const APPLETALK = 16;
|
|
pub const INET6 = 24;
|
|
pub const KEY = 30;
|
|
pub const ROUTE = 17;
|
|
pub const SNA = 11;
|
|
pub const MPLS = 33;
|
|
pub const BLUETOOTH = 32;
|
|
pub const ISDN = 26;
|
|
pub const MAX = 36;
|
|
};
|
|
|
|
pub const DT_UNKNOWN = 0;
|
|
pub const DT_FIFO = 1;
|
|
pub const DT_CHR = 2;
|
|
pub const DT_DIR = 4;
|
|
pub const DT_BLK = 6;
|
|
pub const DT_REG = 8;
|
|
pub const DT_LNK = 10;
|
|
pub const DT_SOCK = 12;
|
|
pub const DT_WHT = 14; // XXX
|
|
|
|
pub const EV_ADD = 0x0001;
|
|
pub const EV_DELETE = 0x0002;
|
|
pub const EV_ENABLE = 0x0004;
|
|
pub const EV_DISABLE = 0x0008;
|
|
pub const EV_ONESHOT = 0x0010;
|
|
pub const EV_CLEAR = 0x0020;
|
|
pub const EV_RECEIPT = 0x0040;
|
|
pub const EV_DISPATCH = 0x0080;
|
|
pub const EV_FLAG1 = 0x2000;
|
|
pub const EV_ERROR = 0x4000;
|
|
pub const EV_EOF = 0x8000;
|
|
|
|
pub const EVFILT_READ = -1;
|
|
pub const EVFILT_WRITE = -2;
|
|
pub const EVFILT_AIO = -3;
|
|
pub const EVFILT_VNODE = -4;
|
|
pub const EVFILT_PROC = -5;
|
|
pub const EVFILT_SIGNAL = -6;
|
|
pub const EVFILT_TIMER = -7;
|
|
pub const EVFILT_EXCEPT = -9;
|
|
|
|
// data/hint flags for EVFILT_{READ|WRITE}
|
|
pub const NOTE_LOWAT = 0x0001;
|
|
pub const NOTE_EOF = 0x0002;
|
|
|
|
// data/hint flags for EVFILT_EXCEPT and EVFILT_{READ|WRITE}
|
|
pub const NOTE_OOB = 0x0004;
|
|
|
|
// data/hint flags for EVFILT_VNODE
|
|
pub const NOTE_DELETE = 0x0001;
|
|
pub const NOTE_WRITE = 0x0002;
|
|
pub const NOTE_EXTEND = 0x0004;
|
|
pub const NOTE_ATTRIB = 0x0008;
|
|
pub const NOTE_LINK = 0x0010;
|
|
pub const NOTE_RENAME = 0x0020;
|
|
pub const NOTE_REVOKE = 0x0040;
|
|
pub const NOTE_TRUNCATE = 0x0080;
|
|
|
|
// data/hint flags for EVFILT_PROC
|
|
pub const NOTE_EXIT = 0x80000000;
|
|
pub const NOTE_FORK = 0x40000000;
|
|
pub const NOTE_EXEC = 0x20000000;
|
|
pub const NOTE_PDATAMASK = 0x000fffff;
|
|
pub const NOTE_PCTRLMASK = 0xf0000000;
|
|
pub const NOTE_TRACK = 0x00000001;
|
|
pub const NOTE_TRACKERR = 0x00000002;
|
|
pub const NOTE_CHILD = 0x00000004;
|
|
|
|
// data/hint flags for EVFILT_DEVICE
|
|
pub const NOTE_CHANGE = 0x00000001;
|
|
|
|
pub const TIOCCBRK = 0x2000747a;
|
|
pub const TIOCCDTR = 0x20007478;
|
|
pub const TIOCCONS = 0x80047462;
|
|
pub const TIOCDCDTIMESTAMP = 0x40107458;
|
|
pub const TIOCDRAIN = 0x2000745e;
|
|
pub const TIOCEXCL = 0x2000740d;
|
|
pub const TIOCEXT = 0x80047460;
|
|
pub const TIOCFLAG_CDTRCTS = 0x10;
|
|
pub const TIOCFLAG_CLOCAL = 0x2;
|
|
pub const TIOCFLAG_CRTSCTS = 0x4;
|
|
pub const TIOCFLAG_MDMBUF = 0x8;
|
|
pub const TIOCFLAG_SOFTCAR = 0x1;
|
|
pub const TIOCFLUSH = 0x80047410;
|
|
pub const TIOCGETA = 0x402c7413;
|
|
pub const TIOCGETD = 0x4004741a;
|
|
pub const TIOCGFLAGS = 0x4004745d;
|
|
pub const TIOCGLINED = 0x40207442;
|
|
pub const TIOCGPGRP = 0x40047477;
|
|
pub const TIOCGQSIZE = 0x40047481;
|
|
pub const TIOCGRANTPT = 0x20007447;
|
|
pub const TIOCGSID = 0x40047463;
|
|
pub const TIOCGSIZE = 0x40087468;
|
|
pub const TIOCGWINSZ = 0x40087468;
|
|
pub const TIOCMBIC = 0x8004746b;
|
|
pub const TIOCMBIS = 0x8004746c;
|
|
pub const TIOCMGET = 0x4004746a;
|
|
pub const TIOCMSET = 0x8004746d;
|
|
pub const TIOCM_CAR = 0x40;
|
|
pub const TIOCM_CD = 0x40;
|
|
pub const TIOCM_CTS = 0x20;
|
|
pub const TIOCM_DSR = 0x100;
|
|
pub const TIOCM_DTR = 0x2;
|
|
pub const TIOCM_LE = 0x1;
|
|
pub const TIOCM_RI = 0x80;
|
|
pub const TIOCM_RNG = 0x80;
|
|
pub const TIOCM_RTS = 0x4;
|
|
pub const TIOCM_SR = 0x10;
|
|
pub const TIOCM_ST = 0x8;
|
|
pub const TIOCNOTTY = 0x20007471;
|
|
pub const TIOCNXCL = 0x2000740e;
|
|
pub const TIOCOUTQ = 0x40047473;
|
|
pub const TIOCPKT = 0x80047470;
|
|
pub const TIOCPKT_DATA = 0x0;
|
|
pub const TIOCPKT_DOSTOP = 0x20;
|
|
pub const TIOCPKT_FLUSHREAD = 0x1;
|
|
pub const TIOCPKT_FLUSHWRITE = 0x2;
|
|
pub const TIOCPKT_IOCTL = 0x40;
|
|
pub const TIOCPKT_NOSTOP = 0x10;
|
|
pub const TIOCPKT_START = 0x8;
|
|
pub const TIOCPKT_STOP = 0x4;
|
|
pub const TIOCPTMGET = 0x40287446;
|
|
pub const TIOCPTSNAME = 0x40287448;
|
|
pub const TIOCRCVFRAME = 0x80087445;
|
|
pub const TIOCREMOTE = 0x80047469;
|
|
pub const TIOCSBRK = 0x2000747b;
|
|
pub const TIOCSCTTY = 0x20007461;
|
|
pub const TIOCSDTR = 0x20007479;
|
|
pub const TIOCSETA = 0x802c7414;
|
|
pub const TIOCSETAF = 0x802c7416;
|
|
pub const TIOCSETAW = 0x802c7415;
|
|
pub const TIOCSETD = 0x8004741b;
|
|
pub const TIOCSFLAGS = 0x8004745c;
|
|
pub const TIOCSIG = 0x2000745f;
|
|
pub const TIOCSLINED = 0x80207443;
|
|
pub const TIOCSPGRP = 0x80047476;
|
|
pub const TIOCSQSIZE = 0x80047480;
|
|
pub const TIOCSSIZE = 0x80087467;
|
|
pub const TIOCSTART = 0x2000746e;
|
|
pub const TIOCSTAT = 0x80047465;
|
|
pub const TIOCSTI = 0x80017472;
|
|
pub const TIOCSTOP = 0x2000746f;
|
|
pub const TIOCSWINSZ = 0x80087467;
|
|
pub const TIOCUCNTL = 0x80047466;
|
|
pub const TIOCXMTFRAME = 0x80087444;
|
|
|
|
pub fn WEXITSTATUS(s: u32) u8 {
|
|
return @intCast(u8, (s >> 8) & 0xff);
|
|
}
|
|
pub fn WTERMSIG(s: u32) u32 {
|
|
return (s & 0x7f);
|
|
}
|
|
pub fn WSTOPSIG(s: u32) u32 {
|
|
return WEXITSTATUS(s);
|
|
}
|
|
pub fn WIFEXITED(s: u32) bool {
|
|
return WTERMSIG(s) == 0;
|
|
}
|
|
|
|
pub fn WIFCONTINUED(s: u32) bool {
|
|
return ((s & 0o177777) == 0o177777);
|
|
}
|
|
|
|
pub fn WIFSTOPPED(s: u32) bool {
|
|
return (s & 0xff == 0o177);
|
|
}
|
|
|
|
pub fn WIFSIGNALED(s: u32) bool {
|
|
return (((s) & 0o177) != 0o177) and (((s) & 0o177) != 0);
|
|
}
|
|
|
|
pub const winsize = extern struct {
|
|
ws_row: c_ushort,
|
|
ws_col: c_ushort,
|
|
ws_xpixel: c_ushort,
|
|
ws_ypixel: c_ushort,
|
|
};
|
|
|
|
const NSIG = 33;
|
|
|
|
pub const SIG_DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
|
|
pub const SIG_IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
|
|
pub const SIG_ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
|
|
pub const SIG_CATCH = @intToPtr(?Sigaction.sigaction_fn, 2);
|
|
pub const SIG_HOLD = @intToPtr(?Sigaction.sigaction_fn, 3);
|
|
|
|
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
|
pub const Sigaction = extern struct {
|
|
pub const handler_fn = fn (c_int) callconv(.C) void;
|
|
pub const sigaction_fn = fn (c_int, *const siginfo_t, ?*const c_void) callconv(.C) void;
|
|
|
|
/// signal handler
|
|
handler: extern union {
|
|
handler: ?handler_fn,
|
|
sigaction: ?sigaction_fn,
|
|
},
|
|
/// signal mask to apply
|
|
mask: sigset_t,
|
|
/// signal options
|
|
flags: c_uint,
|
|
};
|
|
|
|
pub const sigval = extern union {
|
|
int: c_int,
|
|
ptr: ?*c_void,
|
|
};
|
|
|
|
pub const siginfo_t = extern struct {
|
|
signo: c_int,
|
|
code: c_int,
|
|
errno: c_int,
|
|
data: extern union {
|
|
proc: extern struct {
|
|
pid: pid_t,
|
|
pdata: extern union {
|
|
kill: extern struct {
|
|
uid: uid_t,
|
|
value: sigval,
|
|
},
|
|
cld: extern struct {
|
|
utime: clock_t,
|
|
stime: clock_t,
|
|
status: c_int,
|
|
},
|
|
},
|
|
},
|
|
fault: extern struct {
|
|
addr: ?*c_void,
|
|
trapno: c_int,
|
|
},
|
|
__pad: [128 - 3 * @sizeOf(c_int)]u8,
|
|
},
|
|
};
|
|
|
|
comptime {
|
|
if (@sizeOf(usize) == 4)
|
|
std.debug.assert(@sizeOf(siginfo_t) == 128)
|
|
else
|
|
// Take into account the padding between errno and data fields.
|
|
std.debug.assert(@sizeOf(siginfo_t) == 136);
|
|
}
|
|
|
|
const arch_bits = switch (builtin.cpu.arch) {
|
|
.x86_64 => struct {
|
|
pub const ucontext_t = extern struct {
|
|
sc_rdi: c_long,
|
|
sc_rsi: c_long,
|
|
sc_rdx: c_long,
|
|
sc_rcx: c_long,
|
|
sc_r8: c_long,
|
|
sc_r9: c_long,
|
|
sc_r10: c_long,
|
|
sc_r11: c_long,
|
|
sc_r12: c_long,
|
|
sc_r13: c_long,
|
|
sc_r14: c_long,
|
|
sc_r15: c_long,
|
|
sc_rbp: c_long,
|
|
sc_rbx: c_long,
|
|
sc_rax: c_long,
|
|
sc_gs: c_long,
|
|
sc_fs: c_long,
|
|
sc_es: c_long,
|
|
sc_ds: c_long,
|
|
sc_trapno: c_long,
|
|
sc_err: c_long,
|
|
sc_rip: c_long,
|
|
sc_cs: c_long,
|
|
sc_rflags: c_long,
|
|
sc_rsp: c_long,
|
|
sc_ss: c_long,
|
|
|
|
sc_fpstate: fxsave64,
|
|
__sc_unused: c_int,
|
|
sc_mask: c_int,
|
|
sc_cookie: c_long,
|
|
};
|
|
|
|
pub const fxsave64 = packed struct {
|
|
fx_fcw: u16,
|
|
fx_fsw: u16,
|
|
fx_ftw: u8,
|
|
fx_unused1: u8,
|
|
fx_fop: u16,
|
|
fx_rip: u64,
|
|
fx_rdp: u64,
|
|
fx_mxcsr: u32,
|
|
fx_mxcsr_mask: u32,
|
|
fx_st: [8][2]u64,
|
|
fx_xmm: [16][2]u64,
|
|
fx_unused3: [96]u8,
|
|
};
|
|
},
|
|
else => struct {},
|
|
};
|
|
pub const ucontext_t = arch_bits.ucontext_t;
|
|
pub const fxsave64 = arch_bits.fxsave64;
|
|
|
|
pub const sigset_t = c_uint;
|
|
pub const empty_sigset: sigset_t = 0;
|
|
|
|
pub const E = enum(u16) {
|
|
/// No error occurred.
|
|
SUCCESS = 0,
|
|
PERM = 1, // Operation not permitted
|
|
NOENT = 2, // No such file or directory
|
|
SRCH = 3, // No such process
|
|
INTR = 4, // Interrupted system call
|
|
IO = 5, // Input/output error
|
|
NXIO = 6, // Device not configured
|
|
@"2BIG" = 7, // Argument list too long
|
|
NOEXEC = 8, // Exec format error
|
|
BADF = 9, // Bad file descriptor
|
|
CHILD = 10, // No child processes
|
|
DEADLK = 11, // Resource deadlock avoided
|
|
// 11 was AGAIN
|
|
NOMEM = 12, // Cannot allocate memory
|
|
ACCES = 13, // Permission denied
|
|
FAULT = 14, // Bad address
|
|
NOTBLK = 15, // Block device required
|
|
BUSY = 16, // Device busy
|
|
EXIST = 17, // File exists
|
|
XDEV = 18, // Cross-device link
|
|
NODEV = 19, // Operation not supported by device
|
|
NOTDIR = 20, // Not a directory
|
|
ISDIR = 21, // Is a directory
|
|
INVAL = 22, // Invalid argument
|
|
NFILE = 23, // Too many open files in system
|
|
MFILE = 24, // Too many open files
|
|
NOTTY = 25, // Inappropriate ioctl for device
|
|
TXTBSY = 26, // Text file busy
|
|
FBIG = 27, // File too large
|
|
NOSPC = 28, // No space left on device
|
|
SPIPE = 29, // Illegal seek
|
|
ROFS = 30, // Read-only file system
|
|
MLINK = 31, // Too many links
|
|
PIPE = 32, // Broken pipe
|
|
|
|
// math software
|
|
DOM = 33, // Numerical argument out of domain
|
|
RANGE = 34, // Result too large or too small
|
|
|
|
// non-blocking and interrupt i/o
|
|
// also: WOULDBLOCK: operation would block
|
|
AGAIN = 35, // Resource temporarily unavailable
|
|
INPROGRESS = 36, // Operation now in progress
|
|
ALREADY = 37, // Operation already in progress
|
|
|
|
// ipc/network software -- argument errors
|
|
NOTSOCK = 38, // Socket operation on non-socket
|
|
DESTADDRREQ = 39, // Destination address required
|
|
MSGSIZE = 40, // Message too long
|
|
PROTOTYPE = 41, // Protocol wrong type for socket
|
|
NOPROTOOPT = 42, // Protocol option not available
|
|
PROTONOSUPPORT = 43, // Protocol not supported
|
|
SOCKTNOSUPPORT = 44, // Socket type not supported
|
|
OPNOTSUPP = 45, // Operation not supported
|
|
PFNOSUPPORT = 46, // Protocol family not supported
|
|
AFNOSUPPORT = 47, // Address family not supported by protocol family
|
|
ADDRINUSE = 48, // Address already in use
|
|
ADDRNOTAVAIL = 49, // Can't assign requested address
|
|
|
|
// ipc/network software -- operational errors
|
|
NETDOWN = 50, // Network is down
|
|
NETUNREACH = 51, // Network is unreachable
|
|
NETRESET = 52, // Network dropped connection on reset
|
|
CONNABORTED = 53, // Software caused connection abort
|
|
CONNRESET = 54, // Connection reset by peer
|
|
NOBUFS = 55, // No buffer space available
|
|
ISCONN = 56, // Socket is already connected
|
|
NOTCONN = 57, // Socket is not connected
|
|
SHUTDOWN = 58, // Can't send after socket shutdown
|
|
TOOMANYREFS = 59, // Too many references: can't splice
|
|
TIMEDOUT = 60, // Operation timed out
|
|
CONNREFUSED = 61, // Connection refused
|
|
|
|
LOOP = 62, // Too many levels of symbolic links
|
|
NAMETOOLONG = 63, // File name too long
|
|
|
|
// should be rearranged
|
|
HOSTDOWN = 64, // Host is down
|
|
HOSTUNREACH = 65, // No route to host
|
|
NOTEMPTY = 66, // Directory not empty
|
|
|
|
// quotas & mush
|
|
PROCLIM = 67, // Too many processes
|
|
USERS = 68, // Too many users
|
|
DQUOT = 69, // Disc quota exceeded
|
|
|
|
// Network File System
|
|
STALE = 70, // Stale NFS file handle
|
|
REMOTE = 71, // Too many levels of remote in path
|
|
BADRPC = 72, // RPC struct is bad
|
|
RPCMISMATCH = 73, // RPC version wrong
|
|
PROGUNAVAIL = 74, // RPC prog. not avail
|
|
PROGMISMATCH = 75, // Program version wrong
|
|
PROCUNAVAIL = 76, // Bad procedure for program
|
|
|
|
NOLCK = 77, // No locks available
|
|
NOSYS = 78, // Function not implemented
|
|
|
|
FTYPE = 79, // Inappropriate file type or format
|
|
AUTH = 80, // Authentication error
|
|
NEEDAUTH = 81, // Need authenticator
|
|
IPSEC = 82, // IPsec processing failure
|
|
NOATTR = 83, // Attribute not found
|
|
|
|
// Wide/multibyte-character handling, ISO/IEC 9899/AMD1:1995
|
|
ILSEQ = 84, // Illegal byte sequence
|
|
|
|
NOMEDIUM = 85, // No medium found
|
|
MEDIUMTYPE = 86, // Wrong medium type
|
|
OVERFLOW = 87, // Value too large to be stored in data type
|
|
CANCELED = 88, // Operation canceled
|
|
IDRM = 89, // Identifier removed
|
|
NOMSG = 90, // No message of desired type
|
|
NOTSUP = 91, // Not supported
|
|
BADMSG = 92, // Bad or Corrupt message
|
|
NOTRECOVERABLE = 93, // State not recoverable
|
|
OWNERDEAD = 94, // Previous owner died
|
|
PROTO = 95, // Protocol error
|
|
|
|
_,
|
|
};
|
|
|
|
const _MAX_PAGE_SHIFT = switch (builtin.cpu.arch) {
|
|
.i386 => 12,
|
|
.sparcv9 => 13,
|
|
};
|
|
pub const MINSIGSTKSZ = 1 << _MAX_PAGE_SHIFT;
|
|
pub const SIGSTKSZ = MINSIGSTKSZ + (1 << _MAX_PAGE_SHIFT) * 4;
|
|
|
|
pub const SS_ONSTACK = 0x0001;
|
|
pub const SS_DISABLE = 0x0004;
|
|
|
|
pub const stack_t = extern struct {
|
|
ss_sp: [*]u8,
|
|
ss_size: usize,
|
|
ss_flags: c_int,
|
|
};
|
|
|
|
pub const S_IFMT = 0o170000;
|
|
|
|
pub const S_IFIFO = 0o010000;
|
|
pub const S_IFCHR = 0o020000;
|
|
pub const S_IFDIR = 0o040000;
|
|
pub const S_IFBLK = 0o060000;
|
|
pub const S_IFREG = 0o100000;
|
|
pub const S_IFLNK = 0o120000;
|
|
pub const S_IFSOCK = 0o140000;
|
|
|
|
pub const S_ISUID = 0o4000;
|
|
pub const S_ISGID = 0o2000;
|
|
pub const S_ISVTX = 0o1000;
|
|
pub const S_IRWXU = 0o700;
|
|
pub const S_IRUSR = 0o400;
|
|
pub const S_IWUSR = 0o200;
|
|
pub const S_IXUSR = 0o100;
|
|
pub const S_IRWXG = 0o070;
|
|
pub const S_IRGRP = 0o040;
|
|
pub const S_IWGRP = 0o020;
|
|
pub const S_IXGRP = 0o010;
|
|
pub const S_IRWXO = 0o007;
|
|
pub const S_IROTH = 0o004;
|
|
pub const S_IWOTH = 0o002;
|
|
pub const S_IXOTH = 0o001;
|
|
|
|
pub fn S_ISFIFO(m: u32) bool {
|
|
return m & S_IFMT == S_IFIFO;
|
|
}
|
|
|
|
pub fn S_ISCHR(m: u32) bool {
|
|
return m & S_IFMT == S_IFCHR;
|
|
}
|
|
|
|
pub fn S_ISDIR(m: u32) bool {
|
|
return m & S_IFMT == S_IFDIR;
|
|
}
|
|
|
|
pub fn S_ISBLK(m: u32) bool {
|
|
return m & S_IFMT == S_IFBLK;
|
|
}
|
|
|
|
pub fn S_ISREG(m: u32) bool {
|
|
return m & S_IFMT == S_IFREG;
|
|
}
|
|
|
|
pub fn S_ISLNK(m: u32) bool {
|
|
return m & S_IFMT == S_IFLNK;
|
|
}
|
|
|
|
pub fn S_ISSOCK(m: u32) bool {
|
|
return m & S_IFMT == S_IFSOCK;
|
|
}
|
|
|
|
/// Magic value that specify the use of the current working directory
|
|
/// to determine the target of relative file paths in the openat() and
|
|
/// similar syscalls.
|
|
pub const AT_FDCWD = -100;
|
|
|
|
/// Check access using effective user and group ID
|
|
pub const AT_EACCESS = 0x01;
|
|
|
|
/// Do not follow symbolic links
|
|
pub const AT_SYMLINK_NOFOLLOW = 0x02;
|
|
|
|
/// Follow symbolic link
|
|
pub const AT_SYMLINK_FOLLOW = 0x04;
|
|
|
|
/// Remove directory instead of file
|
|
pub const AT_REMOVEDIR = 0x08;
|
|
|
|
pub const HOST_NAME_MAX = 255;
|
|
|
|
pub const IPPROTO = struct {
|
|
/// dummy for IP
|
|
pub const IP = 0;
|
|
/// IP6 hop-by-hop options
|
|
pub const HOPOPTS = IP;
|
|
/// control message protocol
|
|
pub const ICMP = 1;
|
|
/// group mgmt protocol
|
|
pub const IGMP = 2;
|
|
/// gateway^2 (deprecated)
|
|
pub const GGP = 3;
|
|
/// IP header
|
|
pub const IPV4 = IPIP;
|
|
/// IP inside IP
|
|
pub const IPIP = 4;
|
|
/// tcp
|
|
pub const TCP = 6;
|
|
/// exterior gateway protocol
|
|
pub const EGP = 8;
|
|
/// pup
|
|
pub const PUP = 12;
|
|
/// user datagram protocol
|
|
pub const UDP = 17;
|
|
/// xns idp
|
|
pub const IDP = 22;
|
|
/// tp-4 w/ class negotiation
|
|
pub const TP = 29;
|
|
/// IP6 header
|
|
pub const IPV6 = 41;
|
|
/// IP6 routing header
|
|
pub const ROUTING = 43;
|
|
/// IP6 fragmentation header
|
|
pub const FRAGMENT = 44;
|
|
/// resource reservation
|
|
pub const RSVP = 46;
|
|
/// GRE encaps RFC 1701
|
|
pub const GRE = 47;
|
|
/// encap. security payload
|
|
pub const ESP = 50;
|
|
/// authentication header
|
|
pub const AH = 51;
|
|
/// IP Mobility RFC 2004
|
|
pub const MOBILE = 55;
|
|
/// IPv6 ICMP
|
|
pub const IPV6_ICMP = 58;
|
|
/// ICMP6
|
|
pub const ICMPV6 = 58;
|
|
/// IP6 no next header
|
|
pub const NONE = 59;
|
|
/// IP6 destination option
|
|
pub const DSTOPTS = 60;
|
|
/// ISO cnlp
|
|
pub const EON = 80;
|
|
/// Ethernet-in-IP
|
|
pub const ETHERIP = 97;
|
|
/// encapsulation header
|
|
pub const ENCAP = 98;
|
|
/// Protocol indep. multicast
|
|
pub const PIM = 103;
|
|
/// IP Payload Comp. Protocol
|
|
pub const IPCOMP = 108;
|
|
/// VRRP RFC 2338
|
|
pub const VRRP = 112;
|
|
/// Common Address Resolution Protocol
|
|
pub const CARP = 112;
|
|
/// PFSYNC
|
|
pub const PFSYNC = 240;
|
|
/// raw IP packet
|
|
pub const RAW = 255;
|
|
};
|
|
|
|
pub const rlimit_resource = enum(c_int) {
|
|
CPU,
|
|
FSIZE,
|
|
DATA,
|
|
STACK,
|
|
CORE,
|
|
RSS,
|
|
MEMLOCK,
|
|
NPROC,
|
|
NOFILE,
|
|
|
|
_,
|
|
};
|
|
|
|
pub const rlim_t = u64;
|
|
|
|
pub const RLIM = struct {
|
|
/// No limit
|
|
pub const INFINITY: rlim_t = (1 << 63) - 1;
|
|
|
|
pub const SAVED_MAX = INFINITY;
|
|
pub const SAVED_CUR = INFINITY;
|
|
};
|
|
|
|
pub const rlimit = extern struct {
|
|
/// Soft limit
|
|
cur: rlim_t,
|
|
/// Hard limit
|
|
max: rlim_t,
|
|
};
|
|
|
|
pub const SHUT_RD = 0;
|
|
pub const SHUT_WR = 1;
|
|
pub const SHUT_RDWR = 2;
|
|
|
|
pub const nfds_t = c_uint;
|
|
|
|
pub const pollfd = extern struct {
|
|
fd: fd_t,
|
|
events: c_short,
|
|
revents: c_short,
|
|
};
|
|
|
|
pub const POLL = struct {
|
|
pub const IN = 0x0001;
|
|
pub const PRI = 0x0002;
|
|
pub const OUT = 0x0004;
|
|
pub const ERR = 0x0008;
|
|
pub const HUP = 0x0010;
|
|
pub const NVAL = 0x0020;
|
|
pub const RDNORM = 0x0040;
|
|
pub const NORM = RDNORM;
|
|
pub const WRNORM = OUT;
|
|
pub const RDBAND = 0x0080;
|
|
pub const WRBAND = 0x0100;
|
|
};
|
|
|
|
// sysctl mib
|
|
pub const CTL_UNSPEC = 0;
|
|
pub const CTL_KERN = 1;
|
|
pub const CTL_VM = 2;
|
|
pub const CTL_FS = 3;
|
|
pub const CTL_NET = 4;
|
|
pub const CTL_DEBUG = 5;
|
|
pub const CTL_HW = 6;
|
|
pub const CTL_MACHDEP = 7;
|
|
|
|
pub const CTL_DDB = 9;
|
|
pub const CTL_VFS = 10;
|
|
|
|
pub const KERN_OSTYPE = 1;
|
|
pub const KERN_OSRELEASE = 2;
|
|
pub const KERN_OSREV = 3;
|
|
pub const KERN_VERSION = 4;
|
|
pub const KERN_MAXVNODES = 5;
|
|
pub const KERN_MAXPROC = 6;
|
|
pub const KERN_MAXFILES = 7;
|
|
pub const KERN_ARGMAX = 8;
|
|
pub const KERN_SECURELVL = 9;
|
|
pub const KERN_HOSTNAME = 10;
|
|
pub const KERN_HOSTID = 11;
|
|
pub const KERN_CLOCKRATE = 12;
|
|
|
|
pub const KERN_PROF = 16;
|
|
pub const KERN_POSIX1 = 17;
|
|
pub const KERN_NGROUPS = 18;
|
|
pub const KERN_JOB_CONTROL = 19;
|
|
pub const KERN_SAVED_IDS = 20;
|
|
pub const KERN_BOOTTIME = 21;
|
|
pub const KERN_DOMAINNAME = 22;
|
|
pub const KERN_MAXPARTITIONS = 23;
|
|
pub const KERN_RAWPARTITION = 24;
|
|
pub const KERN_MAXTHREAD = 25;
|
|
pub const KERN_NTHREADS = 26;
|
|
pub const KERN_OSVERSION = 27;
|
|
pub const KERN_SOMAXCONN = 28;
|
|
pub const KERN_SOMINCONN = 29;
|
|
|
|
pub const KERN_NOSUIDCOREDUMP = 32;
|
|
pub const KERN_FSYNC = 33;
|
|
pub const KERN_SYSVMSG = 34;
|
|
pub const KERN_SYSVSEM = 35;
|
|
pub const KERN_SYSVSHM = 36;
|
|
|
|
pub const KERN_MSGBUFSIZE = 38;
|
|
pub const KERN_MALLOCSTATS = 39;
|
|
pub const KERN_CPTIME = 40;
|
|
pub const KERN_NCHSTATS = 41;
|
|
pub const KERN_FORKSTAT = 42;
|
|
pub const KERN_NSELCOLL = 43;
|
|
pub const KERN_TTY = 44;
|
|
pub const KERN_CCPU = 45;
|
|
pub const KERN_FSCALE = 46;
|
|
pub const KERN_NPROCS = 47;
|
|
pub const KERN_MSGBUF = 48;
|
|
pub const KERN_POOL = 49;
|
|
pub const KERN_STACKGAPRANDOM = 50;
|
|
pub const KERN_SYSVIPC_INFO = 51;
|
|
pub const KERN_ALLOWKMEM = 52;
|
|
pub const KERN_WITNESSWATCH = 53;
|
|
pub const KERN_SPLASSERT = 54;
|
|
pub const KERN_PROC_ARGS = 55;
|
|
pub const KERN_NFILES = 56;
|
|
pub const KERN_TTYCOUNT = 57;
|
|
pub const KERN_NUMVNODES = 58;
|
|
pub const KERN_MBSTAT = 59;
|
|
pub const KERN_WITNESS = 60;
|
|
pub const KERN_SEMINFO = 61;
|
|
pub const KERN_SHMINFO = 62;
|
|
pub const KERN_INTRCNT = 63;
|
|
pub const KERN_WATCHDOG = 64;
|
|
pub const KERN_ALLOWDT = 65;
|
|
pub const KERN_PROC = 66;
|
|
pub const KERN_MAXCLUSTERS = 67;
|
|
pub const KERN_EVCOUNT = 68;
|
|
pub const KERN_TIMECOUNTER = 69;
|
|
pub const KERN_MAXLOCKSPERUID = 70;
|
|
pub const KERN_CPTIME2 = 71;
|
|
pub const KERN_CACHEPCT = 72;
|
|
pub const KERN_FILE = 73;
|
|
pub const KERN_WXABORT = 74;
|
|
pub const KERN_CONSDEV = 75;
|
|
pub const KERN_NETLIVELOCKS = 76;
|
|
pub const KERN_POOL_DEBUG = 77;
|
|
pub const KERN_PROC_CWD = 78;
|
|
pub const KERN_PROC_NOBROADCASTKILL = 79;
|
|
pub const KERN_PROC_VMMAP = 80;
|
|
pub const KERN_GLOBAL_PTRACE = 81;
|
|
pub const KERN_CONSBUFSIZE = 82;
|
|
pub const KERN_CONSBUF = 83;
|
|
pub const KERN_AUDIO = 84;
|
|
pub const KERN_CPUSTATS = 85;
|
|
pub const KERN_PFSTATUS = 86;
|
|
pub const KERN_TIMEOUT_STATS = 87;
|
|
pub const KERN_UTC_OFFSET = 88;
|
|
pub const KERN_VIDEO = 89;
|
|
|
|
pub const HW_MACHINE = 1;
|
|
pub const HW_MODEL = 2;
|
|
pub const HW_NCPU = 3;
|
|
pub const HW_BYTEORDER = 4;
|
|
pub const HW_PHYSMEM = 5;
|
|
pub const HW_USERMEM = 6;
|
|
pub const HW_PAGESIZE = 7;
|
|
pub const HW_DISKNAMES = 8;
|
|
pub const HW_DISKSTATS = 9;
|
|
pub const HW_DISKCOUNT = 10;
|
|
pub const HW_SENSORS = 11;
|
|
pub const HW_CPUSPEED = 12;
|
|
pub const HW_SETPERF = 13;
|
|
pub const HW_VENDOR = 14;
|
|
pub const HW_PRODUCT = 15;
|
|
pub const HW_VERSION = 16;
|
|
pub const HW_SERIALNO = 17;
|
|
pub const HW_UUID = 18;
|
|
pub const HW_PHYSMEM64 = 19;
|
|
pub const HW_USERMEM64 = 20;
|
|
pub const HW_NCPUFOUND = 21;
|
|
pub const HW_ALLOWPOWERDOWN = 22;
|
|
pub const HW_PERFPOLICY = 23;
|
|
pub const HW_SMT = 24;
|
|
pub const HW_NCPUONLINE = 25;
|
|
|
|
pub const KERN_PROC_ALL = 0;
|
|
pub const KERN_PROC_PID = 1;
|
|
pub const KERN_PROC_PGRP = 2;
|
|
pub const KERN_PROC_SESSION = 3;
|
|
pub const KERN_PROC_TTY = 4;
|
|
pub const KERN_PROC_UID = 5;
|
|
pub const KERN_PROC_RUID = 6;
|
|
pub const KERN_PROC_KTHREAD = 7;
|
|
pub const KERN_PROC_SHOW_THREADS = 0x40000000;
|
|
|
|
pub const KERN_PROC_ARGV = 1;
|
|
pub const KERN_PROC_NARGV = 2;
|
|
pub const KERN_PROC_ENV = 3;
|
|
pub const KERN_PROC_NENV = 4;
|