From cc1d7b4f06cfc9ceeaa88c15e811d4c6f8e4a078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 28 Jul 2024 21:10:16 +0200 Subject: [PATCH] std.os.linux.tls: Add arc support. --- lib/std/os/linux/tls.zig | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/std/os/linux/tls.zig b/lib/std/os/linux/tls.zig index 01e8aa916da8..fc7150e5f89e 100644 --- a/lib/std/os/linux/tls.zig +++ b/lib/std/os/linux/tls.zig @@ -63,6 +63,7 @@ const Variant = enum { }; const current_variant: Variant = switch (native_arch) { + .arc, .arm, .armeb, .aarch64, @@ -239,6 +240,16 @@ pub fn setThreadPointer(addr: usize) void { : [addr] "r" (addr), ); }, + .arc => { + // We apparently need to both set r25 (TP) *and* inform the kernel... + asm volatile ( + \\ mov r25, %[addr] + : + : [addr] "r" (addr), + ); + const rc = @call(.always_inline, linux.syscall1, .{ .arc_settls, addr }); + assert(rc == 0); + }, .arm, .armeb, .thumb, .thumbeb => { const rc = @call(.always_inline, linux.syscall1, .{ .set_tls, addr }); assert(rc == 0);