Commit c05a20fc8c
Changed files (51)
lib
std
c
crypto
25519
event
fs
math
big
os
lib/std/c/darwin.zig
@@ -4,6 +4,7 @@ const builtin = @import("builtin");
const macho = std.macho;
const native_arch = builtin.target.cpu.arch;
const maxInt = std.math.maxInt;
+const iovec_const = std.os.iovec_const;
extern "c" fn __error() *c_int;
pub extern "c" fn NSVersionOfRunTimeLibrary(library_name: [*:0]const u8) u32;
@@ -84,8 +85,6 @@ pub const _errno = __error;
pub extern "c" fn @"close$NOCANCEL"(fd: fd_t) c_int;
pub extern "c" fn mach_host_self() mach_port_t;
pub extern "c" fn clock_get_time(clock_serv: clock_serv_t, cur_time: *mach_timespec_t) kern_return_t;
-pub extern "c" fn host_get_clock_service(host: host_t, clock_id: clock_id_t, clock_serv: ?[*]clock_serv_t) kern_return_t;
-pub extern "c" fn mach_port_deallocate(task: ipc_space_t, name: mach_port_name_t) kern_return_t;
pub const sf_hdtr = extern struct {
headers: [*]const iovec_const,
@@ -1550,19 +1549,17 @@ pub fn S_IWHT(m: u32) bool {
pub const HOST_NAME_MAX = 72;
-pub const AT_FDCWD = -2;
-
-/// Use effective ids in access check
-pub const AT_EACCESS = 0x0010;
-
-/// Act on the symlink itself not the target
-pub const AT_SYMLINK_NOFOLLOW = 0x0020;
-
-/// Act on target of symlink
-pub const AT_SYMLINK_FOLLOW = 0x0040;
-
-/// Path refers to directory
-pub const AT_REMOVEDIR = 0x0080;
+pub const AT = struct {
+ pub const FDCWD = -2;
+ /// Use effective ids in access check
+ pub const EACCESS = 0x0010;
+ /// Act on the symlink itself not the target
+ pub const SYMLINK_NOFOLLOW = 0x0020;
+ /// Act on target of symlink
+ pub const SYMLINK_FOLLOW = 0x0040;
+ /// Path refers to directory
+ pub const REMOVEDIR = 0x0080;
+};
pub const addrinfo = extern struct {
flags: i32,
@@ -1590,164 +1587,117 @@ pub const RTLD = struct {
pub const MAIN_ONLY = @intToPtr(*c_void, @bitCast(usize, @as(isize, -5)));
};
-/// duplicate file descriptor
-pub const F_DUPFD = 0;
-
-/// get file descriptor flags
-pub const F_GETFD = 1;
-
-/// set file descriptor flags
-pub const F_SETFD = 2;
-
-/// get file status flags
-pub const F_GETFL = 3;
-
-/// set file status flags
-pub const F_SETFL = 4;
-
-/// get SIGIO/SIGURG proc/pgrp
-pub const F_GETOWN = 5;
-
-/// set SIGIO/SIGURG proc/pgrp
-pub const F_SETOWN = 6;
-
-/// get record locking information
-pub const F_GETLK = 7;
-
-/// set record locking information
-pub const F_SETLK = 8;
-
-/// F_SETLK; wait if blocked
-pub const F_SETLKW = 9;
-
-/// F_SETLK; wait if blocked, return on timeout
-pub const F_SETLKWTIMEOUT = 10;
-pub const F_FLUSH_DATA = 40;
-
-/// Used for regression test
-pub const F_CHKCLEAN = 41;
-
-/// Preallocate storage
-pub const F_PREALLOCATE = 42;
-
-/// Truncate a file without zeroing space
-pub const F_SETSIZE = 43;
-
-/// Issue an advisory read async with no copy to user
-pub const F_RDADVISE = 44;
-
-/// turn read ahead off/on for this fd
-pub const F_RDAHEAD = 45;
-
-/// turn data caching off/on for this fd
-pub const F_NOCACHE = 48;
-
-/// file offset to device offset
-pub const F_LOG2PHYS = 49;
-
-/// return the full path of the fd
-pub const F_GETPATH = 50;
-
-/// fsync + ask the drive to flush to the media
-pub const F_FULLFSYNC = 51;
-
-/// find which component (if any) is a package
-pub const F_PATHPKG_CHECK = 52;
-
-/// "freeze" all fs operations
-pub const F_FREEZE_FS = 53;
-
-/// "thaw" all fs operations
-pub const F_THAW_FS = 54;
-
-/// turn data caching off/on (globally) for this file
-pub const F_GLOBAL_NOCACHE = 55;
-
-/// add detached signatures
-pub const F_ADDSIGS = 59;
-
-/// add signature from same file (used by dyld for shared libs)
-pub const F_ADDFILESIGS = 61;
-
-/// used in conjunction with F_NOCACHE to indicate that DIRECT, synchonous writes
-/// should not be used (i.e. its ok to temporaily create cached pages)
-pub const F_NODIRECT = 62;
-
-///Get the protection class of a file from the EA, returns int
-pub const F_GETPROTECTIONCLASS = 63;
-
-///Set the protection class of a file for the EA, requires int
-pub const F_SETPROTECTIONCLASS = 64;
-
-///file offset to device offset, extended
-pub const F_LOG2PHYS_EXT = 65;
-
-///get record locking information, per-process
-pub const F_GETLKPID = 66;
-
-///Mark the file as being the backing store for another filesystem
-pub const F_SETBACKINGSTORE = 70;
-
-///return the full path of the FD, but error in specific mtmd circumstances
-pub const F_GETPATH_MTMINFO = 71;
-
-///Returns the code directory, with associated hashes, to the caller
-pub const F_GETCODEDIR = 72;
-
-///No SIGPIPE generated on EPIPE
-pub const F_SETNOSIGPIPE = 73;
-
-///Status of SIGPIPE for this fd
-pub const F_GETNOSIGPIPE = 74;
-
-///For some cases, we need to rewrap the key for AKS/MKB
-pub const F_TRANSCODEKEY = 75;
-
-///file being written to a by single writer... if throttling enabled, writes
-///may be broken into smaller chunks with throttling in between
-pub const F_SINGLE_WRITER = 76;
-
-///Get the protection version number for this filesystem
-pub const F_GETPROTECTIONLEVEL = 77;
-
-///Add detached code signatures (used by dyld for shared libs)
-pub const F_FINDSIGS = 78;
-
-///Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
-pub const F_ADDFILESIGS_FOR_DYLD_SIM = 83;
-
-///fsync + issue barrier to drive
-pub const F_BARRIERFSYNC = 85;
-
-///Add signature from same file, return end offset in structure on success
-pub const F_ADDFILESIGS_RETURN = 97;
-
-///Check if Library Validation allows this Mach-O file to be mapped into the calling process
-pub const F_CHECK_LV = 98;
-
-///Deallocate a range of the file
-pub const F_PUNCHHOLE = 99;
-
-///Trim an active file
-pub const F_TRIM_ACTIVE_FILE = 100;
+pub const F = struct {
+ /// duplicate file descriptor
+ pub const DUPFD = 0;
+ /// get file descriptor flags
+ pub const GETFD = 1;
+ /// set file descriptor flags
+ pub const SETFD = 2;
+ /// get file status flags
+ pub const GETFL = 3;
+ /// set file status flags
+ pub const SETFL = 4;
+ /// get SIGIO/SIGURG proc/pgrp
+ pub const GETOWN = 5;
+ /// set SIGIO/SIGURG proc/pgrp
+ pub const SETOWN = 6;
+ /// get record locking information
+ pub const GETLK = 7;
+ /// set record locking information
+ pub const SETLK = 8;
+ /// F.SETLK; wait if blocked
+ pub const SETLKW = 9;
+ /// F.SETLK; wait if blocked, return on timeout
+ pub const SETLKWTIMEOUT = 10;
+ pub const FLUSH_DATA = 40;
+ /// Used for regression test
+ pub const CHKCLEAN = 41;
+ /// Preallocate storage
+ pub const PREALLOCATE = 42;
+ /// Truncate a file without zeroing space
+ pub const SETSIZE = 43;
+ /// Issue an advisory read async with no copy to user
+ pub const RDADVISE = 44;
+ /// turn read ahead off/on for this fd
+ pub const RDAHEAD = 45;
+ /// turn data caching off/on for this fd
+ pub const NOCACHE = 48;
+ /// file offset to device offset
+ pub const LOG2PHYS = 49;
+ /// return the full path of the fd
+ pub const GETPATH = 50;
+ /// fsync + ask the drive to flush to the media
+ pub const FULLFSYNC = 51;
+ /// find which component (if any) is a package
+ pub const PATHPKG_CHECK = 52;
+ /// "freeze" all fs operations
+ pub const FREEZE_FS = 53;
+ /// "thaw" all fs operations
+ pub const THAW_FS = 54;
+ /// turn data caching off/on (globally) for this file
+ pub const GLOBAL_NOCACHE = 55;
+ /// add detached signatures
+ pub const ADDSIGS = 59;
+ /// add signature from same file (used by dyld for shared libs)
+ pub const ADDFILESIGS = 61;
+ /// used in conjunction with F.NOCACHE to indicate that DIRECT, synchonous writes
+ /// should not be used (i.e. its ok to temporaily create cached pages)
+ pub const NODIRECT = 62;
+ ///Get the protection class of a file from the EA, returns int
+ pub const GETPROTECTIONCLASS = 63;
+ ///Set the protection class of a file for the EA, requires int
+ pub const SETPROTECTIONCLASS = 64;
+ ///file offset to device offset, extended
+ pub const LOG2PHYS_EXT = 65;
+ ///get record locking information, per-process
+ pub const GETLKPID = 66;
+ ///Mark the file as being the backing store for another filesystem
+ pub const SETBACKINGSTORE = 70;
+ ///return the full path of the FD, but error in specific mtmd circumstances
+ pub const GETPATH_MTMINFO = 71;
+ ///Returns the code directory, with associated hashes, to the caller
+ pub const GETCODEDIR = 72;
+ ///No SIGPIPE generated on EPIPE
+ pub const SETNOSIGPIPE = 73;
+ ///Status of SIGPIPE for this fd
+ pub const GETNOSIGPIPE = 74;
+ ///For some cases, we need to rewrap the key for AKS/MKB
+ pub const TRANSCODEKEY = 75;
+ ///file being written to a by single writer... if throttling enabled, writes
+ ///may be broken into smaller chunks with throttling in between
+ pub const SINGLE_WRITER = 76;
+ ///Get the protection version number for this filesystem
+ pub const GETPROTECTIONLEVEL = 77;
+ ///Add detached code signatures (used by dyld for shared libs)
+ pub const FINDSIGS = 78;
+ ///Add signature from same file, only if it is signed by Apple (used by dyld for simulator)
+ pub const ADDFILESIGS_FOR_DYLD_SIM = 83;
+ ///fsync + issue barrier to drive
+ pub const BARRIERFSYNC = 85;
+ ///Add signature from same file, return end offset in structure on success
+ pub const ADDFILESIGS_RETURN = 97;
+ ///Check if Library Validation allows this Mach-O file to be mapped into the calling process
+ pub const CHECK_LV = 98;
+ ///Deallocate a range of the file
+ pub const PUNCHHOLE = 99;
+ ///Trim an active file
+ pub const TRIM_ACTIVE_FILE = 100;
+ ///mark the dup with FD_CLOEXEC
+ pub const DUPFD_CLOEXEC = 67;
+ /// shared or read lock
+ pub const RDLCK = 1;
+ /// unlock
+ pub const UNLCK = 2;
+ /// exclusive or write lock
+ pub const WRLCK = 3;
+};
pub const FCNTL_FS_SPECIFIC_BASE = 0x00010000;
-///mark the dup with FD_CLOEXEC
-pub const F_DUPFD_CLOEXEC = 67;
-
///close-on-exec flag
pub const FD_CLOEXEC = 1;
-/// shared or read lock
-pub const F_RDLCK = 1;
-
-/// unlock
-pub const F_UNLCK = 2;
-
-/// exclusive or write lock
-pub const F_WRLCK = 3;
-
pub const LOCK = struct {
pub const SH = 1;
pub const EX = 2;
lib/std/c/dragonfly.zig
@@ -1,5 +1,6 @@
const std = @import("../std.zig");
const maxInt = std.math.maxInt;
+const iovec = std.os.iovec;
extern "c" threadlocal var errno: c_int;
pub fn _errno() *c_int {
@@ -353,18 +354,39 @@ pub const SEEK_END = 2;
pub const SEEK_DATA = 3;
pub const SEEK_HOLE = 4;
-pub const F_ULOCK = 0;
-pub const F_LOCK = 1;
-pub const F_TLOCK = 2;
-pub const F_TEST = 3;
+pub const F = struct {
+ pub const ULOCK = 0;
+ pub const LOCK = 1;
+ pub const TLOCK = 2;
+ pub const TEST = 3;
+
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const RDLCK = 1;
+ pub const SETFD = 2;
+ pub const UNLCK = 2;
+ pub const WRLCK = 3;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+ pub const GETOWN = 5;
+ pub const SETOWN = 6;
+ pub const GETLK = 7;
+ pub const SETLK = 8;
+ pub const SETLKW = 9;
+ pub const DUP2FD = 10;
+ pub const DUPFD_CLOEXEC = 17;
+ pub const DUP2FD_CLOEXEC = 18;
+};
pub const FD_CLOEXEC = 1;
-pub const AT_FDCWD = -328243;
-pub const AT_SYMLINK_NOFOLLOW = 1;
-pub const AT_REMOVEDIR = 2;
-pub const AT_EACCESS = 4;
-pub const AT_SYMLINK_FOLLOW = 8;
+pub const AT = struct {
+ pub const FDCWD = -328243;
+ pub const SYMLINK_NOFOLLOW = 1;
+ pub const REMOVEDIR = 2;
+ pub const EACCESS = 4;
+ pub const SYMLINK_FOLLOW = 8;
+};
pub fn WEXITSTATUS(s: u32) u8 {
return @intCast(u8, (s & 0xff00) >> 8);
@@ -715,7 +737,7 @@ pub const PF = struct {
pub const ISDN = AF.ISDN;
pub const RTIP = AF.pseudo_RTIP;
pub const LAT = AF.LAT;
- pub const UNIX = PF_LOCAL;
+ pub const UNIX = PF.LOCAL;
pub const XTP = AF.pseudo_XTP;
pub const DECnet = AF.DECnet;
};
@@ -868,23 +890,6 @@ pub const MADV = struct {
pub const SETMAP = 11;
};
-pub const F_DUPFD = 0;
-pub const F_GETFD = 1;
-pub const F_RDLCK = 1;
-pub const F_SETFD = 2;
-pub const F_UNLCK = 2;
-pub const F_WRLCK = 3;
-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_DUP2FD = 10;
-pub const F_DUPFD_CLOEXEC = 17;
-pub const F_DUP2FD_CLOEXEC = 18;
-
pub const LOCK = struct {
pub const SH = 1;
pub const EX = 2;
lib/std/c/freebsd.zig
@@ -1,5 +1,8 @@
const std = @import("../std.zig");
+const builtin = @import("builtin");
const maxInt = std.math.maxInt;
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
extern "c" fn __error() *c_int;
pub const _errno = __error;
@@ -400,60 +403,100 @@ pub const MAP = struct {
pub const @"32BIT" = 0x00080000;
};
-pub const WNOHANG = 1;
-pub const WUNTRACED = 2;
-pub const WSTOPPED = WUNTRACED;
-pub const WCONTINUED = 4;
-pub const WNOWAIT = 8;
-pub const WEXITED = 16;
-pub const WTRAPPED = 32;
-
-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 SIGTHR = 32;
-pub const SIGLWP = SIGTHR;
-pub const SIGLIBRT = 33;
-
-pub const SIGRTMIN = 65;
-pub const SIGRTMAX = 126;
+pub const W = struct {
+ pub const NOHANG = 1;
+ pub const UNTRACED = 2;
+ pub const STOPPED = UNTRACED;
+ pub const CONTINUED = 4;
+ pub const NOWAIT = 8;
+ pub const EXITED = 16;
+ pub const TRAPPED = 32;
+};
+
+pub const SA = struct {
+ pub const ONSTACK = 0x0001;
+ pub const RESTART = 0x0002;
+ pub const RESETHAND = 0x0004;
+ pub const NOCLDSTOP = 0x0008;
+ pub const NODEFER = 0x0010;
+ pub const NOCLDWAIT = 0x0020;
+ pub const SIGINFO = 0x0040;
+};
+
+pub const SIG = struct {
+ pub const HUP = 1;
+ pub const INT = 2;
+ pub const QUIT = 3;
+ pub const ILL = 4;
+ pub const TRAP = 5;
+ pub const ABRT = 6;
+ pub const IOT = ABRT;
+ pub const EMT = 7;
+ pub const FPE = 8;
+ pub const KILL = 9;
+ pub const BUS = 10;
+ pub const SEGV = 11;
+ pub const SYS = 12;
+ pub const PIPE = 13;
+ pub const ALRM = 14;
+ pub const TERM = 15;
+ pub const URG = 16;
+ pub const STOP = 17;
+ pub const TSTP = 18;
+ pub const CONT = 19;
+ pub const CHLD = 20;
+ pub const TTIN = 21;
+ pub const TTOU = 22;
+ pub const IO = 23;
+ pub const XCPU = 24;
+ pub const XFSZ = 25;
+ pub const VTALRM = 26;
+ pub const PROF = 27;
+ pub const WINCH = 28;
+ pub const INFO = 29;
+ pub const USR1 = 30;
+ pub const USR2 = 31;
+ pub const THR = 32;
+ pub const LWP = THR;
+ pub const LIBRT = 33;
+
+ pub const RTMIN = 65;
+ pub const RTMAX = 126;
+
+ pub const BLOCK = 1;
+ pub const UNBLOCK = 2;
+ pub const SETMASK = 3;
+
+ pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+ pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+ pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+
+ pub const WORDS = 4;
+ pub const MAXSIG = 128;
+
+ pub inline fn IDX(sig: usize) usize {
+ return sig - 1;
+ }
+ pub inline fn WORD(sig: usize) usize {
+ return IDX(sig) >> 5;
+ }
+ pub inline fn BIT(sig: usize) usize {
+ return 1 << (IDX(sig) & 31);
+ }
+ pub inline fn VALID(sig: usize) usize {
+ return sig <= MAXSIG and sig > 0;
+ }
+};
+pub const sigval = extern union {
+ int: c_int,
+ ptr: ?*c_void,
+};
+
+pub const sigset_t = extern struct {
+ __bits: [SIG.WORDS]u32,
+};
+
+pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** SIG.WORDS };
// access function
pub const F_OK = 0; // test for existence of file
@@ -489,22 +532,29 @@ pub const O_PATH = 0o10000000;
pub const O_TMPFILE = 0o20200000;
pub const O_NDELAY = O_NONBLOCK;
-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 = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const GETOWN = 5;
+ pub const SETOWN = 6;
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
+ pub const GETLK = 11;
+ pub const SETLK = 12;
+ pub const SETLKW = 13;
-pub const F_GETLK = 11;
-pub const F_SETLK = 12;
-pub const F_SETLKW = 13;
+ pub const RDLCK = 1;
+ pub const WRLCK = 3;
+ pub const UNLCK = 2;
-pub const F_RDLCK = 1;
-pub const F_WRLCK = 3;
-pub const F_UNLCK = 2;
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
pub const LOCK = struct {
pub const SH = 1;
@@ -513,21 +563,12 @@ pub const LOCK = struct {
pub const NB = 4;
};
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
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;
@@ -890,10 +931,6 @@ pub const winsize = extern struct {
const NSIG = 32;
-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));
-
/// 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;
@@ -942,34 +979,7 @@ pub const siginfo_t = extern struct {
},
};
-pub const sigval = extern union {
- int: c_int,
- ptr: ?*c_void,
-};
-
-pub const _SIG_WORDS = 4;
-pub const _SIG_MAXSIG = 128;
-
-pub inline fn _SIG_IDX(sig: usize) usize {
- return sig - 1;
-}
-pub inline fn _SIG_WORD(sig: usize) usize {
- return_SIG_IDX(sig) >> 5;
-}
-pub inline fn _SIG_BIT(sig: usize) usize {
- return 1 << (_SIG_IDX(sig) & 31);
-}
-pub inline fn _SIG_VALID(sig: usize) usize {
- return sig <= _SIG_MAXSIG and sig > 0;
-}
-
-pub const sigset_t = extern struct {
- __bits: [_SIG_WORDS]u32,
-};
-
-pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS };
-
-const arch_bits = switch (builtin.cpu.arch) {
+pub usingnamespace switch (builtin.cpu.arch) {
.x86_64 => struct {
pub const ucontext_t = extern struct {
sigmask: sigset_t,
@@ -1015,8 +1025,6 @@ const arch_bits = switch (builtin.cpu.arch) {
},
else => struct {},
};
-pub const ucontext_t = arch_bits.ucontext_t;
-pub const mcontext_t = arch_bits.mcontext_t;
pub const E = enum(u16) {
/// No error occurred.
@@ -1224,22 +1232,22 @@ pub fn S_IWHT(m: u32) bool {
pub const HOST_NAME_MAX = 255;
-/// 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 = 0x0100;
-
-/// Do not follow symbolic links
-pub const AT_SYMLINK_NOFOLLOW = 0x0200;
-
-/// Follow symbolic link
-pub const AT_SYMLINK_FOLLOW = 0x0400;
-
-/// Remove directory instead of file
-pub const AT_REMOVEDIR = 0x0800;
+pub const AT = struct {
+ /// 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 FDCWD = -100;
+ /// Check access using effective user and group ID
+ pub const EACCESS = 0x0100;
+ /// Do not follow symbolic links
+ pub const SYMLINK_NOFOLLOW = 0x0200;
+ /// Follow symbolic link
+ pub const SYMLINK_FOLLOW = 0x0400;
+ /// Remove directory instead of file
+ pub const REMOVEDIR = 0x0800;
+ /// Fail if not under dirfd
+ pub const BENEATH = 0x1000;
+};
pub const addrinfo = extern struct {
flags: i32,
@@ -1252,9 +1260,6 @@ pub const addrinfo = extern struct {
next: ?*addrinfo,
};
-/// Fail if not under dirfd
-pub const AT_BENEATH = 0x1000;
-
pub const IPPROTO = struct {
/// dummy for IP
pub const IP = 0;
lib/std/c/generic.zig
@@ -1,23 +0,0 @@
-const std = @import("../std.zig");
-const Stat = std.c.Stat;
-const timespec = std.c.timespec;
-const Sigaction = std.c.Sigaction;
-const sigset_t = std.c.sigset_t;
-const rusage = std.c.rusage;
-
-pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
-pub extern "c" fn fstatat(dirfd: fd_t, path: [*:0]const u8, stat_buf: *Stat, flags: u32) c_int;
-pub extern "c" fn clock_getres(clk_id: c_int, tp: *timespec) c_int;
-pub extern "c" fn clock_gettime(clk_id: c_int, tp: *timespec) c_int;
-pub extern "c" fn fstat(fd: fd_t, buf: *Stat) c_int;
-pub extern "c" fn getrusage(who: c_int, usage: *rusage) c_int;
-pub extern "c" fn gettimeofday(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
-pub extern "c" fn nanosleep(rqtp: *const timespec, rmtp: ?*timespec) c_int;
-pub extern "c" fn sched_yield() c_int;
-pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
-pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
-pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
-pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *Stat) c_int;
-pub extern "c" fn sigfillset(set: ?*sigset_t) void;
-pub extern "c" fn alarm(seconds: c_uint) c_uint;
-pub extern "c" fn sigwait(set: ?*sigset_t, sig: ?*c_int) c_int;
lib/std/c/haiku.zig
@@ -1,5 +1,8 @@
const std = @import("../std.zig");
+const builtin = @import("builtin");
const maxInt = std.math.maxInt;
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
extern "c" fn _errnop() *c_int;
@@ -421,43 +424,64 @@ pub const SA_NOMASK = SA_NODEFER;
pub const SA_STACK = SA_ONSTACK;
pub const SA_ONESHOT = SA_RESETHAND;
-pub const SIGHUP = 1;
-pub const SIGINT = 2;
-pub const SIGQUIT = 3;
-pub const SIGILL = 4;
-pub const SIGCHLD = 5;
-pub const SIGABRT = 6;
-pub const SIGIOT = SIGABRT;
-pub const SIGPIPE = 7;
-pub const SIGFPE = 8;
-pub const SIGKILL = 9;
-pub const SIGSTOP = 10;
-pub const SIGSEGV = 11;
-pub const SIGCONT = 12;
-pub const SIGTSTP = 13;
-pub const SIGALRM = 14;
-pub const SIGTERM = 15;
-pub const SIGTTIN = 16;
-pub const SIGTTOU = 17;
-pub const SIGUSR1 = 18;
-pub const SIGUSR2 = 19;
-pub const SIGWINCH = 20;
-pub const SIGKILLTHR = 21;
-pub const SIGTRAP = 22;
-pub const SIGPOLL = 23;
-pub const SIGPROF = 24;
-pub const SIGSYS = 25;
-pub const SIGURG = 26;
-pub const SIGVTALRM = 27;
-pub const SIGXCPU = 28;
-pub const SIGXFSZ = 29;
-pub const SIGBUS = 30;
-pub const SIGRESERVED1 = 31;
-pub const SIGRESERVED2 = 32;
-
-// TODO: check
-pub const SIGRTMIN = 65;
-pub const SIGRTMAX = 126;
+pub const SIG = struct {
+ pub const HUP = 1;
+ pub const INT = 2;
+ pub const QUIT = 3;
+ pub const ILL = 4;
+ pub const CHLD = 5;
+ pub const ABRT = 6;
+ pub const IOT = ABRT;
+ pub const PIPE = 7;
+ pub const FPE = 8;
+ pub const KILL = 9;
+ pub const STOP = 10;
+ pub const SEGV = 11;
+ pub const CONT = 12;
+ pub const TSTP = 13;
+ pub const ALRM = 14;
+ pub const TERM = 15;
+ pub const TTIN = 16;
+ pub const TTOU = 17;
+ pub const USR1 = 18;
+ pub const USR2 = 19;
+ pub const WINCH = 20;
+ pub const KILLTHR = 21;
+ pub const TRAP = 22;
+ pub const POLL = 23;
+ pub const PROF = 24;
+ pub const SYS = 25;
+ pub const URG = 26;
+ pub const VTALRM = 27;
+ pub const XCPU = 28;
+ pub const XFSZ = 29;
+ pub const BUS = 30;
+ pub const RESERVED1 = 31;
+ pub const RESERVED2 = 32;
+
+ // TODO: check
+ pub const RTMIN = 65;
+ pub const RTMAX = 126;
+
+ pub const BLOCK = 1;
+ pub const UNBLOCK = 2;
+ pub const SETMASK = 3;
+
+ pub const WORDS = 4;
+ pub const MAXSIG = 128;
+ pub inline fn IDX(sig: usize) usize {
+ return sig - 1;
+ }
+ pub inline fn WORD(sig: usize) usize {
+ return IDX(sig) >> 5;
+ }
+ pub inline fn BIT(sig: usize) usize {
+ return 1 << (IDX(sig) & 31);
+ }
+ pub inline fn VALID(sig: usize) usize {
+ return sig <= MAXSIG and sig > 0;
+ }
+};
// access function
pub const F_OK = 0; // test for existence of file
@@ -493,22 +517,29 @@ pub const O_PATH = 0o10000000;
pub const O_TMPFILE = 0o20200000;
pub const O_NDELAY = O_NONBLOCK;
-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 = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const GETOWN = 5;
+ pub const SETOWN = 6;
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
+ pub const GETLK = 11;
+ pub const SETLK = 12;
+ pub const SETLKW = 13;
-pub const F_GETLK = 11;
-pub const F_SETLK = 12;
-pub const F_SETLKW = 13;
+ pub const RDLCK = 1;
+ pub const WRLCK = 3;
+ pub const UNLCK = 2;
-pub const F_RDLCK = 1;
-pub const F_WRLCK = 3;
-pub const F_UNLCK = 2;
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
pub const LOCK = struct {
pub const SH = 1;
@@ -517,21 +548,12 @@ pub const LOCK = struct {
pub const NB = 4;
};
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
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;
@@ -615,7 +637,7 @@ pub const PF = struct {
pub const SIP = AF.SIP;
pub const IPX = AF.IPX;
pub const RTIP = AF.pseudo_RTIP;
- pub const PIP = psuedo_AF.PIP;
+ pub const PIP = AF.pseudo_PIP;
pub const ISDN = AF.ISDN;
pub const KEY = AF.pseudo_KEY;
pub const INET6 = AF.pseudo_INET6;
@@ -816,7 +838,6 @@ pub const Sigaction = extern struct {
/// signal handler
__sigaction_u: extern union {
__sa_handler: fn (i32) callconv(.C) void,
- __sa_sigaction: fn (i32, *__siginfo, usize) callconv(.C) void,
},
/// see signal options
@@ -826,23 +847,8 @@ pub const Sigaction = extern struct {
sa_mask: sigset_t,
};
-pub const _SIG_WORDS = 4;
-pub const _SIG_MAXSIG = 128;
-pub inline fn _SIG_IDX(sig: usize) usize {
- return sig - 1;
-}
-pub inline fn _SIG_WORD(sig: usize) usize {
- return_SIG_IDX(sig) >> 5;
-}
-pub inline fn _SIG_BIT(sig: usize) usize {
- return 1 << (_SIG_IDX(sig) & 31);
-}
-pub inline fn _SIG_VALID(sig: usize) usize {
- return sig <= _SIG_MAXSIG and sig > 0;
-}
-
pub const sigset_t = extern struct {
- __bits: [_SIG_WORDS]u32,
+ __bits: [SIG.WORDS]u32,
};
pub const E = enum(i32) {
@@ -1047,22 +1053,22 @@ pub fn S_IWHT(m: u32) bool {
pub const HOST_NAME_MAX = 255;
-/// 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 = 0x0100;
-
-/// Do not follow symbolic links
-pub const AT_SYMLINK_NOFOLLOW = 0x0200;
-
-/// Follow symbolic link
-pub const AT_SYMLINK_FOLLOW = 0x0400;
-
-/// Remove directory instead of file
-pub const AT_REMOVEDIR = 0x0800;
+pub const AT = struct {
+ /// 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 FDCWD = -100;
+ /// Check access using effective user and group ID
+ pub const EACCESS = 0x0100;
+ /// Do not follow symbolic links
+ pub const SYMLINK_NOFOLLOW = 0x0200;
+ /// Follow symbolic link
+ pub const SYMLINK_FOLLOW = 0x0400;
+ /// Remove directory instead of file
+ pub const REMOVEDIR = 0x0800;
+ /// Fail if not under dirfd
+ pub const BENEATH = 0x1000;
+};
pub const addrinfo = extern struct {
flags: i32,
@@ -1075,9 +1081,6 @@ pub const addrinfo = extern struct {
next: ?*addrinfo,
};
-/// Fail if not under dirfd
-pub const AT_BENEATH = 0x1000;
-
pub const IPPROTO = struct {
/// dummy for IP
pub const IP = 0;
lib/std/c/hermit.zig
@@ -1,3 +1,6 @@
+const std = @import("std");
+const maxInt = std.math.maxInt;
+
pub const pthread_mutex_t = extern struct {
inner: usize = ~@as(usize, 0),
};
@@ -5,5 +8,5 @@ pub const pthread_cond_t = extern struct {
inner: usize = ~@as(usize, 0),
};
pub const pthread_rwlock_t = extern struct {
- ptr: usize = std.math.maxInt(usize),
+ ptr: usize = maxInt(usize),
};
lib/std/c/linux.zig
@@ -6,6 +6,7 @@ const native_arch = builtin.cpu.arch;
const linux = std.os.linux;
const iovec = std.os.iovec;
const iovec_const = std.os.iovec_const;
+const FILE = std.c.FILE;
pub const AF = linux.AF;
pub const ARCH = linux.ARCH;
lib/std/c/netbsd.zig
@@ -1,6 +1,10 @@
const std = @import("../std.zig");
const builtin = @import("builtin");
const maxInt = std.math.maxInt;
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
+const timezone = std.c.timezone;
+const rusage = std.c.rusage;
extern "c" fn __errno() *c_int;
pub const _errno = __errno;
@@ -12,56 +16,81 @@ pub extern "c" fn _lwp_self() lwpid_t;
pub extern "c" fn pipe2(fds: *[2]fd_t, flags: u32) c_int;
pub extern "c" fn arc4random_buf(buf: [*]u8, len: usize) void;
+
pub extern "c" fn __fstat50(fd: fd_t, buf: *Stat) c_int;
+pub const fstat = __fstat50;
+
pub extern "c" fn __stat50(path: [*:0]const u8, buf: *Stat) c_int;
+pub const stat = __stat50;
+
pub extern "c" fn __clock_gettime50(clk_id: c_int, tp: *timespec) c_int;
+pub const clock_gettime = __clock_gettime50;
+
pub extern "c" fn __clock_getres50(clk_id: c_int, tp: *timespec) c_int;
+pub const clock_getres = __clock_getres50;
+
pub extern "c" fn __getdents30(fd: c_int, buf_ptr: [*]u8, nbytes: usize) c_int;
+pub const getdents = __getdents30;
+
pub extern "c" fn __sigaltstack14(ss: ?*stack_t, old_ss: ?*stack_t) c_int;
+pub const sigaltstack = __sigaltstack14;
+
pub extern "c" fn __nanosleep50(rqtp: *const timespec, rmtp: ?*timespec) c_int;
+pub const nanosleep = __nanosleep50;
+
pub extern "c" fn __sigaction14(sig: c_int, noalias act: ?*const Sigaction, noalias oact: ?*Sigaction) c_int;
+pub const sigaction = __sigaction14;
+
pub extern "c" fn __sigprocmask14(how: c_int, noalias set: ?*const sigset_t, noalias oset: ?*sigset_t) c_int;
+pub const sigprocmask = __sigaction14;
+
pub extern "c" fn __socket30(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
+pub const socket = __socket30;
+
pub extern "c" fn __gettimeofday50(noalias tv: ?*timeval, noalias tz: ?*timezone) c_int;
+pub const gettimeofday = __gettimeofday50;
+
pub extern "c" fn __getrusage50(who: c_int, usage: *rusage) c_int;
-// libc aliases this as sched_yield
+pub const getrusage = __getrusage50;
+
pub extern "c" fn __libc_thr_yield() c_int;
+pub const sched_yield = __libc_thr_yield;
pub extern "c" fn posix_memalign(memptr: *?*c_void, alignment: usize, size: usize) c_int;
pub const pthread_mutex_t = extern struct {
- ptm_magic: u32 = 0x33330003,
- ptm_errorcheck: padded_pthread_spin_t = 0,
- ptm_ceiling: padded_pthread_spin_t = 0,
- ptm_owner: usize = 0,
- ptm_waiters: ?*u8 = null,
- ptm_recursed: u32 = 0,
- ptm_spare2: ?*c_void = null,
+ magic: u32 = 0x33330003,
+ errorcheck: padded_pthread_spin_t = 0,
+ ceiling: padded_pthread_spin_t = 0,
+ owner: usize = 0,
+ waiters: ?*u8 = null,
+ recursed: u32 = 0,
+ spare2: ?*c_void = null,
};
pub const pthread_cond_t = extern struct {
- ptc_magic: u32 = 0x55550005,
- ptc_lock: pthread_spin_t = 0,
- ptc_waiters_first: ?*u8 = null,
- ptc_waiters_last: ?*u8 = null,
- ptc_mutex: ?*pthread_mutex_t = null,
- ptc_private: ?*c_void = null,
+ magic: u32 = 0x55550005,
+ lock: pthread_spin_t = 0,
+ waiters_first: ?*u8 = null,
+ waiters_last: ?*u8 = null,
+ mutex: ?*pthread_mutex_t = null,
+ private: ?*c_void = null,
};
pub const pthread_rwlock_t = extern struct {
- ptr_magic: c_uint = 0x99990009,
- ptr_interlock: switch (builtin.cpu.arch) {
+ magic: c_uint = 0x99990009,
+ interlock: switch (builtin.cpu.arch) {
.aarch64, .sparc, .x86_64, .i386 => u8,
.arm, .powerpc => c_int,
else => unreachable,
} = 0,
- ptr_rblocked_first: ?*u8 = null,
- ptr_rblocked_last: ?*u8 = null,
- ptr_wblocked_first: ?*u8 = null,
- ptr_wblocked_last: ?*u8 = null,
- ptr_nreaders: c_uint = 0,
- ptr_owner: std.c.pthread_t = null,
- ptr_private: ?*c_void = null,
+ rblocked_first: ?*u8 = null,
+ rblocked_last: ?*u8 = null,
+ wblocked_first: ?*u8 = null,
+ wblocked_last: ?*u8 = null,
+ nreaders: c_uint = 0,
+ owner: std.c.pthread_t = null,
+ private: ?*c_void = null,
};
const pthread_spin_t = switch (builtin.cpu.arch) {
@@ -92,20 +121,6 @@ pub const sem_t = ?*opaque {};
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*c_void) E;
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
-pub const clock_getres = __clock_getres50;
-pub const clock_gettime = __clock_gettime50;
-pub const fstat = __fstat50;
-pub const getdents = __getdents30;
-pub const getrusage = __getrusage50;
-pub const gettimeofday = __gettimeofday50;
-pub const nanosleep = __nanosleep50;
-pub const sched_yield = __libc_thr_yield;
-pub const sigaction = __sigaction14;
-pub const sigaltstack = __sigaltstack14;
-pub const sigprocmask = __sigprocmask14;
-pub const socket = __socket30;
-pub const stat = __stat50;
-
pub const blkcnt_t = i64;
pub const blksize_t = i32;
pub const clock_t = u32;
@@ -568,43 +583,6 @@ 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;
-
-pub const SIGRTMIN = 33;
-pub const SIGRTMAX = 63;
-
// access function
pub const F_OK = 0; // test for existence of file
pub const X_OK = 1; // test for execute or search permission
@@ -677,22 +655,24 @@ pub const O_CLOEXEC = 0x00400000;
/// skip search permission checks
pub const O_SEARCH = 0x00800000;
-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 = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
+ pub const GETOWN = 5;
+ pub const SETOWN = 6;
-pub const F_GETLK = 7;
-pub const F_SETLK = 8;
-pub const F_SETLKW = 9;
+ pub const GETLK = 7;
+ pub const SETLK = 8;
+ pub const SETLKW = 9;
-pub const F_RDLCK = 1;
-pub const F_WRLCK = 3;
-pub const F_UNLCK = 2;
+ pub const RDLCK = 1;
+ pub const WRLCK = 3;
+ pub const UNLCK = 2;
+};
pub const LOCK = struct {
pub const SH = 1;
@@ -918,9 +898,64 @@ pub const winsize = extern struct {
const NSIG = 32;
-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 = struct {
+ pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
+ pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
+ pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
+
+ pub const WORDS = 4;
+ pub const MAXSIG = 128;
+
+ pub const HUP = 1;
+ pub const INT = 2;
+ pub const QUIT = 3;
+ pub const ILL = 4;
+ pub const TRAP = 5;
+ pub const ABRT = 6;
+ pub const IOT = ABRT;
+ pub const EMT = 7;
+ pub const FPE = 8;
+ pub const KILL = 9;
+ pub const BUS = 10;
+ pub const SEGV = 11;
+ pub const SYS = 12;
+ pub const PIPE = 13;
+ pub const ALRM = 14;
+ pub const TERM = 15;
+ pub const URG = 16;
+ pub const STOP = 17;
+ pub const TSTP = 18;
+ pub const CONT = 19;
+ pub const CHLD = 20;
+ pub const TTIN = 21;
+ pub const TTOU = 22;
+ pub const IO = 23;
+ pub const XCPU = 24;
+ pub const XFSZ = 25;
+ pub const VTALRM = 26;
+ pub const PROF = 27;
+ pub const WINCH = 28;
+ pub const INFO = 29;
+ pub const USR1 = 30;
+ pub const USR2 = 31;
+ pub const PWR = 32;
+
+ pub const RTMIN = 33;
+ pub const RTMAX = 63;
+
+ pub inline fn IDX(sig: usize) usize {
+ return sig - 1;
+ }
+ pub inline fn WORD(sig: usize) usize {
+ return IDX(sig) >> 5;
+ }
+ pub inline fn BIT(sig: usize) usize {
+ return 1 << (IDX(sig) & 31);
+ }
+ pub inline fn VALID(sig: usize) usize {
+ return sig <= MAXSIG and sig > 0;
+ }
+};
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
pub const Sigaction = extern struct {
@@ -993,27 +1028,11 @@ pub const _ksiginfo = extern struct {
} align(@sizeOf(usize)),
};
-pub const _SIG_WORDS = 4;
-pub const _SIG_MAXSIG = 128;
-
-pub inline fn _SIG_IDX(sig: usize) usize {
- return sig - 1;
-}
-pub inline fn _SIG_WORD(sig: usize) usize {
- return_SIG_IDX(sig) >> 5;
-}
-pub inline fn _SIG_BIT(sig: usize) usize {
- return 1 << (_SIG_IDX(sig) & 31);
-}
-pub inline fn _SIG_VALID(sig: usize) usize {
- return sig <= _SIG_MAXSIG and sig > 0;
-}
-
pub const sigset_t = extern struct {
- __bits: [_SIG_WORDS]u32,
+ __bits: [SIG.WORDS]u32,
};
-pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** _SIG_WORDS };
+pub const empty_sigset = sigset_t{ .__bits = [_]u32{0} ** SIG.WORDS };
// XXX x86_64 specific
pub const mcontext_t = extern struct {
@@ -1253,22 +1272,20 @@ pub fn S_IWHT(m: u32) bool {
return m & S_IFMT == S_IFWHT;
}
-/// 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 = 0x0100;
-
-/// Do not follow symbolic links
-pub const AT_SYMLINK_NOFOLLOW = 0x0200;
-
-/// Follow symbolic link
-pub const AT_SYMLINK_FOLLOW = 0x0400;
-
-/// Remove directory instead of file
-pub const AT_REMOVEDIR = 0x0800;
+pub const AT = struct {
+ /// 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 FDCWD = -100;
+ /// Check access using effective user and group ID
+ pub const EACCESS = 0x0100;
+ /// Do not follow symbolic links
+ pub const SYMLINK_NOFOLLOW = 0x0200;
+ /// Follow symbolic link
+ pub const SYMLINK_FOLLOW = 0x0400;
+ /// Remove directory instead of file
+ pub const REMOVEDIR = 0x0800;
+};
pub const HOST_NAME_MAX = 255;
lib/std/c/openbsd.zig
@@ -1,6 +1,8 @@
const std = @import("../std.zig");
const maxInt = std.math.maxInt;
const builtin = @import("builtin");
+const iovec = std.os.iovec;
+const iovec_const = std.os.iovec_const;
extern "c" fn __errno() *c_int;
pub const _errno = __errno;
@@ -466,22 +468,24 @@ 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 = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
-pub const F_GETOWN = 5;
-pub const F_SETOWN = 6;
+ pub const GETOWN = 5;
+ pub const SETOWN = 6;
-pub const F_GETLK = 7;
-pub const F_SETLK = 8;
-pub const F_SETLKW = 9;
+ pub const GETLK = 7;
+ pub const SETLK = 8;
+ pub const SETLKW = 9;
-pub const F_RDLCK = 1;
-pub const F_UNLCK = 2;
-pub const F_WRLCK = 3;
+ pub const RDLCK = 1;
+ pub const UNLCK = 2;
+ pub const WRLCK = 3;
+};
pub const LOCK = struct {
pub const SH = 0x01;
@@ -840,7 +844,7 @@ const arch_bits = switch (builtin.cpu.arch) {
sc_rsp: c_long,
sc_ss: c_long,
- sc_fpstate: fxsave64,
+ sc_fpstate: arch_bits.fxsave64,
__sc_unused: c_int,
sc_mask: c_int,
sc_cookie: c_long,
@@ -1063,22 +1067,20 @@ 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 AT = struct {
+ /// 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 FDCWD = -100;
+ /// Check access using effective user and group ID
+ pub const EACCESS = 0x01;
+ /// Do not follow symbolic links
+ pub const SYMLINK_NOFOLLOW = 0x02;
+ /// Follow symbolic link
+ pub const SYMLINK_FOLLOW = 0x04;
+ /// Remove directory instead of file
+ pub const REMOVEDIR = 0x08;
+};
pub const HOST_NAME_MAX = 255;
lib/std/c/wasi.zig
@@ -1,3 +1,7 @@
+const std = @import("../std.zig");
+const wasi = std.os.wasi;
+const FDFLAG = wasi.FDFLAG;
+
extern threadlocal var errno: c_int;
pub fn _errno() *c_int {
@@ -9,6 +13,10 @@ pub const pid_t = c_int;
pub const uid_t = u32;
pub const gid_t = u32;
pub const off_t = i64;
+pub const ino_t = wasi.ino_t;
+pub const mode_t = wasi.mode_t;
+pub const time_t = wasi.time_t;
+pub const timespec = wasi.timespec;
pub const Stat = extern struct {
dev: i32,
@@ -57,22 +65,28 @@ pub const Stat = extern struct {
/// https://github.com/WebAssembly/wasi-libc/blob/main/expected/wasm32-wasi/predefined-macros.txt
pub const O = struct {
pub const ACCMODE = (EXEC | RDWR | SEARCH);
- pub const APPEND = FDFLAG_APPEND;
+ pub const APPEND = FDFLAG.APPEND;
pub const CLOEXEC = (0);
pub const CREAT = ((1 << 0) << 12); // = __WASI_OFLAGS_CREAT << 12
pub const DIRECTORY = ((1 << 1) << 12); // = __WASI_OFLAGS_DIRECTORY << 12
- pub const DSYNC = FDFLAG_DSYNC;
+ pub const DSYNC = FDFLAG.DSYNC;
pub const EXCL = ((1 << 2) << 12); // = __WASI_OFLAGS_EXCL << 12
pub const EXEC = (0x02000000);
pub const NOCTTY = (0);
pub const NOFOLLOW = (0x01000000);
- pub const NONBLOCK = (1 << FDFLAG_NONBLOCK);
+ pub const NONBLOCK = (1 << FDFLAG.NONBLOCK);
pub const RDONLY = (0x04000000);
pub const RDWR = (RDONLY | WRONLY);
- pub const RSYNC = (1 << FDFLAG_RSYNC);
+ pub const RSYNC = (1 << FDFLAG.RSYNC);
pub const SEARCH = (0x08000000);
- pub const SYNC = (1 << FDFLAG_SYNC);
+ pub const SYNC = (1 << FDFLAG.SYNC);
pub const TRUNC = ((1 << 3) << 12); // = __WASI_OFLAGS_TRUNC << 12
pub const TTY_INIT = (0);
pub const WRONLY = (0x10000000);
};
+
+pub const SEEK = struct {
+ pub const SET: wasi.whence_t = .SET;
+ pub const CUR: wasi.whence_t = .CUR;
+ pub const END: wasi.whence_t = .END;
+};
lib/std/c/windows.zig
@@ -1,7 +1,6 @@
//! The reference for these types and values is Microsoft Windows's ucrt (Universal C RunTime).
const std = @import("../std.zig");
const ws2_32 = std.os.windows.ws2_32;
-
const windows = std.os.windows;
pub extern "c" fn _errno() *c_int;
@@ -43,56 +42,51 @@ pub const timeval = extern struct {
tv_usec: c_long,
};
+pub const Stat = @compileError("TODO windows Stat definition");
+
pub const sig_atomic_t = c_int;
+pub const sigset_t = @compileError("TODO windows sigset_t definition");
+pub const Sigaction = @compileError("TODO windows Sigaction definition");
+pub const timezone = @compileError("TODO windows timezone definition");
+pub const rusage = @compileError("TODO windows rusage definition");
+
/// maximum signal number + 1
pub const NSIG = 23;
-// Signal types
-
-/// interrupt
-pub const SIGINT = 2;
-
-/// illegal instruction - invalid function image
-pub const SIGILL = 4;
-
-/// floating point exception
-pub const SIGFPE = 8;
-
-/// segment violation
-pub const SIGSEGV = 11;
-
-/// Software termination signal from kill
-pub const SIGTERM = 15;
-
-/// Ctrl-Break sequence
-pub const SIGBREAK = 21;
-
-/// abnormal termination triggered by abort call
-pub const SIGABRT = 22;
-
-/// SIGABRT compatible with other platforms, same as SIGABRT
-pub const SIGABRT_COMPAT = 6;
-
-// Signal action codes
-
-/// default signal action
-pub const SIG_DFL = 0;
-
-/// ignore signal
-pub const SIG_IGN = 1;
-
-/// return current value
-pub const SIG_GET = 2;
-
-/// signal gets error
-pub const SIG_SGE = 3;
-
-/// acknowledge
-pub const SIG_ACK = 4;
-
-/// Signal error value (returned by signal call on error)
-pub const SIG_ERR = -1;
+/// Signal types
+pub const SIG = struct {
+ /// interrupt
+ pub const INT = 2;
+ /// illegal instruction - invalid function image
+ pub const ILL = 4;
+ /// floating point exception
+ pub const FPE = 8;
+ /// segment violation
+ pub const SEGV = 11;
+ /// Software termination signal from kill
+ pub const TERM = 15;
+ /// Ctrl-Break sequence
+ pub const BREAK = 21;
+ /// abnormal termination triggered by abort call
+ pub const ABRT = 22;
+ /// SIGABRT compatible with other platforms, same as SIGABRT
+ pub const ABRT_COMPAT = 6;
+
+ // Signal action codes
+ /// default signal action
+ pub const DFL = 0;
+ /// ignore signal
+ pub const IGN = 1;
+ /// return current value
+ pub const GET = 2;
+ /// signal gets error
+ pub const SGE = 3;
+ /// acknowledge
+ pub const ACK = 4;
+ /// Signal error value (returned by signal call on error)
+ pub const ERR = -1;
+};
pub const SEEK_SET = 0;
pub const SEEK_CUR = 1;
lib/std/crypto/25519/curve25519.zig
@@ -40,9 +40,7 @@ pub const Curve25519 = struct {
}
/// Multiply a point by the cofactor
- pub fn clearCofactor(p: Edwards25519) Edwards25519 {
- return p.dbl().dbl().dbl();
- }
+ pub const clearCofactor = @compileError("TODO what was this function supposed to do? it didn't compile successfully");
fn ladder(p: Curve25519, s: [32]u8, comptime bits: usize) IdentityElementError!Curve25519 {
var x1 = p.x;
lib/std/dwarf/AT.zig
@@ -0,0 +1,198 @@
+pub const sibling = 0x01;
+pub const location = 0x02;
+pub const name = 0x03;
+pub const ordering = 0x09;
+pub const subscr_data = 0x0a;
+pub const byte_size = 0x0b;
+pub const bit_offset = 0x0c;
+pub const bit_size = 0x0d;
+pub const element_list = 0x0f;
+pub const stmt_list = 0x10;
+pub const low_pc = 0x11;
+pub const high_pc = 0x12;
+pub const language = 0x13;
+pub const member = 0x14;
+pub const discr = 0x15;
+pub const discr_value = 0x16;
+pub const visibility = 0x17;
+pub const import = 0x18;
+pub const string_length = 0x19;
+pub const common_reference = 0x1a;
+pub const comp_dir = 0x1b;
+pub const const_value = 0x1c;
+pub const containing_type = 0x1d;
+pub const default_value = 0x1e;
+pub const @"inline" = 0x20;
+pub const is_optional = 0x21;
+pub const lower_bound = 0x22;
+pub const producer = 0x25;
+pub const prototyped = 0x27;
+pub const return_addr = 0x2a;
+pub const start_scope = 0x2c;
+pub const bit_stride = 0x2e;
+pub const upper_bound = 0x2f;
+pub const abstract_origin = 0x31;
+pub const accessibility = 0x32;
+pub const address_class = 0x33;
+pub const artificial = 0x34;
+pub const base_types = 0x35;
+pub const calling_convention = 0x36;
+pub const count = 0x37;
+pub const data_member_location = 0x38;
+pub const decl_column = 0x39;
+pub const decl_file = 0x3a;
+pub const decl_line = 0x3b;
+pub const declaration = 0x3c;
+pub const discr_list = 0x3d;
+pub const encoding = 0x3e;
+pub const external = 0x3f;
+pub const frame_base = 0x40;
+pub const friend = 0x41;
+pub const identifier_case = 0x42;
+pub const macro_info = 0x43;
+pub const namelist_items = 0x44;
+pub const priority = 0x45;
+pub const segment = 0x46;
+pub const specification = 0x47;
+pub const static_link = 0x48;
+pub const @"type" = 0x49;
+pub const use_location = 0x4a;
+pub const variable_parameter = 0x4b;
+pub const virtuality = 0x4c;
+pub const vtable_elem_location = 0x4d;
+
+// DWARF 3 values.
+pub const allocated = 0x4e;
+pub const associated = 0x4f;
+pub const data_location = 0x50;
+pub const byte_stride = 0x51;
+pub const entry_pc = 0x52;
+pub const use_UTF8 = 0x53;
+pub const extension = 0x54;
+pub const ranges = 0x55;
+pub const trampoline = 0x56;
+pub const call_column = 0x57;
+pub const call_file = 0x58;
+pub const call_line = 0x59;
+pub const description = 0x5a;
+pub const binary_scale = 0x5b;
+pub const decimal_scale = 0x5c;
+pub const small = 0x5d;
+pub const decimal_sign = 0x5e;
+pub const digit_count = 0x5f;
+pub const picture_string = 0x60;
+pub const mutable = 0x61;
+pub const threads_scaled = 0x62;
+pub const explicit = 0x63;
+pub const object_pointer = 0x64;
+pub const endianity = 0x65;
+pub const elemental = 0x66;
+pub const pure = 0x67;
+pub const recursive = 0x68;
+
+// DWARF 4.
+pub const signature = 0x69;
+pub const main_subprogram = 0x6a;
+pub const data_bit_offset = 0x6b;
+pub const const_expr = 0x6c;
+pub const enum_class = 0x6d;
+pub const linkage_name = 0x6e;
+
+// DWARF 5
+pub const alignment = 0x88;
+
+pub const lo_user = 0x2000; // Implementation-defined range start.
+pub const hi_user = 0x3fff; // Implementation-defined range end.
+
+// SGI/MIPS extensions.
+pub const MIPS_fde = 0x2001;
+pub const MIPS_loop_begin = 0x2002;
+pub const MIPS_tail_loop_begin = 0x2003;
+pub const MIPS_epilog_begin = 0x2004;
+pub const MIPS_loop_unroll_factor = 0x2005;
+pub const MIPS_software_pipeline_depth = 0x2006;
+pub const MIPS_linkage_name = 0x2007;
+pub const MIPS_stride = 0x2008;
+pub const MIPS_abstract_name = 0x2009;
+pub const MIPS_clone_origin = 0x200a;
+pub const MIPS_has_inlines = 0x200b;
+
+// HP extensions.
+pub const HP_block_index = 0x2000;
+pub const HP_unmodifiable = 0x2001; // Same as AT.MIPS_fde.
+pub const HP_prologue = 0x2005; // Same as AT.MIPS_loop_unroll.
+pub const HP_epilogue = 0x2008; // Same as AT.MIPS_stride.
+pub const HP_actuals_stmt_list = 0x2010;
+pub const HP_proc_per_section = 0x2011;
+pub const HP_raw_data_ptr = 0x2012;
+pub const HP_pass_by_reference = 0x2013;
+pub const HP_opt_level = 0x2014;
+pub const HP_prof_version_id = 0x2015;
+pub const HP_opt_flags = 0x2016;
+pub const HP_cold_region_low_pc = 0x2017;
+pub const HP_cold_region_high_pc = 0x2018;
+pub const HP_all_variables_modifiable = 0x2019;
+pub const HP_linkage_name = 0x201a;
+pub const HP_prof_flags = 0x201b; // In comp unit of procs_info for -g.
+pub const HP_unit_name = 0x201f;
+pub const HP_unit_size = 0x2020;
+pub const HP_widened_byte_size = 0x2021;
+pub const HP_definition_points = 0x2022;
+pub const HP_default_location = 0x2023;
+pub const HP_is_result_param = 0x2029;
+
+// GNU extensions.
+pub const sf_names = 0x2101;
+pub const src_info = 0x2102;
+pub const mac_info = 0x2103;
+pub const src_coords = 0x2104;
+pub const body_begin = 0x2105;
+pub const body_end = 0x2106;
+pub const GNU_vector = 0x2107;
+// Thread-safety annotations.
+// See http://gcc.gnu.org/wiki/ThreadSafetyAnnotation .
+pub const GNU_guarded_by = 0x2108;
+pub const GNU_pt_guarded_by = 0x2109;
+pub const GNU_guarded = 0x210a;
+pub const GNU_pt_guarded = 0x210b;
+pub const GNU_locks_excluded = 0x210c;
+pub const GNU_exclusive_locks_required = 0x210d;
+pub const GNU_shared_locks_required = 0x210e;
+// One-definition rule violation detection.
+// See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo .
+pub const GNU_odr_signature = 0x210f;
+// Template template argument name.
+// See http://gcc.gnu.org/wiki/TemplateParmsDwarf .
+pub const GNU_template_name = 0x2110;
+// The GNU call site extension.
+// See http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open .
+pub const GNU_call_site_value = 0x2111;
+pub const GNU_call_site_data_value = 0x2112;
+pub const GNU_call_site_target = 0x2113;
+pub const GNU_call_site_target_clobbered = 0x2114;
+pub const GNU_tail_call = 0x2115;
+pub const GNU_all_tail_call_sites = 0x2116;
+pub const GNU_all_call_sites = 0x2117;
+pub const GNU_all_source_call_sites = 0x2118;
+// Section offset into .debug_macro section.
+pub const GNU_macros = 0x2119;
+// Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
+pub const GNU_dwo_name = 0x2130;
+pub const GNU_dwo_id = 0x2131;
+pub const GNU_ranges_base = 0x2132;
+pub const GNU_addr_base = 0x2133;
+pub const GNU_pubnames = 0x2134;
+pub const GNU_pubtypes = 0x2135;
+// VMS extensions.
+pub const VMS_rtnbeg_pd_address = 0x2201;
+// GNAT extensions.
+// GNAT descriptive type.
+// See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type .
+pub const use_GNAT_descriptive_type = 0x2301;
+pub const GNAT_descriptive_type = 0x2302;
+// UPC extension.
+pub const upc_threads_scaled = 0x3210;
+// PGI (STMicroelectronics) extensions.
+pub const PGI_lbase = 0x3a00;
+pub const PGI_soffset = 0x3a01;
+pub const PGI_lstride = 0x3a02;
lib/std/dwarf/OP.zig
@@ -0,0 +1,195 @@
+pub const addr = 0x03;
+pub const deref = 0x06;
+pub const const1u = 0x08;
+pub const const1s = 0x09;
+pub const const2u = 0x0a;
+pub const const2s = 0x0b;
+pub const const4u = 0x0c;
+pub const const4s = 0x0d;
+pub const const8u = 0x0e;
+pub const const8s = 0x0f;
+pub const constu = 0x10;
+pub const consts = 0x11;
+pub const dup = 0x12;
+pub const drop = 0x13;
+pub const over = 0x14;
+pub const pick = 0x15;
+pub const swap = 0x16;
+pub const rot = 0x17;
+pub const xderef = 0x18;
+pub const abs = 0x19;
+pub const @"and" = 0x1a;
+pub const div = 0x1b;
+pub const minus = 0x1c;
+pub const mod = 0x1d;
+pub const mul = 0x1e;
+pub const neg = 0x1f;
+pub const not = 0x20;
+pub const @"or" = 0x21;
+pub const plus = 0x22;
+pub const plus_uconst = 0x23;
+pub const shl = 0x24;
+pub const shr = 0x25;
+pub const shra = 0x26;
+pub const xor = 0x27;
+pub const bra = 0x28;
+pub const eq = 0x29;
+pub const ge = 0x2a;
+pub const gt = 0x2b;
+pub const le = 0x2c;
+pub const lt = 0x2d;
+pub const ne = 0x2e;
+pub const skip = 0x2f;
+pub const lit0 = 0x30;
+pub const lit1 = 0x31;
+pub const lit2 = 0x32;
+pub const lit3 = 0x33;
+pub const lit4 = 0x34;
+pub const lit5 = 0x35;
+pub const lit6 = 0x36;
+pub const lit7 = 0x37;
+pub const lit8 = 0x38;
+pub const lit9 = 0x39;
+pub const lit10 = 0x3a;
+pub const lit11 = 0x3b;
+pub const lit12 = 0x3c;
+pub const lit13 = 0x3d;
+pub const lit14 = 0x3e;
+pub const lit15 = 0x3f;
+pub const lit16 = 0x40;
+pub const lit17 = 0x41;
+pub const lit18 = 0x42;
+pub const lit19 = 0x43;
+pub const lit20 = 0x44;
+pub const lit21 = 0x45;
+pub const lit22 = 0x46;
+pub const lit23 = 0x47;
+pub const lit24 = 0x48;
+pub const lit25 = 0x49;
+pub const lit26 = 0x4a;
+pub const lit27 = 0x4b;
+pub const lit28 = 0x4c;
+pub const lit29 = 0x4d;
+pub const lit30 = 0x4e;
+pub const lit31 = 0x4f;
+pub const reg0 = 0x50;
+pub const reg1 = 0x51;
+pub const reg2 = 0x52;
+pub const reg3 = 0x53;
+pub const reg4 = 0x54;
+pub const reg5 = 0x55;
+pub const reg6 = 0x56;
+pub const reg7 = 0x57;
+pub const reg8 = 0x58;
+pub const reg9 = 0x59;
+pub const reg10 = 0x5a;
+pub const reg11 = 0x5b;
+pub const reg12 = 0x5c;
+pub const reg13 = 0x5d;
+pub const reg14 = 0x5e;
+pub const reg15 = 0x5f;
+pub const reg16 = 0x60;
+pub const reg17 = 0x61;
+pub const reg18 = 0x62;
+pub const reg19 = 0x63;
+pub const reg20 = 0x64;
+pub const reg21 = 0x65;
+pub const reg22 = 0x66;
+pub const reg23 = 0x67;
+pub const reg24 = 0x68;
+pub const reg25 = 0x69;
+pub const reg26 = 0x6a;
+pub const reg27 = 0x6b;
+pub const reg28 = 0x6c;
+pub const reg29 = 0x6d;
+pub const reg30 = 0x6e;
+pub const reg31 = 0x6f;
+pub const breg0 = 0x70;
+pub const breg1 = 0x71;
+pub const breg2 = 0x72;
+pub const breg3 = 0x73;
+pub const breg4 = 0x74;
+pub const breg5 = 0x75;
+pub const breg6 = 0x76;
+pub const breg7 = 0x77;
+pub const breg8 = 0x78;
+pub const breg9 = 0x79;
+pub const breg10 = 0x7a;
+pub const breg11 = 0x7b;
+pub const breg12 = 0x7c;
+pub const breg13 = 0x7d;
+pub const breg14 = 0x7e;
+pub const breg15 = 0x7f;
+pub const breg16 = 0x80;
+pub const breg17 = 0x81;
+pub const breg18 = 0x82;
+pub const breg19 = 0x83;
+pub const breg20 = 0x84;
+pub const breg21 = 0x85;
+pub const breg22 = 0x86;
+pub const breg23 = 0x87;
+pub const breg24 = 0x88;
+pub const breg25 = 0x89;
+pub const breg26 = 0x8a;
+pub const breg27 = 0x8b;
+pub const breg28 = 0x8c;
+pub const breg29 = 0x8d;
+pub const breg30 = 0x8e;
+pub const breg31 = 0x8f;
+pub const regx = 0x90;
+pub const fbreg = 0x91;
+pub const bregx = 0x92;
+pub const piece = 0x93;
+pub const deref_size = 0x94;
+pub const xderef_size = 0x95;
+pub const nop = 0x96;
+
+// DWARF 3 extensions.
+pub const push_object_address = 0x97;
+pub const call2 = 0x98;
+pub const call4 = 0x99;
+pub const call_ref = 0x9a;
+pub const form_tls_address = 0x9b;
+pub const call_frame_cfa = 0x9c;
+pub const bit_piece = 0x9d;
+
+// DWARF 4 extensions.
+pub const implicit_value = 0x9e;
+pub const stack_value = 0x9f;
+
+pub const lo_user = 0xe0; // Implementation-defined range start.
+pub const hi_user = 0xff; // Implementation-defined range end.
+
+// GNU extensions.
+pub const GNU_push_tls_address = 0xe0;
+// The following is for marking variables that are uninitialized.
+pub const GNU_uninit = 0xf0;
+pub const GNU_encoded_addr = 0xf1;
+// The GNU implicit pointer extension.
+// See http://www.dwarfstd.org/ShowIssue.php?issue=100831.1&type=open .
+pub const GNU_implicit_pointer = 0xf2;
+// The GNU entry value extension.
+// See http://www.dwarfstd.org/ShowIssue.php?issue=100909.1&type=open .
+pub const GNU_entry_value = 0xf3;
+// The GNU typed stack extension.
+// See http://www.dwarfstd.org/doc/040408.1.html .
+pub const GNU_const_type = 0xf4;
+pub const GNU_regval_type = 0xf5;
+pub const GNU_deref_type = 0xf6;
+pub const GNU_convert = 0xf7;
+pub const GNU_reinterpret = 0xf9;
+// The GNU parameter ref extension.
+pub const GNU_parameter_ref = 0xfa;
+// Extension for Fission. See http://gcc.gnu.org/wiki/DebugFission.
+pub const GNU_addr_index = 0xfb;
+pub const GNU_const_index = 0xfc;
+// HP extensions.
+pub const HP_unknown = 0xe0; // Ouch, the same as GNU_push_tls_address.
+pub const HP_is_value = 0xe1;
+pub const HP_fltconst4 = 0xe2;
+pub const HP_fltconst8 = 0xe3;
+pub const HP_mod_range = 0xe4;
+pub const HP_unmod_range = 0xe5;
+pub const HP_tls = 0xe6;
+// PGI (STMicroelectronics) extensions.
+pub const PGI_omp_thread_num = 0xf8;
lib/std/dwarf/TAG.zig
@@ -0,0 +1,108 @@
+pub const padding = 0x00;
+pub const array_type = 0x01;
+pub const class_type = 0x02;
+pub const entry_point = 0x03;
+pub const enumeration_type = 0x04;
+pub const formal_parameter = 0x05;
+pub const imported_declaration = 0x08;
+pub const label = 0x0a;
+pub const lexical_block = 0x0b;
+pub const member = 0x0d;
+pub const pointer_type = 0x0f;
+pub const reference_type = 0x10;
+pub const compile_unit = 0x11;
+pub const string_type = 0x12;
+pub const structure_type = 0x13;
+pub const subroutine = 0x14;
+pub const subroutine_type = 0x15;
+pub const typedef = 0x16;
+pub const union_type = 0x17;
+pub const unspecified_parameters = 0x18;
+pub const variant = 0x19;
+pub const common_block = 0x1a;
+pub const common_inclusion = 0x1b;
+pub const inheritance = 0x1c;
+pub const inlined_subroutine = 0x1d;
+pub const module = 0x1e;
+pub const ptr_to_member_type = 0x1f;
+pub const set_type = 0x20;
+pub const subrange_type = 0x21;
+pub const with_stmt = 0x22;
+pub const access_declaration = 0x23;
+pub const base_type = 0x24;
+pub const catch_block = 0x25;
+pub const const_type = 0x26;
+pub const constant = 0x27;
+pub const enumerator = 0x28;
+pub const file_type = 0x29;
+pub const friend = 0x2a;
+pub const namelist = 0x2b;
+pub const namelist_item = 0x2c;
+pub const packed_type = 0x2d;
+pub const subprogram = 0x2e;
+pub const template_type_param = 0x2f;
+pub const template_value_param = 0x30;
+pub const thrown_type = 0x31;
+pub const try_block = 0x32;
+pub const variant_part = 0x33;
+pub const variable = 0x34;
+pub const volatile_type = 0x35;
+
+// DWARF 3
+pub const dwarf_procedure = 0x36;
+pub const restrict_type = 0x37;
+pub const interface_type = 0x38;
+pub const namespace = 0x39;
+pub const imported_module = 0x3a;
+pub const unspecified_type = 0x3b;
+pub const partial_unit = 0x3c;
+pub const imported_unit = 0x3d;
+pub const condition = 0x3f;
+pub const shared_type = 0x40;
+
+// DWARF 4
+pub const type_unit = 0x41;
+pub const rvalue_reference_type = 0x42;
+pub const template_alias = 0x43;
+
+pub const lo_user = 0x4080;
+pub const hi_user = 0xffff;
+
+// SGI/MIPS Extensions.
+pub const MIPS_loop = 0x4081;
+
+// HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz .
+pub const HP_array_descriptor = 0x4090;
+pub const HP_Bliss_field = 0x4091;
+pub const HP_Bliss_field_set = 0x4092;
+
+// GNU extensions.
+pub const format_label = 0x4101; // For FORTRAN 77 and Fortran 90.
+pub const function_template = 0x4102; // For C++.
+pub const class_template = 0x4103; //For C++.
+pub const GNU_BINCL = 0x4104;
+pub const GNU_EINCL = 0x4105;
+
+// Template template parameter.
+// See http://gcc.gnu.org/wiki/TemplateParmsDwarf .
+pub const GNU_template_template_param = 0x4106;
+
+// Template parameter pack extension = specified at
+// http://wiki.dwarfstd.org/index.php?title=C%2B%2B0x:_Variadic_templates
+// The values of these two TAGS are in the DW_TAG_GNU_* space until the tags
+// are properly part of DWARF 5.
+pub const GNU_template_parameter_pack = 0x4107;
+pub const GNU_formal_parameter_pack = 0x4108;
+// The GNU call site extension = specified at
+// http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open .
+// The values of these two TAGS are in the DW_TAG_GNU_* space until the tags
+// are properly part of DWARF 5.
+pub const GNU_call_site = 0x4109;
+pub const GNU_call_site_parameter = 0x410a;
+// Extensions for UPC. See: http://dwarfstd.org/doc/DWARF4.pdf.
+pub const upc_shared_type = 0x8765;
+pub const upc_strict_type = 0x8766;
+pub const upc_relaxed_type = 0x8767;
+// PGI (STMicroelectronics; extensions. No documentation available.
+pub const PGI_kanji_type = 0xA000;
+pub const PGI_interface_block = 0xA020;
lib/std/event/rwlock.zig
@@ -4,6 +4,7 @@ const assert = std.debug.assert;
const testing = std.testing;
const mem = std.mem;
const Loop = std.event.Loop;
+const Allocator = std.mem.Allocator;
/// Thread-safe async/await lock.
/// Functions which are waiting for the lock are suspended, and
lib/std/fs/wasi.zig
@@ -4,6 +4,8 @@ const mem = std.mem;
const math = std.math;
const Allocator = mem.Allocator;
const wasi = std.os.wasi;
+const fd_t = wasi.fd_t;
+const prestat_t = wasi.prestat_t;
/// Type-tag of WASI preopen.
///
@@ -114,7 +116,7 @@ pub const PreopenList = struct {
while (true) {
var buf: prestat_t = undefined;
- switch (fd_prestat_get(fd, &buf)) {
+ switch (wasi.fd_prestat_get(fd, &buf)) {
.SUCCESS => {},
.OPNOTSUPP => {
// not a preopen, so keep going
@@ -130,7 +132,7 @@ pub const PreopenList = struct {
const preopen_len = buf.u.dir.pr_name_len;
const path_buf = try self.buffer.allocator.alloc(u8, preopen_len);
mem.set(u8, path_buf, 0);
- switch (fd_prestat_dir_name(fd, path_buf.ptr, preopen_len)) {
+ switch (wasi.fd_prestat_dir_name(fd, path_buf.ptr, preopen_len)) {
.SUCCESS => {},
else => |err| return os.unexpectedErrno(err),
}
lib/std/io/c_writer.zig
@@ -2,6 +2,7 @@ const std = @import("../std.zig");
const builtin = std.builtin;
const io = std.io;
const testing = std.testing;
+const os = std.os;
pub const CWriter = io.Writer(*std.c.FILE, std.fs.File.WriteError, cWriterWrite);
lib/std/math/big/int.zig
@@ -672,10 +672,9 @@ pub const Mutable = struct {
///
/// `limbs_buffer` is used for temporary storage during the operation.
pub fn gcdNoAlias(rma: *Mutable, x: Const, y: Const, limbs_buffer: *std.ArrayList(Limb)) !void {
- _ = limbs_buffer;
assert(rma.limbs.ptr != x.limbs.ptr); // illegal aliasing
assert(rma.limbs.ptr != y.limbs.ptr); // illegal aliasing
- return gcdLehmer(rma, x, y, allocator);
+ return gcdLehmer(rma, x, y, limbs_buffer);
}
fn gcdLehmer(result: *Mutable, xa: Const, ya: Const, limbs_buffer: *std.ArrayList(Limb)) !void {
lib/std/os/linux/arm-eabi.zig
@@ -551,29 +551,31 @@ pub const O_PATH = 0o10000000;
pub const O_TMPFILE = 0o20040000;
pub const O_NDELAY = O_NONBLOCK;
-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_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 12;
-pub const F_SETLK = 13;
-pub const F_SETLKW = 14;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 12;
+ pub const SETLK = 13;
+ pub const SETLKW = 14;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
pub const LOCK = struct {
pub const SH = 1;
lib/std/os/linux/arm64.zig
@@ -430,24 +430,31 @@ pub const O_PATH = 0o10000000;
pub const O_TMPFILE = 0o20040000;
pub const O_NDELAY = O_NONBLOCK;
-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_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 5;
-pub const F_SETLK = 6;
-pub const F_SETLKW = 7;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 5;
+ pub const SETLK = 6;
+ pub const SETLKW = 7;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
pub const LOCK = struct {
pub const SH = 1;
@@ -456,11 +463,6 @@ pub const LOCK = struct {
pub const NB = 4;
};
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
pub const MAP = struct {
/// stack-like segment
pub const GROWSDOWN = 0x0100;
lib/std/os/linux/io_uring.zig
@@ -1297,12 +1297,12 @@ test "openat" {
const flags: u32 = os.O_CLOEXEC | os.O_RDWR | os.O_CREAT;
const mode: os.mode_t = 0o666;
- const sqe_openat = try ring.openat(0x33333333, linux.AT_FDCWD, path, flags, mode);
+ const sqe_openat = try ring.openat(0x33333333, linux.AT.FDCWD, path, flags, mode);
try testing.expectEqual(io_uring_sqe{
.opcode = .OPENAT,
.flags = 0,
.ioprio = 0,
- .fd = linux.AT_FDCWD,
+ .fd = linux.AT.FDCWD,
.off = 0,
.addr = @ptrToInt(path),
.len = mode,
@@ -1318,7 +1318,7 @@ test "openat" {
const cqe_openat = try ring.copy_cqe();
try testing.expectEqual(@as(u64, 0x33333333), cqe_openat.user_data);
if (cqe_openat.err() == .INVAL) return error.SkipZigTest;
- // AT_FDCWD is not fully supported before kernel 5.6:
+ // AT.FDCWD is not fully supported before kernel 5.6:
// See https://lore.kernel.org/io-uring/20200207155039.12819-1-axboe@kernel.dk/T/
// We use IORING_FEAT_RW_CUR_POS to know if we are pre-5.6 since that feature was added in 5.6.
if (cqe_openat.err() == .BADF and (ring.features & linux.IORING_FEAT_RW_CUR_POS) == 0) {
lib/std/os/linux/mips.zig
@@ -649,24 +649,31 @@ pub const O_PATH = 0o010000000;
pub const O_TMPFILE = 0o020200000;
pub const O_NDELAY = O_NONBLOCK;
-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_SETOWN = 24;
-pub const F_GETOWN = 23;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 33;
-pub const F_SETLK = 34;
-pub const F_SETLKW = 35;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const SETOWN = 24;
+ pub const GETOWN = 23;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 33;
+ pub const SETLK = 34;
+ pub const SETLKW = 35;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
pub const LOCK = struct {
pub const SH = 1;
@@ -675,11 +682,6 @@ pub const LOCK = struct {
pub const NB = 4;
};
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
pub const MMAP2_UNIT = 4096;
pub const MAP = struct {
lib/std/os/linux/powerpc.zig
@@ -581,29 +581,31 @@ pub const O_PATH = 0o10000000;
pub const O_TMPFILE = 0o20040000;
pub const O_NDELAY = O_NONBLOCK;
-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_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 12;
-pub const F_SETLK = 13;
-pub const F_SETLKW = 14;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 12;
+ pub const SETLK = 13;
+ pub const SETLKW = 14;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+};
pub const LOCK = struct {
pub const SH = 1;
lib/std/os/linux/powerpc64.zig
@@ -556,24 +556,31 @@ pub const O_PATH = 0o10000000;
pub const O_TMPFILE = 0o20200000;
pub const O_NDELAY = O_NONBLOCK;
-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_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
-
-pub const F_GETLK = 5;
-pub const F_SETLK = 6;
-pub const F_SETLKW = 7;
-
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
+
+ pub const GETLK = 5;
+ pub const SETLK = 6;
+ pub const SETLKW = 7;
+
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
pub const LOCK = struct {
pub const SH = 1;
@@ -582,11 +589,6 @@ pub const LOCK = struct {
pub const NB = 4;
};
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
pub const MAP = struct {
/// stack-like segment
pub const GROWSDOWN = 0x0100;
lib/std/os/linux/riscv64.zig
@@ -427,22 +427,29 @@ pub const O_PATH = 0o10000000;
pub const O_TMPFILE = 0o20200000;
pub const O_NDELAY = O_NONBLOCK;
-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_GETLK = 5;
-pub const F_SETLK = 6;
-pub const F_SETLKW = 7;
-pub const F_SETOWN = 8;
-pub const F_GETOWN = 9;
-pub const F_SETSIG = 10;
-pub const F_GETSIG = 11;
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+ pub const GETLK = 5;
+ pub const SETLK = 6;
+ pub const SETLKW = 7;
+ pub const SETOWN = 8;
+ pub const GETOWN = 9;
+ pub const SETSIG = 10;
+ pub const GETSIG = 11;
-pub const F_RDLCK = 0;
-pub const F_WRLCK = 1;
-pub const F_UNLCK = 2;
+ pub const RDLCK = 0;
+ pub const WRLCK = 1;
+ pub const UNLCK = 2;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
pub const LOCK = struct {
pub const SH = 1;
@@ -451,11 +458,6 @@ pub const LOCK = struct {
pub const NB = 4;
};
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
-
pub const blksize_t = i32;
pub const nlink_t = u32;
pub const time_t = isize;
lib/std/os/linux/sparc64.zig
@@ -591,26 +591,28 @@ pub const O_PATH = 0x1000000;
pub const O_TMPFILE = 0x2010000;
pub const O_NDELAY = O_NONBLOCK | 0x4;
-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_SETOWN = 5;
-pub const F_GETOWN = 6;
-pub const F_GETLK = 7;
-pub const F_SETLK = 8;
-pub const F_SETLKW = 9;
-
-pub const F_RDLCK = 1;
-pub const F_WRLCK = 2;
-pub const F_UNLCK = 3;
-
-pub const F_SETOWN_EX = 15;
-pub const F_GETOWN_EX = 16;
-
-pub const F_GETOWNER_UIDS = 17;
+pub const F = struct {
+ pub const DUPFD = 0;
+ pub const GETFD = 1;
+ pub const SETFD = 2;
+ pub const GETFL = 3;
+ pub const SETFL = 4;
+
+ pub const SETOWN = 5;
+ pub const GETOWN = 6;
+ pub const GETLK = 7;
+ pub const SETLK = 8;
+ pub const SETLKW = 9;
+
+ pub const RDLCK = 1;
+ pub const WRLCK = 2;
+ pub const UNLCK = 3;
+
+ pub const SETOWN_EX = 15;
+ pub const GETOWN_EX = 16;
+
+ pub const GETOWNER_UIDS = 17;
+};
pub const LOCK = struct {
pub const SH = 1;
lib/std/os/linux/thumb.zig
@@ -3,6 +3,9 @@
//! reserved for the frame pointer.
//! Save and restore r7 around the syscall without touching the stack pointer not
//! to break the frame chain.
+const std = @import("../../std.zig");
+const linux = std.os.linux;
+const SYS = linux.SYS;
pub fn syscall0(number: SYS) usize {
@setRuntimeSafety(false);
lib/std/os/windows/gdi32.zig
@@ -5,6 +5,8 @@ const DWORD = windows.DWORD;
const WINAPI = windows.WINAPI;
const HDC = windows.HDC;
const HGLRC = windows.HGLRC;
+const WORD = windows.WORD;
+const BYTE = windows.BYTE;
pub const PIXELFORMATDESCRIPTOR = extern struct {
nSize: WORD = @sizeOf(PIXELFORMATDESCRIPTOR),
lib/std/os/windows/kernel32.zig
@@ -36,6 +36,26 @@ const HLOCAL = windows.HLOCAL;
const FILETIME = windows.FILETIME;
const STARTUPINFOW = windows.STARTUPINFOW;
const PROCESS_INFORMATION = windows.PROCESS_INFORMATION;
+const OVERLAPPED_ENTRY = windows.OVERLAPPED_ENTRY;
+const LPHEAP_SUMMARY = windows.LPHEAP_SUMMARY;
+const ULONG_PTR = windows.ULONG_PTR;
+const FILE_NOTIFY_INFORMATION = windows.FILE_NOTIFY_INFORMATION;
+const HANDLER_ROUTINE = windows.HANDLER_ROUTINE;
+const ULONG = windows.ULONG;
+const PVOID = windows.PVOID;
+const LPSTR = windows.LPSTR;
+const PENUM_PAGE_FILE_CALLBACKA = windows.PENUM_PAGE_FILE_CALLBACKA;
+const PENUM_PAGE_FILE_CALLBACKW = windows.PENUM_PAGE_FILE_CALLBACKW;
+const INIT_ONCE = windows.INIT_ONCE;
+const CRITICAL_SECTION = windows.CRITICAL_SECTION;
+const WIN32_FIND_DATAW = windows.WIN32_FIND_DATAW;
+const CHAR = windows.CHAR;
+const BY_HANDLE_FILE_INFORMATION = windows.BY_HANDLE_FILE_INFORMATION;
+const SYSTEM_INFO = windows.SYSTEM_INFO;
+const LPOVERLAPPED_COMPLETION_ROUTINE = windows.LPOVERLAPPED_COMPLETION_ROUTINE;
+const UCHAR = windows.UCHAR;
+const FARPROC = windows.FARPROC;
+const INIT_ONCE_FN = windows.INIT_ONCE_FN;
pub extern "kernel32" fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) callconv(WINAPI) ?*c_void;
pub extern "kernel32" fn RemoveVectoredExceptionHandler(Handle: HANDLE) callconv(WINAPI) c_ulong;
lib/std/os/windows/ntdll.zig
@@ -21,6 +21,7 @@ const UNICODE_STRING = windows.UNICODE_STRING;
const RTL_OSVERSIONINFOW = windows.RTL_OSVERSIONINFOW;
const FILE_BASIC_INFORMATION = windows.FILE_BASIC_INFORMATION;
const SIZE_T = windows.SIZE_T;
+const CURDIR = windows.CURDIR;
pub extern "NtDll" fn RtlGetVersion(
lpVersionInformation: *RTL_OSVERSIONINFOW,
lib/std/os/windows/psapi.zig
@@ -2,6 +2,49 @@ const std = @import("../../std.zig");
const windows = std.os.windows;
const WINAPI = windows.WINAPI;
const DWORD = windows.DWORD;
+const HANDLE = windows.HANDLE;
+const PENUM_PAGE_FILE_CALLBACKW = windows.PENUM_PAGE_FILE_CALLBACKW;
+const HMODULE = windows.HMODULE;
+const BOOL = windows.BOOL;
+const BOOLEAN = windows.BOOLEAN;
+const CONDITION_VARIABLE = windows.CONDITION_VARIABLE;
+const CONSOLE_SCREEN_BUFFER_INFO = windows.CONSOLE_SCREEN_BUFFER_INFO;
+const COORD = windows.COORD;
+const FILE_INFO_BY_HANDLE_CLASS = windows.FILE_INFO_BY_HANDLE_CLASS;
+const HRESULT = windows.HRESULT;
+const LARGE_INTEGER = windows.LARGE_INTEGER;
+const LPCWSTR = windows.LPCWSTR;
+const LPTHREAD_START_ROUTINE = windows.LPTHREAD_START_ROUTINE;
+const LPVOID = windows.LPVOID;
+const LPWSTR = windows.LPWSTR;
+const MODULEINFO = windows.MODULEINFO;
+const OVERLAPPED = windows.OVERLAPPED;
+const PERFORMANCE_INFORMATION = windows.PERFORMANCE_INFORMATION;
+const PROCESS_MEMORY_COUNTERS = windows.PROCESS_MEMORY_COUNTERS;
+const PSAPI_WS_WATCH_INFORMATION = windows.PSAPI_WS_WATCH_INFORMATION;
+const PSAPI_WS_WATCH_INFORMATION_EX = windows.PSAPI_WS_WATCH_INFORMATION_EX;
+const SECURITY_ATTRIBUTES = windows.SECURITY_ATTRIBUTES;
+const SIZE_T = windows.SIZE_T;
+const SRWLOCK = windows.SRWLOCK;
+const UINT = windows.UINT;
+const VECTORED_EXCEPTION_HANDLER = windows.VECTORED_EXCEPTION_HANDLER;
+const WCHAR = windows.WCHAR;
+const WORD = windows.WORD;
+const Win32Error = windows.Win32Error;
+const va_list = windows.va_list;
+const HLOCAL = windows.HLOCAL;
+const FILETIME = windows.FILETIME;
+const STARTUPINFOW = windows.STARTUPINFOW;
+const PROCESS_INFORMATION = windows.PROCESS_INFORMATION;
+const OVERLAPPED_ENTRY = windows.OVERLAPPED_ENTRY;
+const LPHEAP_SUMMARY = windows.LPHEAP_SUMMARY;
+const ULONG_PTR = windows.ULONG_PTR;
+const FILE_NOTIFY_INFORMATION = windows.FILE_NOTIFY_INFORMATION;
+const HANDLER_ROUTINE = windows.HANDLER_ROUTINE;
+const ULONG = windows.ULONG;
+const PVOID = windows.PVOID;
+const LPSTR = windows.LPSTR;
+const PENUM_PAGE_FILE_CALLBACKA = windows.PENUM_PAGE_FILE_CALLBACKA;
pub extern "psapi" fn EmptyWorkingSet(hProcess: HANDLE) callconv(WINAPI) BOOL;
pub extern "psapi" fn EnumDeviceDrivers(lpImageBase: [*]LPVOID, cb: DWORD, lpcbNeeded: *DWORD) callconv(WINAPI) BOOL;
lib/std/os/windows/user32.zig
@@ -1,9 +1,31 @@
const std = @import("../../std.zig");
const assert = std.debug.assert;
+
const windows = std.os.windows;
-const unexpectedError = windows.unexpectedError;
const GetLastError = windows.kernel32.GetLastError;
const SetLastError = windows.kernel32.SetLastError;
+const unexpectedError = windows.unexpectedError;
+const HWND = windows.HWND;
+const UINT = windows.UINT;
+const HDC = windows.HDC;
+const LONG = windows.LONG;
+const LONG_PTR = windows.LONG_PTR;
+const WINAPI = windows.WINAPI;
+const RECT = windows.RECT;
+const DWORD = windows.DWORD;
+const BOOL = windows.BOOL;
+const TRUE = windows.TRUE;
+const HMENU = windows.HMENU;
+const HINSTANCE = windows.HINSTANCE;
+const LPVOID = windows.LPVOID;
+const ATOM = windows.ATOM;
+const WPARAM = windows.WPARAM;
+const LRESULT = windows.LRESULT;
+const HICON = windows.HICON;
+const LPARAM = windows.LPARAM;
+const POINT = windows.POINT;
+const HCURSOR = windows.HCURSOR;
+const HBRUSH = windows.HBRUSH;
fn selectSymbol(comptime function_static: anytype, function_dynamic: @TypeOf(function_static), comptime os: std.Target.Os.WindowsVersion) @TypeOf(function_static) {
comptime {
@@ -1316,7 +1338,7 @@ pub fn showWindow(hWnd: HWND, nCmdShow: i32) bool {
pub extern "user32" fn UpdateWindow(hWnd: HWND) callconv(WINAPI) BOOL;
pub fn updateWindow(hWnd: HWND) !void {
- if (ShowWindow(hWnd, nCmdShow) == 0) {
+ if (UpdateWindow(hWnd) == 0) {
switch (GetLastError()) {
.INVALID_WINDOW_HANDLE => unreachable,
.INVALID_PARAMETER => unreachable,
lib/std/os/windows/ws2_32.zig
@@ -8,6 +8,16 @@ const DWORD = windows.DWORD;
const GUID = windows.GUID;
const USHORT = windows.USHORT;
const WCHAR = windows.WCHAR;
+const BOOL = windows.BOOL;
+const HANDLE = windows.HANDLE;
+const timeval = windows.timeval;
+const HWND = windows.HWND;
+const INT = windows.INT;
+const SHORT = windows.SHORT;
+const CHAR = windows.CHAR;
+const ULONG = windows.ULONG;
+const LPARAM = windows.LPARAM;
+const FARPROC = windows.FARPROC;
pub const SOCKET = *opaque {};
pub const INVALID_SOCKET = @intToPtr(SOCKET, ~@as(usize, 0));
lib/std/os/linux.zig
@@ -50,8 +50,12 @@ pub const syscall3 = syscall_bits.syscall3;
pub const syscall4 = syscall_bits.syscall4;
pub const syscall5 = syscall_bits.syscall5;
pub const syscall6 = syscall_bits.syscall6;
+pub const syscall7 = syscall_bits.syscall7;
pub const restore = syscall_bits.restore;
pub const restore_rt = syscall_bits.restore_rt;
+pub const socketcall = syscall_bits.socketcall;
+pub const syscall_pipe = syscall_bits.syscall_pipe;
+pub const syscall_fork = syscall_bits.syscall_fork;
pub const clone = arch_bits.clone;
pub const ARCH = arch_bits.ARCH;
@@ -181,7 +185,7 @@ pub fn dup2(old: i32, new: i32) usize {
} else {
if (old == new) {
if (std.debug.runtime_safety) {
- const rc = syscall2(.fcntl, @bitCast(usize, @as(isize, old)), F_GETFD);
+ const rc = syscall2(.fcntl, @bitCast(usize, @as(isize, old)), F.GETFD);
if (@bitCast(isize, rc) < 0) return rc;
}
return @intCast(usize, old);
@@ -217,7 +221,7 @@ pub fn fork() usize {
} else if (@hasField(SYS, "fork")) {
return syscall0(.fork);
} else {
- return syscall2(.clone, SIGCHLD, 0);
+ return syscall2(.clone, SIG.CHLD, 0);
}
}
@@ -821,7 +825,7 @@ var vdso_clock_gettime = @ptrCast(?*const c_void, init_vdso_clock_gettime);
const vdso_clock_gettime_ty = fn (i32, *timespec) callconv(.C) usize;
pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
- if (@hasDecl(@This(), "VDSO_CGT_SYM")) {
+ if (@hasDecl(VDSO, "CGT_SYM")) {
const ptr = @atomicLoad(?*const c_void, &vdso_clock_gettime, .Unordered);
if (ptr) |fn_ptr| {
const f = @ptrCast(vdso_clock_gettime_ty, fn_ptr);
@@ -836,7 +840,7 @@ pub fn clock_gettime(clk_id: i32, tp: *timespec) usize {
}
fn init_vdso_clock_gettime(clk: i32, ts: *timespec) callconv(.C) usize {
- const ptr = @intToPtr(?*const c_void, vdso.lookup(VDSO_CGT_VER, VDSO_CGT_SYM));
+ const ptr = @intToPtr(?*const c_void, vdso.lookup(VDSO.CGT_VER, VDSO.CGT_SYM));
// Note that we may not have a VDSO at all, update the stub address anyway
// so that clock_gettime will fall back on the good old (and slow) syscall
@atomicStore(?*const c_void, &vdso_clock_gettime, ptr, .Monotonic);
@@ -1070,42 +1074,42 @@ pub fn sigismember(set: *const sigset_t, sig: u6) bool {
pub fn getsockname(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
+ return socketcall(SC.getsockname, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
}
return syscall3(.getsockname, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
}
pub fn getpeername(fd: i32, noalias addr: *sockaddr, noalias len: *socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
+ return socketcall(SC.getpeername, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len) });
}
return syscall3(.getpeername, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len));
}
pub fn socket(domain: u32, socket_type: u32, protocol: u32) usize {
if (native_arch == .i386) {
- return socketcall(SC_socket, &[3]usize{ domain, socket_type, protocol });
+ return socketcall(SC.socket, &[3]usize{ domain, socket_type, protocol });
}
return syscall3(.socket, domain, socket_type, protocol);
}
pub fn setsockopt(fd: i32, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen) });
+ return socketcall(SC.setsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen) });
}
return syscall5(.setsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @intCast(usize, optlen));
}
pub fn getsockopt(fd: i32, level: u32, optname: u32, noalias optval: [*]u8, noalias optlen: *socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen) });
+ return socketcall(SC.getsockopt, &[5]usize{ @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen) });
}
return syscall5(.getsockopt, @bitCast(usize, @as(isize, fd)), level, optname, @ptrToInt(optval), @ptrToInt(optlen));
}
pub fn sendmsg(fd: i32, msg: *const std.x.os.Socket.Message, flags: c_int) usize {
if (native_arch == .i386) {
- return socketcall(SC_sendmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)) });
+ return socketcall(SC.sendmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)) });
}
return syscall3(.sendmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)));
}
@@ -1152,49 +1156,49 @@ pub fn sendmmsg(fd: i32, msgvec: [*]mmsghdr_const, vlen: u32, flags: u32) usize
pub fn connect(fd: i32, addr: *const c_void, len: socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_connect, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len });
+ return socketcall(SC.connect, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len });
}
return syscall3(.connect, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), len);
}
pub fn recvmsg(fd: i32, msg: *std.x.os.Socket.Message, flags: c_int) usize {
if (native_arch == .i386) {
- return socketcall(SC_recvmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)) });
+ return socketcall(SC.recvmsg, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)) });
}
return syscall3(.recvmsg, @bitCast(usize, @as(isize, fd)), @ptrToInt(msg), @bitCast(usize, @as(isize, flags)));
}
pub fn recvfrom(fd: i32, noalias buf: [*]u8, len: usize, flags: u32, noalias addr: ?*sockaddr, noalias alen: ?*socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_recvfrom, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen) });
+ return socketcall(SC.recvfrom, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen) });
}
return syscall6(.recvfrom, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @ptrToInt(alen));
}
pub fn shutdown(fd: i32, how: i32) usize {
if (native_arch == .i386) {
- return socketcall(SC_shutdown, &[2]usize{ @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)) });
+ return socketcall(SC.shutdown, &[2]usize{ @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)) });
}
return syscall2(.shutdown, @bitCast(usize, @as(isize, fd)), @bitCast(usize, @as(isize, how)));
}
pub fn bind(fd: i32, addr: *const sockaddr, len: socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len) });
+ return socketcall(SC.bind, &[3]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len) });
}
return syscall3(.bind, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @intCast(usize, len));
}
pub fn listen(fd: i32, backlog: u32) usize {
if (native_arch == .i386) {
- return socketcall(SC_listen, &[2]usize{ @bitCast(usize, @as(isize, fd)), backlog });
+ return socketcall(SC.listen, &[2]usize{ @bitCast(usize, @as(isize, fd)), backlog });
}
return syscall2(.listen, @bitCast(usize, @as(isize, fd)), backlog);
}
pub fn sendto(fd: i32, buf: [*]const u8, len: usize, flags: u32, addr: ?*const sockaddr, alen: socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen) });
+ return socketcall(SC.sendto, &[6]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen) });
}
return syscall6(.sendto, @bitCast(usize, @as(isize, fd)), @ptrToInt(buf), len, flags, @ptrToInt(addr), @intCast(usize, alen));
}
@@ -1221,21 +1225,21 @@ pub fn sendfile(outfd: i32, infd: i32, offset: ?*i64, count: usize) usize {
pub fn socketpair(domain: i32, socket_type: i32, protocol: i32, fd: [2]i32) usize {
if (native_arch == .i386) {
- return socketcall(SC_socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]) });
+ return socketcall(SC.socketpair, &[4]usize{ @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]) });
}
return syscall4(.socketpair, @intCast(usize, domain), @intCast(usize, socket_type), @intCast(usize, protocol), @ptrToInt(&fd[0]));
}
pub fn accept(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t) usize {
if (native_arch == .i386) {
- return socketcall(SC_accept, &[4]usize{ fd, addr, len, 0 });
+ return socketcall(SC.accept, &[4]usize{ fd, addr, len, 0 });
}
return accept4(fd, addr, len, 0);
}
pub fn accept4(fd: i32, noalias addr: ?*sockaddr, noalias len: ?*socklen_t, flags: u32) usize {
if (native_arch == .i386) {
- return socketcall(SC_accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags });
+ return socketcall(SC.accept4, &[4]usize{ @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags });
}
return syscall4(.accept4, @bitCast(usize, @as(isize, fd)), @ptrToInt(addr), @ptrToInt(len), flags);
}
@@ -1435,11 +1439,11 @@ pub fn getrusage(who: i32, usage: *rusage) usize {
}
pub fn tcgetattr(fd: fd_t, termios_p: *termios) usize {
- return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), TCGETS, @ptrToInt(termios_p));
+ return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CGETS, @ptrToInt(termios_p));
}
pub fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) usize {
- return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), TCSETS + @enumToInt(optional_action), @ptrToInt(termios_p));
+ return syscall3(.ioctl, @bitCast(usize, @as(isize, fd)), T.CSETS + @enumToInt(optional_action), @ptrToInt(termios_p));
}
pub fn ioctl(fd: fd_t, request: u32, arg: usize) usize {
@@ -1900,7 +1904,7 @@ pub const SIG = if (is_mips) struct {
pub const IOT = ABRT;
pub const CLD = CHLD;
pub const PWR = LOST;
- pub const IO = POLL;
+ pub const IO = SIG.POLL;
pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
@@ -1996,8 +2000,8 @@ pub const SOCK = struct {
pub const PF = struct {
pub const UNSPEC = 0;
pub const LOCAL = 1;
- pub const UNIX = PF_LOCAL;
- pub const FILE = PF_LOCAL;
+ pub const UNIX = LOCAL;
+ pub const FILE = LOCAL;
pub const INET = 2;
pub const AX25 = 3;
pub const IPX = 4;
@@ -2013,7 +2017,7 @@ pub const PF = struct {
pub const SECURITY = 14;
pub const KEY = 15;
pub const NETLINK = 16;
- pub const ROUTE = PF_NETLINK;
+ pub const ROUTE = PF.NETLINK;
pub const PACKET = 17;
pub const ASH = 18;
pub const ECONET = 19;
@@ -2357,7 +2361,7 @@ pub const IP = struct {
pub const PASSSEC = 18;
pub const TRANSPARENT = 19;
pub const ORIGDSTADDR = 20;
- pub const RECVORIGDSTADDR = IP_ORIGDSTADDR;
+ pub const RECVORIGDSTADDR = IP.ORIGDSTADDR;
pub const MINTTL = 21;
pub const NODEFRAG = 22;
pub const CHECKSUM = 23;
@@ -2376,7 +2380,7 @@ pub const IP = struct {
pub const MULTICAST_ALL = 49;
pub const UNICAST_IF = 50;
- pub const RECVRETOPTS = IP_RETOPTS;
+ pub const RECVRETOPTS = IP.RETOPTS;
pub const PMTUDISC_DONT = 0;
pub const PMTUDISC_WANT = 1;
@@ -2418,7 +2422,7 @@ pub const IPV6 = struct {
pub const JOIN_ANYCAST = 27;
pub const LEAVE_ANYCAST = 28;
- // IPV6_MTU_DISCOVER values
+ // IPV6.MTU_DISCOVER values
pub const PMTUDISC_DONT = 0;
pub const PMTUDISC_WANT = 1;
pub const PMTUDISC_DO = 2;
@@ -2470,7 +2474,7 @@ pub const IPV6 = struct {
pub const MINHOPCOUNT = 73;
pub const ORIGDSTADDR = 74;
- pub const RECVORIGDSTADDR = IPV6_ORIGDSTADDR;
+ pub const RECVORIGDSTADDR = IPV6.ORIGDSTADDR;
pub const TRANSPARENT = 75;
pub const UNICAST_IF = 76;
pub const RECVFRAGSIZE = 77;
@@ -3924,8 +3928,8 @@ pub const V = switch (native_arch) {
pub const DISCARD = 13;
pub const WERASE = 14;
pub const LNEXT = 15;
- pub const MIN = VEOF;
- pub const TIME = VEOL;
+ pub const MIN = EOF;
+ pub const TIME = EOL;
},
.mips, .mipsel, .mips64, .mips64el => struct {
pub const INTR = 0;
lib/std/os/wasi.zig
@@ -149,8 +149,10 @@ pub const Stat = struct {
pub const IOV_MAX = 1024;
-pub const AT_REMOVEDIR: u32 = 0x4;
-pub const AT_FDCWD: fd_t = -2;
+pub const AT = struct {
+ pub const REMOVEDIR: u32 = 0x4;
+ pub const FDCWD: fd_t = -2;
+};
// As defined in the wasi_snapshot_preview1 spec file:
// https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/witx/typenames.witx
@@ -293,11 +295,13 @@ pub const exitcode_t = u32;
pub const fd_t = u32;
pub const fdflags_t = u16;
-pub const FDFLAG_APPEND: fdflags_t = 0x0001;
-pub const FDFLAG_DSYNC: fdflags_t = 0x0002;
-pub const FDFLAG_NONBLOCK: fdflags_t = 0x0004;
-pub const FDFLAG_RSYNC: fdflags_t = 0x0008;
-pub const FDFLAG_SYNC: fdflags_t = 0x0010;
+pub const FDFLAG = struct {
+ pub const APPEND: fdflags_t = 0x0001;
+ pub const DSYNC: fdflags_t = 0x0002;
+ pub const NONBLOCK: fdflags_t = 0x0004;
+ pub const RSYNC: fdflags_t = 0x0008;
+ pub const SYNC: fdflags_t = 0x0010;
+};
pub const fdstat_t = extern struct {
fs_filetype: filetype_t,
@@ -333,15 +337,17 @@ pub const filestat_t = extern struct {
}
};
-pub const filetype_t = u8;
-pub const FILETYPE_UNKNOWN: filetype_t = 0;
-pub const FILETYPE_BLOCK_DEVICE: filetype_t = 1;
-pub const FILETYPE_CHARACTER_DEVICE: filetype_t = 2;
-pub const FILETYPE_DIRECTORY: filetype_t = 3;
-pub const FILETYPE_REGULAR_FILE: filetype_t = 4;
-pub const FILETYPE_SOCKET_DGRAM: filetype_t = 5;
-pub const FILETYPE_SOCKET_STREAM: filetype_t = 6;
-pub const FILETYPE_SYMBOLIC_LINK: filetype_t = 7;
+pub const filetype_t = enum(u8) {
+ UNKNOWN,
+ BLOCK_DEVICE,
+ CHARACTER_DEVICE,
+ DIRECTORY,
+ REGULAR_FILE,
+ SOCKET_DGRAM,
+ SOCKET_STREAM,
+ SYMBOLIC_LINK,
+ _,
+};
pub const fstflags_t = u16;
pub const FILESTAT_SET_ATIM: fstflags_t = 0x0001;
@@ -392,64 +398,66 @@ pub const SOCK = struct {
};
pub const rights_t = u64;
-pub const RIGHT_FD_DATASYNC: rights_t = 0x0000000000000001;
-pub const RIGHT_FD_READ: rights_t = 0x0000000000000002;
-pub const RIGHT_FD_SEEK: rights_t = 0x0000000000000004;
-pub const RIGHT_FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;
-pub const RIGHT_FD_SYNC: rights_t = 0x0000000000000010;
-pub const RIGHT_FD_TELL: rights_t = 0x0000000000000020;
-pub const RIGHT_FD_WRITE: rights_t = 0x0000000000000040;
-pub const RIGHT_FD_ADVISE: rights_t = 0x0000000000000080;
-pub const RIGHT_FD_ALLOCATE: rights_t = 0x0000000000000100;
-pub const RIGHT_PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;
-pub const RIGHT_PATH_CREATE_FILE: rights_t = 0x0000000000000400;
-pub const RIGHT_PATH_LINK_SOURCE: rights_t = 0x0000000000000800;
-pub const RIGHT_PATH_LINK_TARGET: rights_t = 0x0000000000001000;
-pub const RIGHT_PATH_OPEN: rights_t = 0x0000000000002000;
-pub const RIGHT_FD_READDIR: rights_t = 0x0000000000004000;
-pub const RIGHT_PATH_READLINK: rights_t = 0x0000000000008000;
-pub const RIGHT_PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;
-pub const RIGHT_PATH_RENAME_TARGET: rights_t = 0x0000000000020000;
-pub const RIGHT_PATH_FILESTAT_GET: rights_t = 0x0000000000040000;
-pub const RIGHT_PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;
-pub const RIGHT_PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;
-pub const RIGHT_FD_FILESTAT_GET: rights_t = 0x0000000000200000;
-pub const RIGHT_FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;
-pub const RIGHT_FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;
-pub const RIGHT_PATH_SYMLINK: rights_t = 0x0000000001000000;
-pub const RIGHT_PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;
-pub const RIGHT_PATH_UNLINK_FILE: rights_t = 0x0000000004000000;
-pub const RIGHT_POLL_FD_READWRITE: rights_t = 0x0000000008000000;
-pub const RIGHT_SOCK_SHUTDOWN: rights_t = 0x0000000010000000;
-pub const RIGHT_ALL: rights_t = RIGHT_FD_DATASYNC |
- RIGHT_FD_READ |
- RIGHT_FD_SEEK |
- RIGHT_FD_FDSTAT_SET_FLAGS |
- RIGHT_FD_SYNC |
- RIGHT_FD_TELL |
- RIGHT_FD_WRITE |
- RIGHT_FD_ADVISE |
- RIGHT_FD_ALLOCATE |
- RIGHT_PATH_CREATE_DIRECTORY |
- RIGHT_PATH_CREATE_FILE |
- RIGHT_PATH_LINK_SOURCE |
- RIGHT_PATH_LINK_TARGET |
- RIGHT_PATH_OPEN |
- RIGHT_FD_READDIR |
- RIGHT_PATH_READLINK |
- RIGHT_PATH_RENAME_SOURCE |
- RIGHT_PATH_RENAME_TARGET |
- RIGHT_PATH_FILESTAT_GET |
- RIGHT_PATH_FILESTAT_SET_SIZE |
- RIGHT_PATH_FILESTAT_SET_TIMES |
- RIGHT_FD_FILESTAT_GET |
- RIGHT_FD_FILESTAT_SET_SIZE |
- RIGHT_FD_FILESTAT_SET_TIMES |
- RIGHT_PATH_SYMLINK |
- RIGHT_PATH_REMOVE_DIRECTORY |
- RIGHT_PATH_UNLINK_FILE |
- RIGHT_POLL_FD_READWRITE |
- RIGHT_SOCK_SHUTDOWN;
+pub const RIGHT = struct {
+ pub const FD_DATASYNC: rights_t = 0x0000000000000001;
+ pub const FD_READ: rights_t = 0x0000000000000002;
+ pub const FD_SEEK: rights_t = 0x0000000000000004;
+ pub const FD_FDSTAT_SET_FLAGS: rights_t = 0x0000000000000008;
+ pub const FD_SYNC: rights_t = 0x0000000000000010;
+ pub const FD_TELL: rights_t = 0x0000000000000020;
+ pub const FD_WRITE: rights_t = 0x0000000000000040;
+ pub const FD_ADVISE: rights_t = 0x0000000000000080;
+ pub const FD_ALLOCATE: rights_t = 0x0000000000000100;
+ pub const PATH_CREATE_DIRECTORY: rights_t = 0x0000000000000200;
+ pub const PATH_CREATE_FILE: rights_t = 0x0000000000000400;
+ pub const PATH_LINK_SOURCE: rights_t = 0x0000000000000800;
+ pub const PATH_LINK_TARGET: rights_t = 0x0000000000001000;
+ pub const PATH_OPEN: rights_t = 0x0000000000002000;
+ pub const FD_READDIR: rights_t = 0x0000000000004000;
+ pub const PATH_READLINK: rights_t = 0x0000000000008000;
+ pub const PATH_RENAME_SOURCE: rights_t = 0x0000000000010000;
+ pub const PATH_RENAME_TARGET: rights_t = 0x0000000000020000;
+ pub const PATH_FILESTAT_GET: rights_t = 0x0000000000040000;
+ pub const PATH_FILESTAT_SET_SIZE: rights_t = 0x0000000000080000;
+ pub const PATH_FILESTAT_SET_TIMES: rights_t = 0x0000000000100000;
+ pub const FD_FILESTAT_GET: rights_t = 0x0000000000200000;
+ pub const FD_FILESTAT_SET_SIZE: rights_t = 0x0000000000400000;
+ pub const FD_FILESTAT_SET_TIMES: rights_t = 0x0000000000800000;
+ pub const PATH_SYMLINK: rights_t = 0x0000000001000000;
+ pub const PATH_REMOVE_DIRECTORY: rights_t = 0x0000000002000000;
+ pub const PATH_UNLINK_FILE: rights_t = 0x0000000004000000;
+ pub const POLL_FD_READWRITE: rights_t = 0x0000000008000000;
+ pub const SOCK_SHUTDOWN: rights_t = 0x0000000010000000;
+ pub const ALL: rights_t = FD_DATASYNC |
+ FD_READ |
+ FD_SEEK |
+ FD_FDSTAT_SET_FLAGS |
+ FD_SYNC |
+ FD_TELL |
+ FD_WRITE |
+ FD_ADVISE |
+ FD_ALLOCATE |
+ PATH_CREATE_DIRECTORY |
+ PATH_CREATE_FILE |
+ PATH_LINK_SOURCE |
+ PATH_LINK_TARGET |
+ PATH_OPEN |
+ FD_READDIR |
+ PATH_READLINK |
+ PATH_RENAME_SOURCE |
+ PATH_RENAME_TARGET |
+ PATH_FILESTAT_GET |
+ PATH_FILESTAT_SET_SIZE |
+ PATH_FILESTAT_SET_TIMES |
+ FD_FILESTAT_GET |
+ FD_FILESTAT_SET_SIZE |
+ FD_FILESTAT_SET_TIMES |
+ PATH_SYMLINK |
+ PATH_REMOVE_DIRECTORY |
+ PATH_UNLINK_FILE |
+ POLL_FD_READWRITE |
+ SOCK_SHUTDOWN;
+};
pub const sdflags_t = u8;
pub const SHUT_RD: sdflags_t = 0x01;
@@ -524,25 +532,20 @@ pub const timestamp_t = u64;
pub const userdata_t = u64;
-pub const whence_t = u8;
-pub const WHENCE_SET: whence_t = 0;
-pub const WHENCE_CUR: whence_t = 1;
-pub const WHENCE_END: whence_t = 2;
-
-pub const S_IEXEC = S_IXUSR;
-pub const S_IFBLK = 0x6000;
-pub const S_IFCHR = 0x2000;
-pub const S_IFDIR = 0x4000;
-pub const S_IFIFO = 0xc000;
-pub const S_IFLNK = 0xa000;
-pub const S_IFMT = S_IFBLK | S_IFCHR | S_IFDIR | S_IFIFO | S_IFLNK | S_IFREG | S_IFSOCK;
-pub const S_IFREG = 0x8000;
-// There's no concept of UNIX domain socket but we define this value here in order to line with other OSes.
-pub const S_IFSOCK = 0x1;
-
-pub const SEEK_SET = WHENCE_SET;
-pub const SEEK_CUR = WHENCE_CUR;
-pub const SEEK_END = WHENCE_END;
+pub const whence_t = enum(u8) { SET, CUR, END };
+
+pub const S = struct {
+ pub const IEXEC = @compileError("TODO audit this");
+ pub const IFBLK = 0x6000;
+ pub const IFCHR = 0x2000;
+ pub const IFDIR = 0x4000;
+ pub const IFIFO = 0xc000;
+ pub const IFLNK = 0xa000;
+ pub const IFMT = IFBLK | IFCHR | IFDIR | IFIFO | IFLNK | IFREG | IFSOCK;
+ pub const IFREG = 0x8000;
+ // There's no concept of UNIX domain socket but we define this value here in order to line with other OSes.
+ pub const IFSOCK = 0x1;
+};
pub const LOCK = struct {
pub const SH = 0x1;
lib/std/os/windows.zig
@@ -2971,7 +2971,7 @@ pub const EXCEPTION_RECORD = extern struct {
ExceptionInformation: [15]usize,
};
-const arch_bits = switch (native_arch) {
+pub usingnamespace switch (native_arch) {
.i386 => struct {
pub const FLOATING_SAVE_AREA = extern struct {
ControlWord: DWORD,
@@ -3037,8 +3037,8 @@ const arch_bits = switch (native_arch) {
Reserved3: WORD,
MxCsr: DWORD,
MxCsr_Mask: DWORD,
- FloatRegisters: [8]arch_bits.M128A,
- XmmRegisters: [16]arch_bits.M128A,
+ FloatRegisters: [8]M128A,
+ XmmRegisters: [16]M128A,
Reserved4: [96]BYTE,
};
@@ -3082,8 +3082,8 @@ const arch_bits = switch (native_arch) {
R15: DWORD64,
Rip: DWORD64,
DUMMYUNIONNAME: extern union {
- FltSave: arch_bits.XMM_SAVE_AREA32,
- FloatSave: arch_bits.XMM_SAVE_AREA32,
+ FltSave: XMM_SAVE_AREA32,
+ FloatSave: XMM_SAVE_AREA32,
DUMMYSTRUCTNAME: extern struct {
Header: [2]M128A,
Legacy: [8]M128A,
@@ -3189,15 +3189,10 @@ const arch_bits = switch (native_arch) {
},
else => struct {},
};
-pub const M128A = arch_bits.M128A;
-pub const XMM_SAVE_AREA32 = arch_bits.XMM_SAVE_AREA32;
-pub const CONTEXT = arch_bits.CONTEXT;
-pub const FLOATING_SAVE_AREA = arch_bits.FLOATING_SAVE_AREA;
-pub const NEON128 = arch_bits.NEON128;
pub const EXCEPTION_POINTERS = extern struct {
ExceptionRecord: *EXCEPTION_RECORD,
- ContextRecord: *CONTEXT,
+ ContextRecord: *@This().CONTEXT,
};
pub const VECTORED_EXCEPTION_HANDLER = fn (ExceptionInfo: *EXCEPTION_POINTERS) callconv(WINAPI) c_long;
lib/std/builtin.zig
@@ -27,7 +27,7 @@ pub const code_model = builtin.code_model;
/// used rather than `explicit_subsystem`.
/// On non-Windows targets, this is `null`.
pub const subsystem: ?std.Target.SubSystem = blk: {
- if (@hasDecl(builtin, "explicit_subsystem")) break :blk explicit_subsystem;
+ if (@hasDecl(builtin, "explicit_subsystem")) break :blk builtin.explicit_subsystem;
switch (os.tag) {
.windows => {
if (is_test) {
lib/std/c.zig
@@ -1,181 +1,17 @@
const std = @import("std");
const builtin = std.builtin;
+const c = @This();
const page_size = std.mem.page_size;
const iovec = std.os.iovec;
const iovec_const = std.os.iovec_const;
-pub const tokenizer = @import("c/tokenizer.zig");
-pub const Token = tokenizer.Token;
-pub const Tokenizer = tokenizer.Tokenizer;
-
test {
_ = tokenizer;
}
-const generic = @import("c/generic.zig");
-const system = switch (builtin.os.tag) {
- .linux => @import("c/linux.zig"),
- .windows => @import("c/windows.zig"),
- .macos, .ios, .tvos, .watchos => @import("c/darwin.zig"),
- .freebsd, .kfreebsd => @import("c/freebsd.zig"),
- .netbsd => @import("c/netbsd.zig"),
- .dragonfly => @import("c/dragonfly.zig"),
- .openbsd => @import("c/openbsd.zig"),
- .haiku => @import("c/haiku.zig"),
- .hermit => @import("c/hermit.zig"),
- .solaris => @import("c/solaris.zig"),
- .fuchsia => @import("c/fuchsia.zig"),
- .minix => @import("c/minix.zig"),
- .emscripten => @import("c/emscripten.zig"),
- .wasi => @import("c/wasi.zig"),
- else => struct {},
-};
-
-pub const _errno = system._errno;
-pub const copy_file_range = system.copy_file_range;
-pub const fallocate64 = system.fallocate64;
-pub const fopen64 = system.fopen64;
-pub const fstat64 = system.fstat64;
-pub const fstatat64 = system.fstatat64;
-pub const ftruncate64 = system.ftruncate64;
-pub const getrlimit64 = system.getrlimit64;
-pub const lseek64 = system.lseek64;
-pub const mmap64 = system.mmap64;
-pub const open64 = system.open64;
-pub const openat64 = system.openat64;
-pub const pread64 = system.pread64;
-pub const preadv64 = system.preadv64;
-pub const pwrite64 = system.pwrite64;
-pub const pwritev64 = system.pwritev64;
-pub const sendfile64 = system.sendfile64;
-pub const setrlimit64 = system.setrlimit64;
-
-pub const AF = system.AF;
-pub const AI = system.AI;
-pub const AT = system.AT;
-pub const CLOCK = system.CLOCK;
-pub const CPU_COUNT = system.CPU_COUNT;
-pub const E = system.E;
-pub const EAI = system.EAI;
-pub const F = system.F;
-pub const FD_CLOEXEC = system.FD_CLOEXEC;
-pub const F_OK = system.F_OK;
-pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
-pub const IFNAMESIZE = system.IFNAMESIZE;
-pub const IOV_MAX = system.IOV_MAX;
-pub const IPPROTO = system.IPPROTO;
-pub const LOCK = system.LOCK;
-pub const MADV = system.MADV;
-pub const MAP = system.MAP;
-pub const NAME_MAX = system.NAME_MAX;
-pub const NI = system.NI;
-pub const O = system.O;
-pub const PATH_MAX = system.PATH_MAX;
-pub const POLL = system.POLL;
-pub const PROT = system.PROT;
-pub const REG = system.REG;
-pub const RLIM = system.RLIM;
-pub const RTLD = system.RTLD;
-pub const R_OK = system.R_OK;
-pub const S = system.S;
-pub const SA = system.SA;
-pub const SEEK = system.SEEK;
-pub const SHUT = system.SHUT;
-pub const SIG = system.SIG;
-pub const SIOCGIFINDEX = system.SIOCGIFINDEX;
-pub const SO = system.SO;
-pub const SOCK = system.SOCK;
-pub const SOL = system.SOL;
-pub const STDERR_FILENO = system.STDERR_FILENO;
-pub const STDIN_FILENO = system.STDIN_FILENO;
-pub const STDOUT_FILENO = system.STDOUT_FILENO;
-pub const Sigaction = system.Sigaction;
-pub const Stat = system.Stat;
-pub const W = system.W;
-pub const W_OK = system.W_OK;
-pub const X_OK = system.X_OK;
-pub const addrinfo = system.addrinfo;
-pub const cpu_set_t = system.cpu_set_t;
-pub const dl_iterate_phdr = system.dl_iterate_phdr;
-pub const dl_iterate_phdr_callback = system.dl_iterate_phdr_callback;
-pub const dl_phdr_info = system.dl_phdr_info;
-pub const empty_sigset = system.empty_sigset;
-pub const epoll_create1 = system.epoll_create1;
-pub const epoll_ctl = system.epoll_ctl;
-pub const epoll_pwait = system.epoll_pwait;
-pub const epoll_wait = system.epoll_wait;
-pub const eventfd = system.eventfd;
-pub const fallocate = system.fallocate;
-pub const fd_t = system.fd_t;
-pub const getauxval = system.getauxval;
-pub const getdents = system.getdents;
-pub const getrandom = system.getrandom;
-pub const gid_t = system.gid_t;
-pub const ifreq = system.ifreq;
-pub const ino_t = system.ino_t;
-pub const inotify_add_watch = system.inotify_add_watch;
-pub const inotify_init1 = system.inotify_init1;
-pub const inotify_rm_watch = system.inotify_rm_watch;
-pub const madvise = system.madvise;
-pub const malloc_usable_size = system.malloc_usable_size;
-pub const memfd_create = system.memfd_create;
-pub const mode_t = system.mode_t;
-pub const nfds_t = system.nfds_t;
-pub const off_t = system.off_t;
-pub const pid_t = system.pid_t;
-pub const pipe2 = system.pipe2;
-pub const pollfd = system.pollfd;
-pub const posix_memalign = system.posix_memalign;
-pub const prlimit = system.prlimit;
-pub const pthread_attr_t = system.pthread_attr_t;
-pub const pthread_cond_t = system.pthread_cond_t;
-pub const pthread_getname_np = system.pthread_getname_np;
-pub const pthread_mutex_t = system.pthread_mutex_t;
-pub const pthread_rwlock_t = system.pthread_rwlock_t;
-pub const pthread_setname_np = system.pthread_setname_np;
-pub const rlim_t = system.rlim_t;
-pub const rlimit = system.rlimit;
-pub const rlimit_resource = system.rlimit_resource;
-pub const sched_getaffinity = system.sched_getaffinity;
-pub const sem_t = system.sem_t;
-pub const sendfile = system.sendfile;
-pub const sigaltstack = system.sigaltstack;
-pub const siginfo_t = system.siginfo_t;
-pub const signalfd = system.signalfd;
-pub const sigset_t = system.sigset_t;
-pub const sockaddr = system.sockaddr;
-pub const socklen_t = system.socklen_t;
-pub const stack_t = system.stack_t;
-pub const timespec = system.timespec;
-pub const timeval = system.timeval;
-pub const ucontext_t = system.ucontext_t;
-pub const uid_t = system.uid_t;
-pub const utsname = system.utsname;
-
-pub const alarm = if (@hasDecl(system, "alarm")) system.alarm else generic.alarm;
-pub const clock_getres = if (@hasDecl(system, "clock_getres")) system.clock_getres else generic.clock_getres;
-pub const clock_gettime = if (@hasDecl(system, "clock_gettime")) system.clock_gettime else generic.clock_gettime;
-pub const fstat = if (@hasDecl(system, "fstat")) system.fstat else generic.fstat;
-pub const fstatat = if (@hasDecl(system, "fstatat")) system.fstatat else generic.fstatat;
-pub const getrusage = if (@hasDecl(system, "getrusage")) system.getrusage else generic.getrusage;
-pub const gettimeofday = if (@hasDecl(system, "gettimeofday")) system.gettimeofday else generic.gettimeofday;
-pub const nanosleep = if (@hasDecl(system, "nanosleep")) system.nanosleep else generic.nanosleep;
-pub const realpath = if (@hasDecl(system, "realpath")) system.realpath else generic.realpath;
-pub const sched_yield = if (@hasDecl(system, "sched_yield")) system.sched_yield else generic.sched_yield;
-pub const sigaction = if (@hasDecl(system, "sigaction")) system.sigaction else generic.sigaction;
-pub const sigfillset = if (@hasDecl(system, "sigfillset")) system.sigfillset else generic.sigfillset;
-pub const sigprocmask = if (@hasDecl(system, "sigprocmask")) system.sigprocmask else generic.sigprocmask;
-pub const sigwait = if (@hasDecl(system, "sigwait")) system.sigwait else generic.sigwait;
-pub const socket = if (@hasDecl(system, "socket")) system.socket else generic.socket;
-pub const stat = if (@hasDecl(system, "stat")) system.stat else generic.stat;
-
-pub fn getErrno(rc: anytype) E {
- if (rc == -1) {
- return @intToEnum(E, _errno().*);
- } else {
- return .SUCCESS;
- }
-}
+pub const tokenizer = @import("c/tokenizer.zig");
+pub const Token = tokenizer.Token;
+pub const Tokenizer = tokenizer.Tokenizer;
/// The return type is `type` to force comptime function call execution.
/// TODO: https://github.com/ziglang/zig/issues/425
@@ -203,6 +39,94 @@ pub fn versionCheck(glibc_version: builtin.Version) type {
};
}
+pub usingnamespace switch (builtin.os.tag) {
+ .linux => @import("c/linux.zig"),
+ .windows => @import("c/windows.zig"),
+ .macos, .ios, .tvos, .watchos => @import("c/darwin.zig"),
+ .freebsd, .kfreebsd => @import("c/freebsd.zig"),
+ .netbsd => @import("c/netbsd.zig"),
+ .dragonfly => @import("c/dragonfly.zig"),
+ .openbsd => @import("c/openbsd.zig"),
+ .haiku => @import("c/haiku.zig"),
+ .hermit => @import("c/hermit.zig"),
+ .solaris => @import("c/solaris.zig"),
+ .fuchsia => @import("c/fuchsia.zig"),
+ .minix => @import("c/minix.zig"),
+ .emscripten => @import("c/emscripten.zig"),
+ .wasi => @import("c/wasi.zig"),
+ else => struct {},
+};
+
+pub usingnamespace switch (builtin.os.tag) {
+ .netbsd => struct {},
+ .macos, .ios, .watchos, .tvos => struct {
+ // XXX: close -> close$NOCANCEL
+ // XXX: getdirentries -> _getdirentries64
+ pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
+ pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
+ pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
+ pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
+ pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
+ pub extern "c" fn sched_yield() c_int;
+ pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
+ pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
+ pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
+ pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;
+ pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
+ pub extern "c" fn alarm(seconds: c_uint) c_uint;
+ pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
+ },
+ .windows => struct {
+ // TODO: copied the else case and removed the socket function (because its in ws2_32)
+ // need to verify which of these is actually supported on windows
+ pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
+ pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
+ pub extern "c" fn fstat(fd: c.fd_t, buf: *c.Stat) c_int;
+ pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
+ pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
+ pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
+ pub extern "c" fn sched_yield() c_int;
+ pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
+ pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
+ pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;
+ pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
+ pub extern "c" fn alarm(seconds: c_uint) c_uint;
+ pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
+ },
+ else => struct {
+ pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
+ pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
+ pub extern "c" fn fstat(fd: c.fd_t, buf: *c.Stat) c_int;
+ pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
+ pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
+ pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
+ pub extern "c" fn sched_yield() c_int;
+ pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
+ pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
+ pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
+ pub extern "c" fn stat(noalias path: [*:0]const u8, noalias buf: *c.Stat) c_int;
+ pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
+ pub extern "c" fn alarm(seconds: c_uint) c_uint;
+ pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
+ },
+};
+
+pub usingnamespace switch (builtin.os.tag) {
+ .macos, .ios, .watchos, .tvos => struct {},
+ else => struct {
+ pub extern "c" fn realpath(noalias file_name: [*:0]const u8, noalias resolved_name: [*]u8) ?[*:0]u8;
+ pub extern "c" fn fstatat(dirfd: c.fd_t, path: [*:0]const u8, stat_buf: *c.Stat, flags: u32) c_int;
+ },
+};
+
+pub fn getErrno(rc: anytype) c.E {
+ if (rc == -1) {
+ return @intToEnum(c.E, c._errno().*);
+ } else {
+ return .SUCCESS;
+ }
+}
+
pub extern "c" var environ: [*:null]?[*:0]u8;
pub extern "c" fn fopen(noalias filename: [*:0]const u8, noalias modes: [*:0]const u8) ?*FILE;
@@ -214,175 +138,175 @@ pub extern "c" fn printf(format: [*:0]const u8, ...) c_int;
pub extern "c" fn abort() noreturn;
pub extern "c" fn exit(code: c_int) noreturn;
pub extern "c" fn _exit(code: c_int) noreturn;
-pub extern "c" fn isatty(fd: fd_t) c_int;
-pub extern "c" fn close(fd: fd_t) c_int;
-pub extern "c" fn lseek(fd: fd_t, offset: off_t, whence: c_int) off_t;
+pub extern "c" fn isatty(fd: c.fd_t) c_int;
+pub extern "c" fn close(fd: c.fd_t) c_int;
+pub extern "c" fn lseek(fd: c.fd_t, offset: c.off_t, whence: c_int) c.off_t;
pub extern "c" fn open(path: [*:0]const u8, oflag: c_uint, ...) c_int;
pub extern "c" fn openat(fd: c_int, path: [*:0]const u8, oflag: c_uint, ...) c_int;
-pub extern "c" fn ftruncate(fd: c_int, length: off_t) c_int;
+pub extern "c" fn ftruncate(fd: c_int, length: c.off_t) c_int;
pub extern "c" fn raise(sig: c_int) c_int;
-pub extern "c" fn read(fd: fd_t, buf: [*]u8, nbyte: usize) isize;
+pub extern "c" fn read(fd: c.fd_t, buf: [*]u8, nbyte: usize) isize;
pub extern "c" fn readv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint) isize;
-pub extern "c" fn pread(fd: fd_t, buf: [*]u8, nbyte: usize, offset: off_t) isize;
-pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: off_t) isize;
+pub extern "c" fn pread(fd: c.fd_t, buf: [*]u8, nbyte: usize, offset: c.off_t) isize;
+pub extern "c" fn preadv(fd: c_int, iov: [*]const iovec, iovcnt: c_uint, offset: c.off_t) isize;
pub extern "c" fn writev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint) isize;
-pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: off_t) isize;
-pub extern "c" fn write(fd: fd_t, buf: [*]const u8, nbyte: usize) isize;
-pub extern "c" fn pwrite(fd: fd_t, buf: [*]const u8, nbyte: usize, offset: off_t) isize;
-pub extern "c" fn mmap(addr: ?*align(page_size) c_void, len: usize, prot: c_uint, flags: c_uint, fd: fd_t, offset: off_t) *c_void;
+pub extern "c" fn pwritev(fd: c_int, iov: [*]const iovec_const, iovcnt: c_uint, offset: c.off_t) isize;
+pub extern "c" fn write(fd: c.fd_t, buf: [*]const u8, nbyte: usize) isize;
+pub extern "c" fn pwrite(fd: c.fd_t, buf: [*]const u8, nbyte: usize, offset: c.off_t) isize;
+pub extern "c" fn mmap(addr: ?*align(page_size) c_void, len: usize, prot: c_uint, flags: c_uint, fd: c.fd_t, offset: c.off_t) *c_void;
pub extern "c" fn munmap(addr: *align(page_size) const c_void, len: usize) c_int;
pub extern "c" fn mprotect(addr: *align(page_size) c_void, len: usize, prot: c_uint) c_int;
pub extern "c" fn link(oldpath: [*:0]const u8, newpath: [*:0]const u8, flags: c_int) c_int;
-pub extern "c" fn linkat(oldfd: fd_t, oldpath: [*:0]const u8, newfd: fd_t, newpath: [*:0]const u8, flags: c_int) c_int;
+pub extern "c" fn linkat(oldfd: c.fd_t, oldpath: [*:0]const u8, newfd: c.fd_t, newpath: [*:0]const u8, flags: c_int) c_int;
pub extern "c" fn unlink(path: [*:0]const u8) c_int;
-pub extern "c" fn unlinkat(dirfd: fd_t, path: [*:0]const u8, flags: c_uint) c_int;
+pub extern "c" fn unlinkat(dirfd: c.fd_t, path: [*:0]const u8, flags: c_uint) c_int;
pub extern "c" fn getcwd(buf: [*]u8, size: usize) ?[*]u8;
-pub extern "c" fn waitpid(pid: pid_t, stat_loc: ?*c_int, options: c_int) pid_t;
+pub extern "c" fn waitpid(pid: c.pid_t, stat_loc: ?*c_int, options: c_int) c.pid_t;
pub extern "c" fn fork() c_int;
pub extern "c" fn access(path: [*:0]const u8, mode: c_uint) c_int;
-pub extern "c" fn faccessat(dirfd: fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int;
-pub extern "c" fn pipe(fds: *[2]fd_t) c_int;
+pub extern "c" fn faccessat(dirfd: c.fd_t, path: [*:0]const u8, mode: c_uint, flags: c_uint) c_int;
+pub extern "c" fn pipe(fds: *[2]c.fd_t) c_int;
pub extern "c" fn mkdir(path: [*:0]const u8, mode: c_uint) c_int;
-pub extern "c" fn mkdirat(dirfd: fd_t, path: [*:0]const u8, mode: u32) c_int;
+pub extern "c" fn mkdirat(dirfd: c.fd_t, path: [*:0]const u8, mode: u32) c_int;
pub extern "c" fn symlink(existing: [*:0]const u8, new: [*:0]const u8) c_int;
-pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: fd_t, newpath: [*:0]const u8) c_int;
+pub extern "c" fn symlinkat(oldpath: [*:0]const u8, newdirfd: c.fd_t, newpath: [*:0]const u8) c_int;
pub extern "c" fn rename(old: [*:0]const u8, new: [*:0]const u8) c_int;
-pub extern "c" fn renameat(olddirfd: fd_t, old: [*:0]const u8, newdirfd: fd_t, new: [*:0]const u8) c_int;
+pub extern "c" fn renameat(olddirfd: c.fd_t, old: [*:0]const u8, newdirfd: c.fd_t, new: [*:0]const u8) c_int;
pub extern "c" fn chdir(path: [*:0]const u8) c_int;
-pub extern "c" fn fchdir(fd: fd_t) c_int;
+pub extern "c" fn fchdir(fd: c.fd_t) c_int;
pub extern "c" fn execve(path: [*:0]const u8, argv: [*:null]const ?[*:0]const u8, envp: [*:null]const ?[*:0]const u8) c_int;
-pub extern "c" fn dup(fd: fd_t) c_int;
-pub extern "c" fn dup2(old_fd: fd_t, new_fd: fd_t) c_int;
+pub extern "c" fn dup(fd: c.fd_t) c_int;
+pub extern "c" fn dup2(old_fd: c.fd_t, new_fd: c.fd_t) c_int;
pub extern "c" fn readlink(noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
-pub extern "c" fn readlinkat(dirfd: fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
+pub extern "c" fn readlinkat(dirfd: c.fd_t, noalias path: [*:0]const u8, noalias buf: [*]u8, bufsize: usize) isize;
pub extern "c" fn rmdir(path: [*:0]const u8) c_int;
pub extern "c" fn getenv(name: [*:0]const u8) ?[*:0]u8;
pub extern "c" fn sysctl(name: [*]const c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
pub extern "c" fn sysctlbyname(name: [*:0]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
pub extern "c" fn sysctlnametomib(name: [*:0]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;
-pub extern "c" fn tcgetattr(fd: fd_t, termios_p: *termios) c_int;
-pub extern "c" fn tcsetattr(fd: fd_t, optional_action: TCSA, termios_p: *const termios) c_int;
-pub extern "c" fn fcntl(fd: fd_t, cmd: c_int, ...) c_int;
-pub extern "c" fn flock(fd: fd_t, operation: c_int) c_int;
-pub extern "c" fn ioctl(fd: fd_t, request: c_int, ...) c_int;
-pub extern "c" fn uname(buf: *utsname) c_int;
+pub extern "c" fn tcgetattr(fd: c.fd_t, termios_p: *c.termios) c_int;
+pub extern "c" fn tcsetattr(fd: c.fd_t, optional_action: c.TCSA, termios_p: *const c.termios) c_int;
+pub extern "c" fn fcntl(fd: c.fd_t, cmd: c_int, ...) c_int;
+pub extern "c" fn flock(fd: c.fd_t, operation: c_int) c_int;
+pub extern "c" fn ioctl(fd: c.fd_t, request: c_int, ...) c_int;
+pub extern "c" fn uname(buf: *c.utsname) c_int;
pub extern "c" fn gethostname(name: [*]u8, len: usize) c_int;
-pub extern "c" fn shutdown(socket: fd_t, how: c_int) c_int;
-pub extern "c" fn bind(socket: fd_t, address: ?*const sockaddr, address_len: socklen_t) c_int;
-pub extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]fd_t) c_int;
-pub extern "c" fn listen(sockfd: fd_t, backlog: c_uint) c_int;
-pub extern "c" fn getsockname(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int;
-pub extern "c" fn getpeername(sockfd: fd_t, noalias addr: *sockaddr, noalias addrlen: *socklen_t) c_int;
-pub extern "c" fn connect(sockfd: fd_t, sock_addr: *const sockaddr, addrlen: socklen_t) c_int;
-pub extern "c" fn accept(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t) c_int;
-pub extern "c" fn accept4(sockfd: fd_t, noalias addr: ?*sockaddr, noalias addrlen: ?*socklen_t, flags: c_uint) c_int;
-pub extern "c" fn getsockopt(sockfd: fd_t, level: u32, optname: u32, noalias optval: ?*c_void, noalias optlen: *socklen_t) c_int;
-pub extern "c" fn setsockopt(sockfd: fd_t, level: u32, optname: u32, optval: ?*const c_void, optlen: socklen_t) c_int;
-pub extern "c" fn send(sockfd: fd_t, buf: *const c_void, len: usize, flags: u32) isize;
+pub extern "c" fn shutdown(socket: c.fd_t, how: c_int) c_int;
+pub extern "c" fn bind(socket: c.fd_t, address: ?*const c.sockaddr, address_len: c.socklen_t) c_int;
+pub extern "c" fn socketpair(domain: c_uint, sock_type: c_uint, protocol: c_uint, sv: *[2]c.fd_t) c_int;
+pub extern "c" fn listen(sockfd: c.fd_t, backlog: c_uint) c_int;
+pub extern "c" fn getsockname(sockfd: c.fd_t, noalias addr: *c.sockaddr, noalias addrlen: *c.socklen_t) c_int;
+pub extern "c" fn getpeername(sockfd: c.fd_t, noalias addr: *c.sockaddr, noalias addrlen: *c.socklen_t) c_int;
+pub extern "c" fn connect(sockfd: c.fd_t, sock_addr: *const c.sockaddr, addrlen: c.socklen_t) c_int;
+pub extern "c" fn accept(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t) c_int;
+pub extern "c" fn accept4(sockfd: c.fd_t, noalias addr: ?*c.sockaddr, noalias addrlen: ?*c.socklen_t, flags: c_uint) c_int;
+pub extern "c" fn getsockopt(sockfd: c.fd_t, level: u32, optname: u32, noalias optval: ?*c_void, noalias optlen: *c.socklen_t) c_int;
+pub extern "c" fn setsockopt(sockfd: c.fd_t, level: u32, optname: u32, optval: ?*const c_void, optlen: c.socklen_t) c_int;
+pub extern "c" fn send(sockfd: c.fd_t, buf: *const c_void, len: usize, flags: u32) isize;
pub extern "c" fn sendto(
- sockfd: fd_t,
+ sockfd: c.fd_t,
buf: *const c_void,
len: usize,
flags: u32,
- dest_addr: ?*const sockaddr,
- addrlen: socklen_t,
+ dest_addr: ?*const c.sockaddr,
+ addrlen: c.socklen_t,
) isize;
-pub extern "c" fn sendmsg(sockfd: fd_t, msg: *const std.x.os.Socket.Message, flags: c_int) isize;
+pub extern "c" fn sendmsg(sockfd: c.fd_t, msg: *const std.x.os.Socket.Message, flags: c_int) isize;
-pub extern "c" fn recv(sockfd: fd_t, arg1: ?*c_void, arg2: usize, arg3: c_int) isize;
+pub extern "c" fn recv(sockfd: c.fd_t, arg1: ?*c_void, arg2: usize, arg3: c_int) isize;
pub extern "c" fn recvfrom(
- sockfd: fd_t,
+ sockfd: c.fd_t,
noalias buf: *c_void,
len: usize,
flags: u32,
- noalias src_addr: ?*sockaddr,
- noalias addrlen: ?*socklen_t,
+ noalias src_addr: ?*c.sockaddr,
+ noalias addrlen: ?*c.socklen_t,
) isize;
-pub extern "c" fn recvmsg(sockfd: fd_t, msg: *std.x.os.Socket.Message, flags: c_int) isize;
+pub extern "c" fn recvmsg(sockfd: c.fd_t, msg: *std.x.os.Socket.Message, flags: c_int) isize;
-pub extern "c" fn kill(pid: pid_t, sig: c_int) c_int;
-pub extern "c" fn getdirentries(fd: fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize;
+pub extern "c" fn kill(pid: c.pid_t, sig: c_int) c_int;
+pub extern "c" fn getdirentries(fd: c.fd_t, buf_ptr: [*]u8, nbytes: usize, basep: *i64) isize;
-pub extern "c" fn setuid(uid: uid_t) c_int;
-pub extern "c" fn setgid(gid: gid_t) c_int;
-pub extern "c" fn seteuid(euid: uid_t) c_int;
-pub extern "c" fn setegid(egid: gid_t) c_int;
-pub extern "c" fn setreuid(ruid: uid_t, euid: uid_t) c_int;
-pub extern "c" fn setregid(rgid: gid_t, egid: gid_t) c_int;
-pub extern "c" fn setresuid(ruid: uid_t, euid: uid_t, suid: uid_t) c_int;
-pub extern "c" fn setresgid(rgid: gid_t, egid: gid_t, sgid: gid_t) c_int;
+pub extern "c" fn setuid(uid: c.uid_t) c_int;
+pub extern "c" fn setgid(gid: c.gid_t) c_int;
+pub extern "c" fn seteuid(euid: c.uid_t) c_int;
+pub extern "c" fn setegid(egid: c.gid_t) c_int;
+pub extern "c" fn setreuid(ruid: c.uid_t, euid: c.uid_t) c_int;
+pub extern "c" fn setregid(rgid: c.gid_t, egid: c.gid_t) c_int;
+pub extern "c" fn setresuid(ruid: c.uid_t, euid: c.uid_t, suid: c.uid_t) c_int;
+pub extern "c" fn setresgid(rgid: c.gid_t, egid: c.gid_t, sgid: c.gid_t) c_int;
pub extern "c" fn malloc(usize) ?*c_void;
pub extern "c" fn realloc(?*c_void, usize) ?*c_void;
pub extern "c" fn free(?*c_void) void;
-pub extern "c" fn futimes(fd: fd_t, times: *[2]timeval) c_int;
-pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]timeval) c_int;
+pub extern "c" fn futimes(fd: c.fd_t, times: *[2]c.timeval) c_int;
+pub extern "c" fn utimes(path: [*:0]const u8, times: *[2]c.timeval) c_int;
-pub extern "c" fn utimensat(dirfd: fd_t, pathname: [*:0]const u8, times: *[2]timespec, flags: u32) c_int;
-pub extern "c" fn futimens(fd: fd_t, times: *const [2]timespec) c_int;
+pub extern "c" fn utimensat(dirfd: c.fd_t, pathname: [*:0]const u8, times: *[2]c.timespec, flags: u32) c_int;
+pub extern "c" fn futimens(fd: c.fd_t, times: *const [2]c.timespec) c_int;
-pub extern "c" fn pthread_create(noalias newthread: *pthread_t, noalias attr: ?*const pthread_attr_t, start_routine: fn (?*c_void) callconv(.C) ?*c_void, noalias arg: ?*c_void) E;
-pub extern "c" fn pthread_attr_init(attr: *pthread_attr_t) E;
-pub extern "c" fn pthread_attr_setstack(attr: *pthread_attr_t, stackaddr: *c_void, stacksize: usize) E;
-pub extern "c" fn pthread_attr_setstacksize(attr: *pthread_attr_t, stacksize: usize) E;
-pub extern "c" fn pthread_attr_setguardsize(attr: *pthread_attr_t, guardsize: usize) E;
-pub extern "c" fn pthread_attr_destroy(attr: *pthread_attr_t) E;
+pub extern "c" fn pthread_create(noalias newthread: *pthread_t, noalias attr: ?*const c.pthread_attr_t, start_routine: fn (?*c_void) callconv(.C) ?*c_void, noalias arg: ?*c_void) c.E;
+pub extern "c" fn pthread_attr_init(attr: *c.pthread_attr_t) c.E;
+pub extern "c" fn pthread_attr_setstack(attr: *c.pthread_attr_t, stackaddr: *c_void, stacksize: usize) c.E;
+pub extern "c" fn pthread_attr_setstacksize(attr: *c.pthread_attr_t, stacksize: usize) c.E;
+pub extern "c" fn pthread_attr_setguardsize(attr: *c.pthread_attr_t, guardsize: usize) c.E;
+pub extern "c" fn pthread_attr_destroy(attr: *c.pthread_attr_t) c.E;
pub extern "c" fn pthread_self() pthread_t;
-pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) E;
-pub extern "c" fn pthread_detach(thread: pthread_t) E;
+pub extern "c" fn pthread_join(thread: pthread_t, arg_return: ?*?*c_void) c.E;
+pub extern "c" fn pthread_detach(thread: pthread_t) c.E;
pub extern "c" fn pthread_atfork(
prepare: ?fn () callconv(.C) void,
parent: ?fn () callconv(.C) void,
child: ?fn () callconv(.C) void,
) c_int;
-pub extern "c" fn pthread_key_create(key: *pthread_key_t, destructor: ?fn (value: *c_void) callconv(.C) void) E;
-pub extern "c" fn pthread_key_delete(key: pthread_key_t) E;
-pub extern "c" fn pthread_getspecific(key: pthread_key_t) ?*c_void;
-pub extern "c" fn pthread_setspecific(key: pthread_key_t, value: ?*c_void) c_int;
-pub extern "c" fn sem_init(sem: *sem_t, pshared: c_int, value: c_uint) c_int;
-pub extern "c" fn sem_destroy(sem: *sem_t) c_int;
-pub extern "c" fn sem_post(sem: *sem_t) c_int;
-pub extern "c" fn sem_wait(sem: *sem_t) c_int;
-pub extern "c" fn sem_trywait(sem: *sem_t) c_int;
-pub extern "c" fn sem_timedwait(sem: *sem_t, abs_timeout: *const timespec) c_int;
-pub extern "c" fn sem_getvalue(sem: *sem_t, sval: *c_int) c_int;
+pub extern "c" fn pthread_key_create(key: *c.pthread_key_t, destructor: ?fn (value: *c_void) callconv(.C) void) c.E;
+pub extern "c" fn pthread_key_delete(key: c.pthread_key_t) c.E;
+pub extern "c" fn pthread_getspecific(key: c.pthread_key_t) ?*c_void;
+pub extern "c" fn pthread_setspecific(key: c.pthread_key_t, value: ?*c_void) c_int;
+pub extern "c" fn sem_init(sem: *c.sem_t, pshared: c_int, value: c_uint) c_int;
+pub extern "c" fn sem_destroy(sem: *c.sem_t) c_int;
+pub extern "c" fn sem_post(sem: *c.sem_t) c_int;
+pub extern "c" fn sem_wait(sem: *c.sem_t) c_int;
+pub extern "c" fn sem_trywait(sem: *c.sem_t) c_int;
+pub extern "c" fn sem_timedwait(sem: *c.sem_t, abs_timeout: *const c.timespec) c_int;
+pub extern "c" fn sem_getvalue(sem: *c.sem_t, sval: *c_int) c_int;
pub extern "c" fn kqueue() c_int;
pub extern "c" fn kevent(
kq: c_int,
- changelist: [*]const Kevent,
+ changelist: [*]const c.Kevent,
nchanges: c_int,
- eventlist: [*]Kevent,
+ eventlist: [*]c.Kevent,
nevents: c_int,
- timeout: ?*const timespec,
+ timeout: ?*const c.timespec,
) c_int;
pub extern "c" fn getaddrinfo(
noalias node: ?[*:0]const u8,
noalias service: ?[*:0]const u8,
- noalias hints: ?*const addrinfo,
- noalias res: **addrinfo,
-) EAI;
+ noalias hints: ?*const c.addrinfo,
+ noalias res: **c.addrinfo,
+) c.EAI;
-pub extern "c" fn freeaddrinfo(res: *addrinfo) void;
+pub extern "c" fn freeaddrinfo(res: *c.addrinfo) void;
pub extern "c" fn getnameinfo(
- noalias addr: *const sockaddr,
- addrlen: socklen_t,
+ noalias addr: *const c.sockaddr,
+ addrlen: c.socklen_t,
noalias host: [*]u8,
- hostlen: socklen_t,
+ hostlen: c.socklen_t,
noalias serv: [*]u8,
- servlen: socklen_t,
+ servlen: c.socklen_t,
flags: u32,
-) EAI;
+) c.EAI;
-pub extern "c" fn gai_strerror(errcode: EAI) [*:0]const u8;
+pub extern "c" fn gai_strerror(errcode: c.EAI) [*:0]const u8;
-pub extern "c" fn poll(fds: [*]pollfd, nfds: nfds_t, timeout: c_int) c_int;
-pub extern "c" fn ppoll(fds: [*]pollfd, nfds: nfds_t, timeout: ?*const timespec, sigmask: ?*const sigset_t) c_int;
+pub extern "c" fn poll(fds: [*]c.pollfd, nfds: c.nfds_t, timeout: c_int) c_int;
+pub extern "c" fn ppoll(fds: [*]c.pollfd, nfds: c.nfds_t, timeout: ?*const c.timespec, sigmask: ?*const c.sigset_t) c_int;
pub extern "c" fn dn_expand(
msg: [*:0]const u8,
@@ -392,25 +316,25 @@ pub extern "c" fn dn_expand(
length: c_int,
) c_int;
-pub const PTHREAD_MUTEX_INITIALIZER = pthread_mutex_t{};
-pub extern "c" fn pthread_mutex_lock(mutex: *pthread_mutex_t) E;
-pub extern "c" fn pthread_mutex_unlock(mutex: *pthread_mutex_t) E;
-pub extern "c" fn pthread_mutex_trylock(mutex: *pthread_mutex_t) E;
-pub extern "c" fn pthread_mutex_destroy(mutex: *pthread_mutex_t) E;
-
-pub const PTHREAD_COND_INITIALIZER = pthread_cond_t{};
-pub extern "c" fn pthread_cond_wait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t) E;
-pub extern "c" fn pthread_cond_timedwait(noalias cond: *pthread_cond_t, noalias mutex: *pthread_mutex_t, noalias abstime: *const timespec) E;
-pub extern "c" fn pthread_cond_signal(cond: *pthread_cond_t) E;
-pub extern "c" fn pthread_cond_broadcast(cond: *pthread_cond_t) E;
-pub extern "c" fn pthread_cond_destroy(cond: *pthread_cond_t) E;
-
-pub extern "c" fn pthread_rwlock_destroy(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_rdlock(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_wrlock(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_trywrlock(rwl: *pthread_rwlock_t) callconv(.C) E;
-pub extern "c" fn pthread_rwlock_unlock(rwl: *pthread_rwlock_t) callconv(.C) E;
+pub const PTHREAD_MUTEX_INITIALIZER = c.pthread_mutex_t{};
+pub extern "c" fn pthread_mutex_lock(mutex: *c.pthread_mutex_t) c.E;
+pub extern "c" fn pthread_mutex_unlock(mutex: *c.pthread_mutex_t) c.E;
+pub extern "c" fn pthread_mutex_trylock(mutex: *c.pthread_mutex_t) c.E;
+pub extern "c" fn pthread_mutex_destroy(mutex: *c.pthread_mutex_t) c.E;
+
+pub const PTHREAD_COND_INITIALIZER = c.pthread_cond_t{};
+pub extern "c" fn pthread_cond_wait(noalias cond: *c.pthread_cond_t, noalias mutex: *c.pthread_mutex_t) c.E;
+pub extern "c" fn pthread_cond_timedwait(noalias cond: *c.pthread_cond_t, noalias mutex: *c.pthread_mutex_t, noalias abstime: *const c.timespec) c.E;
+pub extern "c" fn pthread_cond_signal(cond: *c.pthread_cond_t) c.E;
+pub extern "c" fn pthread_cond_broadcast(cond: *c.pthread_cond_t) c.E;
+pub extern "c" fn pthread_cond_destroy(cond: *c.pthread_cond_t) c.E;
+
+pub extern "c" fn pthread_rwlock_destroy(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
+pub extern "c" fn pthread_rwlock_rdlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
+pub extern "c" fn pthread_rwlock_wrlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
+pub extern "c" fn pthread_rwlock_tryrdlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
+pub extern "c" fn pthread_rwlock_trywrlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
+pub extern "c" fn pthread_rwlock_unlock(rwl: *c.pthread_rwlock_t) callconv(.C) c.E;
pub const pthread_t = *opaque {};
pub const FILE = opaque {};
@@ -426,8 +350,8 @@ pub extern "c" fn fdatasync(fd: c_int) c_int;
pub extern "c" fn prctl(option: c_int, ...) c_int;
-pub extern "c" fn getrlimit(resource: rlimit_resource, rlim: *rlimit) c_int;
-pub extern "c" fn setrlimit(resource: rlimit_resource, rlim: *const rlimit) c_int;
+pub extern "c" fn getrlimit(resource: c.rlimit_resource, rlim: *c.rlimit) c_int;
+pub extern "c" fn setrlimit(resource: c.rlimit_resource, rlim: *const c.rlimit) c_int;
pub extern "c" fn fmemopen(noalias buf: ?*c_void, size: usize, noalias mode: [*:0]const u8) ?*FILE;
lib/std/debug.zig
@@ -1341,7 +1341,7 @@ pub const ModuleDebugInfo = switch (native_os) {
if (o_file_di.findCompileUnit(relocated_address_o)) |compile_unit| {
return SymbolInfo{
.symbol_name = o_file_di.getSymbolName(relocated_address_o) orelse "???",
- .compile_unit_name = compile_unit.die.getAttrString(&o_file_di, DW.AT_name) catch |err| switch (err) {
+ .compile_unit_name = compile_unit.die.getAttrString(&o_file_di, DW.AT.name) catch |err| switch (err) {
error.MissingDebugInfo, error.InvalidDebugInfo => "???",
else => return err,
},
@@ -1438,7 +1438,7 @@ fn getSymbolFromDwarf(address: u64, di: *DW.DwarfInfo) !SymbolInfo {
if (nosuspend di.findCompileUnit(address)) |compile_unit| {
return SymbolInfo{
.symbol_name = nosuspend di.getSymbolName(address) orelse "???",
- .compile_unit_name = compile_unit.die.getAttrString(di, DW.AT_name) catch |err| switch (err) {
+ .compile_unit_name = compile_unit.die.getAttrString(di, DW.AT.name) catch |err| switch (err) {
error.MissingDebugInfo, error.InvalidDebugInfo => "???",
else => return err,
},
lib/std/dwarf.zig
@@ -9,7 +9,223 @@ const leb = @import("leb128.zig");
const ArrayList = std.ArrayList;
-pub usingnamespace @import("dwarf_bits.zig");
+pub const TAG = @import("dwarf/TAG.zig");
+pub const AT = @import("dwarf/AT.zig");
+pub const OP = @import("dwarf/OP.zig");
+
+pub const FORM = struct {
+ pub const addr = 0x01;
+ pub const block2 = 0x03;
+ pub const block4 = 0x04;
+ pub const data2 = 0x05;
+ pub const data4 = 0x06;
+ pub const data8 = 0x07;
+ pub const string = 0x08;
+ pub const block = 0x09;
+ pub const block1 = 0x0a;
+ pub const data1 = 0x0b;
+ pub const flag = 0x0c;
+ pub const sdata = 0x0d;
+ pub const strp = 0x0e;
+ pub const udata = 0x0f;
+ pub const ref_addr = 0x10;
+ pub const ref1 = 0x11;
+ pub const ref2 = 0x12;
+ pub const ref4 = 0x13;
+ pub const ref8 = 0x14;
+ pub const ref_udata = 0x15;
+ pub const indirect = 0x16;
+ pub const sec_offset = 0x17;
+ pub const exprloc = 0x18;
+ pub const flag_present = 0x19;
+ pub const ref_sig8 = 0x20;
+
+ // Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
+ pub const GNU_addr_index = 0x1f01;
+ pub const GNU_str_index = 0x1f02;
+
+ // Extensions for DWZ multifile.
+ // See http://www.dwarfstd.org/ShowIssue.php?issue=120604.1&type=open .
+ pub const GNU_ref_alt = 0x1f20;
+ pub const GNU_strp_alt = 0x1f21;
+};
+
+pub const ATE = struct {
+ pub const @"void" = 0x0;
+ pub const address = 0x1;
+ pub const boolean = 0x2;
+ pub const complex_float = 0x3;
+ pub const float = 0x4;
+ pub const signed = 0x5;
+ pub const signed_char = 0x6;
+ pub const unsigned = 0x7;
+ pub const unsigned_char = 0x8;
+
+ // DWARF 3.
+ pub const imaginary_float = 0x9;
+ pub const packed_decimal = 0xa;
+ pub const numeric_string = 0xb;
+ pub const edited = 0xc;
+ pub const signed_fixed = 0xd;
+ pub const unsigned_fixed = 0xe;
+ pub const decimal_float = 0xf;
+
+ // DWARF 4.
+ pub const UTF = 0x10;
+
+ pub const lo_user = 0x80;
+ pub const hi_user = 0xff;
+
+ // HP extensions.
+ pub const HP_float80 = 0x80; // Floating-point (80 bit).
+ pub const HP_complex_float80 = 0x81; // Complex floating-point (80 bit).
+ pub const HP_float128 = 0x82; // Floating-point (128 bit).
+ pub const HP_complex_float128 = 0x83; // Complex fp (128 bit).
+ pub const HP_floathpintel = 0x84; // Floating-point (82 bit IA64).
+ pub const HP_imaginary_float80 = 0x85;
+ pub const HP_imaginary_float128 = 0x86;
+ pub const HP_VAX_float = 0x88; // F or G floating.
+ pub const HP_VAX_float_d = 0x89; // D floating.
+ pub const HP_packed_decimal = 0x8a; // Cobol.
+ pub const HP_zoned_decimal = 0x8b; // Cobol.
+ pub const HP_edited = 0x8c; // Cobol.
+ pub const HP_signed_fixed = 0x8d; // Cobol.
+ pub const HP_unsigned_fixed = 0x8e; // Cobol.
+ pub const HP_VAX_complex_float = 0x8f; // F or G floating complex.
+ pub const HP_VAX_complex_float_d = 0x90; // D floating complex.
+};
+
+pub const CFA = struct {
+ pub const advance_loc = 0x40;
+ pub const offset = 0x80;
+ pub const restore = 0xc0;
+ pub const nop = 0x00;
+ pub const set_loc = 0x01;
+ pub const advance_loc1 = 0x02;
+ pub const advance_loc2 = 0x03;
+ pub const advance_loc4 = 0x04;
+ pub const offset_extended = 0x05;
+ pub const restore_extended = 0x06;
+ pub const @"undefined" = 0x07;
+ pub const same_value = 0x08;
+ pub const register = 0x09;
+ pub const remember_state = 0x0a;
+ pub const restore_state = 0x0b;
+ pub const def_cfa = 0x0c;
+ pub const def_cfa_register = 0x0d;
+ pub const def_cfa_offset = 0x0e;
+
+ // DWARF 3.
+ pub const def_cfa_expression = 0x0f;
+ pub const expression = 0x10;
+ pub const offset_extended_sf = 0x11;
+ pub const def_cfa_sf = 0x12;
+ pub const def_cfa_offset_sf = 0x13;
+ pub const val_offset = 0x14;
+ pub const val_offset_sf = 0x15;
+ pub const val_expression = 0x16;
+
+ pub const lo_user = 0x1c;
+ pub const hi_user = 0x3f;
+
+ // SGI/MIPS specific.
+ pub const MIPS_advance_loc8 = 0x1d;
+
+ // GNU extensions.
+ pub const GNU_window_save = 0x2d;
+ pub const GNU_args_size = 0x2e;
+ pub const GNU_negative_offset_extended = 0x2f;
+};
+
+pub const CHILDREN = struct {
+ pub const no = 0x00;
+ pub const yes = 0x01;
+};
+
+pub const LNS = struct {
+ pub const extended_op = 0x00;
+ pub const copy = 0x01;
+ pub const advance_pc = 0x02;
+ pub const advance_line = 0x03;
+ pub const set_file = 0x04;
+ pub const set_column = 0x05;
+ pub const negate_stmt = 0x06;
+ pub const set_basic_block = 0x07;
+ pub const const_add_pc = 0x08;
+ pub const fixed_advance_pc = 0x09;
+ pub const set_prologue_end = 0x0a;
+ pub const set_epilogue_begin = 0x0b;
+ pub const set_isa = 0x0c;
+};
+
+pub const LNE = struct {
+ pub const end_sequence = 0x01;
+ pub const set_address = 0x02;
+ pub const define_file = 0x03;
+ pub const set_discriminator = 0x04;
+ pub const lo_user = 0x80;
+ pub const hi_user = 0xff;
+};
+
+pub const LANG = struct {
+ pub const C89 = 0x0001;
+ pub const C = 0x0002;
+ pub const Ada83 = 0x0003;
+ pub const C_plus_plus = 0x0004;
+ pub const Cobol74 = 0x0005;
+ pub const Cobol85 = 0x0006;
+ pub const Fortran77 = 0x0007;
+ pub const Fortran90 = 0x0008;
+ pub const Pascal83 = 0x0009;
+ pub const Modula2 = 0x000a;
+ pub const Java = 0x000b;
+ pub const C99 = 0x000c;
+ pub const Ada95 = 0x000d;
+ pub const Fortran95 = 0x000e;
+ pub const PLI = 0x000f;
+ pub const ObjC = 0x0010;
+ pub const ObjC_plus_plus = 0x0011;
+ pub const UPC = 0x0012;
+ pub const D = 0x0013;
+ pub const Python = 0x0014;
+ pub const Go = 0x0016;
+ pub const C_plus_plus_11 = 0x001a;
+ pub const Rust = 0x001c;
+ pub const C11 = 0x001d;
+ pub const C_plus_plus_14 = 0x0021;
+ pub const Fortran03 = 0x0022;
+ pub const Fortran08 = 0x0023;
+ pub const lo_user = 0x8000;
+ pub const hi_user = 0xffff;
+ pub const Mips_Assembler = 0x8001;
+ pub const Upc = 0x8765;
+ pub const HP_Bliss = 0x8003;
+ pub const HP_Basic91 = 0x8004;
+ pub const HP_Pascal91 = 0x8005;
+ pub const HP_IMacro = 0x8006;
+ pub const HP_Assembler = 0x8007;
+};
+
+pub const UT = struct {
+ pub const compile = 0x01;
+ pub const @"type" = 0x02;
+ pub const partial = 0x03;
+ pub const skeleton = 0x04;
+ pub const split_compile = 0x05;
+ pub const split_type = 0x06;
+ pub const lo_user = 0x80;
+ pub const hi_user = 0xff;
+};
+
+pub const LNCT = struct {
+ pub const path = 0x1;
+ pub const directory_index = 0x2;
+ pub const timestamp = 0x3;
+ pub const size = 0x4;
+ pub const MD5 = 0x5;
+ pub const lo_user = 0x2000;
+ pub const hi_user = 0x3fff;
+};
const PcRange = struct {
start: u64,
@@ -322,43 +538,43 @@ fn parseFormValueRef(allocator: *mem.Allocator, in_stream: anytype, endian: buil
// TODO the nosuspends here are workarounds
fn parseFormValue(allocator: *mem.Allocator, in_stream: anytype, form_id: u64, endian: builtin.Endian, is_64: bool) anyerror!FormValue {
return switch (form_id) {
- FORM_addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) },
- FORM_block1 => parseFormValueBlock(allocator, in_stream, endian, 1),
- FORM_block2 => parseFormValueBlock(allocator, in_stream, endian, 2),
- FORM_block4 => parseFormValueBlock(allocator, in_stream, endian, 4),
- FORM_block => {
+ FORM.addr => FormValue{ .Address = try readAddress(in_stream, endian, @sizeOf(usize) == 8) },
+ FORM.block1 => parseFormValueBlock(allocator, in_stream, endian, 1),
+ FORM.block2 => parseFormValueBlock(allocator, in_stream, endian, 2),
+ FORM.block4 => parseFormValueBlock(allocator, in_stream, endian, 4),
+ FORM.block => {
const block_len = try nosuspend leb.readULEB128(usize, in_stream);
return parseFormValueBlockLen(allocator, in_stream, block_len);
},
- FORM_data1 => parseFormValueConstant(allocator, in_stream, false, endian, 1),
- FORM_data2 => parseFormValueConstant(allocator, in_stream, false, endian, 2),
- FORM_data4 => parseFormValueConstant(allocator, in_stream, false, endian, 4),
- FORM_data8 => parseFormValueConstant(allocator, in_stream, false, endian, 8),
- FORM_udata, FORM_sdata => {
- const signed = form_id == FORM_sdata;
+ FORM.data1 => parseFormValueConstant(allocator, in_stream, false, endian, 1),
+ FORM.data2 => parseFormValueConstant(allocator, in_stream, false, endian, 2),
+ FORM.data4 => parseFormValueConstant(allocator, in_stream, false, endian, 4),
+ FORM.data8 => parseFormValueConstant(allocator, in_stream, false, endian, 8),
+ FORM.udata, FORM.sdata => {
+ const signed = form_id == FORM.sdata;
return parseFormValueConstant(allocator, in_stream, signed, endian, -1);
},
- FORM_exprloc => {
+ FORM.exprloc => {
const size = try nosuspend leb.readULEB128(usize, in_stream);
const buf = try readAllocBytes(allocator, in_stream, size);
return FormValue{ .ExprLoc = buf };
},
- FORM_flag => FormValue{ .Flag = (try nosuspend in_stream.readByte()) != 0 },
- FORM_flag_present => FormValue{ .Flag = true },
- FORM_sec_offset => FormValue{ .SecOffset = try readAddress(in_stream, endian, is_64) },
-
- FORM_ref1 => parseFormValueRef(allocator, in_stream, endian, 1),
- FORM_ref2 => parseFormValueRef(allocator, in_stream, endian, 2),
- FORM_ref4 => parseFormValueRef(allocator, in_stream, endian, 4),
- FORM_ref8 => parseFormValueRef(allocator, in_stream, endian, 8),
- FORM_ref_udata => parseFormValueRef(allocator, in_stream, endian, -1),
-
- FORM_ref_addr => FormValue{ .RefAddr = try readAddress(in_stream, endian, is_64) },
- FORM_ref_sig8 => FormValue{ .Ref = try nosuspend in_stream.readInt(u64, endian) },
-
- FORM_string => FormValue{ .String = try in_stream.readUntilDelimiterAlloc(allocator, 0, math.maxInt(usize)) },
- FORM_strp => FormValue{ .StrPtr = try readAddress(in_stream, endian, is_64) },
- FORM_indirect => {
+ FORM.flag => FormValue{ .Flag = (try nosuspend in_stream.readByte()) != 0 },
+ FORM.flag_present => FormValue{ .Flag = true },
+ FORM.sec_offset => FormValue{ .SecOffset = try readAddress(in_stream, endian, is_64) },
+
+ FORM.ref1 => parseFormValueRef(allocator, in_stream, endian, 1),
+ FORM.ref2 => parseFormValueRef(allocator, in_stream, endian, 2),
+ FORM.ref4 => parseFormValueRef(allocator, in_stream, endian, 4),
+ FORM.ref8 => parseFormValueRef(allocator, in_stream, endian, 8),
+ FORM.ref_udata => parseFormValueRef(allocator, in_stream, endian, -1),
+
+ FORM.ref_addr => FormValue{ .RefAddr = try readAddress(in_stream, endian, is_64) },
+ FORM.ref_sig8 => FormValue{ .Ref = try nosuspend in_stream.readInt(u64, endian) },
+
+ FORM.string => FormValue{ .String = try in_stream.readUntilDelimiterAlloc(allocator, 0, math.maxInt(usize)) },
+ FORM.strp => FormValue{ .StrPtr = try readAddress(in_stream, endian, is_64) },
+ FORM.indirect => {
const child_form_id = try nosuspend leb.readULEB128(u64, in_stream);
const F = @TypeOf(async parseFormValue(allocator, in_stream, child_form_id, endian, is_64));
var frame = try allocator.create(F);
@@ -441,24 +657,24 @@ pub const DwarfInfo = struct {
const after_die_offset = try seekable.getPos();
switch (die_obj.tag_id) {
- TAG_subprogram, TAG_inlined_subroutine, TAG_subroutine, TAG_entry_point => {
+ TAG.subprogram, TAG.inlined_subroutine, TAG.subroutine, TAG.entry_point => {
const fn_name = x: {
var depth: i32 = 3;
var this_die_obj = die_obj;
// Prenvent endless loops
while (depth > 0) : (depth -= 1) {
- if (this_die_obj.getAttr(AT_name)) |_| {
- const name = try this_die_obj.getAttrString(di, AT_name);
+ if (this_die_obj.getAttr(AT.name)) |_| {
+ const name = try this_die_obj.getAttrString(di, AT.name);
break :x name;
- } else if (this_die_obj.getAttr(AT_abstract_origin)) |_| {
+ } else if (this_die_obj.getAttr(AT.abstract_origin)) |_| {
// Follow the DIE it points to and repeat
- const ref_offset = try this_die_obj.getAttrRef(AT_abstract_origin);
+ const ref_offset = try this_die_obj.getAttrRef(AT.abstract_origin);
if (ref_offset > next_offset) return error.InvalidDebugInfo;
try seekable.seekTo(this_unit_offset + ref_offset);
this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
- } else if (this_die_obj.getAttr(AT_specification)) |_| {
+ } else if (this_die_obj.getAttr(AT.specification)) |_| {
// Follow the DIE it points to and repeat
- const ref_offset = try this_die_obj.getAttrRef(AT_specification);
+ const ref_offset = try this_die_obj.getAttrRef(AT.specification);
if (ref_offset > next_offset) return error.InvalidDebugInfo;
try seekable.seekTo(this_unit_offset + ref_offset);
this_die_obj = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
@@ -471,8 +687,8 @@ pub const DwarfInfo = struct {
};
const pc_range = x: {
- if (die_obj.getAttrAddr(AT_low_pc)) |low_pc| {
- if (die_obj.getAttr(AT_high_pc)) |high_pc_value| {
+ if (die_obj.getAttrAddr(AT.low_pc)) |low_pc| {
+ if (die_obj.getAttr(AT.high_pc)) |high_pc_value| {
const pc_end = switch (high_pc_value.*) {
FormValue.Address => |value| value,
FormValue.Const => |value| b: {
@@ -539,11 +755,11 @@ pub const DwarfInfo = struct {
const compile_unit_die = try di.allocator().create(Die);
compile_unit_die.* = (try di.parseDie(in, abbrev_table, is_64)) orelse return error.InvalidDebugInfo;
- if (compile_unit_die.tag_id != TAG_compile_unit) return error.InvalidDebugInfo;
+ if (compile_unit_die.tag_id != TAG.compile_unit) return error.InvalidDebugInfo;
const pc_range = x: {
- if (compile_unit_die.getAttrAddr(AT_low_pc)) |low_pc| {
- if (compile_unit_die.getAttr(AT_high_pc)) |high_pc_value| {
+ if (compile_unit_die.getAttrAddr(AT.low_pc)) |low_pc| {
+ if (compile_unit_die.getAttr(AT.high_pc)) |high_pc_value| {
const pc_end = switch (high_pc_value.*) {
FormValue.Address => |value| value,
FormValue.Const => |value| b: {
@@ -582,16 +798,16 @@ pub const DwarfInfo = struct {
if (target_address >= range.start and target_address < range.end) return compile_unit;
}
if (di.debug_ranges) |debug_ranges| {
- if (compile_unit.die.getAttrSecOffset(AT_ranges)) |ranges_offset| {
+ if (compile_unit.die.getAttrSecOffset(AT.ranges)) |ranges_offset| {
var stream = io.fixedBufferStream(debug_ranges);
const in = &stream.reader();
const seekable = &stream.seekableStream();
// All the addresses in the list are relative to the value
- // specified by DW_AT_low_pc or to some other value encoded
+ // specified by DW_AT.low_pc or to some other value encoded
// in the list itself.
// If no starting value is specified use zero.
- var base_address = compile_unit.die.getAttrAddr(AT_low_pc) catch |err| switch (err) {
+ var base_address = compile_unit.die.getAttrAddr(AT.low_pc) catch |err| switch (err) {
error.MissingDebugInfo => 0,
else => return err,
};
@@ -651,7 +867,7 @@ pub const DwarfInfo = struct {
try result.append(AbbrevTableEntry{
.abbrev_code = abbrev_code,
.tag_id = try leb.readULEB128(u64, in),
- .has_children = (try in.readByte()) == CHILDREN_yes,
+ .has_children = (try in.readByte()) == CHILDREN.yes,
.attrs = ArrayList(AbbrevAttr).init(di.allocator()),
});
const attrs = &result.items[result.items.len - 1].attrs;
@@ -693,8 +909,8 @@ pub const DwarfInfo = struct {
const in = &stream.reader();
const seekable = &stream.seekableStream();
- const compile_unit_cwd = try compile_unit.die.getAttrString(di, AT_comp_dir);
- const line_info_offset = try compile_unit.die.getAttrSecOffset(AT_stmt_list);
+ const compile_unit_cwd = try compile_unit.die.getAttrString(di, AT.comp_dir);
+ const line_info_offset = try compile_unit.die.getAttrSecOffset(AT.stmt_list);
try seekable.seekTo(line_info_offset);
@@ -769,21 +985,21 @@ pub const DwarfInfo = struct {
while ((try seekable.getPos()) < next_unit_pos) {
const opcode = try in.readByte();
- if (opcode == LNS_extended_op) {
+ if (opcode == LNS.extended_op) {
const op_size = try leb.readULEB128(u64, in);
if (op_size < 1) return error.InvalidDebugInfo;
var sub_op = try in.readByte();
switch (sub_op) {
- LNE_end_sequence => {
+ LNE.end_sequence => {
prog.end_sequence = true;
if (try prog.checkLineMatch()) |info| return info;
prog.reset();
},
- LNE_set_address => {
+ LNE.set_address => {
const addr = try in.readInt(usize, di.endian);
prog.address = addr;
},
- LNE_define_file => {
+ LNE.define_file => {
const file_name = try in.readUntilDelimiterAlloc(di.allocator(), 0, math.maxInt(usize));
const dir_index = try leb.readULEB128(usize, in);
const mtime = try leb.readULEB128(usize, in);
@@ -811,41 +1027,41 @@ pub const DwarfInfo = struct {
prog.basic_block = false;
} else {
switch (opcode) {
- LNS_copy => {
+ LNS.copy => {
if (try prog.checkLineMatch()) |info| return info;
prog.basic_block = false;
},
- LNS_advance_pc => {
+ LNS.advance_pc => {
const arg = try leb.readULEB128(usize, in);
prog.address += arg * minimum_instruction_length;
},
- LNS_advance_line => {
+ LNS.advance_line => {
const arg = try leb.readILEB128(i64, in);
prog.line += arg;
},
- LNS_set_file => {
+ LNS.set_file => {
const arg = try leb.readULEB128(usize, in);
prog.file = arg;
},
- LNS_set_column => {
+ LNS.set_column => {
const arg = try leb.readULEB128(u64, in);
prog.column = arg;
},
- LNS_negate_stmt => {
+ LNS.negate_stmt => {
prog.is_stmt = !prog.is_stmt;
},
- LNS_set_basic_block => {
+ LNS.set_basic_block => {
prog.basic_block = true;
},
- LNS_const_add_pc => {
+ LNS.const_add_pc => {
const inc_addr = minimum_instruction_length * ((255 - opcode_base) / line_range);
prog.address += inc_addr;
},
- LNS_fixed_advance_pc => {
+ LNS.fixed_advance_pc => {
const arg = try in.readInt(u16, di.endian);
prog.address += arg;
},
- LNS_set_prologue_end => {},
+ LNS.set_prologue_end => {},
else => {
if (opcode - 1 >= standard_opcode_lengths.len) return error.InvalidDebugInfo;
const len_bytes = standard_opcode_lengths[opcode - 1];
lib/std/dwarf_bits.zig
@@ -1,699 +0,0 @@
-pub const TAG_padding = 0x00;
-pub const TAG_array_type = 0x01;
-pub const TAG_class_type = 0x02;
-pub const TAG_entry_point = 0x03;
-pub const TAG_enumeration_type = 0x04;
-pub const TAG_formal_parameter = 0x05;
-pub const TAG_imported_declaration = 0x08;
-pub const TAG_label = 0x0a;
-pub const TAG_lexical_block = 0x0b;
-pub const TAG_member = 0x0d;
-pub const TAG_pointer_type = 0x0f;
-pub const TAG_reference_type = 0x10;
-pub const TAG_compile_unit = 0x11;
-pub const TAG_string_type = 0x12;
-pub const TAG_structure_type = 0x13;
-pub const TAG_subroutine = 0x14;
-pub const TAG_subroutine_type = 0x15;
-pub const TAG_typedef = 0x16;
-pub const TAG_union_type = 0x17;
-pub const TAG_unspecified_parameters = 0x18;
-pub const TAG_variant = 0x19;
-pub const TAG_common_block = 0x1a;
-pub const TAG_common_inclusion = 0x1b;
-pub const TAG_inheritance = 0x1c;
-pub const TAG_inlined_subroutine = 0x1d;
-pub const TAG_module = 0x1e;
-pub const TAG_ptr_to_member_type = 0x1f;
-pub const TAG_set_type = 0x20;
-pub const TAG_subrange_type = 0x21;
-pub const TAG_with_stmt = 0x22;
-pub const TAG_access_declaration = 0x23;
-pub const TAG_base_type = 0x24;
-pub const TAG_catch_block = 0x25;
-pub const TAG_const_type = 0x26;
-pub const TAG_constant = 0x27;
-pub const TAG_enumerator = 0x28;
-pub const TAG_file_type = 0x29;
-pub const TAG_friend = 0x2a;
-pub const TAG_namelist = 0x2b;
-pub const TAG_namelist_item = 0x2c;
-pub const TAG_packed_type = 0x2d;
-pub const TAG_subprogram = 0x2e;
-pub const TAG_template_type_param = 0x2f;
-pub const TAG_template_value_param = 0x30;
-pub const TAG_thrown_type = 0x31;
-pub const TAG_try_block = 0x32;
-pub const TAG_variant_part = 0x33;
-pub const TAG_variable = 0x34;
-pub const TAG_volatile_type = 0x35;
-
-// DWARF 3
-pub const TAG_dwarf_procedure = 0x36;
-pub const TAG_restrict_type = 0x37;
-pub const TAG_interface_type = 0x38;
-pub const TAG_namespace = 0x39;
-pub const TAG_imported_module = 0x3a;
-pub const TAG_unspecified_type = 0x3b;
-pub const TAG_partial_unit = 0x3c;
-pub const TAG_imported_unit = 0x3d;
-pub const TAG_condition = 0x3f;
-pub const TAG_shared_type = 0x40;
-
-// DWARF 4
-pub const TAG_type_unit = 0x41;
-pub const TAG_rvalue_reference_type = 0x42;
-pub const TAG_template_alias = 0x43;
-
-pub const TAG_lo_user = 0x4080;
-pub const TAG_hi_user = 0xffff;
-
-// SGI/MIPS Extensions.
-pub const TAG_MIPS_loop = 0x4081;
-
-// HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz .
-pub const TAG_HP_array_descriptor = 0x4090;
-pub const TAG_HP_Bliss_field = 0x4091;
-pub const TAG_HP_Bliss_field_set = 0x4092;
-
-// GNU extensions.
-pub const TAG_format_label = 0x4101; // For FORTRAN 77 and Fortran 90.
-pub const TAG_function_template = 0x4102; // For C++.
-pub const TAG_class_template = 0x4103; //For C++.
-pub const TAG_GNU_BINCL = 0x4104;
-pub const TAG_GNU_EINCL = 0x4105;
-
-// Template template parameter.
-// See http://gcc.gnu.org/wiki/TemplateParmsDwarf .
-pub const TAG_GNU_template_template_param = 0x4106;
-
-// Template parameter pack extension = specified at
-// http://wiki.dwarfstd.org/index.php?title=C%2B%2B0x:_Variadic_templates
-// The values of these two TAGS are in the DW_TAG_GNU_* space until the tags
-// are properly part of DWARF 5.
-pub const TAG_GNU_template_parameter_pack = 0x4107;
-pub const TAG_GNU_formal_parameter_pack = 0x4108;
-// The GNU call site extension = specified at
-// http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open .
-// The values of these two TAGS are in the DW_TAG_GNU_* space until the tags
-// are properly part of DWARF 5.
-pub const TAG_GNU_call_site = 0x4109;
-pub const TAG_GNU_call_site_parameter = 0x410a;
-// Extensions for UPC. See: http://dwarfstd.org/doc/DWARF4.pdf.
-pub const TAG_upc_shared_type = 0x8765;
-pub const TAG_upc_strict_type = 0x8766;
-pub const TAG_upc_relaxed_type = 0x8767;
-// PGI (STMicroelectronics; extensions. No documentation available.
-pub const TAG_PGI_kanji_type = 0xA000;
-pub const TAG_PGI_interface_block = 0xA020;
-
-pub const FORM_addr = 0x01;
-pub const FORM_block2 = 0x03;
-pub const FORM_block4 = 0x04;
-pub const FORM_data2 = 0x05;
-pub const FORM_data4 = 0x06;
-pub const FORM_data8 = 0x07;
-pub const FORM_string = 0x08;
-pub const FORM_block = 0x09;
-pub const FORM_block1 = 0x0a;
-pub const FORM_data1 = 0x0b;
-pub const FORM_flag = 0x0c;
-pub const FORM_sdata = 0x0d;
-pub const FORM_strp = 0x0e;
-pub const FORM_udata = 0x0f;
-pub const FORM_ref_addr = 0x10;
-pub const FORM_ref1 = 0x11;
-pub const FORM_ref2 = 0x12;
-pub const FORM_ref4 = 0x13;
-pub const FORM_ref8 = 0x14;
-pub const FORM_ref_udata = 0x15;
-pub const FORM_indirect = 0x16;
-pub const FORM_sec_offset = 0x17;
-pub const FORM_exprloc = 0x18;
-pub const FORM_flag_present = 0x19;
-pub const FORM_ref_sig8 = 0x20;
-
-// Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
-pub const FORM_GNU_addr_index = 0x1f01;
-pub const FORM_GNU_str_index = 0x1f02;
-
-// Extensions for DWZ multifile.
-// See http://www.dwarfstd.org/ShowIssue.php?issue=120604.1&type=open .
-pub const FORM_GNU_ref_alt = 0x1f20;
-pub const FORM_GNU_strp_alt = 0x1f21;
-
-pub const AT_sibling = 0x01;
-pub const AT_location = 0x02;
-pub const AT_name = 0x03;
-pub const AT_ordering = 0x09;
-pub const AT_subscr_data = 0x0a;
-pub const AT_byte_size = 0x0b;
-pub const AT_bit_offset = 0x0c;
-pub const AT_bit_size = 0x0d;
-pub const AT_element_list = 0x0f;
-pub const AT_stmt_list = 0x10;
-pub const AT_low_pc = 0x11;
-pub const AT_high_pc = 0x12;
-pub const AT_language = 0x13;
-pub const AT_member = 0x14;
-pub const AT_discr = 0x15;
-pub const AT_discr_value = 0x16;
-pub const AT_visibility = 0x17;
-pub const AT_import = 0x18;
-pub const AT_string_length = 0x19;
-pub const AT_common_reference = 0x1a;
-pub const AT_comp_dir = 0x1b;
-pub const AT_const_value = 0x1c;
-pub const AT_containing_type = 0x1d;
-pub const AT_default_value = 0x1e;
-pub const AT_inline = 0x20;
-pub const AT_is_optional = 0x21;
-pub const AT_lower_bound = 0x22;
-pub const AT_producer = 0x25;
-pub const AT_prototyped = 0x27;
-pub const AT_return_addr = 0x2a;
-pub const AT_start_scope = 0x2c;
-pub const AT_bit_stride = 0x2e;
-pub const AT_upper_bound = 0x2f;
-pub const AT_abstract_origin = 0x31;
-pub const AT_accessibility = 0x32;
-pub const AT_address_class = 0x33;
-pub const AT_artificial = 0x34;
-pub const AT_base_types = 0x35;
-pub const AT_calling_convention = 0x36;
-pub const AT_count = 0x37;
-pub const AT_data_member_location = 0x38;
-pub const AT_decl_column = 0x39;
-pub const AT_decl_file = 0x3a;
-pub const AT_decl_line = 0x3b;
-pub const AT_declaration = 0x3c;
-pub const AT_discr_list = 0x3d;
-pub const AT_encoding = 0x3e;
-pub const AT_external = 0x3f;
-pub const AT_frame_base = 0x40;
-pub const AT_friend = 0x41;
-pub const AT_identifier_case = 0x42;
-pub const AT_macro_info = 0x43;
-pub const AT_namelist_items = 0x44;
-pub const AT_priority = 0x45;
-pub const AT_segment = 0x46;
-pub const AT_specification = 0x47;
-pub const AT_static_link = 0x48;
-pub const AT_type = 0x49;
-pub const AT_use_location = 0x4a;
-pub const AT_variable_parameter = 0x4b;
-pub const AT_virtuality = 0x4c;
-pub const AT_vtable_elem_location = 0x4d;
-
-// DWARF 3 values.
-pub const AT_allocated = 0x4e;
-pub const AT_associated = 0x4f;
-pub const AT_data_location = 0x50;
-pub const AT_byte_stride = 0x51;
-pub const AT_entry_pc = 0x52;
-pub const AT_use_UTF8 = 0x53;
-pub const AT_extension = 0x54;
-pub const AT_ranges = 0x55;
-pub const AT_trampoline = 0x56;
-pub const AT_call_column = 0x57;
-pub const AT_call_file = 0x58;
-pub const AT_call_line = 0x59;
-pub const AT_description = 0x5a;
-pub const AT_binary_scale = 0x5b;
-pub const AT_decimal_scale = 0x5c;
-pub const AT_small = 0x5d;
-pub const AT_decimal_sign = 0x5e;
-pub const AT_digit_count = 0x5f;
-pub const AT_picture_string = 0x60;
-pub const AT_mutable = 0x61;
-pub const AT_threads_scaled = 0x62;
-pub const AT_explicit = 0x63;
-pub const AT_object_pointer = 0x64;
-pub const AT_endianity = 0x65;
-pub const AT_elemental = 0x66;
-pub const AT_pure = 0x67;
-pub const AT_recursive = 0x68;
-
-// DWARF 4.
-pub const AT_signature = 0x69;
-pub const AT_main_subprogram = 0x6a;
-pub const AT_data_bit_offset = 0x6b;
-pub const AT_const_expr = 0x6c;
-pub const AT_enum_class = 0x6d;
-pub const AT_linkage_name = 0x6e;
-
-// DWARF 5
-pub const AT_alignment = 0x88;
-
-pub const AT_lo_user = 0x2000; // Implementation-defined range start.
-pub const AT_hi_user = 0x3fff; // Implementation-defined range end.
-
-// SGI/MIPS extensions.
-pub const AT_MIPS_fde = 0x2001;
-pub const AT_MIPS_loop_begin = 0x2002;
-pub const AT_MIPS_tail_loop_begin = 0x2003;
-pub const AT_MIPS_epilog_begin = 0x2004;
-pub const AT_MIPS_loop_unroll_factor = 0x2005;
-pub const AT_MIPS_software_pipeline_depth = 0x2006;
-pub const AT_MIPS_linkage_name = 0x2007;
-pub const AT_MIPS_stride = 0x2008;
-pub const AT_MIPS_abstract_name = 0x2009;
-pub const AT_MIPS_clone_origin = 0x200a;
-pub const AT_MIPS_has_inlines = 0x200b;
-
-// HP extensions.
-pub const AT_HP_block_index = 0x2000;
-pub const AT_HP_unmodifiable = 0x2001; // Same as AT_MIPS_fde.
-pub const AT_HP_prologue = 0x2005; // Same as AT_MIPS_loop_unroll.
-pub const AT_HP_epilogue = 0x2008; // Same as AT_MIPS_stride.
-pub const AT_HP_actuals_stmt_list = 0x2010;
-pub const AT_HP_proc_per_section = 0x2011;
-pub const AT_HP_raw_data_ptr = 0x2012;
-pub const AT_HP_pass_by_reference = 0x2013;
-pub const AT_HP_opt_level = 0x2014;
-pub const AT_HP_prof_version_id = 0x2015;
-pub const AT_HP_opt_flags = 0x2016;
-pub const AT_HP_cold_region_low_pc = 0x2017;
-pub const AT_HP_cold_region_high_pc = 0x2018;
-pub const AT_HP_all_variables_modifiable = 0x2019;
-pub const AT_HP_linkage_name = 0x201a;
-pub const AT_HP_prof_flags = 0x201b; // In comp unit of procs_info for -g.
-pub const AT_HP_unit_name = 0x201f;
-pub const AT_HP_unit_size = 0x2020;
-pub const AT_HP_widened_byte_size = 0x2021;
-pub const AT_HP_definition_points = 0x2022;
-pub const AT_HP_default_location = 0x2023;
-pub const AT_HP_is_result_param = 0x2029;
-
-// GNU extensions.
-pub const AT_sf_names = 0x2101;
-pub const AT_src_info = 0x2102;
-pub const AT_mac_info = 0x2103;
-pub const AT_src_coords = 0x2104;
-pub const AT_body_begin = 0x2105;
-pub const AT_body_end = 0x2106;
-pub const AT_GNU_vector = 0x2107;
-// Thread-safety annotations.
-// See http://gcc.gnu.org/wiki/ThreadSafetyAnnotation .
-pub const AT_GNU_guarded_by = 0x2108;
-pub const AT_GNU_pt_guarded_by = 0x2109;
-pub const AT_GNU_guarded = 0x210a;
-pub const AT_GNU_pt_guarded = 0x210b;
-pub const AT_GNU_locks_excluded = 0x210c;
-pub const AT_GNU_exclusive_locks_required = 0x210d;
-pub const AT_GNU_shared_locks_required = 0x210e;
-// One-definition rule violation detection.
-// See http://gcc.gnu.org/wiki/DwarfSeparateTypeInfo .
-pub const AT_GNU_odr_signature = 0x210f;
-// Template template argument name.
-// See http://gcc.gnu.org/wiki/TemplateParmsDwarf .
-pub const AT_GNU_template_name = 0x2110;
-// The GNU call site extension.
-// See http://www.dwarfstd.org/ShowIssue.php?issue=100909.2&type=open .
-pub const AT_GNU_call_site_value = 0x2111;
-pub const AT_GNU_call_site_data_value = 0x2112;
-pub const AT_GNU_call_site_target = 0x2113;
-pub const AT_GNU_call_site_target_clobbered = 0x2114;
-pub const AT_GNU_tail_call = 0x2115;
-pub const AT_GNU_all_tail_call_sites = 0x2116;
-pub const AT_GNU_all_call_sites = 0x2117;
-pub const AT_GNU_all_source_call_sites = 0x2118;
-// Section offset into .debug_macro section.
-pub const AT_GNU_macros = 0x2119;
-// Extensions for Fission. See http://gcc.gnu.org/wiki/DebugFission.
-pub const AT_GNU_dwo_name = 0x2130;
-pub const AT_GNU_dwo_id = 0x2131;
-pub const AT_GNU_ranges_base = 0x2132;
-pub const AT_GNU_addr_base = 0x2133;
-pub const AT_GNU_pubnames = 0x2134;
-pub const AT_GNU_pubtypes = 0x2135;
-// VMS extensions.
-pub const AT_VMS_rtnbeg_pd_address = 0x2201;
-// GNAT extensions.
-// GNAT descriptive type.
-// See http://gcc.gnu.org/wiki/DW_AT_GNAT_descriptive_type .
-pub const AT_use_GNAT_descriptive_type = 0x2301;
-pub const AT_GNAT_descriptive_type = 0x2302;
-// UPC extension.
-pub const AT_upc_threads_scaled = 0x3210;
-// PGI (STMicroelectronics) extensions.
-pub const AT_PGI_lbase = 0x3a00;
-pub const AT_PGI_soffset = 0x3a01;
-pub const AT_PGI_lstride = 0x3a02;
-
-pub const OP_addr = 0x03;
-pub const OP_deref = 0x06;
-pub const OP_const1u = 0x08;
-pub const OP_const1s = 0x09;
-pub const OP_const2u = 0x0a;
-pub const OP_const2s = 0x0b;
-pub const OP_const4u = 0x0c;
-pub const OP_const4s = 0x0d;
-pub const OP_const8u = 0x0e;
-pub const OP_const8s = 0x0f;
-pub const OP_constu = 0x10;
-pub const OP_consts = 0x11;
-pub const OP_dup = 0x12;
-pub const OP_drop = 0x13;
-pub const OP_over = 0x14;
-pub const OP_pick = 0x15;
-pub const OP_swap = 0x16;
-pub const OP_rot = 0x17;
-pub const OP_xderef = 0x18;
-pub const OP_abs = 0x19;
-pub const OP_and = 0x1a;
-pub const OP_div = 0x1b;
-pub const OP_minus = 0x1c;
-pub const OP_mod = 0x1d;
-pub const OP_mul = 0x1e;
-pub const OP_neg = 0x1f;
-pub const OP_not = 0x20;
-pub const OP_or = 0x21;
-pub const OP_plus = 0x22;
-pub const OP_plus_uconst = 0x23;
-pub const OP_shl = 0x24;
-pub const OP_shr = 0x25;
-pub const OP_shra = 0x26;
-pub const OP_xor = 0x27;
-pub const OP_bra = 0x28;
-pub const OP_eq = 0x29;
-pub const OP_ge = 0x2a;
-pub const OP_gt = 0x2b;
-pub const OP_le = 0x2c;
-pub const OP_lt = 0x2d;
-pub const OP_ne = 0x2e;
-pub const OP_skip = 0x2f;
-pub const OP_lit0 = 0x30;
-pub const OP_lit1 = 0x31;
-pub const OP_lit2 = 0x32;
-pub const OP_lit3 = 0x33;
-pub const OP_lit4 = 0x34;
-pub const OP_lit5 = 0x35;
-pub const OP_lit6 = 0x36;
-pub const OP_lit7 = 0x37;
-pub const OP_lit8 = 0x38;
-pub const OP_lit9 = 0x39;
-pub const OP_lit10 = 0x3a;
-pub const OP_lit11 = 0x3b;
-pub const OP_lit12 = 0x3c;
-pub const OP_lit13 = 0x3d;
-pub const OP_lit14 = 0x3e;
-pub const OP_lit15 = 0x3f;
-pub const OP_lit16 = 0x40;
-pub const OP_lit17 = 0x41;
-pub const OP_lit18 = 0x42;
-pub const OP_lit19 = 0x43;
-pub const OP_lit20 = 0x44;
-pub const OP_lit21 = 0x45;
-pub const OP_lit22 = 0x46;
-pub const OP_lit23 = 0x47;
-pub const OP_lit24 = 0x48;
-pub const OP_lit25 = 0x49;
-pub const OP_lit26 = 0x4a;
-pub const OP_lit27 = 0x4b;
-pub const OP_lit28 = 0x4c;
-pub const OP_lit29 = 0x4d;
-pub const OP_lit30 = 0x4e;
-pub const OP_lit31 = 0x4f;
-pub const OP_reg0 = 0x50;
-pub const OP_reg1 = 0x51;
-pub const OP_reg2 = 0x52;
-pub const OP_reg3 = 0x53;
-pub const OP_reg4 = 0x54;
-pub const OP_reg5 = 0x55;
-pub const OP_reg6 = 0x56;
-pub const OP_reg7 = 0x57;
-pub const OP_reg8 = 0x58;
-pub const OP_reg9 = 0x59;
-pub const OP_reg10 = 0x5a;
-pub const OP_reg11 = 0x5b;
-pub const OP_reg12 = 0x5c;
-pub const OP_reg13 = 0x5d;
-pub const OP_reg14 = 0x5e;
-pub const OP_reg15 = 0x5f;
-pub const OP_reg16 = 0x60;
-pub const OP_reg17 = 0x61;
-pub const OP_reg18 = 0x62;
-pub const OP_reg19 = 0x63;
-pub const OP_reg20 = 0x64;
-pub const OP_reg21 = 0x65;
-pub const OP_reg22 = 0x66;
-pub const OP_reg23 = 0x67;
-pub const OP_reg24 = 0x68;
-pub const OP_reg25 = 0x69;
-pub const OP_reg26 = 0x6a;
-pub const OP_reg27 = 0x6b;
-pub const OP_reg28 = 0x6c;
-pub const OP_reg29 = 0x6d;
-pub const OP_reg30 = 0x6e;
-pub const OP_reg31 = 0x6f;
-pub const OP_breg0 = 0x70;
-pub const OP_breg1 = 0x71;
-pub const OP_breg2 = 0x72;
-pub const OP_breg3 = 0x73;
-pub const OP_breg4 = 0x74;
-pub const OP_breg5 = 0x75;
-pub const OP_breg6 = 0x76;
-pub const OP_breg7 = 0x77;
-pub const OP_breg8 = 0x78;
-pub const OP_breg9 = 0x79;
-pub const OP_breg10 = 0x7a;
-pub const OP_breg11 = 0x7b;
-pub const OP_breg12 = 0x7c;
-pub const OP_breg13 = 0x7d;
-pub const OP_breg14 = 0x7e;
-pub const OP_breg15 = 0x7f;
-pub const OP_breg16 = 0x80;
-pub const OP_breg17 = 0x81;
-pub const OP_breg18 = 0x82;
-pub const OP_breg19 = 0x83;
-pub const OP_breg20 = 0x84;
-pub const OP_breg21 = 0x85;
-pub const OP_breg22 = 0x86;
-pub const OP_breg23 = 0x87;
-pub const OP_breg24 = 0x88;
-pub const OP_breg25 = 0x89;
-pub const OP_breg26 = 0x8a;
-pub const OP_breg27 = 0x8b;
-pub const OP_breg28 = 0x8c;
-pub const OP_breg29 = 0x8d;
-pub const OP_breg30 = 0x8e;
-pub const OP_breg31 = 0x8f;
-pub const OP_regx = 0x90;
-pub const OP_fbreg = 0x91;
-pub const OP_bregx = 0x92;
-pub const OP_piece = 0x93;
-pub const OP_deref_size = 0x94;
-pub const OP_xderef_size = 0x95;
-pub const OP_nop = 0x96;
-
-// DWARF 3 extensions.
-pub const OP_push_object_address = 0x97;
-pub const OP_call2 = 0x98;
-pub const OP_call4 = 0x99;
-pub const OP_call_ref = 0x9a;
-pub const OP_form_tls_address = 0x9b;
-pub const OP_call_frame_cfa = 0x9c;
-pub const OP_bit_piece = 0x9d;
-
-// DWARF 4 extensions.
-pub const OP_implicit_value = 0x9e;
-pub const OP_stack_value = 0x9f;
-
-pub const OP_lo_user = 0xe0; // Implementation-defined range start.
-pub const OP_hi_user = 0xff; // Implementation-defined range end.
-
-// GNU extensions.
-pub const OP_GNU_push_tls_address = 0xe0;
-// The following is for marking variables that are uninitialized.
-pub const OP_GNU_uninit = 0xf0;
-pub const OP_GNU_encoded_addr = 0xf1;
-// The GNU implicit pointer extension.
-// See http://www.dwarfstd.org/ShowIssue.php?issue=100831.1&type=open .
-pub const OP_GNU_implicit_pointer = 0xf2;
-// The GNU entry value extension.
-// See http://www.dwarfstd.org/ShowIssue.php?issue=100909.1&type=open .
-pub const OP_GNU_entry_value = 0xf3;
-// The GNU typed stack extension.
-// See http://www.dwarfstd.org/doc/040408.1.html .
-pub const OP_GNU_const_type = 0xf4;
-pub const OP_GNU_regval_type = 0xf5;
-pub const OP_GNU_deref_type = 0xf6;
-pub const OP_GNU_convert = 0xf7;
-pub const OP_GNU_reinterpret = 0xf9;
-// The GNU parameter ref extension.
-pub const OP_GNU_parameter_ref = 0xfa;
-// Extension for Fission. See http://gcc.gnu.org/wiki/DebugFission.
-pub const OP_GNU_addr_index = 0xfb;
-pub const OP_GNU_const_index = 0xfc;
-// HP extensions.
-pub const OP_HP_unknown = 0xe0; // Ouch, the same as GNU_push_tls_address.
-pub const OP_HP_is_value = 0xe1;
-pub const OP_HP_fltconst4 = 0xe2;
-pub const OP_HP_fltconst8 = 0xe3;
-pub const OP_HP_mod_range = 0xe4;
-pub const OP_HP_unmod_range = 0xe5;
-pub const OP_HP_tls = 0xe6;
-// PGI (STMicroelectronics) extensions.
-pub const OP_PGI_omp_thread_num = 0xf8;
-
-pub const ATE_void = 0x0;
-pub const ATE_address = 0x1;
-pub const ATE_boolean = 0x2;
-pub const ATE_complex_float = 0x3;
-pub const ATE_float = 0x4;
-pub const ATE_signed = 0x5;
-pub const ATE_signed_char = 0x6;
-pub const ATE_unsigned = 0x7;
-pub const ATE_unsigned_char = 0x8;
-
-// DWARF 3.
-pub const ATE_imaginary_float = 0x9;
-pub const ATE_packed_decimal = 0xa;
-pub const ATE_numeric_string = 0xb;
-pub const ATE_edited = 0xc;
-pub const ATE_signed_fixed = 0xd;
-pub const ATE_unsigned_fixed = 0xe;
-pub const ATE_decimal_float = 0xf;
-
-// DWARF 4.
-pub const ATE_UTF = 0x10;
-
-pub const ATE_lo_user = 0x80;
-pub const ATE_hi_user = 0xff;
-
-// HP extensions.
-pub const ATE_HP_float80 = 0x80; // Floating-point (80 bit).
-pub const ATE_HP_complex_float80 = 0x81; // Complex floating-point (80 bit).
-pub const ATE_HP_float128 = 0x82; // Floating-point (128 bit).
-pub const ATE_HP_complex_float128 = 0x83; // Complex fp (128 bit).
-pub const ATE_HP_floathpintel = 0x84; // Floating-point (82 bit IA64).
-pub const ATE_HP_imaginary_float80 = 0x85;
-pub const ATE_HP_imaginary_float128 = 0x86;
-pub const ATE_HP_VAX_float = 0x88; // F or G floating.
-pub const ATE_HP_VAX_float_d = 0x89; // D floating.
-pub const ATE_HP_packed_decimal = 0x8a; // Cobol.
-pub const ATE_HP_zoned_decimal = 0x8b; // Cobol.
-pub const ATE_HP_edited = 0x8c; // Cobol.
-pub const ATE_HP_signed_fixed = 0x8d; // Cobol.
-pub const ATE_HP_unsigned_fixed = 0x8e; // Cobol.
-pub const ATE_HP_VAX_complex_float = 0x8f; // F or G floating complex.
-pub const ATE_HP_VAX_complex_float_d = 0x90; // D floating complex.
-
-pub const CFA_advance_loc = 0x40;
-pub const CFA_offset = 0x80;
-pub const CFA_restore = 0xc0;
-pub const CFA_nop = 0x00;
-pub const CFA_set_loc = 0x01;
-pub const CFA_advance_loc1 = 0x02;
-pub const CFA_advance_loc2 = 0x03;
-pub const CFA_advance_loc4 = 0x04;
-pub const CFA_offset_extended = 0x05;
-pub const CFA_restore_extended = 0x06;
-pub const CFA_undefined = 0x07;
-pub const CFA_same_value = 0x08;
-pub const CFA_register = 0x09;
-pub const CFA_remember_state = 0x0a;
-pub const CFA_restore_state = 0x0b;
-pub const CFA_def_cfa = 0x0c;
-pub const CFA_def_cfa_register = 0x0d;
-pub const CFA_def_cfa_offset = 0x0e;
-
-// DWARF 3.
-pub const CFA_def_cfa_expression = 0x0f;
-pub const CFA_expression = 0x10;
-pub const CFA_offset_extended_sf = 0x11;
-pub const CFA_def_cfa_sf = 0x12;
-pub const CFA_def_cfa_offset_sf = 0x13;
-pub const CFA_val_offset = 0x14;
-pub const CFA_val_offset_sf = 0x15;
-pub const CFA_val_expression = 0x16;
-
-pub const CFA_lo_user = 0x1c;
-pub const CFA_hi_user = 0x3f;
-
-// SGI/MIPS specific.
-pub const CFA_MIPS_advance_loc8 = 0x1d;
-
-// GNU extensions.
-pub const CFA_GNU_window_save = 0x2d;
-pub const CFA_GNU_args_size = 0x2e;
-pub const CFA_GNU_negative_offset_extended = 0x2f;
-
-pub const CHILDREN_no = 0x00;
-pub const CHILDREN_yes = 0x01;
-
-pub const LNS_extended_op = 0x00;
-pub const LNS_copy = 0x01;
-pub const LNS_advance_pc = 0x02;
-pub const LNS_advance_line = 0x03;
-pub const LNS_set_file = 0x04;
-pub const LNS_set_column = 0x05;
-pub const LNS_negate_stmt = 0x06;
-pub const LNS_set_basic_block = 0x07;
-pub const LNS_const_add_pc = 0x08;
-pub const LNS_fixed_advance_pc = 0x09;
-pub const LNS_set_prologue_end = 0x0a;
-pub const LNS_set_epilogue_begin = 0x0b;
-pub const LNS_set_isa = 0x0c;
-
-pub const LNE_end_sequence = 0x01;
-pub const LNE_set_address = 0x02;
-pub const LNE_define_file = 0x03;
-pub const LNE_set_discriminator = 0x04;
-pub const LNE_lo_user = 0x80;
-pub const LNE_hi_user = 0xff;
-
-pub const LANG_C89 = 0x0001;
-pub const LANG_C = 0x0002;
-pub const LANG_Ada83 = 0x0003;
-pub const LANG_C_plus_plus = 0x0004;
-pub const LANG_Cobol74 = 0x0005;
-pub const LANG_Cobol85 = 0x0006;
-pub const LANG_Fortran77 = 0x0007;
-pub const LANG_Fortran90 = 0x0008;
-pub const LANG_Pascal83 = 0x0009;
-pub const LANG_Modula2 = 0x000a;
-pub const LANG_Java = 0x000b;
-pub const LANG_C99 = 0x000c;
-pub const LANG_Ada95 = 0x000d;
-pub const LANG_Fortran95 = 0x000e;
-pub const LANG_PLI = 0x000f;
-pub const LANG_ObjC = 0x0010;
-pub const LANG_ObjC_plus_plus = 0x0011;
-pub const LANG_UPC = 0x0012;
-pub const LANG_D = 0x0013;
-pub const LANG_Python = 0x0014;
-pub const LANG_Go = 0x0016;
-pub const LANG_C_plus_plus_11 = 0x001a;
-pub const LANG_Rust = 0x001c;
-pub const LANG_C11 = 0x001d;
-pub const LANG_C_plus_plus_14 = 0x0021;
-pub const LANG_Fortran03 = 0x0022;
-pub const LANG_Fortran08 = 0x0023;
-pub const LANG_lo_user = 0x8000;
-pub const LANG_hi_user = 0xffff;
-pub const LANG_Mips_Assembler = 0x8001;
-pub const LANG_Upc = 0x8765;
-pub const LANG_HP_Bliss = 0x8003;
-pub const LANG_HP_Basic91 = 0x8004;
-pub const LANG_HP_Pascal91 = 0x8005;
-pub const LANG_HP_IMacro = 0x8006;
-pub const LANG_HP_Assembler = 0x8007;
-
-pub const UT_compile = 0x01;
-pub const UT_type = 0x02;
-pub const UT_partial = 0x03;
-pub const UT_skeleton = 0x04;
-pub const UT_split_compile = 0x05;
-pub const UT_split_type = 0x06;
-pub const UT_lo_user = 0x80;
-pub const UT_hi_user = 0xff;
-
-pub const LNCT_path = 0x1;
-pub const LNCT_directory_index = 0x2;
-pub const LNCT_timestamp = 0x3;
-pub const LNCT_size = 0x4;
-pub const LNCT_MD5 = 0x5;
-pub const LNCT_lo_user = 0x2000;
-pub const LNCT_hi_user = 0x3fff;
lib/std/fmt.zig
@@ -902,7 +902,7 @@ pub fn formatText(
} else if (comptime std.mem.eql(u8, fmt, "Z")) {
@compileError("specifier 'Z' has been deprecated, wrap your argument in std.zig.fmtEscapes instead");
} else {
- @compileError("Unsupported format string '" ++ fmt ++ "' for type '" ++ @typeName(@TypeOf(value)) ++ "'");
+ @compileError("Unsupported format string '" ++ fmt ++ "' when formatting text");
}
}
lib/std/fs.zig
@@ -880,20 +880,20 @@ pub const Dir = struct {
var fdflags: w.fdflags_t = 0x0;
var base: w.rights_t = 0x0;
if (flags.read) {
- base |= w.RIGHT_FD_READ | w.RIGHT_FD_TELL | w.RIGHT_FD_SEEK | w.RIGHT_FD_FILESTAT_GET;
+ base |= w.RIGHT.FD_READ | w.RIGHT.FD_TELL | w.RIGHT.FD_SEEK | w.RIGHT.FD_FILESTAT_GET;
}
if (flags.write) {
- fdflags |= w.FDFLAG_APPEND;
- base |= w.RIGHT_FD_WRITE |
- w.RIGHT_FD_TELL |
- w.RIGHT_FD_SEEK |
- w.RIGHT_FD_DATASYNC |
- w.RIGHT_FD_FDSTAT_SET_FLAGS |
- w.RIGHT_FD_SYNC |
- w.RIGHT_FD_ALLOCATE |
- w.RIGHT_FD_ADVISE |
- w.RIGHT_FD_FILESTAT_SET_TIMES |
- w.RIGHT_FD_FILESTAT_SET_SIZE;
+ fdflags |= w.FDFLAG.APPEND;
+ base |= w.RIGHT.FD_WRITE |
+ w.RIGHT.FD_TELL |
+ w.RIGHT.FD_SEEK |
+ w.RIGHT.FD_DATASYNC |
+ w.RIGHT.FD_FDSTAT_SET_FLAGS |
+ w.RIGHT.FD_SYNC |
+ w.RIGHT.FD_ALLOCATE |
+ w.RIGHT.FD_ADVISE |
+ w.RIGHT.FD_FILESTAT_SET_TIMES |
+ w.RIGHT.FD_FILESTAT_SET_SIZE;
}
const fd = try os.openatWasi(self.fd, sub_path, 0x0, 0x0, fdflags, base, 0x0);
return File{ .handle = fd };
@@ -958,14 +958,14 @@ pub const Dir = struct {
}
if (has_flock_open_flags and flags.lock_nonblocking) {
- var fl_flags = os.fcntl(fd, os.F_GETFL, 0) catch |err| switch (err) {
+ var fl_flags = os.fcntl(fd, os.F.GETFL, 0) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
else => |e| return e,
};
fl_flags &= ~@as(usize, os.O.NONBLOCK);
- _ = os.fcntl(fd, os.F_SETFL, fl_flags) catch |err| switch (err) {
+ _ = os.fcntl(fd, os.F.SETFL, fl_flags) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
@@ -1040,19 +1040,19 @@ pub const Dir = struct {
pub fn createFileWasi(self: Dir, sub_path: []const u8, flags: File.CreateFlags) File.OpenError!File {
const w = os.wasi;
var oflags = w.O.CREAT;
- var base: w.rights_t = w.RIGHT_FD_WRITE |
- w.RIGHT_FD_DATASYNC |
- w.RIGHT_FD_SEEK |
- w.RIGHT_FD_TELL |
- w.RIGHT_FD_FDSTAT_SET_FLAGS |
- w.RIGHT_FD_SYNC |
- w.RIGHT_FD_ALLOCATE |
- w.RIGHT_FD_ADVISE |
- w.RIGHT_FD_FILESTAT_SET_TIMES |
- w.RIGHT_FD_FILESTAT_SET_SIZE |
- w.RIGHT_FD_FILESTAT_GET;
+ var base: w.rights_t = w.RIGHT.FD_WRITE |
+ w.RIGHT.FD_DATASYNC |
+ w.RIGHT.FD_SEEK |
+ w.RIGHT.FD_TELL |
+ w.RIGHT.FD_FDSTAT_SET_FLAGS |
+ w.RIGHT.FD_SYNC |
+ w.RIGHT.FD_ALLOCATE |
+ w.RIGHT.FD_ADVISE |
+ w.RIGHT.FD_FILESTAT_SET_TIMES |
+ w.RIGHT.FD_FILESTAT_SET_SIZE |
+ w.RIGHT.FD_FILESTAT_GET;
if (flags.read) {
- base |= w.RIGHT_FD_READ;
+ base |= w.RIGHT.FD_READ;
}
if (flags.truncate) {
oflags |= w.O.TRUNC;
@@ -1112,14 +1112,14 @@ pub const Dir = struct {
}
if (has_flock_open_flags and flags.lock_nonblocking) {
- var fl_flags = os.fcntl(fd, os.F_GETFL, 0) catch |err| switch (err) {
+ var fl_flags = os.fcntl(fd, os.F.GETFL, 0) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
else => |e| return e,
};
fl_flags &= ~@as(usize, os.O.NONBLOCK);
- _ = os.fcntl(fd, os.F_SETFL, fl_flags) catch |err| switch (err) {
+ _ = os.fcntl(fd, os.F.SETFL, fl_flags) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
@@ -1402,27 +1402,27 @@ pub const Dir = struct {
/// Same as `openDir` except only WASI.
pub fn openDirWasi(self: Dir, sub_path: []const u8, args: OpenDirOptions) OpenError!Dir {
const w = os.wasi;
- var base: w.rights_t = w.RIGHT_FD_FILESTAT_GET | w.RIGHT_FD_FDSTAT_SET_FLAGS | w.RIGHT_FD_FILESTAT_SET_TIMES;
+ var base: w.rights_t = w.RIGHT.FD_FILESTAT_GET | w.RIGHT.FD_FDSTAT_SET_FLAGS | w.RIGHT.FD_FILESTAT_SET_TIMES;
if (args.access_sub_paths) {
- base |= w.RIGHT_FD_READDIR |
- w.RIGHT_PATH_CREATE_DIRECTORY |
- w.RIGHT_PATH_CREATE_FILE |
- w.RIGHT_PATH_LINK_SOURCE |
- w.RIGHT_PATH_LINK_TARGET |
- w.RIGHT_PATH_OPEN |
- w.RIGHT_PATH_READLINK |
- w.RIGHT_PATH_RENAME_SOURCE |
- w.RIGHT_PATH_RENAME_TARGET |
- w.RIGHT_PATH_FILESTAT_GET |
- w.RIGHT_PATH_FILESTAT_SET_SIZE |
- w.RIGHT_PATH_FILESTAT_SET_TIMES |
- w.RIGHT_PATH_SYMLINK |
- w.RIGHT_PATH_REMOVE_DIRECTORY |
- w.RIGHT_PATH_UNLINK_FILE;
+ base |= w.RIGHT.FD_READDIR |
+ w.RIGHT.PATH_CREATE_DIRECTORY |
+ w.RIGHT.PATH_CREATE_FILE |
+ w.RIGHT.PATH_LINK_SOURCE |
+ w.RIGHT.PATH_LINK_TARGET |
+ w.RIGHT.PATH_OPEN |
+ w.RIGHT.PATH_READLINK |
+ w.RIGHT.PATH_RENAME_SOURCE |
+ w.RIGHT.PATH_RENAME_TARGET |
+ w.RIGHT.PATH_FILESTAT_GET |
+ w.RIGHT.PATH_FILESTAT_SET_SIZE |
+ w.RIGHT.PATH_FILESTAT_SET_TIMES |
+ w.RIGHT.PATH_SYMLINK |
+ w.RIGHT.PATH_REMOVE_DIRECTORY |
+ w.RIGHT.PATH_UNLINK_FILE;
}
const symlink_flags: w.lookupflags_t = if (args.no_follow) 0x0 else w.LOOKUP_SYMLINK_FOLLOW;
// TODO do we really need all the rights here?
- const inheriting: w.rights_t = w.RIGHT_ALL ^ w.RIGHT_SOCK_SHUTDOWN;
+ const inheriting: w.rights_t = w.RIGHT.ALL ^ w.RIGHT.SOCK_SHUTDOWN;
const result = os.openatWasi(self.fd, sub_path, symlink_flags, w.O.DIRECTORY, 0x0, base, inheriting);
const fd = result catch |err| switch (err) {
lib/std/hash_map.zig
@@ -622,8 +622,12 @@ pub fn HashMap(
return other.promoteContext(self.allocator, new_ctx);
}
- /// Creates a copy of this map, using a specified allocator and context
- pub fn cloneWithAllocatorAndContext(new_allocator: *Allocator, new_ctx: anytype) !HashMap(K, V, @TypeOf(new_ctx), max_load_percentage) {
+ /// Creates a copy of this map, using a specified allocator and context.
+ pub fn cloneWithAllocatorAndContext(
+ self: Self,
+ new_allocator: *Allocator,
+ new_ctx: anytype,
+ ) !HashMap(K, V, @TypeOf(new_ctx), max_load_percentage) {
var other = try self.unmanaged.cloneContext(new_allocator, new_ctx);
return other.promoteContext(new_allocator, new_ctx);
}
lib/std/heap.zig
@@ -88,12 +88,12 @@ const CAllocator = struct {
fn alignedAllocSize(ptr: [*]u8) usize {
if (supports_posix_memalign) {
- return malloc_size(ptr);
+ return CAllocator.malloc_size(ptr);
}
const unaligned_ptr = getHeader(ptr).*;
const delta = @ptrToInt(ptr) - @ptrToInt(unaligned_ptr);
- return malloc_size(unaligned_ptr) - delta;
+ return CAllocator.malloc_size(unaligned_ptr) - delta;
}
fn alloc(
@@ -113,7 +113,7 @@ const CAllocator = struct {
return ptr[0..len];
}
const full_len = init: {
- if (supports_malloc_size) {
+ if (CAllocator.supports_malloc_size) {
const s = alignedAllocSize(ptr);
assert(s >= len);
break :init s;
@@ -141,7 +141,7 @@ const CAllocator = struct {
if (new_len <= buf.len) {
return mem.alignAllocLen(buf.len, new_len, len_align);
}
- if (supports_malloc_size) {
+ if (CAllocator.supports_malloc_size) {
const full_len = alignedAllocSize(buf.ptr);
if (new_len <= full_len) {
return mem.alignAllocLen(full_len, new_len, len_align);
lib/std/json.zig
@@ -1405,7 +1405,7 @@ fn parsedEqual(a: anytype, b: @TypeOf(a)) bool {
if (a == null or b == null) return false;
return parsedEqual(a.?, b.?);
},
- .Union => {
+ .Union => |info| {
if (info.tag_type) |UnionTag| {
const tag_a = std.meta.activeTag(a);
const tag_b = std.meta.activeTag(b);
lib/std/os.zig
@@ -78,6 +78,7 @@ pub const HOST_NAME_MAX = system.HOST_NAME_MAX;
pub const IFNAMESIZE = system.IFNAMESIZE;
pub const IOV_MAX = system.IOV_MAX;
pub const IPPROTO = system.IPPROTO;
+pub const Kevent = system.Kevent;
pub const LOCK = system.LOCK;
pub const MADV = system.MADV;
pub const MAP = system.MAP;
@@ -89,8 +90,10 @@ pub const O = system.O;
pub const PATH_MAX = system.PATH_MAX;
pub const POLL = system.POLL;
pub const POSIX_FADV = system.POSIX_FADV;
+pub const PR = system.PR;
pub const PROT = system.PROT;
pub const REG = system.REG;
+pub const RIGHT = system.RIGHT;
pub const RLIM = system.RLIM;
pub const RR = system.RR;
pub const R_OK = system.R_OK;
@@ -110,6 +113,7 @@ pub const STDOUT_FILENO = system.STDOUT_FILENO;
pub const SYS = system.SYS;
pub const Sigaction = system.Sigaction;
pub const Stat = system.Stat;
+pub const TCSA = system.TCSA;
pub const VDSO = system.VDSO;
pub const W = system.W;
pub const W_OK = system.W_OK;
@@ -123,9 +127,12 @@ pub const dev_t = system.dev_t;
pub const dl_phdr_info = system.dl_phdr_info;
pub const empty_sigset = system.empty_sigset;
pub const fd_t = system.fd_t;
+pub const fdflags_t = system.fdflags_t;
+pub const fdstat_t = system.fdstat_t;
pub const gid_t = system.gid_t;
pub const ifreq = system.ifreq;
pub const ino_t = system.ino_t;
+pub const lookupflags_t = system.lookupflags_t;
pub const mcontext_t = system.mcontext_t;
pub const mode_t = system.mode_t;
pub const msghdr = system.msghdr;
@@ -133,19 +140,24 @@ pub const msghdr_const = system.msghdr_const;
pub const nfds_t = system.nfds_t;
pub const nlink_t = system.nlink_t;
pub const off_t = system.off_t;
+pub const oflags_t = system.oflags_t;
pub const pid_t = system.pid_t;
pub const pollfd = system.pollfd;
+pub const rights_t = system.rights_t;
pub const rlim_t = system.rlim_t;
pub const rlimit = system.rlimit;
pub const rlimit_resource = system.rlimit_resource;
+pub const rusage = system.rusage;
pub const sa_family_t = system.sa_family_t;
pub const siginfo_t = system.siginfo_t;
pub const sigset_t = system.sigset_t;
pub const sockaddr = system.sockaddr;
pub const socklen_t = system.socklen_t;
pub const stack_t = system.stack_t;
+pub const termios = system.termios;
pub const time_t = system.time_t;
pub const timespec = system.timespec;
+pub const timestamp_t = system.timestamp_t;
pub const timeval = system.timeval;
pub const timezone = system.timezone;
pub const ucontext_t = system.ucontext_t;
@@ -2770,8 +2782,8 @@ pub fn isatty(handle: fd_t) bool {
}
// A tty is a character device that we can't seek or tell on.
- if (statbuf.fs_filetype != FILETYPE_CHARACTER_DEVICE or
- (statbuf.fs_rights_base & (RIGHT_FD_SEEK | RIGHT_FD_TELL)) != 0)
+ if (statbuf.fs_filetype != .CHARACTER_DEVICE or
+ (statbuf.fs_rights_base & (RIGHT.FD_SEEK | RIGHT.FD_TELL)) != 0)
{
// errno = ENOTTY;
return false;
@@ -3933,7 +3945,7 @@ pub const AccessError = error{
} || UnexpectedError;
/// check user's permissions for a file
-/// TODO currently this assumes `mode` is `F_OK` on Windows.
+/// TODO currently this assumes `mode` is `F.OK` on Windows.
pub fn access(path: []const u8, mode: u32) AccessError!void {
if (builtin.os.tag == .windows) {
const path_w = try windows.sliceToPrefixedFileW(path);
@@ -4104,10 +4116,10 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {
return fds;
// O.CLOEXEC is special, it's a file descriptor flag and must be set using
- // F_SETFD.
+ // F.SETFD.
if (flags & O.CLOEXEC != 0) {
for (fds) |fd| {
- switch (errno(system.fcntl(fd, F_SETFD, @as(u32, FD_CLOEXEC)))) {
+ switch (errno(system.fcntl(fd, F.SETFD, @as(u32, FD_CLOEXEC)))) {
.SUCCESS => {},
.INVAL => unreachable, // Invalid flags
.BADF => unreachable, // Always a race condition
@@ -4117,10 +4129,10 @@ pub fn pipe2(flags: u32) PipeError![2]fd_t {
}
const new_flags = flags & ~@as(u32, O.CLOEXEC);
- // Set every other flag affecting the file status using F_SETFL.
+ // Set every other flag affecting the file status using F.SETFL.
if (new_flags != 0) {
for (fds) |fd| {
- switch (errno(system.fcntl(fd, F_SETFL, new_flags))) {
+ switch (errno(system.fcntl(fd, F.SETFL, new_flags))) {
.SUCCESS => {},
.INVAL => unreachable, // Invalid flags
.BADF => unreachable, // Always a race condition
@@ -4425,14 +4437,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
if (builtin.os.tag == .windows) {
// TODO: Find out if this is supported for sockets
} else {
- var fd_flags = fcntl(sock, F_GETFD, 0) catch |err| switch (err) {
+ var fd_flags = fcntl(sock, F.GETFD, 0) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
else => |e| return e,
};
fd_flags |= FD_CLOEXEC;
- _ = fcntl(sock, F_SETFD, fd_flags) catch |err| switch (err) {
+ _ = fcntl(sock, F.SETFD, fd_flags) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
@@ -4453,14 +4465,14 @@ fn setSockFlags(sock: socket_t, flags: u32) !void {
}
}
} else {
- var fl_flags = fcntl(sock, F_GETFL, 0) catch |err| switch (err) {
+ var fl_flags = fcntl(sock, F.GETFL, 0) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
else => |e| return e,
};
fl_flags |= O.NONBLOCK;
- _ = fcntl(sock, F_SETFL, fl_flags) catch |err| switch (err) {
+ _ = fcntl(sock, F.SETFL, fl_flags) catch |err| switch (err) {
error.FileBusy => unreachable,
error.Locked => unreachable,
error.PermissionDenied => unreachable,
@@ -4625,14 +4637,14 @@ pub fn getFdPath(fd: fd_t, out_buffer: *[MAX_PATH_BYTES]u8) RealPathError![]u8 {
return out_buffer[0..end_index];
},
.macos, .ios, .watchos, .tvos => {
- // On macOS, we can use F_GETPATH fcntl command to query the OS for
+ // On macOS, we can use F.GETPATH fcntl command to query the OS for
// the path to the file descriptor.
@memset(out_buffer, 0, MAX_PATH_BYTES);
- switch (errno(system.fcntl(fd, F_GETPATH, out_buffer))) {
+ switch (errno(system.fcntl(fd, F.GETPATH, out_buffer))) {
.SUCCESS => {},
.BADF => return error.FileNotFound,
// TODO man pages for fcntl on macOS don't really tell you what
- // errno values to expect when command is F_GETPATH...
+ // errno values to expect when command is F.GETPATH...
else => |err| return unexpectedErrno(err),
}
const len = mem.indexOfScalar(u8, out_buffer[0..], @as(u8, 0)) orelse MAX_PATH_BYTES;
lib/std/time.zig
@@ -200,8 +200,6 @@ pub const Timer = struct {
.frequency = {},
};
}
-
- return self;
}
/// Reads the timer value since start or the last reset in nanoseconds
lib/std/zig.zig
@@ -157,7 +157,6 @@ pub fn binNameAlloc(allocator: *std.mem.Allocator, options: BinNameOptions) erro
}
},
}
- return std.fmt.allocPrint(allocator, "{s}{s}{s}", .{ target.libPrefix(), root_name, suffix });
},
.Obj => return std.fmt.allocPrint(allocator, "{s}.o", .{root_name}),
},
CMakeLists.txt
@@ -431,7 +431,6 @@ set(ZIG_STAGE2_SOURCES
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/io_uring.zig"
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"
"${CMAKE_SOURCE_DIR}/lib/std/os/windows.zig"
- "${CMAKE_SOURCE_DIR}/lib/std/os/windows/bits.zig"
"${CMAKE_SOURCE_DIR}/lib/std/os/windows/ntstatus.zig"
"${CMAKE_SOURCE_DIR}/lib/std/os/windows/win32error.zig"
"${CMAKE_SOURCE_DIR}/lib/std/Progress.zig"