2017-12-23 19:08:53 -08:00
|
|
|
const std = @import("../index.zig");
|
|
|
|
const c = std.c;
|
|
|
|
const assert = std.debug.assert;
|
2016-09-11 21:01:06 -07:00
|
|
|
|
2017-08-27 02:15:24 -07:00
|
|
|
pub use @import("darwin_errno.zig");
|
|
|
|
|
2017-08-27 14:16:42 -07:00
|
|
|
pub const PATH_MAX = 1024;
|
|
|
|
|
2017-04-02 15:19:59 -07:00
|
|
|
pub const STDIN_FILENO = 0;
|
|
|
|
pub const STDOUT_FILENO = 1;
|
|
|
|
pub const STDERR_FILENO = 2;
|
|
|
|
|
2017-08-26 21:11:09 -07:00
|
|
|
pub const PROT_NONE = 0x00; /// [MC2] no permissions
|
|
|
|
pub const PROT_READ = 0x01; /// [MC2] pages can be read
|
|
|
|
pub const PROT_WRITE = 0x02; /// [MC2] pages can be written
|
|
|
|
pub const PROT_EXEC = 0x04; /// [MC2] pages can be executed
|
|
|
|
|
|
|
|
pub const MAP_ANONYMOUS = 0x1000; /// allocated from memory, swap space
|
|
|
|
pub const MAP_FILE = 0x0000; /// map from file (default)
|
|
|
|
pub const MAP_FIXED = 0x0010; /// interpret addr exactly
|
|
|
|
pub const MAP_HASSEMAPHORE = 0x0200; /// region may contain semaphores
|
|
|
|
pub const MAP_PRIVATE = 0x0002; /// changes are private
|
|
|
|
pub const MAP_SHARED = 0x0001; /// share changes
|
|
|
|
pub const MAP_NOCACHE = 0x0400; /// don't cache pages for this mapping
|
|
|
|
pub const MAP_NORESERVE = 0x0040; /// don't reserve needed swap area
|
|
|
|
pub const MAP_FAILED = @maxValue(usize);
|
|
|
|
|
2017-09-07 21:04:43 -07:00
|
|
|
pub const WNOHANG = 0x00000001; /// [XSI] no hang in wait/no child to reap
|
|
|
|
pub const WUNTRACED = 0x00000002; /// [XSI] notify on stop, untraced child
|
|
|
|
|
|
|
|
pub const SA_ONSTACK = 0x0001; /// take signal on signal stack
|
|
|
|
pub const SA_RESTART = 0x0002; /// restart system on signal return
|
|
|
|
pub const SA_RESETHAND = 0x0004; /// reset to SIG_DFL when taking signal
|
|
|
|
pub const SA_NOCLDSTOP = 0x0008; /// do not generate SIGCHLD on child stop
|
|
|
|
pub const SA_NODEFER = 0x0010; /// don't mask the signal we're delivering
|
|
|
|
pub const SA_NOCLDWAIT = 0x0020; /// don't keep zombies around
|
|
|
|
pub const SA_SIGINFO = 0x0040; /// signal handler with SA_SIGINFO args
|
|
|
|
pub const SA_USERTRAMP = 0x0100; /// do not bounce off kernel's sigtramp
|
|
|
|
pub const SA_64REGSET = 0x0200; /// signal handler with SA_SIGINFO args with 64bit regs information
|
|
|
|
|
2016-09-11 21:01:06 -07:00
|
|
|
pub const O_LARGEFILE = 0x0000;
|
2017-08-27 02:44:03 -07:00
|
|
|
pub const O_PATH = 0x0000;
|
2017-08-26 21:11:09 -07:00
|
|
|
|
|
|
|
pub const O_RDONLY = 0x0000; /// open for reading only
|
|
|
|
pub const O_WRONLY = 0x0001; /// open for writing only
|
|
|
|
pub const O_RDWR = 0x0002; /// open for reading and writing
|
|
|
|
pub const O_NONBLOCK = 0x0004; /// do not block on open or for data to become available
|
|
|
|
pub const O_APPEND = 0x0008; /// append on each write
|
|
|
|
pub const O_CREAT = 0x0200; /// create file if it does not exist
|
|
|
|
pub const O_TRUNC = 0x0400; /// truncate size to 0
|
|
|
|
pub const O_EXCL = 0x0800; /// error if O_CREAT and the file exists
|
|
|
|
pub const O_SHLOCK = 0x0010; /// atomically obtain a shared lock
|
|
|
|
pub const O_EXLOCK = 0x0020; /// atomically obtain an exclusive lock
|
|
|
|
pub const O_NOFOLLOW = 0x0100; /// do not follow symlinks
|
|
|
|
pub const O_SYMLINK = 0x200000; /// allow open of symlinks
|
|
|
|
pub const O_EVTONLY = 0x8000; /// descriptor requested for event notifications only
|
|
|
|
pub const O_CLOEXEC = 0x1000000; /// mark as close-on-exec
|
2016-09-11 21:01:06 -07:00
|
|
|
|
2018-03-04 21:57:02 -08:00
|
|
|
pub const O_ACCMODE = 3;
|
|
|
|
pub const O_ALERT = 536870912;
|
|
|
|
pub const O_ASYNC = 64;
|
|
|
|
pub const O_DIRECTORY = 1048576;
|
|
|
|
pub const O_DP_GETRAWENCRYPTED = 1;
|
|
|
|
pub const O_DP_GETRAWUNENCRYPTED = 2;
|
|
|
|
pub const O_DSYNC = 4194304;
|
|
|
|
pub const O_FSYNC = O_SYNC;
|
|
|
|
pub const O_NOCTTY = 131072;
|
|
|
|
pub const O_POPUP = 2147483648;
|
|
|
|
pub const O_SYNC = 128;
|
|
|
|
|
2016-09-11 21:01:06 -07:00
|
|
|
pub const SEEK_SET = 0x0;
|
|
|
|
pub const SEEK_CUR = 0x1;
|
|
|
|
pub const SEEK_END = 0x2;
|
|
|
|
|
2018-03-04 21:57:02 -08:00
|
|
|
pub const DT_UNKNOWN = 0;
|
|
|
|
pub const DT_FIFO = 1;
|
|
|
|
pub const DT_CHR = 2;
|
|
|
|
pub const DT_DIR = 4;
|
|
|
|
pub const DT_BLK = 6;
|
|
|
|
pub const DT_REG = 8;
|
|
|
|
pub const DT_LNK = 10;
|
|
|
|
pub const DT_SOCK = 12;
|
|
|
|
pub const DT_WHT = 14;
|
|
|
|
|
2017-09-07 21:04:43 -07:00
|
|
|
pub const SIG_BLOCK = 1; /// block specified signal set
|
|
|
|
pub const SIG_UNBLOCK = 2; /// unblock specified signal set
|
|
|
|
pub const SIG_SETMASK = 3; /// set specified signal set
|
|
|
|
|
|
|
|
pub const SIGHUP = 1; /// hangup
|
|
|
|
pub const SIGINT = 2; /// interrupt
|
|
|
|
pub const SIGQUIT = 3; /// quit
|
|
|
|
pub const SIGILL = 4; /// illegal instruction (not reset when caught)
|
|
|
|
pub const SIGTRAP = 5; /// trace trap (not reset when caught)
|
|
|
|
pub const SIGABRT = 6; /// abort()
|
|
|
|
pub const SIGPOLL = 7; /// pollable event ([XSR] generated, not supported)
|
|
|
|
pub const SIGIOT = SIGABRT; /// compatibility
|
|
|
|
pub const SIGEMT = 7; /// EMT instruction
|
|
|
|
pub const SIGFPE = 8; /// floating point exception
|
|
|
|
pub const SIGKILL = 9; /// kill (cannot be caught or ignored)
|
|
|
|
pub const SIGBUS = 10; /// bus error
|
|
|
|
pub const SIGSEGV = 11; /// segmentation violation
|
|
|
|
pub const SIGSYS = 12; /// bad argument to system call
|
|
|
|
pub const SIGPIPE = 13; /// write on a pipe with no one to read it
|
|
|
|
pub const SIGALRM = 14; /// alarm clock
|
|
|
|
pub const SIGTERM = 15; /// software termination signal from kill
|
|
|
|
pub const SIGURG = 16; /// urgent condition on IO channel
|
|
|
|
pub const SIGSTOP = 17; /// sendable stop signal not from tty
|
|
|
|
pub const SIGTSTP = 18; /// stop signal from tty
|
|
|
|
pub const SIGCONT = 19; /// continue a stopped process
|
|
|
|
pub const SIGCHLD = 20; /// to parent on child stop or exit
|
|
|
|
pub const SIGTTIN = 21; /// to readers pgrp upon background tty read
|
|
|
|
pub const SIGTTOU = 22; /// like TTIN for output if (tp->t_local<OSTOP)
|
|
|
|
pub const SIGIO = 23; /// input/output possible signal
|
|
|
|
pub const SIGXCPU = 24; /// exceeded CPU time limit
|
|
|
|
pub const SIGXFSZ = 25; /// exceeded file size limit
|
|
|
|
pub const SIGVTALRM = 26; /// virtual time alarm
|
|
|
|
pub const SIGPROF = 27; /// profiling time alarm
|
|
|
|
pub const SIGWINCH = 28; /// window size changes
|
|
|
|
pub const SIGINFO = 29; /// information request
|
|
|
|
pub const SIGUSR1 = 30; /// user defined signal 1
|
|
|
|
pub const SIGUSR2 = 31; /// user defined signal 2
|
2016-09-11 21:01:06 -07:00
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
fn wstatus(x: i32) i32 { return x & 0o177; }
|
2017-08-26 21:11:09 -07:00
|
|
|
const wstopped = 0o177;
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn WEXITSTATUS(x: i32) i32 { return x >> 8; }
|
|
|
|
pub fn WTERMSIG(x: i32) i32 { return wstatus(x); }
|
|
|
|
pub fn WSTOPSIG(x: i32) i32 { return x >> 8; }
|
|
|
|
pub fn WIFEXITED(x: i32) bool { return wstatus(x) == 0; }
|
|
|
|
pub fn WIFSTOPPED(x: i32) bool { return wstatus(x) == wstopped and WSTOPSIG(x) != 0x13; }
|
|
|
|
pub fn WIFSIGNALED(x: i32) bool { return wstatus(x) != wstopped and wstatus(x) != 0; }
|
2017-02-23 13:13:57 -08:00
|
|
|
|
2016-09-11 21:01:06 -07:00
|
|
|
/// Get the errno from a syscall return value, or 0 for no error.
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn getErrno(r: usize) usize {
|
2017-08-26 21:11:09 -07:00
|
|
|
const signed_r = @bitCast(isize, r);
|
2017-12-21 21:50:30 -08:00
|
|
|
return if (signed_r > -4096 and signed_r < 0) usize(-signed_r) else 0;
|
2016-09-11 21:01:06 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn close(fd: i32) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.close(fd));
|
2016-09-11 21:01:06 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn abort() noreturn {
|
2017-12-21 23:33:39 -08:00
|
|
|
c.abort();
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn exit(code: i32) noreturn {
|
2017-12-21 23:33:39 -08:00
|
|
|
c.exit(code);
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn isatty(fd: i32) bool {
|
2017-12-21 21:50:30 -08:00
|
|
|
return c.isatty(fd) != 0;
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn fstat(fd: i32, buf: &c.Stat) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.@"fstat$INODE64"(fd, buf));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn lseek(fd: i32, offset: isize, whence: c_int) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.lseek(fd, offset, whence));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn open(path: &const u8, flags: u32, mode: usize) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.open(path, @bitCast(c_int, flags), mode));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn raise(sig: i32) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.raise(sig));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn read(fd: i32, buf: &u8, nbyte: usize) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.read(fd, @ptrCast(&c_void, buf), nbyte));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn stat(noalias path: &const u8, noalias buf: &stat) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.stat(path, buf));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn write(fd: i32, buf: &const u8, nbyte: usize) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.write(fd, @ptrCast(&const c_void, buf), nbyte));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn mmap(address: ?&u8, length: usize, prot: usize, flags: usize, fd: i32,
|
2018-01-25 01:10:11 -08:00
|
|
|
offset: isize) usize
|
2017-08-26 21:11:09 -07:00
|
|
|
{
|
|
|
|
const ptr_result = c.mmap(@ptrCast(&c_void, address), length,
|
|
|
|
@bitCast(c_int, c_uint(prot)), @bitCast(c_int, c_uint(flags)), fd, offset);
|
|
|
|
const isize_result = @bitCast(isize, @ptrToInt(ptr_result));
|
|
|
|
return errnoWrap(isize_result);
|
2016-09-11 21:01:06 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn munmap(address: &u8, length: usize) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.munmap(@ptrCast(&c_void, address), length));
|
2016-09-11 21:01:06 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn unlink(path: &const u8) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.unlink(path));
|
2016-09-11 21:01:06 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn getcwd(buf: &u8, size: usize) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return if (c.getcwd(buf, size) == null) @bitCast(usize, -isize(*c._errno())) else 0;
|
2016-09-11 21:01:06 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn waitpid(pid: i32, status: &i32, options: u32) usize {
|
2017-08-26 21:11:09 -07:00
|
|
|
comptime assert(i32.bit_count == c_int.bit_count);
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.waitpid(pid, @ptrCast(&c_int, status), @bitCast(c_int, options)));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
2016-09-11 21:01:06 -07:00
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn fork() usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.fork());
|
2016-09-11 21:01:06 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn pipe(fds: &[2]i32) usize {
|
2017-08-26 21:11:09 -07:00
|
|
|
comptime assert(i32.bit_count == c_int.bit_count);
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.pipe(@ptrCast(&c_int, fds)));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
2016-09-11 21:01:06 -07:00
|
|
|
|
2018-03-04 21:57:02 -08:00
|
|
|
|
|
|
|
pub fn getdirentries64(fd: i32, buf_ptr: &u8, buf_len: usize, basep: &i64) usize {
|
|
|
|
return errnoWrap(@bitCast(isize, c.__getdirentries64(fd, buf_ptr, buf_len, basep)));
|
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn mkdir(path: &const u8, mode: u32) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.mkdir(path, mode));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
2016-09-11 21:01:06 -07:00
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn symlink(existing: &const u8, new: &const u8) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.symlink(existing, new));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
2016-09-11 21:01:06 -07:00
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn rename(old: &const u8, new: &const u8) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.rename(old, new));
|
2016-09-11 21:01:06 -07:00
|
|
|
}
|
|
|
|
|
2018-03-04 21:57:02 -08:00
|
|
|
pub fn rmdir(path: &const u8) usize {
|
|
|
|
return errnoWrap(c.rmdir(path));
|
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn chdir(path: &const u8) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.chdir(path));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn execve(path: &const u8, argv: &const ?&const u8, envp: &const ?&const u8) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.execve(path, argv, envp));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn dup2(old: i32, new: i32) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.dup2(old, new));
|
2017-08-26 21:11:09 -07:00
|
|
|
}
|
2016-09-13 23:44:31 -07:00
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn readlink(noalias path: &const u8, noalias buf_ptr: &u8, buf_len: usize) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.readlink(path, buf_ptr, buf_len));
|
2017-08-27 02:44:03 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn nanosleep(req: &const timespec, rem: ?×pec) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.nanosleep(req, rem));
|
2017-09-19 06:46:41 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn realpath(noalias filename: &const u8, noalias resolved_name: &u8) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return if (c.realpath(filename, resolved_name) == null) @bitCast(usize, -isize(*c._errno())) else 0;
|
2017-08-27 14:16:42 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn setreuid(ruid: u32, euid: u32) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.setreuid(ruid, euid));
|
2017-09-26 00:35:21 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn setregid(rgid: u32, egid: u32) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.setregid(rgid, egid));
|
2017-09-26 00:35:21 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn sigprocmask(flags: u32, noalias set: &const sigset_t, noalias oldset: ?&sigset_t) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return errnoWrap(c.sigprocmask(@bitCast(c_int, flags), set, oldset));
|
2017-09-07 21:04:43 -07:00
|
|
|
}
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn sigaction(sig: u5, noalias act: &const Sigaction, noalias oact: ?&Sigaction) usize {
|
2017-09-07 21:04:43 -07:00
|
|
|
assert(sig != SIGKILL);
|
|
|
|
assert(sig != SIGSTOP);
|
|
|
|
var cact = c.Sigaction {
|
2018-01-25 01:10:11 -08:00
|
|
|
.handler = @ptrCast(extern fn(c_int)void, act.handler),
|
2017-09-07 21:04:43 -07:00
|
|
|
.sa_flags = @bitCast(c_int, act.flags),
|
|
|
|
.sa_mask = act.mask,
|
|
|
|
};
|
|
|
|
var coact: c.Sigaction = undefined;
|
|
|
|
const result = errnoWrap(c.sigaction(sig, &cact, &coact));
|
|
|
|
if (result != 0) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
if (oact) |old| {
|
|
|
|
*old = Sigaction {
|
2018-01-25 01:10:11 -08:00
|
|
|
.handler = @ptrCast(extern fn(i32)void, coact.handler),
|
2017-09-07 21:04:43 -07:00
|
|
|
.flags = @bitCast(u32, coact.sa_flags),
|
|
|
|
.mask = coact.sa_mask,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub const sigset_t = c.sigset_t;
|
|
|
|
pub const empty_sigset = sigset_t(0);
|
|
|
|
|
2017-09-19 06:46:41 -07:00
|
|
|
pub const timespec = c.timespec;
|
2017-11-09 10:46:53 -08:00
|
|
|
pub const Stat = c.Stat;
|
2018-03-04 21:57:02 -08:00
|
|
|
pub const dirent = c.dirent;
|
2017-09-19 06:46:41 -07:00
|
|
|
|
2017-09-07 21:04:43 -07:00
|
|
|
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
|
|
|
|
pub const Sigaction = struct {
|
2018-01-25 01:10:11 -08:00
|
|
|
handler: extern fn(i32)void,
|
2017-09-07 21:04:43 -07:00
|
|
|
mask: sigset_t,
|
|
|
|
flags: u32,
|
|
|
|
};
|
|
|
|
|
2018-01-25 01:10:11 -08:00
|
|
|
pub fn sigaddset(set: &sigset_t, signo: u5) void {
|
2017-09-07 21:04:43 -07:00
|
|
|
*set |= u32(1) << (signo - 1);
|
|
|
|
}
|
|
|
|
|
2017-08-26 21:11:09 -07:00
|
|
|
/// Takes the return value from a syscall and formats it back in the way
|
|
|
|
/// that the kernel represents it to libc. Errno was a mistake, let's make
|
|
|
|
/// it go away forever.
|
2018-01-25 01:10:11 -08:00
|
|
|
fn errnoWrap(value: isize) usize {
|
2017-12-21 21:50:30 -08:00
|
|
|
return @bitCast(usize, if (value == -1) -isize(*c._errno()) else value);
|
2016-09-11 21:01:06 -07:00
|
|
|
}
|