authorgravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2021-06-20 15:39:23-05:00
committergravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2021-06-30 21:49:00-05:00
logd016caaccba8ae9372c56d2a47e21f36cc2f4d83
tree67119ba6f39e8038d3caef9228c36541477d725f
parent281a9a60f07afaf1b72bc66b2bb3c925b3c908f4

std.Thread: more compile error fixes


1 files changed, 14 insertions(+), 4 deletions(-)

lib/std/Thread.zig+14-4
...@@ -10,6 +10,7 @@...@@ -10,6 +10,7 @@
1010
11const std = @import("std.zig");11const std = @import("std.zig");
12const os = std.os;12const os = std.os;
13const assert = std.debug.assert;
13const target = std.Target.current;14const target = std.Target.current;
14const Atomic = std.atomic.Atomic;15const Atomic = std.atomic.Atomic;
1516
...@@ -259,11 +260,20 @@ const WindowsThreadImpl = struct {...@@ -259,11 +260,20 @@ const WindowsThreadImpl = struct {
259 },260 },
260 };261 };
261262
262 const stack_size = std.math.min(64 * 1024, std.math.cast(u32, config.stack_size) catch std.math.maxInt(u32));263 // Windows appears to only support SYSTEM_INFO.dwAllocationGranularity minimum stack size.
263264 // Going lower makes it default to that specified in the executable (~1mb).
264 const parameter = @ptrCast(*c_void, impl);265 // Its also fine if the limit here is incorrect as stack size is only a hint.
266 var stack_size = std.math.cast(u32, config.stack_size) catch std.math.maxInt(u32);
267 stack_size = std.math.max(64 * 1024, stack_size);
265 268
266 instance.thread.thread_handle = windows.CreateThread(null, stack_size, Impl.entry, parameter, 0, null) orelse {269 instance.thread.thread_handle = windows.CreateThread(
270 null,
271 stack_size,
272 Instance.entry,
273 @ptrCast(*c_void, instance),
274 0,
275 null,
276 ) orelse {
267 return windows.unexpectedError(windows.kernel32.GetLastError());277 return windows.unexpectedError(windows.kernel32.GetLastError());
268 };278 };
269279