Merge pull request #17027 from Ratakor/master

std.os.linux: Add filled_sigset and pause()
This commit is contained in:
Andrew Kelley
2023-10-06 16:10:16 -07:00
committed by GitHub
2 changed files with 12 additions and 1 deletions

View File

@@ -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;

View File

@@ -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;