aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Thread.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/Thread.zig')
-rw-r--r--lib/std/Thread.zig19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
index fc4f676a1f..d27474584f 100644
--- a/lib/std/Thread.zig
+++ b/lib/std/Thread.zig
@@ -255,8 +255,19 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
return error.Unsupported;
}
-/// Represents a unique ID per thread.
-pub const Id = u64;
+/// Represents an ID per thread guaranteed to be unique only within a process.
+pub const Id = switch (target.os.tag) {
+ .linux,
+ .dragonfly,
+ .netbsd,
+ .freebsd,
+ .openbsd,
+ .haiku,
+ => u32,
+ .macos, .ios, .watchos, .tvos => u64,
+ .windows => os.windows.DWORD,
+ else => usize,
+};
/// Returns the platform ID of the callers thread.
/// Attempts to use thread locals and avoid syscalls when possible.
@@ -431,7 +442,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
const UnsupportedImpl = struct {
pub const ThreadHandle = void;
- fn getCurrentId() u64 {
+ fn getCurrentId() usize {
return unsupported({});
}
@@ -466,7 +477,7 @@ const WindowsThreadImpl = struct {
pub const ThreadHandle = windows.HANDLE;
- fn getCurrentId() u64 {
+ fn getCurrentId() windows.DWORD {
return windows.kernel32.GetCurrentThreadId();
}