handle visionos target OS tag in the compiler

* rename .xros to .visionos as agreed in the tracking issue
* add support for VisionOS platform in the MachO linker
This commit is contained in:
Jakub Konka
2024-05-09 15:04:13 +02:00
parent 8f202ba7c7
commit 2e1fc0dd14
25 changed files with 82 additions and 68 deletions

View File

@@ -39,7 +39,7 @@ impl: Impl,
pub const max_name_len = switch (native_os) {
.linux => 15,
.windows => 31,
.macos, .ios, .watchos, .tvos => 63,
.macos, .ios, .watchos, .tvos, .visionos => 63,
.netbsd => 31,
.freebsd => 15,
.openbsd => 23,
@@ -114,7 +114,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
else => |err| return windows.unexpectedStatus(err),
}
},
.macos, .ios, .watchos, .tvos => if (use_pthreads) {
.macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
// There doesn't seem to be a way to set the name for an arbitrary thread, only the current one.
if (self.getHandle() != std.c.pthread_self()) return error.Unsupported;
@@ -217,7 +217,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
else => |err| return windows.unexpectedStatus(err),
}
},
.macos, .ios, .watchos, .tvos => if (use_pthreads) {
.macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
switch (err) {
.SUCCESS => return std.mem.sliceTo(buffer, 0),
@@ -266,7 +266,7 @@ pub const Id = switch (native_os) {
.haiku,
.wasi,
=> u32,
.macos, .ios, .watchos, .tvos => u64,
.macos, .ios, .watchos, .tvos, .visionos => u64,
.windows => windows.DWORD,
else => usize,
};
@@ -588,7 +588,7 @@ const PosixThreadImpl = struct {
.linux => {
return LinuxThreadImpl.getCurrentId();
},
.macos, .ios, .watchos, .tvos => {
.macos, .ios, .watchos, .tvos, .visionos => {
var thread_id: u64 = undefined;
// Pass thread=null to get the current thread ID.
assert(c.pthread_threadid_np(null, &thread_id) == 0);
@@ -1434,7 +1434,7 @@ test "setName, getName" {
context.test_done_event.wait();
switch (native_os) {
.macos, .ios, .watchos, .tvos => {
.macos, .ios, .watchos, .tvos, .visionos => {
const res = thread.setName("foobar");
try std.testing.expectError(error.Unsupported, res);
},