| ... | ... | @@ -255,8 +255,19 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co |
| 255 | 255 | return error.Unsupported; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | | /// Represents a unique ID per thread. |
| 259 | | pub const Id = u64; |
| 258 | /// Represents an ID per thread guaranteed to be unique only within a process. |
| 259 | pub const Id = switch (target.os.tag) { |
| 260 | .linux, |
| 261 | .dragonfly, |
| 262 | .netbsd, |
| 263 | .freebsd, |
| 264 | .openbsd, |
| 265 | .haiku, |
| 266 | => u32, |
| 267 | .macos, .ios, .watchos, .tvos => u64, |
| 268 | .windows => os.windows.DWORD, |
| 269 | else => usize, |
| 270 | }; |
| 260 | 271 | |
| 261 | 272 | /// Returns the platform ID of the callers thread. |
| 262 | 273 | /// Attempts to use thread locals and avoid syscalls when possible. |
| ... | ... | @@ -431,7 +442,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) { |
| 431 | 442 | const UnsupportedImpl = struct { |
| 432 | 443 | pub const ThreadHandle = void; |
| 433 | 444 | |
| 434 | | fn getCurrentId() u64 { |
| 445 | fn getCurrentId() usize { |
| 435 | 446 | return unsupported({}); |
| 436 | 447 | } |
| 437 | 448 | |
| ... | ... | @@ -466,7 +477,7 @@ const WindowsThreadImpl = struct { |
| 466 | 477 | |
| 467 | 478 | pub const ThreadHandle = windows.HANDLE; |
| 468 | 479 | |
| 469 | | fn getCurrentId() u64 { |
| 480 | fn getCurrentId() windows.DWORD { |
| 470 | 481 | return windows.kernel32.GetCurrentThreadId(); |
| 471 | 482 | } |
| 472 | 483 | |