aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Thread.zig
diff options
context:
space:
mode:
authorr00ster91 <r00ster91@proton.me>2023-02-24 20:58:36 +0100
committerr00ster91 <r00ster91@proton.me>2023-02-26 00:15:46 +0100
commit140ca67ea6d42d635c837558c075d8d9abd4e884 (patch)
tree92da2459d2d96151e2577456043350df5d0ae27d /lib/std/Thread.zig
parentf10100cf9b3d6929f2ed2df64835b2773e117665 (diff)
downloadzig-140ca67ea6d42d635c837558c075d8d9abd4e884.tar.gz
zig-140ca67ea6d42d635c837558c075d8d9abd4e884.zip
std.Thread: use pthread_getname_np on musl
Starting with version 1.2.3, musl now supports pthread_getname_np: https://github.com/bminor/musl/blob/7a43f6fea9081bdd53d8a11cef9e9fab0348c53d/WHATSNEW#L2293-L2329
Diffstat (limited to 'lib/std/Thread.zig')
-rw-r--r--lib/std/Thread.zig15
1 files changed, 1 insertions, 14 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
index 795dfb2daa..bbd6862b88 100644
--- a/lib/std/Thread.zig
+++ b/lib/std/Thread.zig
@@ -179,10 +179,6 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
else => |e| return os.unexpectedErrno(e),
}
} else {
- if (target.abi.isMusl()) {
- // musl doesn't provide pthread_getname_np and there's no way to retrieve the thread id of an arbitrary thread.
- return error.Unsupported;
- }
const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
switch (err) {
.SUCCESS => return std.mem.sliceTo(buffer, 0),
@@ -1133,16 +1129,7 @@ test "setName, getName" {
error.Unsupported => return error.SkipZigTest,
else => return err,
},
- else => |tag| if (tag == .linux and use_pthreads and comptime target.abi.isMusl()) {
- try thread.setName("foobar");
-
- var name_buffer: [max_name_len:0]u8 = undefined;
- const res = thread.getName(&name_buffer);
-
- try std.testing.expectError(error.Unsupported, res);
- } else {
- try testThreadName(&thread);
- },
+ else => try testThreadName(&thread),
}
context.thread_done_event.set();