authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-10-06 16:10:16-07:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2023-10-06 16:10:16-07:00
log2d0ddce309cbc0cac8a91e7aed5b3cdb988c9fa8
tree00144f5dd1a57c59bf107656348ef0940776cf6b
parentad6f8e3a5955df4d26478bc284919f4e5c8a6913
parent8ce33795e95ea0390d320ea2acc60059b460941e
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #17027 from Ratakor/master

std.os.linux: Add filled_sigset and pause()

2 files changed, 12 insertions(+), 1 deletions(-)

lib/std/os.zig+1
......@@ -149,6 +149,7 @@ pub const cpu_set_t = system.cpu_set_t;
149149pub const dev_t = system.dev_t;
150150pub const dl_phdr_info = system.dl_phdr_info;
151151pub const empty_sigset = system.empty_sigset;
152pub const filled_sigset = system.filled_sigset;
152153pub const fd_t = system.fd_t;
153154pub const fdflags_t = system.fdflags_t;
154155pub const fdstat_t = system.fdstat_t;
lib/std/os/linux.zig+11-1
......@@ -1042,6 +1042,14 @@ pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize {
10421042 return syscall2(.nanosleep, @intFromPtr(req), @intFromPtr(rem));
10431043}
10441044
1045pub fn pause() usize {
1046 if (@hasField(SYS, "pause")) {
1047 return syscall0(.pause);
1048 } else {
1049 return syscall4(.ppoll, 0, 0, 0, 0);
1050 }
1051}
1052
10451053pub fn setuid(uid: uid_t) usize {
10461054 if (@hasField(SYS, "setuid32")) {
10471055 return syscall1(.setuid32, uid);
......@@ -3350,7 +3358,9 @@ pub const Sigaction = extern struct {
33503358 restorer: ?*const fn () callconv(.C) void = null,
33513359};
33523360
3353pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).Array.len;
3361const sigset_len = @typeInfo(sigset_t).Array.len;
3362pub const empty_sigset = [_]u32{0} ** sigset_len;
3363pub const filled_sigset = [_]u32{(1 << (31 & (usize_bits - 1))) - 1} ++ [_]u32{0} ** (sigset_len - 1);
33543364
33553365pub const SFD = struct {
33563366 pub const CLOEXEC = O.CLOEXEC;