| ... | @@ -41,6 +41,7 @@ pub const max_name_len = switch (target.os.tag) { | ... | @@ -41,6 +41,7 @@ pub const max_name_len = switch (target.os.tag) { |
| 41 | .netbsd => 31, | 41 | .netbsd => 31, |
| 42 | .freebsd => 15, | 42 | .freebsd => 15, |
| 43 | .openbsd => 31, | 43 | .openbsd => 31, |
| | 44 | .dragonfly => 1023, |
| 44 | .solaris => 31, | 45 | .solaris => 31, |
| 45 | else => 0, | 46 | else => 0, |
| 46 | }; | 47 | }; |
| ... | @@ -130,6 +131,17 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void { | ... | @@ -130,6 +131,17 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void { |
| 130 | | 131 | |
| 131 | std.c.pthread_set_name_np(self.getHandle(), name_with_terminator.ptr); | 132 | std.c.pthread_set_name_np(self.getHandle(), name_with_terminator.ptr); |
| 132 | }, | 133 | }, |
| | 134 | .dragonfly => if (use_pthreads) { |
| | 135 | const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr); |
| | 136 | switch (err) { |
| | 137 | .SUCCESS => return, |
| | 138 | .INVAL => unreachable, |
| | 139 | .FAULT => unreachable, |
| | 140 | .NAMETOOLONG => unreachable, // already checked |
| | 141 | .SRCH => unreachable, |
| | 142 | else => |e| return os.unexpectedErrno(e), |
| | 143 | } |
| | 144 | }, |
| 133 | else => return error.Unsupported, | 145 | else => return error.Unsupported, |
| 134 | } | 146 | } |
| 135 | } | 147 | } |
| ... | @@ -219,6 +231,16 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co | ... | @@ -219,6 +231,16 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co |
| 219 | std.c.pthread_get_name_np(self.getHandle(), buffer.ptr, max_name_len + 1); | 231 | std.c.pthread_get_name_np(self.getHandle(), buffer.ptr, max_name_len + 1); |
| 220 | return std.mem.sliceTo(buffer, 0); | 232 | return std.mem.sliceTo(buffer, 0); |
| 221 | }, | 233 | }, |
| | 234 | .dragonfly => if (use_pthreads) { |
| | 235 | const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1); |
| | 236 | switch (err) { |
| | 237 | .SUCCESS => return std.mem.sliceTo(buffer, 0), |
| | 238 | .INVAL => unreachable, |
| | 239 | .FAULT => unreachable, |
| | 240 | .SRCH => unreachable, |
| | 241 | else => |e| return os.unexpectedErrno(e), |
| | 242 | } |
| | 243 | }, |
| 222 | else => return error.Unsupported, | 244 | else => return error.Unsupported, |
| 223 | } | 245 | } |
| 224 | } | 246 | } |