diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-10-06 16:10:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-06 16:10:16 -0700 |
| commit | 2d0ddce309cbc0cac8a91e7aed5b3cdb988c9fa8 (patch) | |
| tree | 00144f5dd1a57c59bf107656348ef0940776cf6b /lib | |
| parent | ad6f8e3a5955df4d26478bc284919f4e5c8a6913 (diff) | |
| parent | 8ce33795e95ea0390d320ea2acc60059b460941e (diff) | |
| download | zig-2d0ddce309cbc0cac8a91e7aed5b3cdb988c9fa8.tar.gz zig-2d0ddce309cbc0cac8a91e7aed5b3cdb988c9fa8.zip | |
Merge pull request #17027 from Ratakor/master
std.os.linux: Add filled_sigset and pause()
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/std/os.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/linux.zig | 12 |
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/std/os.zig b/lib/std/os.zig index c8d4f82ff4..d6d4f596a1 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -149,6 +149,7 @@ pub const cpu_set_t = system.cpu_set_t; 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 filled_sigset = system.filled_sigset; pub const fd_t = system.fd_t; pub const fdflags_t = system.fdflags_t; pub const fdstat_t = system.fdstat_t; diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index acf31d1845..2ecb5da231 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -1042,6 +1042,14 @@ pub fn nanosleep(req: *const timespec, rem: ?*timespec) usize { return syscall2(.nanosleep, @intFromPtr(req), @intFromPtr(rem)); } +pub fn pause() usize { + if (@hasField(SYS, "pause")) { + return syscall0(.pause); + } else { + return syscall4(.ppoll, 0, 0, 0, 0); + } +} + pub fn setuid(uid: uid_t) usize { if (@hasField(SYS, "setuid32")) { return syscall1(.setuid32, uid); @@ -3350,7 +3358,9 @@ pub const Sigaction = extern struct { restorer: ?*const fn () callconv(.C) void = null, }; -pub const empty_sigset = [_]u32{0} ** @typeInfo(sigset_t).Array.len; +const sigset_len = @typeInfo(sigset_t).Array.len; +pub const empty_sigset = [_]u32{0} ** sigset_len; +pub const filled_sigset = [_]u32{(1 << (31 & (usize_bits - 1))) - 1} ++ [_]u32{0} ** (sigset_len - 1); pub const SFD = struct { pub const CLOEXEC = O.CLOEXEC; |
