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;...@@ -149,6 +149,7 @@ pub const cpu_set_t = system.cpu_set_t;
149pub const dev_t = system.dev_t;149pub const dev_t = system.dev_t;
150pub const dl_phdr_info = system.dl_phdr_info;150pub const dl_phdr_info = system.dl_phdr_info;
151pub const empty_sigset = system.empty_sigset;151pub const empty_sigset = system.empty_sigset;
152pub const filled_sigset = system.filled_sigset;
152pub const fd_t = system.fd_t;153pub const fd_t = system.fd_t;
153pub const fdflags_t = system.fdflags_t;154pub const fdflags_t = system.fdflags_t;
154pub const fdstat_t = system.fdstat_t;155pub 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 {...@@ -1042,6 +1042,14 @@ pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize {
1042 return syscall2(.nanosleep, @intFromPtr(req), @intFromPtr(rem));1042 return syscall2(.nanosleep, @intFromPtr(req), @intFromPtr(rem));
1043}1043}
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
1045pub fn setuid(uid: uid_t) usize {1053pub fn setuid(uid: uid_t) usize {
1046 if (@hasField(SYS, "setuid32")) {1054 if (@hasField(SYS, "setuid32")) {
1047 return syscall1(.setuid32, uid);1055 return syscall1(.setuid32, uid);
...@@ -3350,7 +3358,9 @@ pub const Sigaction = extern struct {...@@ -3350,7 +3358,9 @@ pub const Sigaction = extern struct {
3350 restorer: ?*const fn () callconv(.C) void = null,3358 restorer: ?*const fn () callconv(.C) void = null,
3351};3359};
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
3355pub const SFD = struct {3365pub const SFD = struct {
3356 pub const CLOEXEC = O.CLOEXEC;3366 pub const CLOEXEC = O.CLOEXEC;