mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
Apple's own headers and tbd files prefer to think of Mac Catalyst as a distinct OS target. Earlier, when DriverKit support was added to LLVM, it was represented a distinct OS. So why Apple decided to only represent Mac Catalyst as an ABI in the target triple is beyond me. But this isn't the first time they've ignored established target triple norms (see: armv7k and aarch64_32) and it probably won't be the last. While doing this, I also audited all Darwin OS prongs throughout the codebase and made sure they cover all the tags.
60 lines
2.0 KiB
Zig
60 lines
2.0 KiB
Zig
const std = @import("std");
|
|
const builtin = @import("builtin");
|
|
const expect = std.testing.expect;
|
|
|
|
test "thread local variable" {
|
|
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
|
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
|
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
|
if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; // TODO
|
|
|
|
if (builtin.zig_backend == .stage2_x86_64 and builtin.os.tag.isDarwin()) {
|
|
// Fails due to register hazards.
|
|
return error.SkipZigTest;
|
|
}
|
|
|
|
const S = struct {
|
|
threadlocal var t: i32 = 1234;
|
|
};
|
|
S.t += 1;
|
|
try expect(S.t == 1235);
|
|
}
|
|
|
|
test "pointer to thread local array" {
|
|
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
|
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
|
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
|
|
|
const s = "Hello world";
|
|
@memcpy(buffer[0..s.len], s);
|
|
try std.testing.expectEqualSlices(u8, buffer[0..], s);
|
|
}
|
|
|
|
threadlocal var buffer: [11]u8 = undefined;
|
|
|
|
test "reference a global threadlocal variable" {
|
|
if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO
|
|
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO
|
|
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
|
|
if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest;
|
|
|
|
try nrfx_uart_rx(&g_uart0);
|
|
}
|
|
|
|
const nrfx_uart_t = extern struct {
|
|
p_reg: [*c]u32,
|
|
drv_inst_idx: u8,
|
|
};
|
|
|
|
pub fn nrfx_uart_rx(p_instance: [*c]const nrfx_uart_t) !void {
|
|
try expect(p_instance.*.p_reg == 0);
|
|
try expect(p_instance.*.drv_inst_idx == 0xab);
|
|
}
|
|
|
|
threadlocal var g_uart0 = nrfx_uart_t{
|
|
.p_reg = 0,
|
|
.drv_inst_idx = 0xab,
|
|
};
|