| author | |
| committer | |
| log | f66067546775a04ca0cda1c74cb9002d02dc49d5 |
| tree | bc8b5a6b84a4179a4092fd299693d568c185ed68 |
| parent | 79a0de2a2f5467e0ac7a20743e21a409677bfd95 |
Not nearly the entire downstream patchset but these are completely
uncontroversial and known to work.7 files changed, 56 insertions(+), 16 deletions(-)
lib/std/Thread.zig+28-3| ... | ... | @@ -122,6 +122,8 @@ pub const max_name_len = switch (native_os) { |
| 122 | 122 | .openbsd => 23, |
| 123 | 123 | .dragonfly => 1023, |
| 124 | 124 | .solaris, .illumos => 31, |
| 125 | // https://github.com/SerenityOS/serenity/blob/6b4c300353da49d3508b5442cf61da70bd04d757/Kernel/Tasks/Thread.h#L102 | |
| 126 | .serenity => 63, | |
| 125 | 127 | else => 0, |
| 126 | 128 | }; |
| 127 | 129 | |
| ... | ... | @@ -201,6 +203,15 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void { |
| 201 | 203 | else => |e| return posix.unexpectedErrno(e), |
| 202 | 204 | } |
| 203 | 205 | }, |
| 206 | .serenity => if (use_pthreads) { | |
| 207 | const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr); | |
| 208 | switch (@as(posix.E, @enumFromInt(err))) { | |
| 209 | .SUCCESS => return, | |
| 210 | .NAMETOOLONG => unreachable, | |
| 211 | .SRCH => unreachable, | |
| 212 | else => |e| return posix.unexpectedErrno(e), | |
| 213 | } | |
| 214 | }, | |
| 204 | 215 | .netbsd, .solaris, .illumos => if (use_pthreads) { |
| 205 | 216 | const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr, null); |
| 206 | 217 | switch (@as(posix.E, @enumFromInt(err))) { |
| ... | ... | @@ -302,6 +313,16 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co |
| 302 | 313 | else => |e| return posix.unexpectedErrno(e), |
| 303 | 314 | } |
| 304 | 315 | }, |
| 316 | .serenity => if (use_pthreads) { | |
| 317 | const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1); | |
| 318 | switch (@as(posix.E, @enumFromInt(err))) { | |
| 319 | .SUCCESS => return, | |
| 320 | .NAMETOOLONG => unreachable, | |
| 321 | .SRCH => unreachable, | |
| 322 | .FAULT => unreachable, | |
| 323 | else => |e| return posix.unexpectedErrno(e), | |
| 324 | } | |
| 325 | }, | |
| 305 | 326 | .netbsd, .solaris, .illumos => if (use_pthreads) { |
| 306 | 327 | const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1); |
| 307 | 328 | switch (@as(posix.E, @enumFromInt(err))) { |
| ... | ... | @@ -342,6 +363,7 @@ pub const Id = switch (native_os) { |
| 342 | 363 | .openbsd, |
| 343 | 364 | .haiku, |
| 344 | 365 | .wasi, |
| 366 | .serenity, | |
| 345 | 367 | => u32, |
| 346 | 368 | .macos, .ios, .watchos, .tvos, .visionos => u64, |
| 347 | 369 | .windows => windows.DWORD, |
| ... | ... | @@ -692,6 +714,9 @@ const PosixThreadImpl = struct { |
| 692 | 714 | .haiku => { |
| 693 | 715 | return @as(u32, @bitCast(c.find_thread(null))); |
| 694 | 716 | }, |
| 717 | .serenity => { | |
| 718 | return @as(u32, @bitCast(c.pthread_self())); | |
| 719 | }, | |
| 695 | 720 | else => { |
| 696 | 721 | return @intFromPtr(c.pthread_self()); |
| 697 | 722 | }, |
| ... | ... | @@ -713,11 +738,11 @@ const PosixThreadImpl = struct { |
| 713 | 738 | }; |
| 714 | 739 | return @as(usize, @intCast(count)); |
| 715 | 740 | }, |
| 716 | .solaris, .illumos => { | |
| 741 | .solaris, .illumos, .serenity => { | |
| 717 | 742 | // The "proper" way to get the cpu count would be to query |
| 718 | 743 | // /dev/kstat via ioctls, and traverse a linked list for each |
| 719 | // cpu. | |
| 720 | const rc = c.sysconf(std.c._SC.NPROCESSORS_ONLN); | |
| 744 | // cpu. (solaris, illumos) | |
| 745 | const rc = c.sysconf(@intFromEnum(std.c._SC.NPROCESSORS_ONLN)); | |
| 721 | 746 | return switch (posix.errno(rc)) { |
| 722 | 747 | .SUCCESS => @as(usize, @intCast(rc)), |
| 723 | 748 | else => |err| posix.unexpectedErrno(err), |
lib/std/crypto/Certificate/Bundle.zig+9-7| ... | ... | @@ -50,7 +50,7 @@ pub fn deinit(cb: *Bundle, gpa: Allocator) void { |
| 50 | 50 | cb.* = undefined; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | pub const RescanError = RescanLinuxError || RescanMacError || RescanBSDError || RescanWindowsError; | |
| 53 | pub const RescanError = RescanLinuxError || RescanMacError || RescanWithPathError || RescanWindowsError; | |
| 54 | 54 | |
| 55 | 55 | /// Clears the set of certificates and then scans the host operating system |
| 56 | 56 | /// file system standard locations for certificates. |
| ... | ... | @@ -60,10 +60,12 @@ pub fn rescan(cb: *Bundle, gpa: Allocator) RescanError!void { |
| 60 | 60 | switch (builtin.os.tag) { |
| 61 | 61 | .linux => return rescanLinux(cb, gpa), |
| 62 | 62 | .macos => return rescanMac(cb, gpa), |
| 63 | .freebsd, .openbsd => return rescanBSD(cb, gpa, "/etc/ssl/cert.pem"), | |
| 64 | .netbsd => return rescanBSD(cb, gpa, "/etc/openssl/certs/ca-certificates.crt"), | |
| 65 | .dragonfly => return rescanBSD(cb, gpa, "/usr/local/etc/ssl/cert.pem"), | |
| 66 | .solaris, .illumos => return rescanBSD(cb, gpa, "/etc/ssl/cacert.pem"), | |
| 63 | .freebsd, .openbsd => return rescanWithPath(cb, gpa, "/etc/ssl/cert.pem"), | |
| 64 | .netbsd => return rescanWithPath(cb, gpa, "/etc/openssl/certs/ca-certificates.crt"), | |
| 65 | .dragonfly => return rescanWithPath(cb, gpa, "/usr/local/etc/ssl/cert.pem"), | |
| 66 | .solaris, .illumos => return rescanWithPath(cb, gpa, "/etc/ssl/cacert.pem"), | |
| 67 | // https://github.com/SerenityOS/serenity/blob/222acc9d389bc6b490d4c39539761b043a4bfcb0/Ports/ca-certificates/package.sh#L19 | |
| 68 | .serenity => return rescanWithPath(cb, gpa, "/etc/ssl/certs/ca-certificates.crt"), | |
| 67 | 69 | .windows => return rescanWindows(cb, gpa), |
| 68 | 70 | else => {}, |
| 69 | 71 | } |
| ... | ... | @@ -116,9 +118,9 @@ fn rescanLinux(cb: *Bundle, gpa: Allocator) RescanLinuxError!void { |
| 116 | 118 | cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); |
| 117 | 119 | } |
| 118 | 120 | |
| 119 | const RescanBSDError = AddCertsFromFilePathError; | |
| 121 | const RescanWithPathError = AddCertsFromFilePathError; | |
| 120 | 122 | |
| 121 | fn rescanBSD(cb: *Bundle, gpa: Allocator, cert_file_path: []const u8) RescanBSDError!void { | |
| 123 | fn rescanWithPath(cb: *Bundle, gpa: Allocator, cert_file_path: []const u8) RescanWithPathError!void { | |
| 122 | 124 | cb.bytes.clearRetainingCapacity(); |
| 123 | 125 | cb.map.clearRetainingCapacity(); |
| 124 | 126 | try addCertsFromFilePathAbsolute(cb, gpa, cert_file_path); |
lib/std/fs.zig+4-4| ... | ... | @@ -52,7 +52,7 @@ pub const MAX_PATH_BYTES = @compileError("deprecated; renamed to max_path_bytes" |
| 52 | 52 | /// * On other platforms, `[]u8` file paths are opaque sequences of bytes with |
| 53 | 53 | /// no particular encoding. |
| 54 | 54 | pub const max_path_bytes = switch (native_os) { |
| 55 | .linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly, .haiku, .solaris, .illumos, .plan9, .emscripten, .wasi => posix.PATH_MAX, | |
| 55 | .linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly, .haiku, .solaris, .illumos, .plan9, .emscripten, .wasi, .serenity => posix.PATH_MAX, | |
| 56 | 56 | // Each WTF-16LE code unit may be expanded to 3 WTF-8 bytes. |
| 57 | 57 | // If it would require 4 WTF-8 bytes, then there would be a surrogate |
| 58 | 58 | // pair in the WTF-16LE, and we (over)account 3 bytes for it that way. |
| ... | ... | @@ -73,7 +73,7 @@ pub const max_path_bytes = switch (native_os) { |
| 73 | 73 | /// On WASI, file name components are encoded as valid UTF-8. |
| 74 | 74 | /// On other platforms, `[]u8` components are an opaque sequence of bytes with no particular encoding. |
| 75 | 75 | pub const max_name_bytes = switch (native_os) { |
| 76 | .linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly, .solaris, .illumos => posix.NAME_MAX, | |
| 76 | .linux, .macos, .ios, .freebsd, .openbsd, .netbsd, .dragonfly, .solaris, .illumos, .serenity => posix.NAME_MAX, | |
| 77 | 77 | // Haiku's NAME_MAX includes the null terminator, so subtract one. |
| 78 | 78 | .haiku => posix.NAME_MAX - 1, |
| 79 | 79 | // Each WTF-16LE character may be expanded to 3 WTF-8 bytes. |
| ... | ... | @@ -466,7 +466,7 @@ pub fn symLinkAbsoluteZ( |
| 466 | 466 | pub const OpenSelfExeError = posix.OpenError || SelfExePathError || posix.FlockError; |
| 467 | 467 | |
| 468 | 468 | pub fn openSelfExe(flags: File.OpenFlags) OpenSelfExeError!File { |
| 469 | if (native_os == .linux) { | |
| 469 | if (native_os == .linux or native_os == .serenity) { | |
| 470 | 470 | return openFileAbsoluteZ("/proc/self/exe", flags); |
| 471 | 471 | } |
| 472 | 472 | if (native_os == .windows) { |
| ... | ... | @@ -572,7 +572,7 @@ pub fn selfExePath(out_buffer: []u8) SelfExePathError![]u8 { |
| 572 | 572 | return result; |
| 573 | 573 | } |
| 574 | 574 | switch (native_os) { |
| 575 | .linux => return posix.readlinkZ("/proc/self/exe", out_buffer) catch |err| switch (err) { | |
| 575 | .linux, .serenity => return posix.readlinkZ("/proc/self/exe", out_buffer) catch |err| switch (err) { | |
| 576 | 576 | error.InvalidUtf8 => unreachable, // WASI-only |
| 577 | 577 | error.InvalidWtf8 => unreachable, // Windows-only |
| 578 | 578 | error.UnsupportedReparsePointType => unreachable, // Windows-only |
lib/std/fs/get_app_data_dir.zig+1-1| ... | ... | @@ -30,7 +30,7 @@ pub fn getAppDataDir(allocator: mem.Allocator, appname: []const u8) GetAppDataDi |
| 30 | 30 | }; |
| 31 | 31 | return fs.path.join(allocator, &[_][]const u8{ home_dir, "Library", "Application Support", appname }); |
| 32 | 32 | }, |
| 33 | .linux, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris, .illumos => { | |
| 33 | .linux, .freebsd, .netbsd, .dragonfly, .openbsd, .solaris, .illumos, .serenity => { | |
| 34 | 34 | if (posix.getenv("XDG_DATA_HOME")) |xdg| { |
| 35 | 35 | if (xdg.len > 0) { |
| 36 | 36 | return fs.path.join(allocator, &[_][]const u8{ xdg, appname }); |
lib/std/os.zig+2-1| ... | ... | @@ -82,6 +82,7 @@ pub fn isGetFdPathSupportedOnTarget(os: std.Target.Os) bool { |
| 82 | 82 | .solaris, |
| 83 | 83 | .illumos, |
| 84 | 84 | .freebsd, |
| 85 | .serenity, | |
| 85 | 86 | => true, |
| 86 | 87 | |
| 87 | 88 | .dragonfly => os.version_range.semver.max.order(.{ .major = 6, .minor = 0, .patch = 0 }) != .lt, |
| ... | ... | @@ -127,7 +128,7 @@ pub fn getFdPath(fd: std.posix.fd_t, out_buffer: *[max_path_bytes]u8) std.posix. |
| 127 | 128 | const len = mem.indexOfScalar(u8, out_buffer[0..], 0) orelse max_path_bytes; |
| 128 | 129 | return out_buffer[0..len]; |
| 129 | 130 | }, |
| 130 | .linux => { | |
| 131 | .linux, .serenity => { | |
| 131 | 132 | var procfs_buf: ["/proc/self/fd/-2147483648\x00".len]u8 = undefined; |
| 132 | 133 | const proc_path = std.fmt.bufPrintZ(procfs_buf[0..], "/proc/self/fd/{d}", .{fd}) catch unreachable; |
| 133 | 134 |
lib/std/process.zig+1| ... | ... | @@ -1539,6 +1539,7 @@ pub fn getUserInfo(name: []const u8) !UserInfo { |
| 1539 | 1539 | .haiku, |
| 1540 | 1540 | .solaris, |
| 1541 | 1541 | .illumos, |
| 1542 | .serenity, | |
| 1542 | 1543 | => posixGetUserInfo(name), |
| 1543 | 1544 | else => @compileError("Unsupported OS"), |
| 1544 | 1545 | }; |
lib/std/zig/target.zig+11| ... | ... | @@ -318,6 +318,17 @@ pub fn isLibCLibName(target: std.Target, name: []const u8) bool { |
| 318 | 318 | return true; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | if (target.os.tag == .serenity) { | |
| 322 | if (eqlIgnoreCase(ignore_case, name, "dl")) | |
| 323 | return true; | |
| 324 | if (eqlIgnoreCase(ignore_case, name, "m")) | |
| 325 | return true; | |
| 326 | if (eqlIgnoreCase(ignore_case, name, "pthread")) | |
| 327 | return true; | |
| 328 | if (eqlIgnoreCase(ignore_case, name, "ssp")) | |
| 329 | return true; | |
| 330 | } | |
| 331 | ||
| 321 | 332 | return false; |
| 322 | 333 | } |
| 323 | 334 |