diff options
| author | kprotty <kbutcher6200@gmail.com> | 2021-06-20 15:39:23 -0500 |
|---|---|---|
| committer | kprotty <kbutcher6200@gmail.com> | 2021-06-30 21:49:00 -0500 |
| commit | d016caaccba8ae9372c56d2a47e21f36cc2f4d83 (patch) | |
| tree | 67119ba6f39e8038d3caef9228c36541477d725f /lib/std/Thread.zig | |
| parent | 281a9a60f07afaf1b72bc66b2bb3c925b3c908f4 (diff) | |
| download | zig-d016caaccba8ae9372c56d2a47e21f36cc2f4d83.tar.gz zig-d016caaccba8ae9372c56d2a47e21f36cc2f4d83.zip | |
std.Thread: more compile error fixes
Diffstat (limited to 'lib/std/Thread.zig')
| -rw-r--r-- | lib/std/Thread.zig | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 22f12c3c95..c5cf49929c 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -10,6 +10,7 @@ const std = @import("std.zig"); const os = std.os; +const assert = std.debug.assert; const target = std.Target.current; const Atomic = std.atomic.Atomic; @@ -259,11 +260,20 @@ const WindowsThreadImpl = struct { }, }; - const stack_size = std.math.min(64 * 1024, std.math.cast(u32, config.stack_size) catch std.math.maxInt(u32)); - - const parameter = @ptrCast(*c_void, impl); + // Windows appears to only support SYSTEM_INFO.dwAllocationGranularity minimum stack size. + // Going lower makes it default to that specified in the executable (~1mb). + // Its also fine if the limit here is incorrect as stack size is only a hint. + var stack_size = std.math.cast(u32, config.stack_size) catch std.math.maxInt(u32); + stack_size = std.math.max(64 * 1024, stack_size); - instance.thread.thread_handle = windows.CreateThread(null, stack_size, Impl.entry, parameter, 0, null) orelse { + instance.thread.thread_handle = windows.CreateThread( + null, + stack_size, + Instance.entry, + @ptrCast(*c_void, instance), + 0, + null, + ) orelse { return windows.unexpectedError(windows.kernel32.GetLastError()); }; |
