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