authorgravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2021-06-26 10:52:34-05:00
committergravatar for kbutcher6200@gmail.comkprotty <kbutcher6200@gmail.com> 2021-06-30 21:49:00-05:00
logc6fb968a3d702fbf8067164052ccf562f5e362ef
tree999e66ef1066e813c788df367e0ced2243b1ed94
parentfd4a607bb2f1a1cbf8b8c1fd5d35f5f775e79114

std.Thread: fix posix


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

lib/std/Thread.zig+9-4
......@@ -376,11 +376,16 @@ const PosixThreadImpl = struct {
376376 fn spawn(config: SpawnConfig, comptime f: anytype, args: anytype) !Impl {
377377 const Args = @TypeOf(args);
378378 const allocator = std.heap.c_allocator;
379
379380 const Instance = struct {
380381 fn entryFn(raw_arg: ?*c_void) callconv(.C) ?*c_void {
381 const args_ptr = @ptrCast(*Args, @alignCast(@alignOf(Args), raw_arg orelse unreachable));
382 defer allocator.destroy(args_ptr);
383 return callFn(f, args_ptr.*);
382 if (@sizeOf(Args) < 1) {
383 return callFn(f, @as(Args, undefined));
384 }
385
386 const args_ptr = @ptrCast(*Args, @alignCast(@alignOf(Args), raw_arg));
387 defer allocator.destroy(args_ptr);
388 return callFn(f, args_ptr.*);
384389 }
385390 };
386391
......@@ -402,7 +407,7 @@ const PosixThreadImpl = struct {
402407 &handle,
403408 &attr,
404409 Instance.entryFn,
405 @ptrCast(*c_void, args_ptr),
410 if (@sizeOf(Args) > 1) @ptrCast(*c_void, args_ptr) else undefined,
406411 )) {
407412 0 => return Impl{ .handle = handle },
408413 os.EAGAIN => return error.SystemResources,