commit 140ca67ea6d42d635c837558c075d8d9abd4e884 (tree)
parent f10100cf9b3d6929f2ed2df64835b2773e117665
Author: r00ster91 <r00ster91@proton.me>
Date: Fri, 24 Feb 2023 20:58:36 +0100
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:
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git 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();