authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-21 02:19:03+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-23 09:27:17+02:00
log5e921261a08a9b27f95ce982e8a10b461520b922
tree94acf2f2cfeea87d35f1de37bee819347001defb
parent9fde44229c30d6dbdc943af2a2c2cb82adf703f6
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.os.linux.tls: add microblaze support

Implemented according to glibc because I'm pretty sure musl gets it wrong.

1 files changed, 13 insertions(+), 4 deletions(-)

lib/std/os/linux/tls.zig+13-4
......@@ -46,7 +46,7 @@ const Variant = enum {
4646 /// -------------------------------------^-------------
4747 /// `-- The TP register points here.
4848 ///
49 /// The offset (which can be zero) is applied to the TP only; there is never physical gap
49 /// The offset (which can be zero) is applied to the TP only; there is never a physical gap
5050 /// between the ABI TCB and the TLS blocks. This implies that we only need to align the TP.
5151 ///
5252 /// The first (and only) word in the ABI TCB points to the DTV.
......@@ -71,6 +71,8 @@ const current_variant: Variant = switch (native_arch) {
7171 .arm,
7272 .armeb,
7373 .csky,
74 .microblaze,
75 .microblazeel,
7476 .thumb,
7577 .thumbeb,
7678 => .I_original,
......@@ -135,19 +137,19 @@ const current_dtv_offset = switch (native_arch) {
135137/// Per-thread storage for the ELF TLS ABI.
136138const AbiTcb = switch (current_variant) {
137139 .I_original, .I_modified => switch (native_arch) {
138 // ARM EABI mandates enough space for two pointers: the first one points to the DTV as
139 // usual, while the second one is unspecified.
140140 .aarch64,
141141 .aarch64_be,
142142 .alpha,
143143 .arm,
144144 .armeb,
145 .microblaze,
146 .microblazeel,
145147 .thumb,
146148 .thumbeb,
147149 => extern struct {
148150 /// This is offset by `current_dtv_offset`.
149151 dtv: usize,
150 reserved: ?*anyopaque,
152 _reserved: ?*anyopaque,
151153 },
152154 else => extern struct {
153155 /// This is offset by `current_dtv_offset`.
......@@ -297,6 +299,13 @@ pub fn setThreadPointer(addr: usize) void {
297299 const rc = @call(.always_inline, linux.syscall1, .{ .set_thread_area, addr });
298300 assert(rc == 0);
299301 },
302 .microblaze, .microblazeel => {
303 asm volatile (
304 \\ ori r21, %[addr], 0
305 :
306 : [addr] "r" (addr),
307 );
308 },
300309 .or1k => {
301310 asm volatile (
302311 \\ l.ori r10, %[addr], 0