authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-10-02 14:08:32-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-10-02 14:08:32-04:00
logacefcdbca58efd97bf5346eb7dae22c49efa1a3d
tree4b4f9c3320b9c6b166c41cfb7b248dba6df179d9
parent364bc66924648c798d9eb5f70607ba8a5fb991d6
signature Commit is signed but in an unrecognized format.

add std.os.linux.vfork and std.os.linux.exit_group


2 files changed, 32 insertions(+), 11 deletions(-)

std/os/index.zig+18-11
......@@ -634,18 +634,25 @@ pub const PosixExecveError = error{
634634
635635fn posixExecveErrnoToErr(err: usize) PosixExecveError {
636636 assert(err > 0);
637 return switch (err) {
637 switch (err) {
638638 posix.EFAULT => unreachable,
639 posix.E2BIG, posix.EMFILE, posix.ENAMETOOLONG, posix.ENFILE, posix.ENOMEM => error.SystemResources,
640 posix.EACCES, posix.EPERM => error.AccessDenied,
641 posix.EINVAL, posix.ENOEXEC => error.InvalidExe,
642 posix.EIO, posix.ELOOP => error.FileSystem,
643 posix.EISDIR => error.IsDir,
644 posix.ENOENT => error.FileNotFound,
645 posix.ENOTDIR => error.NotDir,
646 posix.ETXTBSY => error.FileBusy,
647 else => unexpectedErrorPosix(err),
648 };
639 posix.E2BIG => return error.SystemResources,
640 posix.EMFILE => return error.SystemResources,
641 posix.ENAMETOOLONG => return error.SystemResources,
642 posix.ENFILE => return error.SystemResources,
643 posix.ENOMEM => return error.SystemResources,
644 posix.EACCES => return error.AccessDenied,
645 posix.EPERM => return error.AccessDenied,
646 posix.EINVAL => return error.InvalidExe,
647 posix.ENOEXEC => return error.InvalidExe,
648 posix.EIO => return error.FileSystem,
649 posix.ELOOP => return error.FileSystem,
650 posix.EISDIR => return error.IsDir,
651 posix.ENOENT => return error.FileNotFound,
652 posix.ENOTDIR => return error.NotDir,
653 posix.ETXTBSY => return error.FileBusy,
654 else => return unexpectedErrorPosix(err),
655 }
649656}
650657
651658pub var linux_aux_raw = []usize{0} ** 38;
std/os/linux/index.zig+14
......@@ -719,6 +719,15 @@ pub fn fork() usize {
719719 return syscall0(SYS_fork);
720720}
721721
722/// This must be inline, and inline call the syscall function, because if the
723/// child does a return it will clobber the parent's stack.
724/// It is advised to avoid this function and use clone instead, because
725/// the compiler is not aware of how vfork affects control flow and you may
726/// see different results in optimized builds.
727pub inline fn vfork() usize {
728 return @inlineCall(syscall0, SYS_vfork);
729}
730
722731pub fn futex_wait(uaddr: usize, futex_op: u32, val: i32, timeout: ?*timespec) usize {
723732 return syscall4(SYS_futex, uaddr, futex_op, @bitCast(u32, val), @ptrToInt(timeout));
724733}
......@@ -883,6 +892,11 @@ pub fn exit(status: i32) noreturn {
883892 unreachable;
884893}
885894
895pub fn exit_group(status: i32) noreturn {
896 _ = syscall1(SYS_exit_group, @bitCast(usize, isize(status)));
897 unreachable;
898}
899
886900pub fn getrandom(buf: [*]u8, count: usize, flags: u32) usize {
887901 return syscall3(SYS_getrandom, @ptrToInt(buf), count, @intCast(usize, flags));
888902}