authorgravatar for dev@sgregoratto.meStephen Gregoratto <dev@sgregoratto.me> 2026-02-20 12:34:29+11:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-05-23 06:15:24+02:00
loga9b7df4ca238bbf773a08c4c2c29ec15a4bc79bb
tree6b11ea35e63458431d610e373190bee0a93b8902
parent7534ac736727c69c7314fdf194ef6a0ec30216a7
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

Linux: Map Alpha `getx*id` to their regularly named versions

These syscalls also store the value of `euid/egid/ppid` in `r20`, but are otherwise the same.

3 files changed, 9 insertions(+), 7 deletions(-)

lib/std/os/linux.zig+1-4
...@@ -2266,10 +2266,7 @@ pub fn getsid(pid: pid_t) usize {...@@ -2266,10 +2266,7 @@ pub fn getsid(pid: pid_t) usize {
22662266
2267pub fn getpid() pid_t {2267pub fn getpid() pid_t {
2268 // Casts result to a pid_t, safety-checking >= 0, because getpid() cannot fail2268 // Casts result to a pid_t, safety-checking >= 0, because getpid() cannot fail
2269 return @intCast(@as(u32, @truncate(syscall0(comptime switch (native_arch) {2269 return @intCast(@as(u32, @truncate(syscall0(.getpid))));
2270 .alpha => .getxpid,
2271 else => .getpid,
2272 }))));
2273}2270}
22742271
2275pub fn getppid() pid_t {2272pub fn getppid() pid_t {
lib/std/os/linux/syscalls.zig+3-3
...@@ -5872,11 +5872,11 @@ pub const Alpha = enum(usize) {...@@ -5872,11 +5872,11 @@ pub const Alpha = enum(usize) {
5872 brk = 17,5872 brk = 17,
5873 osf_getfsstat = 18,5873 osf_getfsstat = 18,
5874 lseek = 19,5874 lseek = 19,
5875 getxpid = 20,5875 getpid = 20,
5876 osf_mount = 21,5876 osf_mount = 21,
5877 umount2 = 22,5877 umount2 = 22,
5878 setuid = 23,5878 setuid = 23,
5879 getxuid = 24,5879 getuid = 24,
5880 exec_with_loader = 25,5880 exec_with_loader = 25,
5881 ptrace = 26,5881 ptrace = 26,
5882 osf_nrecvmsg = 27,5882 osf_nrecvmsg = 27,
...@@ -5899,7 +5899,7 @@ pub const Alpha = enum(usize) {...@@ -5899,7 +5899,7 @@ pub const Alpha = enum(usize) {
5899 osf_profil = 44,5899 osf_profil = 44,
5900 open = 45,5900 open = 45,
5901 osf_old_sigaction = 46,5901 osf_old_sigaction = 46,
5902 getxgid = 47,5902 getgid = 47,
5903 osf_sigprocmask = 48,5903 osf_sigprocmask = 48,
5904 osf_getlogin = 49,5904 osf_getlogin = 49,
5905 osf_setlogin = 50,5905 osf_setlogin = 50,
tools/generate_linux_syscalls.zig+5
...@@ -28,6 +28,11 @@ const stdlib_renames = std.StaticStringMap([]const u8).initComptime(.{...@@ -28,6 +28,11 @@ const stdlib_renames = std.StaticStringMap([]const u8).initComptime(.{
28 // ARM EABI/Thumb.28 // ARM EABI/Thumb.
29 .{ "arm_sync_file_range", "sync_file_range" },29 .{ "arm_sync_file_range", "sync_file_range" },
30 .{ "arm_fadvise64_64", "fadvise64_64" },30 .{ "arm_fadvise64_64", "fadvise64_64" },
31 // Alpha
32 // See https://github.com/torvalds/linux/blob/8bf22c33e7a172fbc72464f4cc484d23a6b412ba/arch/alpha/include/uapi/asm/unistd.h#L10
33 .{ "getxpid", "getpid" },
34 .{ "getxuid", "getuid" },
35 .{ "getxgid", "getgid" },
31});36});
3237
33/// Filter syscalls that aren't actually syscalls.38/// Filter syscalls that aren't actually syscalls.