From cd537f822b0b60e00eff34c4e11c43f718705699 Mon Sep 17 00:00:00 2001 From: Sahnvour Date: Wed, 8 May 2019 18:14:35 +0200 Subject: Use unprotected heap when in single_threaded mode. --- std/heap.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'std') diff --git a/std/heap.zig b/std/heap.zig index e8bf02a2a8..8e3cccc365 100644 --- a/std/heap.zig +++ b/std/heap.zig @@ -280,7 +280,8 @@ pub const HeapAllocator = switch (builtin.os) { const amt = n + alignment + @sizeOf(usize); const optional_heap_handle = @atomicLoad(?HeapHandle, &self.heap_handle, builtin.AtomicOrder.SeqCst); const heap_handle = optional_heap_handle orelse blk: { - const hh = os.windows.HeapCreate(0, amt, 0) orelse return error.OutOfMemory; + const options = if (builtin.single_threaded) os.windows.HEAP_NO_SERIALIZE else 0; + const hh = os.windows.HeapCreate(options, amt, 0) orelse return error.OutOfMemory; const other_hh = @cmpxchgStrong(?HeapHandle, &self.heap_handle, null, hh, builtin.AtomicOrder.SeqCst, builtin.AtomicOrder.SeqCst) orelse break :blk hh; _ = os.windows.HeapDestroy(hh); break :blk other_hh.?; // can't be null because of the cmpxchg -- cgit v1.2.3