Skip to content

Commit

Permalink
std.os.linux.tls: Add arc support.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrp committed Jul 29, 2024
1 parent 89804fb commit cc1d7b4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/std/os/linux/tls.zig
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const Variant = enum {
};

const current_variant: Variant = switch (native_arch) {
.arc,
.arm,
.armeb,
.aarch64,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit cc1d7b4

Please sign in to comment.