From 834202bf985c257b2bf79df7cb804af9cb0ca422 Mon Sep 17 00:00:00 2001 From: Koakuma Date: Mon, 27 Sep 2021 21:00:07 +0700 Subject: [PATCH 1/3] SPARCv9: Fix freeAndExit implementation This fixes the wrong branch target and register check. (https://github.com/ziglang/zig/issues/9801) --- lib/std/Thread.zig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index ae3a3e9d9e..625255d411 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -813,12 +813,11 @@ const LinuxThreadImpl = struct { \\ # force-deactivate it by running `restore` until \\ # all frames are cleared. \\ 1: - \\ cmp %%sp, 0 + \\ cmp %%fp, 0 \\ beq 2f \\ nop + \\ ba 1b \\ restore - \\ ba 1f - \\ nop \\ 2: \\ mov 73, %%g1 \\ mov %[ptr], %%o0 From 569802160e187b9a51e5e62b3f456b6680973e0c Mon Sep 17 00:00:00 2001 From: Koakuma Date: Mon, 27 Sep 2021 21:01:03 +0700 Subject: [PATCH 2/3] Linux: fix socket constants for SPARCv9 --- lib/std/os/linux.zig | 244 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 195 insertions(+), 49 deletions(-) diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig index 7e482fe2f4..8cc9eb1254 100644 --- a/lib/std/os/linux.zig +++ b/lib/std/os/linux.zig @@ -2005,8 +2005,8 @@ pub const SOCK = struct { pub const SEQPACKET = 5; pub const DCCP = 6; pub const PACKET = 10; - pub const CLOEXEC = 0o2000000; - pub const NONBLOCK = if (is_mips) 0o200 else 0o4000; + 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 TCP = struct { @@ -2218,6 +2218,47 @@ pub const SO = struct { pub const PEERSEC = 30; pub const SNDBUFFORCE = 31; pub const RCVBUFFORCE = 33; + pub const SECURITY_AUTHENTICATION = 22; + pub const SECURITY_ENCRYPTION_TRANSPORT = 23; + pub const SECURITY_ENCRYPTION_NETWORK = 24; + 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 if (is_ppc or is_ppc64) struct { pub const DEBUG = 1; pub const REUSEADDR = 2; @@ -2246,6 +2287,116 @@ pub const SO = struct { pub const RCVBUFFORCE = 33; pub const PROTOCOL = 38; pub const DOMAIN = 39; + pub const SECURITY_AUTHENTICATION = 22; + pub const SECURITY_ENCRYPTION_TRANSPORT = 23; + pub const SECURITY_ENCRYPTION_NETWORK = 24; + 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 if (is_sparc) struct { + pub const DEBUG = 1; + pub const REUSEADDR = 4; + pub const TYPE = 4104; + pub const ERROR = 4103; + pub const DONTROUTE = 16; + pub const BROADCAST = 32; + pub const SNDBUF = 4097; + pub const RCVBUF = 4098; + pub const KEEPALIVE = 8; + pub const OOBINLINE = 256; + pub const NO_CHECK = 11; + pub const PRIORITY = 12; + pub const LINGER = 128; + pub const BSDCOMPAT = 1024; + pub const REUSEPORT = 512; + pub const PASSCRED = 2; + pub const PEERCRED = 64; + pub const RCVLOWAT = 2048; + pub const SNDLOWAT = 4096; + pub const RCVTIMEO = 8192; + pub const SNDTIMEO = 16384; + pub const ACCEPTCONN = 32768; + pub const PEERSEC = 30; + pub const SNDBUFFORCE = 4106; + pub const RCVBUFFORCE = 4107; + pub const PROTOCOL = 4136; + pub const DOMAIN = 4137; + pub const SECURITY_AUTHENTICATION = 20481; + pub const SECURITY_ENCRYPTION_TRANSPORT = 20482; + pub const SECURITY_ENCRYPTION_NETWORK = 20484; + pub const BINDTODEVICE = 13; + pub const ATTACH_FILTER = 26; + pub const DETACH_FILTER = 27; + pub const GET_FILTER = 26; + pub const PEERNAME = 28; + pub const TIMESTAMP_OLD = 29; + pub const PASSSEC = 31; + pub const TIMESTAMPNS_OLD = 33; + pub const MARK = 34; + pub const TIMESTAMPING_OLD = 35; + pub const RXQ_OVFL = 36; + pub const WIFI_STATUS = 37; + pub const PEEK_OFF = 38; + pub const NOFCS = 39; + pub const LOCK_FILTER = 40; + pub const SELECT_ERR_QUEUE = 41; + pub const BUSY_POLL = 48; + pub const MAX_PACING_RATE = 49; + pub const BPF_EXTENSIONS = 50; + pub const INCOMING_CPU = 51; + pub const ATTACH_BPF = 52; + pub const DETACH_BPF = 27; + pub const ATTACH_REUSEPORT_CBPF = 53; + pub const ATTACH_REUSEPORT_EBPF = 54; + pub const CNX_ADVICE = 55; + pub const MEMINFO = 57; + pub const INCOMING_NAPI_ID = 58; + pub const COOKIE = 59; + pub const PEERGROUPS = 61; + pub const ZEROCOPY = 62; + pub const TXTIME = 63; + pub const BINDTOIFINDEX = 65; + pub const TIMESTAMP_NEW = 70; + pub const TIMESTAMPNS_NEW = 66; + pub const TIMESTAMPING_NEW = 67; + pub const RCVTIMEO_NEW = 68; + pub const SNDTIMEO_NEW = 69; + pub const DETACH_REUSEPORT_BPF = 71; } else struct { pub const DEBUG = 1; pub const REUSEADDR = 2; @@ -2274,53 +2425,48 @@ pub const SO = struct { pub const RCVBUFFORCE = 33; pub const PROTOCOL = 38; pub const DOMAIN = 39; + pub const SECURITY_AUTHENTICATION = 22; + pub const SECURITY_ENCRYPTION_TRANSPORT = 23; + pub const SECURITY_ENCRYPTION_NETWORK = 24; + 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; }; - - pub const SECURITY_AUTHENTICATION = 22; - pub const SECURITY_ENCRYPTION_TRANSPORT = 23; - pub const SECURITY_ENCRYPTION_NETWORK = 24; - - 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; }; pub const SCM = struct { @@ -2331,7 +2477,7 @@ pub const SCM = struct { }; pub const SOL = struct { - pub const SOCKET = if (is_mips) 65535 else 1; + pub const SOCKET = if (is_mips or is_sparc) 65535 else 1; pub const IP = 0; pub const IPV6 = 41; From d7a5b12f94b0c8c4ee9d28af16b14fcc62bef9e7 Mon Sep 17 00:00:00 2001 From: Koakuma Date: Tue, 28 Sep 2021 21:35:58 +0700 Subject: [PATCH 3/3] SPARCv9: fix timeval definition --- lib/std/os/linux/sparc64.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/std/os/linux/sparc64.zig b/lib/std/os/linux/sparc64.zig index b1f96f144c..6af1325990 100644 --- a/lib/std/os/linux/sparc64.zig +++ b/lib/std/os/linux/sparc64.zig @@ -715,7 +715,7 @@ pub const Stat = extern struct { pub const timeval = extern struct { tv_sec: isize, - tv_usec: isize, + tv_usec: i32, }; pub const timezone = extern struct {