aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Thread.zig
diff options
context:
space:
mode:
authorStephen Gregoratto <dev@sgregoratto.me>2023-10-01 23:09:14 +1100
committerRyan Zezeski <ryan@zinascii.com>2023-10-02 15:31:49 -0600
commit285970982a662ae1882858ab8076b8c20609b9bb (patch)
tree5141c17d8bbb44b401bbda3cbbfdf7dc73106a8a /lib/std/Thread.zig
parent51fa7ef1c43c2b159cfba15ee06cd6f3fab3e556 (diff)
downloadzig-285970982a662ae1882858ab8076b8c20609b9bb.tar.gz
zig-285970982a662ae1882858ab8076b8c20609b9bb.zip
Add illumos OS tag
- Adds `illumos` to the `Target.Os.Tag` enum. A new function, `isSolarish` has been added that returns true if the tag is either Solaris or Illumos. This matches the naming convention found in Rust's `libc` crate[1]. - Add the tag wherever `.solaris` is being checked against. - Check for the C pre-processor macro `__illumos__` in CMake to set the proper target tuple. Illumos distros patch their compilers to have this in the "built-in" set (verified with `echo | cc -dM -E -`). Alternatively you could check the output of `uname -o`. Right now, both Solaris and Illumos import from `c/solaris.zig`. In the future it may be worth putting the shared ABI bits in a base file, and mixing that in with specific `c/solaris.zig`/`c/illumos.zig` files. [1]: https://github.com/rust-lang/libc/tree/6e02a329a2a27f6887ea86952f389ca11e06448c/src/unix/solarish
Diffstat (limited to 'lib/std/Thread.zig')
-rw-r--r--lib/std/Thread.zig8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
index 74f8e98df4..5ede51022d 100644
--- a/lib/std/Thread.zig
+++ b/lib/std/Thread.zig
@@ -43,7 +43,7 @@ pub const max_name_len = switch (target.os.tag) {
.freebsd => 15,
.openbsd => 23,
.dragonfly => 1023,
- .solaris => 31,
+ .solaris, .illumos => 31,
else => 0,
};
@@ -123,7 +123,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
else => |e| return os.unexpectedErrno(e),
}
},
- .netbsd, .solaris => if (use_pthreads) {
+ .netbsd, .solaris, .illumos => if (use_pthreads) {
const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr, null);
switch (err) {
.SUCCESS => return,
@@ -229,7 +229,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
else => |e| return os.unexpectedErrno(e),
}
},
- .netbsd, .solaris => if (use_pthreads) {
+ .netbsd, .solaris, .illumos => 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),
@@ -636,7 +636,7 @@ const PosixThreadImpl = struct {
};
return @as(usize, @intCast(count));
},
- .solaris => {
+ .solaris, .illumos => {
// The "proper" way to get the cpu count would be to query
// /dev/kstat via ioctls, and traverse a linked list for each
// cpu.