Skip to content

Commit 68629fe

Browse files
authored
Merge pull request #19918 from ziglang/xros
Add support for VisionOS
2 parents c9ad1b5 + 47e840a commit 68629fe

27 files changed

+120
-80
lines changed

build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ fn addCmakeCfgOptionsToExe(
705705
};
706706
exe.linkSystemLibrary("unwind");
707707
},
708-
.ios, .macos, .watchos, .tvos => {
708+
.ios, .macos, .watchos, .tvos, .visionos => {
709709
exe.linkLibCpp();
710710
},
711711
.windows => {

lib/compiler/aro/aro/Compilation.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,12 +912,12 @@ fn generateVaListType(comp: *Compilation) !Type {
912912
const kind: Kind = switch (comp.target.cpu.arch) {
913913
.aarch64 => switch (comp.target.os.tag) {
914914
.windows => @as(Kind, .char_ptr),
915-
.ios, .macos, .tvos, .watchos => .char_ptr,
915+
.ios, .macos, .tvos, .watchos, .visionos => .char_ptr,
916916
else => .aarch64_va_list,
917917
},
918918
.sparc, .wasm32, .wasm64, .bpfel, .bpfeb, .riscv32, .riscv64, .avr, .spirv32, .spirv64 => .void_ptr,
919919
.powerpc => switch (comp.target.os.tag) {
920-
.ios, .macos, .tvos, .watchos, .aix => @as(Kind, .char_ptr),
920+
.ios, .macos, .tvos, .watchos, .visionos, .aix => @as(Kind, .char_ptr),
921921
else => return Type{ .specifier = .void }, // unknown
922922
},
923923
.x86, .msp430 => .char_ptr,

lib/compiler/aro/aro/target.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ pub fn toLLVMTriple(target: std.Target, buf: []u8) []const u8 {
706706
.ios => "ios",
707707
.tvos => "tvos",
708708
.watchos => "watchos",
709+
.visionos => "xros",
709710
.driverkit => "driverkit",
710711
.shadermodel => "shadermodel",
711712
.liteos => "liteos",

lib/compiler_rt/clear_cache.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn clear_cache(start: usize, end: usize) callconv(.C) void {
4545
else => false,
4646
};
4747
const apple = switch (os) {
48-
.ios, .macos, .watchos, .tvos => true,
48+
.ios, .macos, .watchos, .tvos, .visionos => true,
4949
else => false,
5050
};
5151
if (x86) {

lib/std/Target.zig

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub const Os = struct {
4747
tvos,
4848
watchos,
4949
driverkit,
50-
xros,
50+
visionos,
5151
mesa3d,
5252
contiki,
5353
amdpal,
@@ -67,7 +67,7 @@ pub const Os = struct {
6767

6868
pub inline fn isDarwin(tag: Tag) bool {
6969
return switch (tag) {
70-
.ios, .macos, .watchos, .tvos => true,
70+
.ios, .macos, .watchos, .tvos, .visionos => true,
7171
else => false,
7272
};
7373
}
@@ -108,7 +108,7 @@ pub const Os = struct {
108108
pub fn dynamicLibSuffix(tag: Tag) [:0]const u8 {
109109
return switch (tag) {
110110
.windows, .uefi => ".dll",
111-
.ios, .macos, .watchos, .tvos => ".dylib",
111+
.ios, .macos, .watchos, .tvos, .visionos => ".dylib",
112112
else => ".so",
113113
};
114114
}
@@ -178,7 +178,7 @@ pub const Os = struct {
178178
.ios,
179179
.tvos,
180180
.watchos,
181-
.xros,
181+
.visionos,
182182
.netbsd,
183183
.openbsd,
184184
.dragonfly,
@@ -434,7 +434,12 @@ pub const Os = struct {
434434
.max = .{ .major = 17, .minor = 1, .patch = 0 },
435435
},
436436
},
437-
.xros => @panic("TODO what version is xros on right now?"),
437+
.visionos => .{
438+
.semver = .{
439+
.min = .{ .major = 1, .minor = 0, .patch = 0 },
440+
.max = .{ .major = 1, .minor = 0, .patch = 0 },
441+
},
442+
},
438443
.netbsd => .{
439444
.semver = .{
440445
.min = .{ .major = 8, .minor = 0, .patch = 0 },
@@ -531,7 +536,7 @@ pub const Os = struct {
531536
.ios,
532537
.tvos,
533538
.watchos,
534-
.xros,
539+
.visionos,
535540
.dragonfly,
536541
.openbsd,
537542
.haiku,
@@ -691,7 +696,7 @@ pub const Abi = enum {
691696
.ios,
692697
.tvos,
693698
.watchos,
694-
.xros,
699+
.visionos,
695700
.driverkit,
696701
.shadermodel,
697702
.liteos, // TODO: audit this
@@ -768,7 +773,7 @@ pub const ObjectFormat = enum {
768773
pub fn default(os_tag: Os.Tag, arch: Cpu.Arch) ObjectFormat {
769774
return switch (os_tag) {
770775
.windows, .uefi => .coff,
771-
.ios, .macos, .watchos, .tvos => .macho,
776+
.ios, .macos, .watchos, .tvos, .visionos => .macho,
772777
.plan9 => .plan9,
773778
else => switch (arch) {
774779
.wasm32, .wasm64 => .wasm,
@@ -1633,6 +1638,7 @@ pub inline fn hasDynamicLinker(target: Target) bool {
16331638
.tvos,
16341639
.watchos,
16351640
.macos,
1641+
.visionos,
16361642
.uefi,
16371643
.windows,
16381644
.emscripten,
@@ -1807,7 +1813,7 @@ pub const DynamicLinker = struct {
18071813
.tvos,
18081814
.watchos,
18091815
.macos,
1810-
.xros,
1816+
.visionos,
18111817
=> init("/usr/lib/dyld"),
18121818

18131819
// Operating systems in this list have been verified as not having a standard
@@ -2287,7 +2293,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
22872293
},
22882294
},
22892295

2290-
.macos, .ios, .tvos, .watchos, .xros => switch (c_type) {
2296+
.macos, .ios, .tvos, .watchos, .visionos => switch (c_type) {
22912297
.char => return 8,
22922298
.short, .ushort => return 16,
22932299
.int, .uint, .float => return 32,
@@ -2407,7 +2413,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {
24072413

24082414
else => 4,
24092415
},
2410-
.ios, .tvos, .watchos => 4,
2416+
.ios, .tvos, .watchos, .visionos => 4,
24112417
else => 8,
24122418
},
24132419

@@ -2500,7 +2506,7 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
25002506
else => {},
25012507
},
25022508
},
2503-
.ios, .tvos, .watchos => switch (c_type) {
2509+
.ios, .tvos, .watchos, .visionos => switch (c_type) {
25042510
.longdouble => return 4,
25052511
else => {},
25062512
},

lib/std/Thread.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl: Impl,
3939
pub const max_name_len = switch (native_os) {
4040
.linux => 15,
4141
.windows => 31,
42-
.macos, .ios, .watchos, .tvos => 63,
42+
.macos, .ios, .watchos, .tvos, .visionos => 63,
4343
.netbsd => 31,
4444
.freebsd => 15,
4545
.openbsd => 23,
@@ -114,7 +114,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
114114
else => |err| return windows.unexpectedStatus(err),
115115
}
116116
},
117-
.macos, .ios, .watchos, .tvos => if (use_pthreads) {
117+
.macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
118118
// There doesn't seem to be a way to set the name for an arbitrary thread, only the current one.
119119
if (self.getHandle() != std.c.pthread_self()) return error.Unsupported;
120120

@@ -217,7 +217,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
217217
else => |err| return windows.unexpectedStatus(err),
218218
}
219219
},
220-
.macos, .ios, .watchos, .tvos => if (use_pthreads) {
220+
.macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
221221
const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
222222
switch (err) {
223223
.SUCCESS => return std.mem.sliceTo(buffer, 0),
@@ -266,7 +266,7 @@ pub const Id = switch (native_os) {
266266
.haiku,
267267
.wasi,
268268
=> u32,
269-
.macos, .ios, .watchos, .tvos => u64,
269+
.macos, .ios, .watchos, .tvos, .visionos => u64,
270270
.windows => windows.DWORD,
271271
else => usize,
272272
};
@@ -588,7 +588,7 @@ const PosixThreadImpl = struct {
588588
.linux => {
589589
return LinuxThreadImpl.getCurrentId();
590590
},
591-
.macos, .ios, .watchos, .tvos => {
591+
.macos, .ios, .watchos, .tvos, .visionos => {
592592
var thread_id: u64 = undefined;
593593
// Pass thread=null to get the current thread ID.
594594
assert(c.pthread_threadid_np(null, &thread_id) == 0);
@@ -1434,7 +1434,7 @@ test "setName, getName" {
14341434
context.test_done_event.wait();
14351435

14361436
switch (native_os) {
1437-
.macos, .ios, .watchos, .tvos => {
1437+
.macos, .ios, .watchos, .tvos, .visionos => {
14381438
const res = thread.setName("foobar");
14391439
try std.testing.expectError(error.Unsupported, res);
14401440
},

lib/std/builtin.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -597,11 +597,11 @@ pub const VaListX86_64 = extern struct {
597597
pub const VaList = switch (builtin.cpu.arch) {
598598
.aarch64, .aarch64_be => switch (builtin.os.tag) {
599599
.windows => *u8,
600-
.ios, .macos, .tvos, .watchos => *u8,
600+
.ios, .macos, .tvos, .watchos, .visionos => *u8,
601601
else => @compileError("disabled due to miscompilations"), // VaListAarch64,
602602
},
603603
.arm => switch (builtin.os.tag) {
604-
.ios, .macos, .tvos, .watchos => *u8,
604+
.ios, .macos, .tvos, .watchos, .visionos => *u8,
605605
else => *anyopaque,
606606
},
607607
.amdgcn => *u8,
@@ -611,7 +611,7 @@ pub const VaList = switch (builtin.cpu.arch) {
611611
.mips, .mipsel, .mips64, .mips64el => *anyopaque,
612612
.riscv32, .riscv64 => *anyopaque,
613613
.powerpc, .powerpcle => switch (builtin.os.tag) {
614-
.ios, .macos, .tvos, .watchos, .aix => *u8,
614+
.ios, .macos, .tvos, .watchos, .visionos, .aix => *u8,
615615
else => VaListPowerPc,
616616
},
617617
.powerpc64, .powerpc64le => *u8,

lib/std/c.zig

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub inline fn versionCheck(comptime glibc_version: std.SemanticVersion) bool {
3535
pub usingnamespace switch (native_os) {
3636
.linux => @import("c/linux.zig"),
3737
.windows => @import("c/windows.zig"),
38-
.macos, .ios, .tvos, .watchos => @import("c/darwin.zig"),
38+
.macos, .ios, .tvos, .watchos, .visionos => @import("c/darwin.zig"),
3939
.freebsd, .kfreebsd => @import("c/freebsd.zig"),
4040
.netbsd => @import("c/netbsd.zig"),
4141
.dragonfly => @import("c/dragonfly.zig"),
@@ -63,7 +63,7 @@ pub const pthread_mutex_t = switch (native_os) {
6363
else => @compileError("unsupported ABI"),
6464
};
6565
},
66-
.macos, .ios, .tvos, .watchos => extern struct {
66+
.macos, .ios, .tvos, .watchos, .visionos => extern struct {
6767
sig: c_long = 0x32AAABA7,
6868
data: [data_len]u8 = [_]u8{0} ** data_len,
6969

@@ -113,7 +113,7 @@ pub const pthread_cond_t = switch (native_os) {
113113
.linux => extern struct {
114114
data: [48]u8 align(@alignOf(usize)) = [_]u8{0} ** 48,
115115
},
116-
.macos, .ios, .tvos, .watchos => extern struct {
116+
.macos, .ios, .tvos, .watchos, .visionos => extern struct {
117117
sig: c_long = 0x3CB0B1BB,
118118
data: [data_len]u8 = [_]u8{0} ** data_len,
119119
const data_len = if (@sizeOf(usize) == 8) 40 else 24;
@@ -166,7 +166,7 @@ pub const pthread_rwlock_t = switch (native_os) {
166166
data: [56]u8 align(@alignOf(usize)) = [_]u8{0} ** 56,
167167
},
168168
},
169-
.macos, .ios, .tvos, .watchos => extern struct {
169+
.macos, .ios, .tvos, .watchos, .visionos => extern struct {
170170
sig: c_long = 0x2DA8B3B4,
171171
data: [192]u8 = [_]u8{0} ** 192,
172172
},
@@ -214,7 +214,7 @@ pub const AT = switch (native_os) {
214214
/// Remove directory instead of unlinking file
215215
pub const REMOVEDIR = 0x200;
216216
},
217-
.macos, .ios, .tvos, .watchos => struct {
217+
.macos, .ios, .tvos, .watchos, .visionos => struct {
218218
pub const FDCWD = -2;
219219
/// Use effective ids in access check
220220
pub const EACCESS = 0x0010;
@@ -458,7 +458,7 @@ pub const O = switch (native_os) {
458458
DIRECTORY: bool = false,
459459
_: u10 = 0,
460460
},
461-
.macos, .ios, .tvos, .watchos => packed struct(u32) {
461+
.macos, .ios, .tvos, .watchos, .visionos => packed struct(u32) {
462462
ACCMODE: std.posix.ACCMODE = .RDONLY,
463463
NONBLOCK: bool = false,
464464
APPEND: bool = false,
@@ -620,7 +620,7 @@ pub const MAP = switch (native_os) {
620620
NORESERVE: bool = false,
621621
_: u27 = 0,
622622
},
623-
.macos, .ios, .tvos, .watchos => packed struct(u32) {
623+
.macos, .ios, .tvos, .watchos, .visionos => packed struct(u32) {
624624
TYPE: enum(u4) {
625625
SHARED = 0x01,
626626
PRIVATE = 0x02,
@@ -685,7 +685,7 @@ pub const cc_t = u8;
685685
/// Indices into the `cc` array in the `termios` struct.
686686
pub const V = switch (native_os) {
687687
.linux => linux.V,
688-
.macos, .ios, .tvos, .watchos, .netbsd, .openbsd => enum {
688+
.macos, .ios, .tvos, .watchos, .visionos, .netbsd, .openbsd => enum {
689689
EOF,
690690
EOL,
691691
EOL2,
@@ -784,7 +784,7 @@ pub const V = switch (native_os) {
784784

785785
pub const NCCS = switch (native_os) {
786786
.linux => linux.NCCS,
787-
.macos, .ios, .tvos, .watchos, .freebsd, .kfreebsd, .netbsd, .openbsd, .dragonfly => 20,
787+
.macos, .ios, .tvos, .watchos, .visionos, .freebsd, .kfreebsd, .netbsd, .openbsd, .dragonfly => 20,
788788
.haiku => 11,
789789
.solaris, .illumos => 19,
790790
.emscripten, .wasi => 32,
@@ -793,7 +793,7 @@ pub const NCCS = switch (native_os) {
793793

794794
pub const termios = switch (native_os) {
795795
.linux => linux.termios,
796-
.macos, .ios, .tvos, .watchos => extern struct {
796+
.macos, .ios, .tvos, .watchos, .visionos => extern struct {
797797
iflag: tc_iflag_t,
798798
oflag: tc_oflag_t,
799799
cflag: tc_cflag_t,
@@ -843,7 +843,7 @@ pub const termios = switch (native_os) {
843843

844844
pub const tc_iflag_t = switch (native_os) {
845845
.linux => linux.tc_iflag_t,
846-
.macos, .ios, .tvos, .watchos => packed struct(u64) {
846+
.macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
847847
IGNBRK: bool = false,
848848
BRKINT: bool = false,
849849
IGNPAR: bool = false,
@@ -953,7 +953,7 @@ pub const tc_iflag_t = switch (native_os) {
953953

954954
pub const tc_oflag_t = switch (native_os) {
955955
.linux => linux.tc_oflag_t,
956-
.macos, .ios, .tvos, .watchos => packed struct(u64) {
956+
.macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
957957
OPOST: bool = false,
958958
ONLCR: bool = false,
959959
OXTABS: bool = false,
@@ -1050,7 +1050,7 @@ pub const CSIZE = switch (native_os) {
10501050

10511051
pub const tc_cflag_t = switch (native_os) {
10521052
.linux => linux.tc_cflag_t,
1053-
.macos, .ios, .tvos, .watchos => packed struct(u64) {
1053+
.macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
10541054
CIGNORE: bool = false,
10551055
_1: u5 = 0,
10561056
CSTOPB: bool = false,
@@ -1186,7 +1186,7 @@ pub const tc_cflag_t = switch (native_os) {
11861186

11871187
pub const tc_lflag_t = switch (native_os) {
11881188
.linux => linux.tc_lflag_t,
1189-
.macos, .ios, .tvos, .watchos => packed struct(u64) {
1189+
.macos, .ios, .tvos, .watchos, .visionos => packed struct(u64) {
11901190
ECHOKE: bool = false,
11911191
ECHOE: bool = false,
11921192
ECHOK: bool = false,
@@ -1312,7 +1312,7 @@ pub const tc_lflag_t = switch (native_os) {
13121312

13131313
pub const speed_t = switch (native_os) {
13141314
.linux => linux.speed_t,
1315-
.macos, .ios, .tvos, .watchos, .openbsd => enum(u64) {
1315+
.macos, .ios, .tvos, .watchos, .visionos, .openbsd => enum(u64) {
13161316
B0 = 0,
13171317
B50 = 50,
13181318
B75 = 75,
@@ -1535,7 +1535,7 @@ pub const fstatat = switch (native_os) {
15351535
};
15361536

15371537
pub const getdirentries = switch (native_os) {
1538-
.macos, .ios, .tvos, .watchos => private.__getdirentries64,
1538+
.macos, .ios, .tvos, .watchos, .visionos => private.__getdirentries64,
15391539
else => private.getdirentries,
15401540
};
15411541

@@ -1569,7 +1569,7 @@ pub const readdir = switch (native_os) {
15691569
};
15701570

15711571
pub const realpath = switch (native_os) {
1572-
.macos, .ios, .tvos, .watchos => private.@"realpath$DARWIN_EXTSN",
1572+
.macos, .ios, .tvos, .watchos, .visionos => private.@"realpath$DARWIN_EXTSN",
15731573
else => private.realpath,
15741574
};
15751575

lib/std/crypto/tlcsprng.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const os_has_fork = switch (native_os) {
2929
.illumos,
3030
.tvos,
3131
.watchos,
32+
.visionos,
3233
.haiku,
3334
=> true,
3435

0 commit comments

Comments
 (0)