diff options
| author | LemonBoy <thatlemon@gmail.com> | 2021-04-20 10:31:02 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-04-25 13:21:15 -0400 |
| commit | 5a94794b73c8f9d042bc7928d071cc1004487983 (patch) | |
| tree | 8e1ed3d94464ccf97088dfc6c5c2d0cc8c262fd0 /lib/std | |
| parent | 3a55cda14d38a2f83e3c6a9ecb782fcb81d1347d (diff) | |
| download | zig-5a94794b73c8f9d042bc7928d071cc1004487983.tar.gz zig-5a94794b73c8f9d042bc7928d071cc1004487983.zip | |
std: Fix thread creation with field-less context type
Closes #8524
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/Thread.zig | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig index 7e8a6226e6..01405b104f 100644 --- a/lib/std/Thread.zig +++ b/lib/std/Thread.zig @@ -199,7 +199,8 @@ pub fn spawn(comptime startFn: anytype, context: SpawnContextType(@TypeOf(startF inner: Context, }; fn threadMain(raw_arg: windows.LPVOID) callconv(.C) windows.DWORD { - const arg = if (@sizeOf(Context) == 0) {} else @ptrCast(*Context, @alignCast(@alignOf(Context), raw_arg)).*; + const arg = if (@sizeOf(Context) == 0) undefined // + else @ptrCast(*Context, @alignCast(@alignOf(Context), raw_arg)).*; switch (@typeInfo(@typeInfo(@TypeOf(startFn)).Fn.return_type.?)) { .NoReturn => { @@ -260,7 +261,8 @@ pub fn spawn(comptime startFn: anytype, context: SpawnContextType(@TypeOf(startF const MainFuncs = struct { fn linuxThreadMain(ctx_addr: usize) callconv(.C) u8 { - const arg = if (@sizeOf(Context) == 0) {} else @intToPtr(*const Context, ctx_addr).*; + const arg = if (@sizeOf(Context) == 0) undefined // + else @intToPtr(*Context, ctx_addr).*; switch (@typeInfo(@typeInfo(@TypeOf(startFn)).Fn.return_type.?)) { .NoReturn => { @@ -292,7 +294,8 @@ pub fn spawn(comptime startFn: anytype, context: SpawnContextType(@TypeOf(startF } } fn posixThreadMain(ctx: ?*c_void) callconv(.C) ?*c_void { - const arg = if (@sizeOf(Context) == 0) {} else @ptrCast(*Context, @alignCast(@alignOf(Context), ctx)).*; + const arg = if (@sizeOf(Context) == 0) undefined // + else @ptrCast(*Context, @alignCast(@alignOf(Context), ctx)).*; switch (@typeInfo(@typeInfo(@TypeOf(startFn)).Fn.return_type.?)) { .NoReturn => { |
