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 {
22662266
22672267pub fn getpid() pid_t {
22682268 // Casts result to a pid_t, safety-checking >= 0, because getpid() cannot fail
2269 return @intCast(@as(u32, @truncate(syscall0(comptime switch (native_arch) {
2270 .alpha => .getxpid,
2271 else => .getpid,
2272 }))));
2269 return @intCast(@as(u32, @truncate(syscall0(.getpid))));
22732270}
22742271
22752272pub fn getppid() pid_t {
lib/std/os/linux/syscalls.zig+3-3
......@@ -5872,11 +5872,11 @@ pub const Alpha = enum(usize) {
58725872 brk = 17,
58735873 osf_getfsstat = 18,
58745874 lseek = 19,
5875 getxpid = 20,
5875 getpid = 20,
58765876 osf_mount = 21,
58775877 umount2 = 22,
58785878 setuid = 23,
5879 getxuid = 24,
5879 getuid = 24,
58805880 exec_with_loader = 25,
58815881 ptrace = 26,
58825882 osf_nrecvmsg = 27,
......@@ -5899,7 +5899,7 @@ pub const Alpha = enum(usize) {
58995899 osf_profil = 44,
59005900 open = 45,
59015901 osf_old_sigaction = 46,
5902 getxgid = 47,
5902 getgid = 47,
59035903 osf_sigprocmask = 48,
59045904 osf_getlogin = 49,
59055905 osf_setlogin = 50,
tools/generate_linux_syscalls.zig+5
......@@ -28,6 +28,11 @@ const stdlib_renames = std.StaticStringMap([]const u8).initComptime(.{
2828 // ARM EABI/Thumb.
2929 .{ "arm_sync_file_range", "sync_file_range" },
3030 .{ "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" },
3136});
3237
3338/// Filter syscalls that aren't actually syscalls.