diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 338d17a487a1526c7cac741f92c8628735b79736..caa22ea4cb4548363d40007e4e2b58a4e829cec8 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -1217,8 +1217,8 @@ const LinuxThreadImpl = struct { \\ ldi $16, 0 \\ callsys : - : [ptr] "{r16}" (@intFromPtr(self.mapped.ptr)), - [len] "{r17}" (self.mapped.len), + : [ptr] "{$16}" (@intFromPtr(self.mapped.ptr)), + [len] "{$17}" (self.mapped.len), ), .hexagon => asm volatile ( \\ r6 = #215 // SYS_munmap diff --git a/lib/std/debug/Dwarf.zig b/lib/std/debug/Dwarf.zig index 126b55d5d87be33eab8212dc289616186fbe78ba..28d83d463bd9eef5b0edf815ff132b1c24d35c92 100644 --- a/lib/std/debug/Dwarf.zig +++ b/lib/std/debug/Dwarf.zig @@ -1436,6 +1436,7 @@ pub fn compactUnwindToDwarfRegNumber(unwind_reg_number: u3) !u16 { pub fn ipRegNum(arch: std.Target.Cpu.Arch) ?u16 { return switch (arch) { .aarch64, .aarch64_be => 32, + .alpha => 64, .arc, .arceb => 160, .arm, .armeb, .thumb, .thumbeb => 15, .csky => 64, @@ -1460,6 +1461,7 @@ pub fn ipRegNum(arch: std.Target.Cpu.Arch) ?u16 { pub fn fpRegNum(arch: std.Target.Cpu.Arch) u16 { return switch (arch) { .aarch64, .aarch64_be => 29, + .alpha => 15, .arc, .arceb => 27, .arm, .armeb, .thumb, .thumbeb => 11, .csky => 14, @@ -1484,6 +1486,7 @@ pub fn fpRegNum(arch: std.Target.Cpu.Arch) u16 { pub fn spRegNum(arch: std.Target.Cpu.Arch) u16 { return switch (arch) { .aarch64, .aarch64_be => 31, + .alpha => 30, .arc, .arceb => 28, .arm, .armeb, .thumb, .thumbeb => 13, .csky => 14, diff --git a/lib/std/debug/cpu_context.zig b/lib/std/debug/cpu_context.zig index 2c6355531b91abecf86f1b663220f7c406435b88..4766a124caa8bd2199320bb1f8c2bba8dff4b8a1 100644 --- a/lib/std/debug/cpu_context.zig +++ b/lib/std/debug/cpu_context.zig @@ -5,6 +5,7 @@ pub const Native = if (@hasDecl(root, "debug") and @hasDecl(root.debug, "CpuCont root.debug.CpuContext else switch (native_arch) { .aarch64, .aarch64_be => Aarch64, + .alpha => Alpha, .arc, .arceb => Arc, .arm, .armeb, .thumb, .thumbeb => Arm, .csky => Csky, @@ -103,6 +104,10 @@ pub fn fromPosixSignalContext(ctx_ptr: ?*const anyopaque) ?Native { .sp = uc.mcontext.sp, .pc = uc.mcontext.pc, }, + .alpha => .{ + .r = uc.mcontext.r, + .pc = uc.mcontext.pc, + }, .csky => .{ .r = uc.mcontext.r0_13 ++ [_]u32{ uc.mcontext.r14, uc.mcontext.r15 } ++ @@ -293,6 +298,75 @@ const Aarch64 = extern struct { } }; +const Alpha = extern struct { + /// The numbered general-purpose registers R0 - R31. + r: [32]u64, + pc: u64, + + pub inline fn current() Alpha { + var ctx: Alpha = undefined; + asm volatile ( + \\ stq $0 , 0x000($0) + \\ stq $1 , 0x008($0) + \\ stq $2 , 0x010($0) + \\ stq $3 , 0x018($0) + \\ stq $4 , 0x020($0) + \\ stq $5 , 0x028($0) + \\ stq $6 , 0x030($0) + \\ stq $7 , 0x038($0) + \\ stq $8 , 0x040($0) + \\ stq $9 , 0x048($0) + \\ stq $10, 0x050($0) + \\ stq $11, 0x058($0) + \\ stq $12, 0x060($0) + \\ stq $13, 0x068($0) + \\ stq $14, 0x070($0) + \\ stq $15, 0x078($0) + \\ stq $16, 0x080($0) + \\ stq $17, 0x088($0) + \\ stq $18, 0x090($0) + \\ stq $19, 0x098($0) + \\ stq $20, 0x0a0($0) + \\ stq $21, 0x0a8($0) + \\ stq $22, 0x0b0($0) + \\ stq $23, 0x0b8($0) + \\ stq $24, 0x0c0($0) + \\ stq $25, 0x0c8($0) + \\ stq $26, 0x0d0($0) + \\ stq $27, 0x0d8($0) + \\ stq $28, 0x0e0($0) + \\ stq $29, 0x0e8($0) + \\ stq $30, 0x0f0($0) + \\ + \\ br $1, 1f + \\1: + \\ stq $1, 0x100($0) + : + : [ctx] "{r0}" (&ctx), + : .{ .r1 = true, .memory = true }); + return ctx; + } + + pub fn getFp(ctx: *const Alpha) u64 { + return ctx.r[15]; + } + pub fn getPc(ctx: *const Alpha) u64 { + return ctx.pc; + } + + pub fn dwarfRegisterBytes(ctx: *Aarch64, register_num: u16) DwarfRegisterError![]u8 { + switch (register_num) { + 0...31 => return @ptrCast(&ctx.r[register_num]), + 64 => return @ptrCast(&ctx.pc), + + 32...63 => return error.UnsupportedRegister, // f0 - f31 + 66 => return error.UnsupportedRegister, // uniq + + else => return error.InvalidRegister, + } + } +}; + /// This is an `extern struct` so that inline assembly in `current` can use field offsets. const Arc = extern struct { /// The numbered general-purpose registers r0 - r31. diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 0df906340ef804685e6bca37df379b1fddb8ec4d..8f9e7c178307bff79c98356155549c8bbd9ff360 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -18,6 +18,7 @@ const is_mips = native_arch.isMIPS(); const is_ppc = native_arch.isPowerPC(); const is_riscv = native_arch.isRISCV(); const is_sparc = native_arch.isSPARC(); +const is_hppa = native_arch.isHppa(); const iovec = std.posix.iovec; const iovec_const = std.posix.iovec_const; const winsize = std.posix.winsize; @@ -31,6 +32,7 @@ test { const arch_bits = switch (native_arch) { .aarch64, .aarch64_be => @import("linux/aarch64.zig"), + .alpha => @import("linux/alpha.zig"), .arc, .arceb => @import("linux/arc.zig"), .arm, .armeb, .thumb, .thumbeb => @import("linux/arm.zig"), .hexagon => @import("linux/hexagon.zig"), @@ -124,6 +126,7 @@ pub const syscalls = @import("linux/syscalls.zig"); pub const SYS = switch (native_arch) { .arc, .arceb => syscalls.Arc, .aarch64, .aarch64_be => syscalls.Arm64, + .alpha => syscalls.Alpha, .arm, .armeb, .thumb, .thumbeb => syscalls.Arm, .csky => syscalls.CSky, .hexagon => syscalls.Hexagon, @@ -311,6 +314,30 @@ pub const MAP = switch (native_arch) { UNINITIALIZED: bool = false, _: u5 = 0, }, + .alpha => packed struct(u32) { + TYPE: MAP_TYPE, + ANONYMOUS: bool = false, + _3: u1 = 0, + _4: u1 = 0, + _5: u1 = 0, + FIXED: bool = false, + _7: u1 = 0, + _8: u1 = 0, + _9: u1 = 0, + GROWSDOWN: bool = false, + DENYWRITE: bool = false, + EXECUTABLE: bool = false, + LOCKED: bool = false, + NORESERVE: bool = false, + POPULATE: bool = false, + NONBLOCK: bool = false, + STACK: bool = false, + HUGHETLB: bool = false, + FIXED_NOREPLACE: bool = false, + _19: u4 = 0, + _20: u1 = 0, + _: u5 = 0, + }, else => @compileError("missing std.os.linux.MAP constants for this architecture"), }; @@ -520,6 +547,29 @@ pub const O = switch (native_arch) { PATH: bool = false, _22: u10 = 0, }, + .alpha => packed struct(u32) { + ACCMODE: ACCMODE = .RDONLY, + NONBLOCK: bool = false, + APPEND: bool = false, + _4: u5 = 0, + CREAT: bool = false, + TRUNC: bool = false, + EXCL: bool = false, + NOCTTY: bool = false, + _9: u1 = 0, + DSYNC: bool = false, + DIRECTORY: bool = false, + NOFOLLOW: bool = false, + LARGEFILE: bool = false, + _14: u1 = 0, + DIRECT: bool = false, + NOATIME: bool = false, + CLOEXEC: bool = false, + SYNC: bool = false, + PATH: bool = false, + TMPFILE: bool = false, + _: u7 = 0, + }, else => @compileError("missing std.os.linux.O constants for this architecture"), }; @@ -1894,23 +1944,68 @@ pub const F = struct { pub const SETLK = GET_SET_LK.SETLK; pub const SETLKW = GET_SET_LK.SETLKW; - const GET_SET_LK = if (@sizeOf(usize) == 64) extern struct { - pub const GETLK = if (is_mips) 14 else if (is_sparc) 7 else 5; - pub const SETLK = if (is_mips) 6 else if (is_sparc) 8 else 6; - pub const SETLKW = if (is_mips) 7 else if (is_sparc) 9 else 7; - } else extern struct { - // Ensure that 32-bit code uses the large-file variants (GETLK64, etc). + pub const SETOWN = GET_SET_OWN.SETOWN; + pub const GETOWN = GET_SET_OWN.GETOWN; - pub const GETLK = if (is_mips) 33 else 12; - pub const SETLK = if (is_mips) 34 else 13; - pub const SETLKW = if (is_mips) 35 else 14; + const GET_SET_LK = switch (native_arch) { + .mips, .mipsel => struct { + const GETLK = 33; + const SETLK = 34; + const SETLKW = 35; + }, + .mips64, .mips64el => switch (native_abi) { + .gnuabin32, .muslabin32 => struct { + const GETLK = 33; + const SETLK = 34; + const SETLKW = 35; + }, + else => struct { + const GETLK = 14; + const SETLK = 6; + const SETLKW = 7; + }, + }, + .alpha, .sparc64 => struct { + const GETLK = 7; + const SETLK = 8; + const SETLKW = 9; + }, + .hppa, .hppa64 => struct { + const GETLK = 8; + const SETLK = 9; + const SETLKW = 10; + }, + else => if (@sizeOf(usize) == 8) struct { + const GETLK = 5; + const SETLK = 6; + const SETLKW = 7; + } else struct { + const GETLK = 12; + const SETLK = 13; + const SETLKW = 14; + }, + }; + const GET_SET_OWN = switch (native_arch) { + .mips, .mipsel, .mips64, .mips64el => struct { + const GETOWN = 23; + const SETOWN = 24; + }, + .alpha, .sparc, .sparc64 => struct { + const GETOWN = 5; + const SETOWN = 6; + }, + .hppa, .hppa64 => struct { + const GETOWN = 11; + const SETOWN = 12; + }, + else => struct { + const GETOWN = 8; + const SETOWN = 9; + }, }; - pub const SETOWN = if (is_mips) 24 else if (is_sparc) 6 else 8; - pub const GETOWN = if (is_mips) 23 else if (is_sparc) 5 else 9; - - pub const SETSIG = 10; - pub const GETSIG = 11; + pub const SETSIG = if (is_hppa or native_arch == .alpha) 13 else 11; + pub const GETSIG = if (is_hppa or native_arch == .alpha) 14 else 12; pub const SETOWN_EX = 15; pub const GETOWN_EX = 16; @@ -1923,7 +2018,7 @@ pub const F = struct { pub const RDLCK = if (is_sparc) 1 else 0; pub const WRLCK = if (is_sparc) 2 else 1; - pub const UNLCK = if (is_sparc) 3 else 2; + pub const UNLCK = if (is_sparc) 3 else if (native_arch == .alpha) 8 else 2; pub const LINUX_SPECIFIC_BASE = 1024; @@ -3388,6 +3483,294 @@ pub const E = switch (native_arch) { HWPOISON = 135, _, }, + .alpha => enum(u16) { + /// No error occurred. + SUCCESS = 0, + + /// Operation not permitted + PERM = 1, + /// No such file or directory + NOENT = 2, + /// No such process + SRCH = 3, + /// Interrupted system call + INTR = 4, + /// I/O error + IO = 5, + /// No such device or address + NXIO = 6, + /// Argument list too long + @"2BIG" = 7, + /// Exec format error + NOEXEC = 8, + /// Bad file number + BADF = 9, + /// No child processes + CHILD = 10, + /// Out of memory + NOMEM = 12, + /// Permission denied + ACCES = 13, + /// Bad address + FAULT = 14, + /// Block device required + NOTBLK = 15, + /// Device or resource busy + BUSY = 16, + /// File exists + EXIST = 17, + /// Cross-device link + XDEV = 18, + /// No such device + NODEV = 19, + /// Not a directory + NOTDIR = 20, + /// Is a directory + ISDIR = 21, + /// Invalid argument + INVAL = 22, + /// File table overflow + NFILE = 23, + /// Too many open files + MFILE = 24, + /// Not a typewriter + NOTTY = 25, + /// Text file busy + TXTBSY = 26, + /// File too large + FBIG = 27, + /// No space left on device + NOSPC = 28, + /// Illegal seek + SPIPE = 29, + /// Read-only file system + ROFS = 30, + /// Too many links + MLINK = 31, + /// Broken pipe + PIPE = 32, + /// Math argument out of domain of func + DOM = 33, + /// Math result not representable + RANGE = 34, + + /// Resource deadlock would occur + DEADLK = 11, + + /// Try again. + /// Also used for WOULDBLOCK. + AGAIN = 35, + /// Operation now in progress + INPROGRESS = 36, + /// Operation already in progress + ALREADY = 37, + /// Socket operation on non-socket + NOTSOCK = 38, + /// Destination address required + DESTADDRREQ = 39, + /// Message too long + MSGSIZE = 40, + /// Protocol wrong type for socket + PROTOTYPE = 41, + /// Protocol not available + NOPROTOOPT = 42, + /// Protocol not supported + PROTONOSUPPORT = 43, + /// Socket type not supported + SOCKTNOSUPPORT = 44, + /// Operation not supported on transport endpoint + OPNOTSUPP = 45, + /// Protocol family not supported + PFNOSUPPORT = 46, + /// Address family not supported by protocol + AFNOSUPPORT = 47, + /// Address already in use + ADDRINUSE = 48, + /// Cannot assign requested address + ADDRNOTAVAIL = 49, + /// Network is down + NETDOWN = 50, + /// Network is unreachable + NETUNREACH = 51, + /// Network dropped connection because of reset + NETRESET = 52, + /// Software caused connection abort + CONNABORTED = 53, + /// Connection reset by peer + CONNRESET = 54, + /// No buffer space available + NOBUFS = 55, + /// Transport endpoint is already connected + ISCONN = 56, + /// Transport endpoint is not connected + NOTCONN = 57, + /// Cannot send after transport endpoint shutdown + SHUTDOWN = 58, + /// Too many references: cannot splice + TOOMANYREFS = 59, + /// Connection timed out + TIMEDOUT = 60, + /// Connection refused + CONNREFUSED = 61, + /// Too many symbolic links encountered + LOOP = 62, + /// File name too long + NAMETOOLONG = 63, + /// Host is down + HOSTDOWN = 64, + /// No route to host + HOSTUNREACH = 65, + /// Directory not empty + NOTEMPTY = 66, + + /// Too many users + USERS = 68, + /// Quota exceeded + DQUOT = 69, + /// Stale file handle + STALE = 70, + /// Object is remote + REMOTE = 71, + + /// No record locks available + NOLCK = 77, + /// Function not implemented + NOSYS = 78, + + /// No message of desired type + NOMSG = 80, + /// Identifier removed + IDRM = 81, + /// Out of streams resources + NOSR = 82, + /// Timer expired + TIME = 83, + /// Not a data message + /// Also used for FSBADCRC. + BADMSG = 84, + /// Protocol error + PROTO = 85, + /// No data available + NODATA = 86, + /// Device not a stream + NOSTR = 87, + + /// Package not installed + NOPKG = 92, + + /// Illegal byte sequence + ILSEQ = 116, + + // The following are designated "random noise" by the kernel sources. + /// Channel number out of range + CHRNG = 88, + /// Level 2 not synchronized + L2NSYNC = 89, + /// Level 3 halted + L3HLT = 90, + /// Level 3 reset + L3RST = 91, + + /// Link number out of range + LNRNG = 93, + /// Protocol driver not attached + UNATCH = 94, + /// No CSI structure available + NOCSI = 95, + /// Level 2 halted + L2HLT = 96, + /// Invalid exchange + BADE = 97, + /// Invalid request descriptor + BADR = 98, + /// Exchange full + XFULL = 99, + /// No anode + NOANO = 100, + /// Invalid request code + BADRQC = 101, + /// Invalid slot + BADSLT = 102, + + /// Bad font file format + BFONT = 104, + /// Machine is not on the network + NONET = 105, + /// Link has been severed + NOLINK = 106, + /// Advertise error + ADV = 107, + /// Srmount error + SRMNT = 108, + /// Communication error on send + COMM = 109, + /// Multihop attempted + MULTIHOP = 110, + /// RFS specific error + DOTDOT = 111, + /// Value too large for defined data type + OVERFLOW = 112, + /// Name not unique on network + NOTUNIQ = 113, + /// File descriptor in bad state + BADFD = 114, + /// Remote address changed + REMCHG = 115, + + /// Structure needs cleaning + /// Also used for FSCORRUPTED. + UCLEAN = 117, + /// Not a XENIX named type file + NOTNAM = 118, + /// No XENIX semaphores available + NAVAIL = 119, + /// Is a named type file + ISNAM = 120, + /// Remote I/O error + REMOTEIO = 121, + + /// Can not access a needed shared library + LIBACC = 122, + /// Accessing a corrupted shared library + LIBBAD = 123, + /// .lib section in a.out corrupted + LIBSCN = 124, + /// Attempting to link in too many shared libraries + LIBMAX = 125, + /// Cannot exec a shared library directly + LIBEXEC = 126, + /// Interrupted system call should be restarted + RESTART = 127, + /// Streams pipe error + STRPIPE = 128, + + /// No medium found + NOMEDIUM = 129, + /// Wrong medium type + MEDIUMTYPE = 130, + /// Operation Cancelled + CANCELED = 131, + /// Required key not available + NOKEY = 132, + /// Key has expired + KEYEXPIRED = 133, + /// Key has been revoked + KEYREVOKED = 134, + /// Key was rejected by service + KEYREJECTED = 135, + + // For robust mutexes + /// Owner died + OWNERDEAD = 136, + /// State not recoverable + NOTRECOVERABLE = 137, + + /// Operation not possible due to RF-kill + RFKILL = 138, + /// Memory page has hardware error + HWPOISON = 139, + _, + }, else => enum(u16) { /// No error occurred. /// Same code used for `NSROK`. @@ -3959,6 +4342,14 @@ pub const SA = if (is_mips) struct { pub const RESETHAND = 0x80000000; pub const ONSTACK = 0x08000000; pub const NODEFER = 0x40000000; +} else if (native_arch == .alpha) struct { + pub const ONSTACK = 0x00000001; + pub const RESTART = 0x00000002; + pub const NOCLDSTOP = 0x00000004; + pub const NODEFER = 0x00000008; + pub const RESETHAND = 0x00000010; + pub const NOCLDWAIT = 0x00000020; + pub const SIGINFO = 0x00000040; } else struct { pub const NOCLDSTOP = 1; pub const NOCLDWAIT = 2; @@ -4061,6 +4452,95 @@ pub const SIG = if (is_mips) enum(u32) { USR1 = 30, USR2 = 31, _, +} else if (native_arch == .alpha) enum(u32) { + pub const BLOCK = 1; + pub const UNBLOCK = 2; + pub const SETMASK = 3; + + pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); + pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); + pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); + + pub const POLL: SIG = .IO; + pub const PWR: SIG = .INFO; + pub const IOT: SIG = .ABRT; + + HUP = 1, + INT = 2, + QUIT = 3, + ILL = 4, + TRAP = 5, + ABRT = 6, + EMT = 7, + FPE = 8, + KILL = 9, + BUS = 10, + SEGV = 11, + SYS = 12, + PIPE = 13, + ALRM = 14, + TERM = 15, + URG = 16, + STOP = 17, + TSTP = 18, + CONT = 19, + CHLD = 20, + TTIN = 21, + TTOU = 22, + IO = 23, + XCPU = 24, + XFSZ = 25, + VTALRM = 26, + PROF = 27, + WINCH = 28, + INFO = 29, + USR1 = 30, + USR2 = 31, + _, +} else if (is_hppa) enum(u32) { + pub const BLOCK = 0; + pub const UNBLOCK = 1; + pub const SETMASK = 2; + + pub const ERR: ?Sigaction.handler_fn = @ptrFromInt(maxInt(usize)); + pub const DFL: ?Sigaction.handler_fn = @ptrFromInt(0); + pub const IGN: ?Sigaction.handler_fn = @ptrFromInt(1); + + pub const POLL: SIG = .IO; + pub const IOT: SIG = .ABRT; + + HUP = 1, + INT = 2, + QUIT = 3, + ILL = 4, + TRAP = 5, + ABRT = 6, + STKFLT = 7, + FPE = 8, + KILL = 9, + BUS = 10, + SEGV = 11, + XCPU = 12, + PIPE = 13, + ALRM = 14, + TERM = 15, + USR1 = 16, + USR2 = 17, + CHLD = 18, + PWR = 19, + VTALRM = 20, + PROF = 21, + IO = 22, + WINCH = 23, + STOP = 24, + TSTP = 25, + CONT = 26, + TTIN = 27, + TTOU = 28, + URG = 29, + XFSZ = 30, + SYS = 31, + _, } else enum(u32) { pub const BLOCK = 0; pub const UNBLOCK = 1; @@ -4137,8 +4617,20 @@ pub const SOCK = struct { pub const SEQPACKET = 5; pub const DCCP = 6; pub const PACKET = 10; - pub const CLOEXEC = if (is_sparc) 0o20000000 else 0o2000000; - pub const NONBLOCK = if (is_mips) 0o200 else if (is_sparc) 0o40000 else 0o4000; + pub const CLOEXEC = if (is_sparc) + 0o20000000 + else if (native_arch == .alpha) + 0o10000000 + else + 0o2000000; + pub const NONBLOCK = if (is_mips) + 0o200 + else if (is_sparc) + 0o40000 + else if (is_hppa or native_arch == .alpha) + 0x40000000 + else + 0o4000; }; pub const TCP = struct { @@ -4552,6 +5044,77 @@ pub const SO = if (is_mips) struct { pub const RCVTIMEO_NEW = 68; pub const SNDTIMEO_NEW = 69; pub const DETACH_REUSEPORT_BPF = 71; +} else if (native_arch == .alpha) struct { + pub const DEBUG = 1; + pub const REUSEADDR = 0x0004; + pub const KEEPALIVE = 0x0008; + pub const DONTROUTE = 0x0010; + pub const BROADCAST = 0x0020; + pub const LINGER = 0x0080; + pub const OOBINLINE = 0x0100; + pub const REUSEPORT = 0x0200; + + pub const SNDBUF = 0x1001; + pub const RCVBUF = 0x1002; + pub const SNDLOWAT = 0x1011; + pub const RCVLOWAT = 0x1010; + pub const RCVTIMEO = 0x1012; + pub const SNDTIMEO = 0x1013; + pub const ERROR = 0x1007; + pub const TYPE = 0x1008; + pub const ACCEPTCONN = 0x1014; + pub const PROTOCOL = 0x1028; + pub const DOMAIN = 0x1029; + + pub const NO_CHECK = 11; + pub const PRIORITY = 12; + pub const BSDCOMPAT = 14; + pub const PASSCRED = 17; + pub const PEERCRED = 18; + pub const PEERSEC = 30; + pub const SNDBUFFORCE = 0x100a; + pub const RCVBUFFORCE = 0x100b; + pub const SECURITY_AUTHENTICATION = 19; + pub const SECURITY_ENCRYPTION_TRANSPORT = 20; + pub const SECURITY_ENCRYPTION_NETWORK = 21; + pub const BINDTODEVICE = 25; + pub const ATTACH_FILTER = 26; + pub const DETACH_FILTER = 27; + pub const GET_FILTER = ATTACH_FILTER; + pub const PEERNAME = 28; + pub const TIMESTAMP_OLD = 29; + pub const PASSSEC = 34; + pub const TIMESTAMPNS_OLD = 35; + pub const MARK = 36; + pub const TIMESTAMPING_OLD = 37; + pub const RXQ_OVFL = 40; + pub const WIFI_STATUS = 41; + pub const PEEK_OFF = 42; + pub const NOFCS = 43; + pub const LOCK_FILTER = 44; + pub const SELECT_ERR_QUEUE = 45; + pub const BUSY_POLL = 46; + pub const MAX_PACING_RATE = 47; + pub const BPF_EXTENSIONS = 48; + pub const INCOMING_CPU = 49; + pub const ATTACH_BPF = 50; + pub const DETACH_BPF = DETACH_FILTER; + pub const ATTACH_REUSEPORT_CBPF = 51; + pub const ATTACH_REUSEPORT_EBPF = 52; + pub const CNX_ADVICE = 53; + pub const MEMINFO = 55; + pub const INCOMING_NAPI_ID = 56; + pub const COOKIE = 57; + pub const PEERGROUPS = 59; + pub const ZEROCOPY = 60; + pub const TXTIME = 61; + pub const BINDTOIFINDEX = 62; + pub const TIMESTAMP_NEW = 63; + pub const TIMESTAMPNS_NEW = 64; + pub const TIMESTAMPING_NEW = 65; + pub const RCVTIMEO_NEW = 66; + pub const SNDTIMEO_NEW = 67; + pub const DETACH_REUSEPORT_BPF = 68; } else struct { pub const DEBUG = 1; pub const REUSEADDR = 2; @@ -4637,7 +5200,10 @@ pub const SCM = struct { }; pub const SOL = struct { - pub const SOCKET = if (is_mips or is_sparc) 65535 else 1; + pub const SOCKET = if (is_mips or is_sparc or native_arch == .alpha) + 0xffff + else + 1; pub const IP = 0; pub const IPV6 = 41; @@ -5224,7 +5790,7 @@ pub const T = if (is_mips) struct { pub const IOCSERSETMULTI = 0x5490; pub const IOCMIWAIT = 0x5491; pub const IOCGICOUNT = 0x5492; -} else if (is_ppc) struct { +} else if (is_ppc or native_arch == .alpha) struct { pub const FIOCLEX = IOCTL.IO('f', 1); pub const FIONCLEX = IOCTL.IO('f', 2); pub const FIOASYNC = IOCTL.IOW('f', 125, c_int); @@ -6008,6 +6574,15 @@ pub const TFD = switch (native_arch) { pub const TIMER = TFD_TIMER; }, + .alpha => packed struct(u32) { + _0: u2 = 0, + NONBLOCK: bool = false, + _3: u18 = 0, + CLOEXEC: bool = false, + _: u10 = 0, + + pub const TIMER = TFD_TIMER; + }, else => packed struct(u32) { _0: u11 = 0, NONBLOCK: bool = false, @@ -6037,6 +6612,11 @@ pub const k_sigaction = switch (native_arch) { flags: c_ulong, mask: sigset_t, }, + .alpha => extern struct { + handler: k_sigaction_funcs.handler, + mask: sigset_t, + flags: c_int, + }, else => extern struct { handler: k_sigaction_funcs.handler, flags: c_ulong, @@ -6061,6 +6641,7 @@ pub const Sigaction = struct { mask: sigset_t, flags: switch (native_arch) { .mips, .mipsel, .mips64, .mips64el => c_uint, + .alpha => c_int, else => c_ulong, }, }; @@ -7531,7 +8112,14 @@ pub const rusage = extern struct { }; pub const NCC = if (is_ppc) 10 else 8; -pub const NCCS = if (is_mips) 32 else if (is_ppc) 19 else if (is_sparc) 17 else 32; +pub const NCCS = if (is_mips) + 32 +else if (is_ppc or native_arch == .alpha) + 19 +else if (is_sparc) + 17 +else + 32; pub const speed_t = if (is_ppc) enum(c_uint) { B0 = 0x0000000, @@ -7645,7 +8233,7 @@ pub const speed_t = if (is_ppc) enum(c_uint) { pub const tcflag_t = if (native_arch == .sparc) c_ulong else c_uint; -pub const tc_iflag_t = if (is_ppc) packed struct(tcflag_t) { +pub const tc_iflag_t = if (is_ppc or native_arch == .alpha) packed struct(tcflag_t) { IGNBRK: bool = false, BRKINT: bool = false, IGNPAR: bool = false, @@ -7681,7 +8269,7 @@ pub const tc_iflag_t = if (is_ppc) packed struct(tcflag_t) { _15: u17 = 0, }; -pub const NLDLY = if (is_ppc) enum(u2) { +pub const NLDLY = if (is_ppc or native_arch == .alpha) enum(u2) { NL0 = 0, NL1 = 1, NL2 = 2, @@ -7722,7 +8310,7 @@ pub const FFDLY = enum(u1) { FF1 = 1, }; -pub const tc_oflag_t = if (is_ppc) packed struct(tcflag_t) { +pub const tc_oflag_t = if (is_ppc or native_arch == .alpha) packed struct(tcflag_t) { OPOST: bool = false, ONLCR: bool = false, OLCUC: bool = false, @@ -7781,7 +8369,7 @@ pub const CSIZE = enum(u2) { CS8 = 3, }; -pub const tc_cflag_t = if (is_ppc) packed struct(tcflag_t) { +pub const tc_cflag_t = if (is_ppc or native_arch == .alpha) packed struct(tcflag_t) { _0: u8 = 0, CSIZE: CSIZE = .CS5, CSTOPB: bool = false, @@ -7828,7 +8416,7 @@ pub const tc_lflag_t = if (is_mips) packed struct(tcflag_t) { TOSTOP: bool = false, EXTPROC: bool = false, _17: u15 = 0, -} else if (is_ppc) packed struct(tcflag_t) { +} else if (is_ppc or native_arch == .alpha) packed struct(tcflag_t) { ECHOKE: bool = false, ECHOE: bool = false, ECHOK: bool = false, @@ -7929,6 +8517,24 @@ pub const V = if (is_mips) enum(u32) { STOP = 14, LNEXT = 15, DISCARD = 16, +} else if (arch_bits == .alpha) enum(u32) { + EOF = 0, + EOL = 1, + EOL2 = 2, + ERASE = 3, + WERASE = 4, + KILL = 5, + REPRINT = 6, + SWTC = 7, + INTR = 8, + QUIT = 9, + SUSP = 10, + START = 12, + STOP = 13, + LNEXT = 14, + DISCARD = 15, + MIN = 16, + TIME = 17, } else enum(u32) { INTR = 0, QUIT = 1, @@ -7959,7 +8565,7 @@ pub const sgttyb = if (is_mips or is_ppc or is_sparc) extern struct { flags: if (is_mips) c_int else c_short, } else void; -pub const tchars = if (is_mips or is_ppc or is_sparc) extern struct { +pub const tchars = if (is_mips or is_ppc or is_sparc or native_arch == .alpha) extern struct { intrc: c_char, quitc: c_char, startc: c_char, @@ -7968,7 +8574,7 @@ pub const tchars = if (is_mips or is_ppc or is_sparc) extern struct { brkc: c_char, } else void; -pub const ltchars = if (is_mips or is_ppc or is_sparc) extern struct { +pub const ltchars = if (is_mips or is_ppc or is_sparc or native_arch == .alpha) extern struct { suspc: c_char, dsuspc: c_char, rprntc: c_char, @@ -7993,7 +8599,7 @@ pub const termios = if (is_mips or is_sparc) extern struct { lflag: tc_lflag_t, line: cc_t, cc: [NCCS]cc_t, -} else if (is_ppc) extern struct { +} else if (is_ppc or native_arch == .alpha) extern struct { iflag: tc_iflag_t, oflag: tc_oflag_t, cflag: tc_cflag_t, @@ -8013,7 +8619,7 @@ pub const termios = if (is_mips or is_sparc) extern struct { ospeed: speed_t, }; -pub const termios2 = if (is_mips) extern struct { +pub const termios2 = if (is_mips or native_arch == .alpha) extern struct { iflag: tc_iflag_t, oflag: tc_oflag_t, cflag: tc_cflag_t, @@ -8592,6 +9198,49 @@ pub const rlimit_resource = if (native_arch.isMIPS()) enum(c_int) { /// call before being forcibly descheduled. RTTIME = 15, + _, +} else if (native_arch == .alpha) enum(c_int) { + /// Per-process CPU limit, in seconds. + CPU = 0, + /// Largest file that can be created, in bytes. + FSIZE = 1, + /// Maximum size of data segment, in bytes. + DATA = 2, + /// Maximum size of stack segment, in bytes. + STACK = 3, + /// Largest core file that can be created, in bytes. + CORE = 4, + /// Largest resident set size, in bytes. + /// This affects swapping; processes that are exceeding their + /// resident set size will be more likely to have physical memory + /// taken from them. + RSS = 5, + /// Number of open files. + NOFILE = 6, + /// Address space limit. + AS = 7, + /// Number of processes. + NPROC = 8, + /// Locked-in-memory address space. + MEMLOCK = 9, + /// Maximum number of file locks. + LOCKS = 10, + /// Maximum number of pending signals. + SIGPENDING = 11, + /// Maximum bytes in POSIX message queues. + MSGQUEUE = 12, + /// Maximum nice priority allowed to raise to. + /// Nice levels 19 .. -20 correspond to 0 .. 39 + /// values of this resource limit. + NICE = 13, + /// Maximum realtime priority allowed for non-privileged + /// processes. + RTPRIO = 14, + /// Maximum CPU time in µs that a process scheduled under a real-time + /// scheduling policy may consume without making a blocking system + /// call before being forcibly descheduled. + RTTIME = 15, + _, } else enum(c_int) { /// Per-process CPU limit, in seconds. @@ -8642,7 +9291,10 @@ pub const rlim_t = u64; pub const RLIM = struct { /// No limit - pub const INFINITY = ~@as(rlim_t, 0); + pub const INFINITY: rlim_t = if (native_arch == .alpha) + ~@as(u63, 0) + else + ~@as(rlim_t, 0); pub const SAVED_MAX = INFINITY; pub const SAVED_CUR = INFINITY; diff --git a/lib/std/os/linux/IoUring/test.zig b/lib/std/os/linux/IoUring/test.zig index 44e570f50b7a49ad36717dfbf4b7bee05094850f..add4f30f8512e1c0c470cba0f253a7ff80159cf1 100644 --- a/lib/std/os/linux/IoUring/test.zig +++ b/lib/std/os/linux/IoUring/test.zig @@ -1273,6 +1273,8 @@ test "symlinkat" { .SUCCESS => {}, // This kernel's io_uring does not yet implement symlinkat (kernel version < 5.15) .BADF, .INVAL => return error.SkipZigTest, + // Can occur on certain filesystems (seen on CIFS) + .OPNOTSUPP => return error.SkipZigTest, else => |errno| std.debug.panic("unhandled errno: {}", .{errno}), } try testing.expectEqual(linux.io_uring_cqe{ diff --git a/lib/std/os/linux/alpha.zig b/lib/std/os/linux/alpha.zig new file mode 100644 index 0000000000000000000000000000000000000000..20bf4bd14bbceacc74e2e9328dcfac74c7603b46 --- /dev/null +++ b/lib/std/os/linux/alpha.zig @@ -0,0 +1,358 @@ +const builtin = @import("builtin"); +const std = @import("../../std.zig"); +const SYS = std.os.linux.SYS; + +pub fn syscall0(number: SYS) u64 { + return asm volatile ( + \\ callsys + \\ beq $19, 1f + \\ negq $0, $0 + \\1: + : [ret] "={$0}" (-> u64), + : [number] "{$0}" (number), + : .{ + .r1 = true, + .r2 = true, + .r3 = true, + .r4 = true, + .r5 = true, + .r6 = true, + .r7 = true, + .r8 = true, + .r22 = true, + .r23 = true, + .r24 = true, + .r25 = true, + .r27 = true, + .r28 = true, + .memory = true, + .r16 = true, + .r17 = true, + .r18 = true, + .r20 = true, + .r21 = true, + }); +} + +pub fn syscall1(number: SYS, arg1: u64) u64 { + // These registers are both inputs and clobbers. + var r16_out: u64 = undefined; + return asm volatile ( + \\ callsys + \\ beq $19, 1f + \\ negq $0, $0 + \\1: + : [ret] "={$0}" (-> u64), + [r16_out] "={$16}" (r16_out), + : [number] "{$0}" (number), + [arg1] "{$16}" (arg1), + : .{ + .r1 = true, + .r2 = true, + .r3 = true, + .r4 = true, + .r5 = true, + .r6 = true, + .r7 = true, + .r8 = true, + .r22 = true, + .r23 = true, + .r24 = true, + .r25 = true, + .r27 = true, + .r28 = true, + .memory = true, + .r17 = true, + .r18 = true, + .r20 = true, + .r21 = true, + }); +} + +pub fn syscall2(number: SYS, arg1: u64, arg2: u64) u64 { + // These registers are both inputs and clobbers. + var r16_out: u64 = undefined; + var r17_out: u64 = undefined; + return asm volatile ( + \\ callsys + \\ beq $19, 1f + \\ negq $0, $0 + \\1: + : [ret] "={$0}" (-> u64), + [r16_out] "={$16}" (r16_out), + [r17_out] "={$17}" (r17_out), + : [number] "{$0}" (number), + [arg1] "{$16}" (arg1), + [arg2] "{$17}" (arg2), + : .{ + .r1 = true, + .r2 = true, + .r3 = true, + .r4 = true, + .r5 = true, + .r6 = true, + .r7 = true, + .r8 = true, + .r22 = true, + .r23 = true, + .r24 = true, + .r25 = true, + .r27 = true, + .r28 = true, + .memory = true, + .r18 = true, + .r20 = true, + .r21 = true, + }); +} + +pub fn syscall3(number: SYS, arg1: u64, arg2: u64, arg3: u64) u64 { + // These registers are both inputs and clobbers. + var r16_out: u64 = undefined; + var r17_out: u64 = undefined; + var r18_out: u64 = undefined; + return asm volatile ( + \\ callsys + \\ beq $19, 1f + \\ negq $0, $0 + \\1: + : [ret] "={$0}" (-> u64), + [r16_out] "={$16}" (r16_out), + [r17_out] "={$17}" (r17_out), + [r18_out] "={$18}" (r18_out), + : [number] "{$0}" (number), + [arg1] "{$16}" (arg1), + [arg2] "{$17}" (arg2), + [arg3] "{$18}" (arg3), + : .{ + .r1 = true, + .r2 = true, + .r3 = true, + .r4 = true, + .r5 = true, + .r6 = true, + .r7 = true, + .r8 = true, + .r22 = true, + .r23 = true, + .r24 = true, + .r25 = true, + .r27 = true, + .r28 = true, + .memory = true, + .r20 = true, + .r21 = true, + }); +} + +pub fn syscall4(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64) u64 { + // These registers are both inputs and clobbers. + var r16_out: u64 = undefined; + var r17_out: u64 = undefined; + var r18_out: u64 = undefined; + var r19_out: u64 = undefined; + return asm volatile ( + \\ callsys + \\ beq $19, 1f + \\ negq $0, $0 + \\1: + : [ret] "={$0}" (-> u64), + [r16_out] "={$16}" (r16_out), + [r17_out] "={$17}" (r17_out), + [r18_out] "={$18}" (r18_out), + [r19_out] "={$19}" (r19_out), + : [number] "{$0}" (number), + [arg1] "{$16}" (arg1), + [arg2] "{$17}" (arg2), + [arg3] "{$18}" (arg3), + [arg4] "{$19}" (arg4), + : .{ + .r1 = true, + .r2 = true, + .r3 = true, + .r4 = true, + .r5 = true, + .r6 = true, + .r7 = true, + .r8 = true, + .r22 = true, + .r23 = true, + .r24 = true, + .r25 = true, + .r27 = true, + .r28 = true, + .memory = true, + .r20 = true, + .r21 = true, + }); +} + +pub fn syscall5(number: SYS, arg1: u64, arg2: u64, arg3: u64, arg4: u64, arg5: u64) u64 { + // These registers are both inputs and clobbers. + var r16_out: u64 = undefined; + var r17_out: u64 = undefined; + var r18_out: u64 = undefined; + var r19_out: u64 = undefined; + var r20_out: u64 = undefined; + return asm volatile ( + \\ callsys + \\ beq $19, 1f + \\ negq $0, $0 + \\1: + : [ret] "={$0}" (-> u64), + [r16_out] "={$16}" (r16_out), + [r17_out] "={$17}" (r17_out), + [r18_out] "={$18}" (r18_out), + [r19_out] "={$19}" (r19_out), + [r20_out] "={$20}" (r20_out), + : [number] "{$0}" (number), + [arg1] "{$16}" (arg1), + [arg2] "{$17}" (arg2), + [arg3] "{$18}" (arg3), + [arg4] "{$19}" (arg4), + [arg5] "{$20}" (arg5), + : .{ + .r1 = true, + .r2 = true, + .r3 = true, + .r4 = true, + .r5 = true, + .r6 = true, + .r7 = true, + .r8 = true, + .r22 = true, + .r23 = true, + .r24 = true, + .r25 = true, + .r27 = true, + .r28 = true, + .memory = true, + .r21 = true, + }); +} + +pub fn syscall6( + number: SYS, + arg1: u64, + arg2: u64, + arg3: u64, + arg4: u64, + arg5: u64, + arg6: u64, +) u64 { + // These registers are both inputs and clobbers. + var r16_out: u64 = undefined; + var r17_out: u64 = undefined; + var r18_out: u64 = undefined; + var r19_out: u64 = undefined; + var r20_out: u64 = undefined; + var r21_out: u64 = undefined; + return asm volatile ( + \\ callsys + \\ beq $19, 1f + \\ negq $0, $0 + \\1: + : [ret] "={$0}" (-> u64), + [r16_out] "={$16}" (r16_out), + [r17_out] "={$17}" (r17_out), + [r18_out] "={$18}" (r18_out), + [r19_out] "={$19}" (r19_out), + [r20_out] "={$20}" (r20_out), + [r21_out] "={$21}" (r21_out), + : [number] "{$0}" (number), + [arg1] "{$16}" (arg1), + [arg2] "{$17}" (arg2), + [arg3] "{$18}" (arg3), + [arg4] "{$19}" (arg4), + [arg5] "{$20}" (arg5), + [arg6] "{$21}" (arg6), + : .{ + .r1 = true, + .r2 = true, + .r3 = true, + .r4 = true, + .r5 = true, + .r6 = true, + .r7 = true, + .r8 = true, + .r22 = true, + .r23 = true, + .r24 = true, + .r25 = true, + .r27 = true, + .r28 = true, + .memory = true, + }); +} + +pub fn clone() callconv(.naked) u64 { + // __clone(func, stack, flags, arg, ptid, tls, ctid) + // a0, a1, a2, a3, a4, a5, +0 + // + // syscall(SYS_clone, flags, stack, ptid, ctid, tls) + // v0 a0, a1, a2, a3, a4 + asm volatile ( + // a0 = $16, a1 = $17, a2 = $18, a3 = $19, + // a4 = $20, a5 = $21, sp = $30, v0 = $0 + \\ # Save function pointer and argument pointer on new thread stack + \\ ldi $1, -8 + \\ and $17, $17, $1 + \\ lda $17, -16($17) + \\ stq $16, 0($17) + \\ stq $19, 8($17) + \\ + \\ # Shuffle (fn,sp,fl,arg,ptid,tls,ctid) to (fl,sp,ptid,ctid,tls) + \\ mov $18, $16 + \\ mov $20, $18 + \\ ldq $19, 0($30) + \\ mov $21, $20 + \\ + \\ # Actual syscall + \\ ldi $0, 312 # SYS_clone + \\ callsys + \\ beq $19, 1f + \\ negq $0, $0 + \\ ret + \\1: + \\ beq $0, 2f + \\ ret + \\2: + ); + if (builtin.unwind_tables != .none or !builtin.strip_debug_info) asm volatile ( + // ra = $26 + \\ .cfi_undefined $26 + ); + asm volatile ( + // v0 = $0, t9 = $23, a0 = $16, ra = $26, sp = $30, fp = $15 + \\ mov 0, $15 + \\ + \\ ldq $23, 0($30) + \\ ldq $16, 8($30) + \\ lda $30, 16($30) + \\ jsr $26, ($23) + \\ + \\ mov $0, $16 + \\ ldi $0, 1 # SYS_EXIT + \\ callsys + ); +} + +pub fn restore() noreturn { + asm volatile ( + // v0 = $0, a0 = $16, sp = $30 + \\ mov $30, $16 + \\ ldi $0, 103 # SIGRETURN + \\ callsys + ); +} + +pub fn restore_rt() noreturn { + asm volatile ( + // v0 = $0, a0 = $16, sp = $30 + \\ mov $30, $16 + \\ ldi $0, 351 # RT_SIGRETURN + \\ callsys + ); +} + +pub const VDSO = void; diff --git a/lib/std/os/linux/ioctl.zig b/lib/std/os/linux/ioctl.zig index a5a6e854f70defa5f9a0e07547bfbb97909cab8c..4cf1c497ebbfcc6e170c59a4ed7f1c9958c2a518 100644 --- a/lib/std/os/linux/ioctl.zig +++ b/lib/std/os/linux/ioctl.zig @@ -11,6 +11,7 @@ const bits = switch (@import("builtin").cpu.arch) { .powerpc64le, .sparc, .sparc64, + .alpha, => .{ .size = 13, .dir = 3, .none = 1, .read = 2, .write = 4 }, else => .{ .size = 14, .dir = 2, .none = 0, .read = 2, .write = 1 }, }; diff --git a/lib/std/os/linux/syscalls.zig b/lib/std/os/linux/syscalls.zig index afd41fc65b7c2097cccc059cb9b32a8bc9bec6fc..2bf58d4d096fec09ded5eb8e14d34a01fa1a30d9 100644 --- a/lib/std/os/linux/syscalls.zig +++ b/lib/std/os/linux/syscalls.zig @@ -5851,6 +5851,508 @@ pub const Xtensa = enum(usize) { rseq_slice_yield = 471, }; +pub const Alpha = enum(usize) { + osf_syscall = 0, + exit = 1, + fork = 2, + read = 3, + write = 4, + osf_old_open = 5, + close = 6, + osf_wait4 = 7, + osf_old_creat = 8, + link = 9, + unlink = 10, + osf_execve = 11, + chdir = 12, + fchdir = 13, + mknod = 14, + chmod = 15, + chown = 16, + brk = 17, + osf_getfsstat = 18, + lseek = 19, + getpid = 20, + osf_mount = 21, + umount2 = 22, + setuid = 23, + getuid = 24, + exec_with_loader = 25, + ptrace = 26, + osf_nrecvmsg = 27, + osf_nsendmsg = 28, + osf_nrecvfrom = 29, + osf_naccept = 30, + osf_ngetpeername = 31, + osf_ngetsockname = 32, + access = 33, + osf_chflags = 34, + osf_fchflags = 35, + sync = 36, + kill = 37, + osf_old_stat = 38, + setpgid = 39, + osf_old_lstat = 40, + dup = 41, + pipe = 42, + osf_set_program_attributes = 43, + osf_profil = 44, + open = 45, + osf_old_sigaction = 46, + getgid = 47, + osf_sigprocmask = 48, + osf_getlogin = 49, + osf_setlogin = 50, + acct = 51, + sigpending = 52, + ioctl = 54, + osf_reboot = 55, + osf_revoke = 56, + symlink = 57, + readlink = 58, + execve = 59, + umask = 60, + chroot = 61, + osf_old_fstat = 62, + getpgrp = 63, + getpagesize = 64, + osf_mremap = 65, + vfork = 66, + stat = 67, + lstat = 68, + osf_sbrk = 69, + osf_sstk = 70, + mmap = 71, + osf_old_vadvise = 72, + munmap = 73, + mprotect = 74, + madvise = 75, + vhangup = 76, + osf_kmodcall = 77, + osf_mincore = 78, + getgroups = 79, + setgroups = 80, + osf_old_getpgrp = 81, + setpgrp = 82, + osf_setitimer = 83, + osf_old_wait = 84, + osf_table = 85, + osf_getitimer = 86, + gethostname = 87, + sethostname = 88, + getdtablesize = 89, + dup2 = 90, + fstat = 91, + fcntl = 92, + osf_select = 93, + poll = 94, + fsync = 95, + setpriority = 96, + socket = 97, + connect = 98, + accept = 99, + getpriority = 100, + send = 101, + recv = 102, + sigreturn = 103, + bind = 104, + setsockopt = 105, + listen = 106, + osf_plock = 107, + osf_old_sigvec = 108, + osf_old_sigblock = 109, + osf_old_sigsetmask = 110, + sigsuspend = 111, + osf_sigstack = 112, + recvmsg = 113, + sendmsg = 114, + osf_old_vtrace = 115, + osf_gettimeofday = 116, + osf_getrusage = 117, + getsockopt = 118, + readv = 120, + writev = 121, + osf_settimeofday = 122, + fchown = 123, + fchmod = 124, + recvfrom = 125, + setreuid = 126, + setregid = 127, + rename = 128, + truncate = 129, + ftruncate = 130, + flock = 131, + setgid = 132, + sendto = 133, + shutdown = 134, + socketpair = 135, + mkdir = 136, + rmdir = 137, + osf_utimes = 138, + osf_old_sigreturn = 139, + osf_adjtime = 140, + getpeername = 141, + osf_gethostid = 142, + osf_sethostid = 143, + getrlimit = 144, + setrlimit = 145, + osf_old_killpg = 146, + setsid = 147, + quotactl = 148, + osf_oldquota = 149, + getsockname = 150, + osf_pid_block = 153, + osf_pid_unblock = 154, + sigaction = 156, + osf_sigwaitprim = 157, + osf_nfssvc = 158, + osf_getdirentries = 159, + osf_statfs = 160, + osf_fstatfs = 161, + osf_asynch_daemon = 163, + osf_getfh = 164, + osf_getdomainname = 165, + setdomainname = 166, + osf_exportfs = 169, + osf_alt_plock = 181, + osf_getmnt = 184, + osf_alt_sigpending = 187, + osf_alt_setsid = 188, + osf_swapon = 199, + msgctl = 200, + msgget = 201, + msgrcv = 202, + msgsnd = 203, + semctl = 204, + semget = 205, + semop = 206, + osf_utsname = 207, + lchown = 208, + shmat = 209, + shmctl = 210, + shmdt = 211, + shmget = 212, + osf_mvalid = 213, + osf_getaddressconf = 214, + osf_msleep = 215, + osf_mwakeup = 216, + msync = 217, + osf_signal = 218, + osf_utc_gettime = 219, + osf_utc_adjtime = 220, + osf_security = 222, + osf_kloadcall = 223, + osf_stat = 224, + osf_lstat = 225, + osf_fstat = 226, + osf_statfs64 = 227, + osf_fstatfs64 = 228, + getpgid = 233, + getsid = 234, + sigaltstack = 235, + osf_waitid = 236, + osf_priocntlset = 237, + osf_sigsendset = 238, + osf_set_speculative = 239, + osf_msfs_syscall = 240, + osf_sysinfo = 241, + osf_uadmin = 242, + osf_fuser = 243, + osf_proplist_syscall = 244, + osf_ntp_adjtime = 245, + osf_ntp_gettime = 246, + osf_pathconf = 247, + osf_fpathconf = 248, + osf_uswitch = 250, + osf_usleep_thread = 251, + osf_audcntl = 252, + osf_audgen = 253, + sysfs = 254, + osf_subsys_info = 255, + osf_getsysinfo = 256, + osf_setsysinfo = 257, + osf_afs_syscall = 258, + osf_swapctl = 259, + osf_memcntl = 260, + osf_fdatasync = 261, + bdflush = 300, + sethae = 301, + mount = 302, + old_adjtimex = 303, + swapoff = 304, + getdents = 305, + create_module = 306, + init_module = 307, + delete_module = 308, + get_kernel_syms = 309, + syslog = 310, + reboot = 311, + clone = 312, + uselib = 313, + mlock = 314, + munlock = 315, + mlockall = 316, + munlockall = 317, + sysinfo = 318, + sysctl = 319, + oldumount = 321, + swapon = 322, + times = 323, + personality = 324, + setfsuid = 325, + setfsgid = 326, + ustat = 327, + statfs = 328, + fstatfs = 329, + sched_setparam = 330, + sched_getparam = 331, + sched_setscheduler = 332, + sched_getscheduler = 333, + sched_yield = 334, + sched_get_priority_max = 335, + sched_get_priority_min = 336, + sched_rr_get_interval = 337, + afs_syscall = 338, + uname = 339, + nanosleep = 340, + mremap = 341, + nfsservctl = 342, + setresuid = 343, + getresuid = 344, + pciconfig_read = 345, + pciconfig_write = 346, + query_module = 347, + prctl = 348, + pread64 = 349, + pwrite64 = 350, + rt_sigreturn = 351, + rt_sigaction = 352, + rt_sigprocmask = 353, + rt_sigpending = 354, + rt_sigtimedwait = 355, + rt_sigqueueinfo = 356, + rt_sigsuspend = 357, + select = 358, + gettimeofday = 359, + settimeofday = 360, + getitimer = 361, + setitimer = 362, + utimes = 363, + getrusage = 364, + wait4 = 365, + adjtimex = 366, + getcwd = 367, + capget = 368, + capset = 369, + sendfile = 370, + setresgid = 371, + getresgid = 372, + dipc = 373, + pivot_root = 374, + mincore = 375, + pciconfig_iobase = 376, + getdents64 = 377, + gettid = 378, + readahead = 379, + tkill = 381, + setxattr = 382, + lsetxattr = 383, + fsetxattr = 384, + getxattr = 385, + lgetxattr = 386, + fgetxattr = 387, + listxattr = 388, + llistxattr = 389, + flistxattr = 390, + removexattr = 391, + lremovexattr = 392, + fremovexattr = 393, + futex = 394, + sched_setaffinity = 395, + sched_getaffinity = 396, + tuxcall = 397, + io_setup = 398, + io_destroy = 399, + io_getevents = 400, + io_submit = 401, + io_cancel = 402, + exit_group = 405, + lookup_dcookie = 406, + epoll_create = 407, + epoll_ctl = 408, + epoll_wait = 409, + remap_file_pages = 410, + set_tid_address = 411, + restart_syscall = 412, + fadvise64 = 413, + timer_create = 414, + timer_settime = 415, + timer_gettime = 416, + timer_getoverrun = 417, + timer_delete = 418, + clock_settime = 419, + clock_gettime = 420, + clock_getres = 421, + clock_nanosleep = 422, + semtimedop = 423, + tgkill = 424, + stat64 = 425, + lstat64 = 426, + fstat64 = 427, + vserver = 428, + mbind = 429, + get_mempolicy = 430, + set_mempolicy = 431, + mq_open = 432, + mq_unlink = 433, + mq_timedsend = 434, + mq_timedreceive = 435, + mq_notify = 436, + mq_getsetattr = 437, + waitid = 438, + add_key = 439, + request_key = 440, + keyctl = 441, + ioprio_set = 442, + ioprio_get = 443, + inotify_init = 444, + inotify_add_watch = 445, + inotify_rm_watch = 446, + fdatasync = 447, + kexec_load = 448, + migrate_pages = 449, + openat = 450, + mkdirat = 451, + mknodat = 452, + fchownat = 453, + futimesat = 454, + fstatat64 = 455, + unlinkat = 456, + renameat = 457, + linkat = 458, + symlinkat = 459, + readlinkat = 460, + fchmodat = 461, + faccessat = 462, + pselect6 = 463, + ppoll = 464, + unshare = 465, + set_robust_list = 466, + get_robust_list = 467, + splice = 468, + sync_file_range = 469, + tee = 470, + vmsplice = 471, + move_pages = 472, + getcpu = 473, + epoll_pwait = 474, + utimensat = 475, + signalfd = 476, + timerfd = 477, + eventfd = 478, + recvmmsg = 479, + fallocate = 480, + timerfd_create = 481, + timerfd_settime = 482, + timerfd_gettime = 483, + signalfd4 = 484, + eventfd2 = 485, + epoll_create1 = 486, + dup3 = 487, + pipe2 = 488, + inotify_init1 = 489, + preadv = 490, + pwritev = 491, + rt_tgsigqueueinfo = 492, + perf_event_open = 493, + fanotify_init = 494, + fanotify_mark = 495, + prlimit64 = 496, + name_to_handle_at = 497, + open_by_handle_at = 498, + clock_adjtime = 499, + syncfs = 500, + setns = 501, + accept4 = 502, + sendmmsg = 503, + process_vm_readv = 504, + process_vm_writev = 505, + kcmp = 506, + finit_module = 507, + sched_setattr = 508, + sched_getattr = 509, + renameat2 = 510, + getrandom = 511, + memfd_create = 512, + execveat = 513, + seccomp = 514, + bpf = 515, + userfaultfd = 516, + membarrier = 517, + mlock2 = 518, + copy_file_range = 519, + preadv2 = 520, + pwritev2 = 521, + statx = 522, + io_pgetevents = 523, + pkey_mprotect = 524, + pkey_alloc = 525, + pkey_free = 526, + rseq = 527, + statfs64 = 528, + fstatfs64 = 529, + getegid = 530, + geteuid = 531, + getppid = 532, + pidfd_send_signal = 534, + io_uring_setup = 535, + io_uring_enter = 536, + io_uring_register = 537, + open_tree = 538, + move_mount = 539, + fsopen = 540, + fsconfig = 541, + fsmount = 542, + fspick = 543, + pidfd_open = 544, + clone3 = 545, + close_range = 546, + openat2 = 547, + pidfd_getfd = 548, + faccessat2 = 549, + process_madvise = 550, + epoll_pwait2 = 551, + mount_setattr = 552, + quotactl_fd = 553, + landlock_create_ruleset = 554, + landlock_add_rule = 555, + landlock_restrict_self = 556, + process_mrelease = 558, + futex_waitv = 559, + set_mempolicy_home_node = 560, + cachestat = 561, + fchmodat2 = 562, + map_shadow_stack = 563, + futex_wake = 564, + futex_wait = 565, + futex_requeue = 566, + statmount = 567, + listmount = 568, + lsm_get_self_attr = 569, + lsm_set_self_attr = 570, + lsm_list_modules = 571, + mseal = 572, + setxattrat = 573, + getxattrat = 574, + listxattrat = 575, + removexattrat = 576, + open_tree_attr = 577, + file_getattr = 578, + file_setattr = 579, + listns = 580, + rseq_slice_yield = 581, +}; + pub const Arm64 = enum(usize) { io_setup = 0, io_destroy = 1, diff --git a/lib/std/os/linux/tls.zig b/lib/std/os/linux/tls.zig index 3d180f05dce1bc8e3a7a3fb7d818651bd9cf6055..e188f954626cb7b6ad9b78faf5d723ffc2eae4cd 100644 --- a/lib/std/os/linux/tls.zig +++ b/lib/std/os/linux/tls.zig @@ -256,7 +256,7 @@ pub fn setThreadPointer(addr: usize) void { }, .alpha => { asm volatile ( - \\ lda a0, %[addr] + \\ lda $16, 0(%[addr]) \\ wruniq : : [addr] "r" (addr), diff --git a/tools/generate_linux_syscalls.zig b/tools/generate_linux_syscalls.zig index de537563127047c338ea71390c717589e9e426f1..d612138eb2673b4620fb54b87fbb4e3d6c38947d 100644 --- a/tools/generate_linux_syscalls.zig +++ b/tools/generate_linux_syscalls.zig @@ -28,6 +28,11 @@ const stdlib_renames = std.StaticStringMap([]const u8).initComptime(.{ // ARM EABI/Thumb. .{ "arm_sync_file_range", "sync_file_range" }, .{ "arm_fadvise64_64", "fadvise64_64" }, + // Alpha + // See https://github.com/torvalds/linux/blob/8bf22c33e7a172fbc72464f4cc484d23a6b412ba/arch/alpha/include/uapi/asm/unistd.h#L10 + .{ "getxpid", "getpid" }, + .{ "getxuid", "getuid" }, + .{ "getxgid", "getgid" }, }); /// Filter syscalls that aren't actually syscalls. @@ -156,6 +161,7 @@ const architectures: []const Arch = &.{ .{ .@"var" = "PowerPC64", .table = .{ .specific = "arch/powerpc/kernel/syscalls/syscall.tbl" }, .abi = &.{ .common, .@"64", .nospu } }, .{ .@"var" = "S390x", .table = .{ .specific = "arch/s390/kernel/syscalls/syscall.tbl" }, .abi = &.{ .common, .@"64" } }, .{ .@"var" = "Xtensa", .table = .{ .specific = "arch/xtensa/kernel/syscalls/syscall.tbl" } }, + .{ .@"var" = "Alpha", .table = .{ .specific = "arch/alpha/kernel/syscalls/syscall.tbl" } }, .{ .@"var" = "Arm64", .table = .generic, .abi = &.{ .common, .@"64", .renameat, .rlimit, .memfd_secret } }, .{ .@"var" = "RiscV32", .table = .generic, .abi = &.{ .common, .@"32", .riscv, .memfd_secret } }, .{ .@"var" = "RiscV64", .table = .generic, .abi = &.{ .common, .@"64", .riscv, .rlimit, .memfd_secret } },