| ... | @@ -63,11 +63,8 @@ pub fn setName(self: Thread, io: Io, name: []const u8) SetNameError!void { | ... | @@ -63,11 +63,8 @@ pub fn setName(self: Thread, io: Io, name: []const u8) SetNameError!void { |
| 63 | .linux => if (use_pthreads) { | 63 | .linux => if (use_pthreads) { |
| 64 | if (self.getHandle() == std.c.pthread_self()) { | 64 | if (self.getHandle() == std.c.pthread_self()) { |
| 65 | // Set the name of the calling thread (no thread id required). | 65 | // Set the name of the calling thread (no thread id required). |
| 66 | const err = try posix.prctl(.SET_NAME, .{@intFromPtr(name_with_terminator.ptr)}); | 66 | assert(try posix.prctl(.SET_NAME, .{@intFromPtr(name_with_terminator.ptr)}) == 0); |
| 67 | switch (@as(posix.E, @enumFromInt(err))) { | 67 | return; |
| 68 | .SUCCESS => return, | | |
| 69 | else => |e| return posix.unexpectedErrno(e), | | |
| 70 | } | | |
| 71 | } else { | 68 | } else { |
| 72 | const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr); | 69 | const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr); |
| 73 | switch (@as(posix.E, @enumFromInt(err))) { | 70 | switch (@as(posix.E, @enumFromInt(err))) { |
| ... | @@ -167,11 +164,8 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co | ... | @@ -167,11 +164,8 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co |
| 167 | .linux => if (use_pthreads) { | 164 | .linux => if (use_pthreads) { |
| 168 | if (self.getHandle() == std.c.pthread_self()) { | 165 | if (self.getHandle() == std.c.pthread_self()) { |
| 169 | // Get the name of the calling thread (no thread id required). | 166 | // Get the name of the calling thread (no thread id required). |
| 170 | const err = try posix.prctl(.GET_NAME, .{@intFromPtr(buffer.ptr)}); | 167 | assert(try posix.prctl(.GET_NAME, .{@intFromPtr(buffer.ptr)}) == 0); |
| 171 | switch (@as(posix.E, @enumFromInt(err))) { | 168 | return std.mem.sliceTo(buffer, 0); |
| 172 | .SUCCESS => return std.mem.sliceTo(buffer, 0), | | |
| 173 | else => |e| return posix.unexpectedErrno(e), | | |
| 174 | } | | |
| 175 | } else { | 169 | } else { |
| 176 | const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1); | 170 | const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1); |
| 177 | switch (@as(posix.E, @enumFromInt(err))) { | 171 | switch (@as(posix.E, @enumFromInt(err))) { |