diff options
| author | Benjamin Feng <benjamin.feng@glassdoor.com> | 2019-12-06 16:03:15 -0600 |
|---|---|---|
| committer | Benjamin Feng <benjamin.feng@glassdoor.com> | 2019-12-06 17:27:11 -0600 |
| commit | e91522b875b72cc3990fd4086a331ab63ac70dc8 (patch) | |
| tree | 6c3fac3674bf4835c336d735a64c6575aaeec218 /lib/std/heap.zig | |
| parent | 5a004ed834b62a15ebf1649856580baeb68501fa (diff) | |
| download | zig-e91522b875b72cc3990fd4086a331ab63ac70dc8.tar.gz zig-e91522b875b72cc3990fd4086a331ab63ac70dc8.zip | |
Add back comptime check for wasm
Diffstat (limited to 'lib/std/heap.zig')
| -rw-r--r-- | lib/std/heap.zig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/std/heap.zig b/lib/std/heap.zig index d456407706..b6a6c6e3fe 100644 --- a/lib/std/heap.zig +++ b/lib/std/heap.zig @@ -252,6 +252,12 @@ extern fn @"llvm.wasm.memory.size.i32"(u32) u32; extern fn @"llvm.wasm.memory.grow.i32"(u32, u32) i32; const WasmPageAllocator = struct { + comptime { + if (!std.Target.current.isWasm()) { + @compileError("WasmPageAllocator is only available for wasm32 arch"); + } + } + const PageStatus = enum(u1) { used = 0, free = 1, @@ -797,7 +803,7 @@ test "c_allocator" { } test "WasmPageAllocator internals" { - if (std.Target.current.isWasm()) { + if (comptime std.Target.current.isWasm()) { const none_free = WasmPageAllocator.PageStatus.none_free; std.debug.assert(none_free == WasmPageAllocator.conventional.data[0]); // Passes if this test runs first std.debug.assert(!WasmPageAllocator.extended.isInitialized()); // Passes if this test runs first |
