Skip to content

Commit 3e0e654

Browse files
authored
Merge branch 'ziglang:master' into master
2 parents f58379f + 9161923 commit 3e0e654

File tree

14 files changed

+61
-33
lines changed

14 files changed

+61
-33
lines changed

doc/langref.html.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3025,7 +3025,7 @@ or
30253025
{#syntax#}catch{#endsyntax#} after performing some logic, you
30263026
can combine {#syntax#}catch{#endsyntax#} with named {#link|Blocks#}:
30273027
</p>
3028-
{#code|handle_error_with_catch_block.zig.zig#}
3028+
{#code|handle_error_with_catch_block.zig#}
30293029

30303030
{#header_close#}
30313031
{#header_open|try#}
File renamed without changes.

lib/libtsan/sanitizer_common/sanitizer_linux.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ const int FUTEX_WAKE_PRIVATE = FUTEX_WAKE | FUTEX_PRIVATE_FLAG;
174174

175175
# if SANITIZER_FREEBSD
176176
# define SANITIZER_USE_GETENTROPY 1
177-
extern "C" void *__sys_mmap(void *addr, size_t len, int prot, int flags, int fd,
178-
off_t offset);
179177
# endif
180178

181179
namespace __sanitizer {
@@ -265,9 +263,8 @@ ScopedBlockSignals::~ScopedBlockSignals() { SetSigProcMask(&saved_, nullptr); }
265263
# if !SANITIZER_S390
266264
uptr internal_mmap(void *addr, uptr length, int prot, int flags, int fd,
267265
u64 offset) {
268-
# if SANITIZER_FREEBSD
269-
return (uptr)__sys_mmap(addr, length, prot, flags, fd, offset);
270-
# elif SANITIZER_LINUX_USES_64BIT_SYSCALLS
266+
/* zig patch: use direct syscall for freebsd mmap */
267+
# if SANITIZER_FREEBSD || SANITIZER_LINUX_USES_64BIT_SYSCALLS
271268
return internal_syscall(SYSCALL(mmap), (uptr)addr, length, prot, flags, fd,
272269
offset);
273270
# else
@@ -942,6 +939,11 @@ int internal_fork() {
942939
}
943940

944941
# if SANITIZER_FREEBSD
942+
int internal_sigaction(int signum, const void *act, void *oldact) {
943+
/* zig patch: use direct syscall for freebsd mmap */
944+
return internal_syscall(SYSCALL(sigaction), signum, (uptr)act, (uptr)oldact);
945+
}
946+
945947
int internal_sysctl(const int *name, unsigned int namelen, void *oldp,
946948
uptr *oldlenp, const void *newp, uptr newlen) {
947949
return internal_syscall(SYSCALL(__sysctl), name, namelen, oldp,

lib/libtsan/sanitizer_common/sanitizer_linux_libcdep.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@
6969
# undef MAP_NORESERVE
7070
# define MAP_NORESERVE 0
7171
extern const Elf_Auxinfo *__elf_aux_vector __attribute__((weak));
72-
extern "C" int __sys_sigaction(int signum, const struct sigaction *act,
73-
struct sigaction *oldact);
7472
# endif
7573

7674
# if SANITIZER_NETBSD
@@ -100,24 +98,17 @@ namespace __sanitizer {
10098
SANITIZER_WEAK_ATTRIBUTE int real_sigaction(int signum, const void *act,
10199
void *oldact);
102100

101+
/* zig patch: use direct syscall for freebsd sigaction (sanitizer_linux.cpp) */
102+
# if !SANITIZER_FREEBSD
103103
int internal_sigaction(int signum, const void *act, void *oldact) {
104-
# if SANITIZER_FREEBSD
105-
// On FreeBSD, call the sigaction syscall directly (part of libsys in FreeBSD
106-
// 15) since the libc version goes via a global interposing table. Due to
107-
// library initialization order the table can be relocated after the call to
108-
// InitializeDeadlySignals() which then crashes when dereferencing the
109-
// uninitialized pointer in libc.
110-
return __sys_sigaction(signum, (const struct sigaction *)act,
111-
(struct sigaction *)oldact);
112-
# else
113104
# if !SANITIZER_GO
114105
if (&real_sigaction)
115106
return real_sigaction(signum, act, oldact);
116107
# endif
117108
return sigaction(signum, (const struct sigaction *)act,
118109
(struct sigaction *)oldact);
119-
# endif
120110
}
111+
# endif
121112

122113
void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top,
123114
uptr *stack_bottom) {

lib/std/Target.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3713,7 +3713,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
37133713
.sh, .sheb => .{ .sh_gnu = .{} },
37143714
.ve => .{ .ve_sysv = .{} },
37153715
.xcore => .{ .xcore_xs1 = .{} },
3716-
.xtensa, .xtensaeb => .{ .xtensa_windowed = .{} },
3716+
.xtensa, .xtensaeb => .{ .xtensa_call0 = .{} },
37173717
.amdgcn => .{ .amdgcn_device = .{} },
37183718
.nvptx, .nvptx64 => .nvptx_device,
37193719
.spirv32, .spirv64 => .spirv_device,

lib/std/c.zig

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2528,6 +2528,8 @@ pub const _SC = if (builtin.abi.isAndroid()) enum(c_int) {
25282528
.solaris, .illumos => enum(c_int) {
25292529
PAGESIZE = 11,
25302530
NPROCESSORS_ONLN = 15,
2531+
SIGRT_MIN = 40,
2532+
SIGRT_MAX = 41,
25312533
},
25322534
// https://github.com/SerenityOS/serenity/blob/1dfc9e2df39dd23f1de92530677c845aae4345f2/Kernel/API/POSIX/unistd.h#L36-L52
25332535
.serenity => enum(c_int) {
@@ -5776,6 +5778,20 @@ pub const MSG = switch (native_os) {
57765778
pub const FBLOCKING = 0x10000;
57775779
pub const FNONBLOCKING = 0x20000;
57785780
},
5781+
.solaris, .illumos => struct {
5782+
pub const OOB = 0x0001;
5783+
pub const PEEK = 0x0002;
5784+
pub const DONTROUTE = 0x0004;
5785+
pub const EOR = 0x0008;
5786+
pub const CTRUNC = 0x0010;
5787+
pub const TRUNC = 0x0020;
5788+
pub const WAITALL = 0x0040;
5789+
pub const DONTWAIT = 0x0080;
5790+
pub const NOTIFICATION = 0x0100;
5791+
pub const NOSIGNAL = 0x0200;
5792+
pub const CMSG_CLOEXEC = 0x1000;
5793+
pub const CMSG_CLOFORK = 0x2000;
5794+
},
57795795
else => void,
57805796
};
57815797
pub const SOCK = switch (native_os) {
@@ -10298,7 +10314,7 @@ pub extern "c" fn setrlimit64(resource: rlimit_resource, rlim: *const rlimit) c_
1029810314

1029910315
pub const arc4random_buf = switch (native_os) {
1030010316
.linux => if (builtin.abi.isAndroid()) private.arc4random_buf else {},
10301-
.dragonfly, .netbsd, .freebsd, .solaris, .openbsd, .serenity, .macos, .ios, .tvos, .watchos, .visionos => private.arc4random_buf,
10317+
.dragonfly, .netbsd, .freebsd, .solaris, .illumos, .openbsd, .serenity, .macos, .ios, .tvos, .watchos, .visionos => private.arc4random_buf,
1030210318
else => {},
1030310319
};
1030410320
pub const getentropy = switch (native_os) {
@@ -10475,6 +10491,7 @@ pub fn sigrtmin() u8 {
1047510491
return switch (native_os) {
1047610492
.freebsd => 65,
1047710493
.netbsd => 33,
10494+
.solaris, .illumos => @truncate(sysconf(@intFromEnum(_SC.SIGRT_MIN))),
1047810495
else => @truncate(@as(c_uint, @bitCast(private.__libc_current_sigrtmin()))),
1047910496
};
1048010497
}
@@ -10484,6 +10501,7 @@ pub fn sigrtmax() u8 {
1048410501
return switch (native_os) {
1048510502
.freebsd => 126,
1048610503
.netbsd => 63,
10504+
.solaris, .illumos => @truncate(sysconf(@intFromEnum(_SC.SIGRT_MAX))),
1048710505
else => @truncate(@as(c_uint, @bitCast(private.__libc_current_sigrtmax()))),
1048810506
};
1048910507
}

lib/std/debug/cpu_context.zig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1963,6 +1963,9 @@ const signal_ucontext_t = switch (native_os) {
19631963
_trapno: i64,
19641964
_err: i64,
19651965
rip: u64,
1966+
_cs: i64,
1967+
_rflags: i64,
1968+
rsp: u64,
19661969
},
19671970
},
19681971
else => unreachable,
@@ -1994,7 +1997,7 @@ const signal_ucontext_t = switch (native_os) {
19941997
},
19951998
// https://github.com/illumos/illumos-gate/blob/d4ce137bba3bd16823db6374d9e9a643264ce245/usr/src/uts/intel/sys/mcontext.h
19961999
.x86_64 => extern struct {
1997-
r15: u64,
2000+
r15: u64 align(16),
19982001
r14: u64,
19992002
r13: u64,
20002003
r12: u64,
@@ -2012,6 +2015,9 @@ const signal_ucontext_t = switch (native_os) {
20122015
_trapno: i64,
20132016
_err: i64,
20142017
rip: u64,
2018+
_cs: i64,
2019+
_rflags: i64,
2020+
rsp: u64,
20152021
},
20162022
else => unreachable,
20172023
},

lib/std/fs/path.zig

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ pub fn windowsParsePath(path: []const u8) WindowsPath {
413413
return relative_path;
414414
}
415415

416-
var it = mem.tokenizeScalar(u8, path, this_sep);
416+
var it = mem.tokenizeAny(u8, path, "/\\");
417417
_ = (it.next() orelse return relative_path);
418418
_ = (it.next() orelse return relative_path);
419419
return WindowsPath{
@@ -439,6 +439,12 @@ test windowsParsePath {
439439
try testing.expect(parsed.kind == WindowsPath.Kind.NetworkShare);
440440
try testing.expect(mem.eql(u8, parsed.disk_designator, "\\\\a\\b"));
441441
}
442+
{
443+
const parsed = windowsParsePath("\\\\a/b");
444+
try testing.expect(parsed.is_abs);
445+
try testing.expect(parsed.kind == WindowsPath.Kind.NetworkShare);
446+
try testing.expect(mem.eql(u8, parsed.disk_designator, "\\\\a/b"));
447+
}
442448
{
443449
const parsed = windowsParsePath("\\\\a\\");
444450
try testing.expect(!parsed.is_abs);
@@ -492,11 +498,8 @@ fn compareDiskDesignators(kind: WindowsPath.Kind, p1: []const u8, p2: []const u8
492498
return ascii.toUpper(p1[0]) == ascii.toUpper(p2[0]);
493499
},
494500
WindowsPath.Kind.NetworkShare => {
495-
const sep1 = p1[0];
496-
const sep2 = p2[0];
497-
498-
var it1 = mem.tokenizeScalar(u8, p1, sep1);
499-
var it2 = mem.tokenizeScalar(u8, p2, sep2);
501+
var it1 = mem.tokenizeAny(u8, p1, "/\\");
502+
var it2 = mem.tokenizeAny(u8, p2, "/\\");
500503

501504
return windows.eqlIgnoreCaseWtf8(it1.next().?, it2.next().?) and windows.eqlIgnoreCaseWtf8(it1.next().?, it2.next().?);
502505
},
@@ -795,6 +798,7 @@ test resolveWindows {
795798
try testResolveWindows(&[_][]const u8{ "c:/ignore", "c:/some/file" }, "C:\\some\\file");
796799
try testResolveWindows(&[_][]const u8{ "d:/ignore", "d:some/dir//" }, "D:\\ignore\\some\\dir");
797800
try testResolveWindows(&[_][]const u8{ "//server/share", "..", "relative\\" }, "\\\\server\\share\\relative");
801+
try testResolveWindows(&[_][]const u8{ "\\\\server/share", "..", "relative\\" }, "\\\\server\\share\\relative");
798802
try testResolveWindows(&[_][]const u8{ "c:/", "//" }, "C:\\");
799803
try testResolveWindows(&[_][]const u8{ "c:/", "//dir" }, "C:\\dir");
800804
try testResolveWindows(&[_][]const u8{ "c:/", "//server/share" }, "\\\\server\\share\\");

src/Compilation.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6864,8 +6864,11 @@ fn addCommonCCArgs(
68646864
},
68656865
}
68666866

6867-
// Homebrew targets without LLVM support; use communities's preferred macros.
68686867
switch (target.os.tag) {
6868+
// LLVM doesn't distinguish between Solaris and illumos, but the illumos GCC fork
6869+
// defines this macro.
6870+
.illumos => try argv.append("__illumos__"),
6871+
// Homebrew targets without LLVM support; use communities's preferred macros.
68696872
.@"3ds" => try argv.append("-D__3DS__"),
68706873
.vita => try argv.append("-D__vita__"),
68716874
else => {},

src/target.zig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ pub fn hasNewLinkerSupport(ofmt: std.Target.ObjectFormat, backend: std.builtin.C
257257
pub fn selfHostedBackendIsAsRobustAsLlvm(target: *const std.Target) bool {
258258
if (target.cpu.arch.isSpirV()) return true;
259259
if (target.cpu.arch == .x86_64 and target.ptrBitWidth() == 64) {
260+
if (target.os.tag.isSolarish()) {
261+
// https://github.com/ziglang/zig/issues/25699
262+
return false;
263+
}
260264
if (target.os.tag.isBSD()) {
261265
// Self-hosted linker needs work: https://github.com/ziglang/zig/issues/24341
262266
return false;

0 commit comments

Comments
 (0)