| ... | @@ -82,9 +82,9 @@ pub const Mutex = switch(builtin.os) { | ... | @@ -82,9 +82,9 @@ pub const Mutex = switch(builtin.os) { |
| 82 | }; | 82 | }; |
| 83 | } | 83 | } |
| 84 | | 84 | |
| 85 | extern fn initCriticalSection(InitOnce: *windows.PINIT_ONCE, Parameter: ?windows.PVOID, Context: ?*windows.PVOID) windows.BOOL { | 85 | extern fn initCriticalSection(InitOnce: *windows.PINIT_ONCE, Parameter: ?windows.PVOID, Context: ?windows.PVOID) windows.BOOL { |
| 86 | if (Context) |ctx| { | 86 | if (Context) |ctx| { |
| 87 | var mutex = @ptrCast(*?windows.CRITICAL_SECTION, ctx); | 87 | var mutex = @ptrCast(*?windows.CRITICAL_SECTION, @alignCast(8, ctx)); |
| 88 | if (mutex.* == null) { | 88 | if (mutex.* == null) { |
| 89 | var lock: windows.CRITICAL_SECTION = undefined; | 89 | var lock: windows.CRITICAL_SECTION = undefined; |
| 90 | windows.InitializeCriticalSection(&lock); | 90 | windows.InitializeCriticalSection(&lock); |
| ... | @@ -105,7 +105,8 @@ pub const Mutex = switch(builtin.os) { | ... | @@ -105,7 +105,8 @@ pub const Mutex = switch(builtin.os) { |
| 105 | if (self.lock) |*lock| { | 105 | if (self.lock) |*lock| { |
| 106 | windows.EnterCriticalSection(lock); | 106 | windows.EnterCriticalSection(lock); |
| 107 | } else { | 107 | } else { |
| 108 | if (windows.InitOnceExecuteOnce(&self.init_once, initCriticalSection, null, @ptrCast(?*windows.PVOID, self)) == windows.TRUE) { | 108 | var mutex = @ptrCast(?windows.PVOID, self); |
| | 109 | if (windows.InitOnceExecuteOnce(&self.init_once, initCriticalSection, null, mutex) == windows.TRUE) { |
| 109 | windows.EnterCriticalSection(&self.lock.?); | 110 | windows.EnterCriticalSection(&self.lock.?); |
| 110 | } else { | 111 | } else { |
| 111 | @panic("unable to initialize Mutex"); | 112 | @panic("unable to initialize Mutex"); |