| author | |
| committer | |
| log | cb38bd0a1436bd18de8ed57c45ffc890c8ddfb78 |
| tree | c695fdb19e30581b8227ab286ce0a3b35971f34c |
| parent | 35d65cceb8aa4360accc0db30b2b1448159e7d26 |
| signature |
std.heap.direct_allocator is still available for now but it is marked
deprecated.28 files changed, 110 insertions(+), 104 deletions(-)
doc/docgen.zig+1-1| ... | ... | @@ -16,7 +16,7 @@ const tmp_dir_name = "docgen_tmp"; |
| 16 | 16 | const test_out_path = tmp_dir_name ++ fs.path.sep_str ++ "test" ++ exe_ext; |
| 17 | 17 | |
| 18 | 18 | pub fn main() !void { |
| 19 | var arena = std.heap.ArenaAllocator.init(std.heap.direct_allocator); | |
| 19 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
| 20 | 20 | defer arena.deinit(); |
| 21 | 21 | |
| 22 | 22 | const allocator = &arena.allocator; |
doc/langref.html.in+4-4| ... | ... | @@ -6428,7 +6428,7 @@ fn amainWrap() void { |
| 6428 | 6428 | } |
| 6429 | 6429 | |
| 6430 | 6430 | fn amain() !void { |
| 6431 | const allocator = std.heap.direct_allocator; | |
| 6431 | const allocator = std.heap.page_allocator; | |
| 6432 | 6432 | var download_frame = async fetchUrl(allocator, "https://example.com/"); |
| 6433 | 6433 | var awaited_download_frame = false; |
| 6434 | 6434 | errdefer if (!awaited_download_frame) { |
| ... | ... | @@ -6498,7 +6498,7 @@ fn amainWrap() void { |
| 6498 | 6498 | } |
| 6499 | 6499 | |
| 6500 | 6500 | fn amain() !void { |
| 6501 | const allocator = std.heap.direct_allocator; | |
| 6501 | const allocator = std.heap.page_allocator; | |
| 6502 | 6502 | var download_frame = async fetchUrl(allocator, "https://example.com/"); |
| 6503 | 6503 | var awaited_download_frame = false; |
| 6504 | 6504 | errdefer if (!awaited_download_frame) { |
| ... | ... | @@ -7315,7 +7315,7 @@ test "field access by string" { |
| 7315 | 7315 | const std = @import("std"); |
| 7316 | 7316 | |
| 7317 | 7317 | test "heap allocated frame" { |
| 7318 | const frame = try std.heap.direct_allocator.create(@Frame(func)); | |
| 7318 | const frame = try std.heap.page_allocator.create(@Frame(func)); | |
| 7319 | 7319 | frame.* = async func(); |
| 7320 | 7320 | } |
| 7321 | 7321 | |
| ... | ... | @@ -9341,7 +9341,7 @@ fn concat(allocator: *Allocator, a: []const u8, b: []const u8) ![]u8 { |
| 9341 | 9341 | const std = @import("std"); |
| 9342 | 9342 | |
| 9343 | 9343 | pub fn main() !void { |
| 9344 | var arena = std.heap.ArenaAllocator.init(std.heap.direct_allocator); | |
| 9344 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
| 9345 | 9345 | defer arena.deinit(); |
| 9346 | 9346 | |
| 9347 | 9347 | const allocator = &arena.allocator; |
lib/std/atomic/queue.zig+2-2| ... | ... | @@ -152,8 +152,8 @@ const puts_per_thread = 500; |
| 152 | 152 | const put_thread_count = 3; |
| 153 | 153 | |
| 154 | 154 | test "std.atomic.Queue" { |
| 155 | var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024); | |
| 156 | defer std.heap.direct_allocator.free(plenty_of_memory); | |
| 155 | var plenty_of_memory = try std.heap.page_allocator.alloc(u8, 300 * 1024); | |
| 156 | defer std.heap.page_allocator.free(plenty_of_memory); | |
| 157 | 157 | |
| 158 | 158 | var fixed_buffer_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(plenty_of_memory); |
| 159 | 159 | var a = &fixed_buffer_allocator.allocator; |
lib/std/atomic/stack.zig+2-2| ... | ... | @@ -86,8 +86,8 @@ const puts_per_thread = 500; |
| 86 | 86 | const put_thread_count = 3; |
| 87 | 87 | |
| 88 | 88 | test "std.atomic.stack" { |
| 89 | var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024); | |
| 90 | defer std.heap.direct_allocator.free(plenty_of_memory); | |
| 89 | var plenty_of_memory = try std.heap.page_allocator.alloc(u8, 300 * 1024); | |
| 90 | defer std.heap.page_allocator.free(plenty_of_memory); | |
| 91 | 91 | |
| 92 | 92 | var fixed_buffer_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(plenty_of_memory); |
| 93 | 93 | var a = &fixed_buffer_allocator.allocator; |
lib/std/buf_map.zig+1-1| ... | ... | @@ -83,7 +83,7 @@ pub const BufMap = struct { |
| 83 | 83 | }; |
| 84 | 84 | |
| 85 | 85 | test "BufMap" { |
| 86 | var bufmap = BufMap.init(std.heap.direct_allocator); | |
| 86 | var bufmap = BufMap.init(std.heap.page_allocator); | |
| 87 | 87 | defer bufmap.deinit(); |
| 88 | 88 | |
| 89 | 89 | try bufmap.set("x", "1"); |
lib/std/buf_set.zig+1-1| ... | ... | @@ -65,7 +65,7 @@ pub const BufSet = struct { |
| 65 | 65 | }; |
| 66 | 66 | |
| 67 | 67 | test "BufSet" { |
| 68 | var bufset = BufSet.init(std.heap.direct_allocator); | |
| 68 | var bufset = BufSet.init(std.heap.page_allocator); | |
| 69 | 69 | defer bufset.deinit(); |
| 70 | 70 | |
| 71 | 71 | try bufset.put("x"); |
lib/std/build.zig+1-1| ... | ... | @@ -969,7 +969,7 @@ pub const Builder = struct { |
| 969 | 969 | }; |
| 970 | 970 | |
| 971 | 971 | test "builder.findProgram compiles" { |
| 972 | const builder = try Builder.create(std.heap.direct_allocator, "zig", "zig-cache", "zig-cache"); | |
| 972 | const builder = try Builder.create(std.heap.page_allocator, "zig", "zig-cache", "zig-cache"); | |
| 973 | 973 | _ = builder.findProgram([_][]const u8{}, [_][]const u8{}) catch null; |
| 974 | 974 | } |
| 975 | 975 |
lib/std/debug.zig+1-1| ... | ... | @@ -2352,7 +2352,7 @@ var debug_info_arena_allocator: std.heap.ArenaAllocator = undefined; |
| 2352 | 2352 | fn getDebugInfoAllocator() *mem.Allocator { |
| 2353 | 2353 | if (debug_info_allocator) |a| return a; |
| 2354 | 2354 | |
| 2355 | debug_info_arena_allocator = std.heap.ArenaAllocator.init(std.heap.direct_allocator); | |
| 2355 | debug_info_arena_allocator = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
| 2356 | 2356 | debug_info_allocator = &debug_info_arena_allocator.allocator; |
| 2357 | 2357 | return &debug_info_arena_allocator.allocator; |
| 2358 | 2358 | } |
lib/std/event/fs.zig+1-1| ... | ... | @@ -1306,7 +1306,7 @@ test "write a file, watch it, write it again" { |
| 1306 | 1306 | // TODO provide a way to run tests in evented I/O mode |
| 1307 | 1307 | if (!std.io.is_async) return error.SkipZigTest; |
| 1308 | 1308 | |
| 1309 | const allocator = std.heap.direct_allocator; | |
| 1309 | const allocator = std.heap.page_allocator; | |
| 1310 | 1310 | |
| 1311 | 1311 | // TODO move this into event loop too |
| 1312 | 1312 | try os.makePath(allocator, test_tmp_dir); |
lib/std/event/group.zig+1-1| ... | ... | @@ -115,7 +115,7 @@ test "std.event.Group" { |
| 115 | 115 | // TODO provide a way to run tests in evented I/O mode |
| 116 | 116 | if (!std.io.is_async) return error.SkipZigTest; |
| 117 | 117 | |
| 118 | const handle = async testGroup(std.heap.direct_allocator); | |
| 118 | const handle = async testGroup(std.heap.page_allocator); | |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | async fn testGroup(allocator: *Allocator) void { |
lib/std/event/loop.zig+1-1| ... | ... | @@ -129,7 +129,7 @@ pub const Loop = struct { |
| 129 | 129 | /// max(thread_count - 1, 0) |
| 130 | 130 | pub fn initThreadPool(self: *Loop, thread_count: usize) !void { |
| 131 | 131 | // TODO: https://github.com/ziglang/zig/issues/3539 |
| 132 | const allocator = std.heap.direct_allocator; | |
| 132 | const allocator = std.heap.page_allocator; | |
| 133 | 133 | self.* = Loop{ |
| 134 | 134 | .pending_event_count = 1, |
| 135 | 135 | .allocator = allocator, |
lib/std/event/rwlock.zig+1-1| ... | ... | @@ -220,7 +220,7 @@ test "std.event.RwLock" { |
| 220 | 220 | var lock = RwLock.init(); |
| 221 | 221 | defer lock.deinit(); |
| 222 | 222 | |
| 223 | const handle = testLock(std.heap.direct_allocator, &lock); | |
| 223 | const handle = testLock(std.heap.page_allocator, &lock); | |
| 224 | 224 | |
| 225 | 225 | const expected_result = [1]i32{shared_it_count * @intCast(i32, shared_test_data.len)} ** shared_test_data.len; |
| 226 | 226 | testing.expectEqualSlices(i32, expected_result, shared_test_data); |
lib/std/hash/auto_hash.zig+5-5| ... | ... | @@ -235,8 +235,8 @@ test "hash pointer" { |
| 235 | 235 | test "hash slice shallow" { |
| 236 | 236 | // Allocate one array dynamically so that we're assured it is not merged |
| 237 | 237 | // with the other by the optimization passes. |
| 238 | const array1 = try std.heap.direct_allocator.create([6]u32); | |
| 239 | defer std.heap.direct_allocator.destroy(array1); | |
| 238 | const array1 = try std.heap.page_allocator.create([6]u32); | |
| 239 | defer std.heap.page_allocator.destroy(array1); | |
| 240 | 240 | array1.* = [_]u32{ 1, 2, 3, 4, 5, 6 }; |
| 241 | 241 | const array2 = [_]u32{ 1, 2, 3, 4, 5, 6 }; |
| 242 | 242 | const a = array1[0..]; |
| ... | ... | @@ -251,8 +251,8 @@ test "hash slice shallow" { |
| 251 | 251 | test "hash slice deep" { |
| 252 | 252 | // Allocate one array dynamically so that we're assured it is not merged |
| 253 | 253 | // with the other by the optimization passes. |
| 254 | const array1 = try std.heap.direct_allocator.create([6]u32); | |
| 255 | defer std.heap.direct_allocator.destroy(array1); | |
| 254 | const array1 = try std.heap.page_allocator.create([6]u32); | |
| 255 | defer std.heap.page_allocator.destroy(array1); | |
| 256 | 256 | array1.* = [_]u32{ 1, 2, 3, 4, 5, 6 }; |
| 257 | 257 | const array2 = [_]u32{ 1, 2, 3, 4, 5, 6 }; |
| 258 | 258 | const a = array1[0..]; |
| ... | ... | @@ -279,7 +279,7 @@ test "hash struct deep" { |
| 279 | 279 | } |
| 280 | 280 | }; |
| 281 | 281 | |
| 282 | const allocator = std.heap.direct_allocator; | |
| 282 | const allocator = std.heap.page_allocator; | |
| 283 | 283 | const foo = try Foo.init(allocator, 123, 1.0, true); |
| 284 | 284 | const bar = try Foo.init(allocator, 123, 1.0, true); |
| 285 | 285 | const baz = try Foo.init(allocator, 123, 1.0, false); |
lib/std/hash_map.zig+3-3| ... | ... | @@ -414,7 +414,7 @@ pub fn HashMap(comptime K: type, comptime V: type, comptime hash: fn (key: K) u3 |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | test "basic hash map usage" { |
| 417 | var map = AutoHashMap(i32, i32).init(std.heap.direct_allocator); | |
| 417 | var map = AutoHashMap(i32, i32).init(std.heap.page_allocator); | |
| 418 | 418 | defer map.deinit(); |
| 419 | 419 | |
| 420 | 420 | testing.expect((try map.put(1, 11)) == null); |
| ... | ... | @@ -458,7 +458,7 @@ test "basic hash map usage" { |
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | test "iterator hash map" { |
| 461 | var reset_map = AutoHashMap(i32, i32).init(std.heap.direct_allocator); | |
| 461 | var reset_map = AutoHashMap(i32, i32).init(std.heap.page_allocator); | |
| 462 | 462 | defer reset_map.deinit(); |
| 463 | 463 | |
| 464 | 464 | try reset_map.putNoClobber(1, 11); |
| ... | ... | @@ -504,7 +504,7 @@ test "iterator hash map" { |
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | test "ensure capacity" { |
| 507 | var map = AutoHashMap(i32, i32).init(std.heap.direct_allocator); | |
| 507 | var map = AutoHashMap(i32, i32).init(std.heap.page_allocator); | |
| 508 | 508 | defer map.deinit(); |
| 509 | 509 | |
| 510 | 510 | try map.ensureCapacity(20); |
lib/std/heap.zig+13-10| ... | ... | @@ -33,13 +33,16 @@ fn cShrink(self: *Allocator, old_mem: []u8, old_align: u29, new_size: usize, new |
| 33 | 33 | |
| 34 | 34 | /// This allocator makes a syscall directly for every allocation and free. |
| 35 | 35 | /// Thread-safe and lock-free. |
| 36 | pub const direct_allocator = &direct_allocator_state; | |
| 37 | var direct_allocator_state = Allocator{ | |
| 38 | .reallocFn = DirectAllocator.realloc, | |
| 39 | .shrinkFn = DirectAllocator.shrink, | |
| 36 | pub const page_allocator = &page_allocator_state; | |
| 37 | var page_allocator_state = Allocator{ | |
| 38 | .reallocFn = PageAllocator.realloc, | |
| 39 | .shrinkFn = PageAllocator.shrink, | |
| 40 | 40 | }; |
| 41 | 41 | |
| 42 | const DirectAllocator = struct { | |
| 42 | /// Deprecated. Use `page_allocator`. | |
| 43 | pub const direct_allocator = page_allocator; | |
| 44 | ||
| 45 | const PageAllocator = struct { | |
| 43 | 46 | fn alloc(allocator: *Allocator, n: usize, alignment: u29) error{OutOfMemory}![]u8 { |
| 44 | 47 | if (n == 0) return &[0]u8{}; |
| 45 | 48 | |
| ... | ... | @@ -484,7 +487,7 @@ pub const FixedBufferAllocator = struct { |
| 484 | 487 | } |
| 485 | 488 | }; |
| 486 | 489 | |
| 487 | // FIXME: Exposed LLVM intrinsics is a bug | |
| 490 | // TODO Exposed LLVM intrinsics is a bug | |
| 488 | 491 | // See: https://github.com/ziglang/zig/issues/2291 |
| 489 | 492 | extern fn @"llvm.wasm.memory.size.i32"(u32) u32; |
| 490 | 493 | extern fn @"llvm.wasm.memory.grow.i32"(u32, u32) i32; |
| ... | ... | @@ -725,8 +728,8 @@ test "c_allocator" { |
| 725 | 728 | } |
| 726 | 729 | } |
| 727 | 730 | |
| 728 | test "DirectAllocator" { | |
| 729 | const allocator = direct_allocator; | |
| 731 | test "PageAllocator" { | |
| 732 | const allocator = page_allocator; | |
| 730 | 733 | try testAllocator(allocator); |
| 731 | 734 | try testAllocatorAligned(allocator, 16); |
| 732 | 735 | try testAllocatorLargeAlignment(allocator); |
| ... | ... | @@ -735,7 +738,7 @@ test "DirectAllocator" { |
| 735 | 738 | if (builtin.os == .windows) { |
| 736 | 739 | // Trying really large alignment. As mentionned in the implementation, |
| 737 | 740 | // VirtualAlloc returns 64K aligned addresses. We want to make sure |
| 738 | // DirectAllocator works beyond that, as it's not tested by | |
| 741 | // PageAllocator works beyond that, as it's not tested by | |
| 739 | 742 | // `testAllocatorLargeAlignment`. |
| 740 | 743 | const slice = try allocator.alignedAlloc(u8, 1 << 20, 128); |
| 741 | 744 | slice[0] = 0x12; |
| ... | ... | @@ -758,7 +761,7 @@ test "HeapAllocator" { |
| 758 | 761 | } |
| 759 | 762 | |
| 760 | 763 | test "ArenaAllocator" { |
| 761 | var arena_allocator = ArenaAllocator.init(direct_allocator); | |
| 764 | var arena_allocator = ArenaAllocator.init(page_allocator); | |
| 762 | 765 | defer arena_allocator.deinit(); |
| 763 | 766 | |
| 764 | 767 | try testAllocator(&arena_allocator.allocator); |
lib/std/mutex.zig+2-2| ... | ... | @@ -125,8 +125,8 @@ const TestContext = struct { |
| 125 | 125 | }; |
| 126 | 126 | |
| 127 | 127 | test "std.Mutex" { |
| 128 | var plenty_of_memory = try std.heap.direct_allocator.alloc(u8, 300 * 1024); | |
| 129 | defer std.heap.direct_allocator.free(plenty_of_memory); | |
| 128 | var plenty_of_memory = try std.heap.page_allocator.alloc(u8, 300 * 1024); | |
| 129 | defer std.heap.page_allocator.free(plenty_of_memory); | |
| 130 | 130 | |
| 131 | 131 | var fixed_buffer_allocator = std.heap.ThreadSafeFixedBufferAllocator.init(plenty_of_memory); |
| 132 | 132 | var a = &fixed_buffer_allocator.allocator; |
lib/std/os/test.zig+2-2| ... | ... | @@ -234,6 +234,6 @@ test "pipe" { |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | test "argsAlloc" { |
| 237 | var args = try std.process.argsAlloc(std.heap.direct_allocator); | |
| 238 | std.heap.direct_allocator.free(args); | |
| 237 | var args = try std.process.argsAlloc(std.heap.page_allocator); | |
| 238 | std.process.argsFree(std.heap.page_allocator, args); | |
| 239 | 239 | } |
lib/std/packed_int_array.zig+2-2| ... | ... | @@ -622,7 +622,7 @@ test "PackedIntArray at end of available memory" { |
| 622 | 622 | p: PackedArray, |
| 623 | 623 | }; |
| 624 | 624 | |
| 625 | const allocator = std.heap.direct_allocator; | |
| 625 | const allocator = std.heap.page_allocator; | |
| 626 | 626 | |
| 627 | 627 | var pad = try allocator.create(Padded); |
| 628 | 628 | defer allocator.destroy(pad); |
| ... | ... | @@ -636,7 +636,7 @@ test "PackedIntSlice at end of available memory" { |
| 636 | 636 | } |
| 637 | 637 | const PackedSlice = PackedIntSlice(u11); |
| 638 | 638 | |
| 639 | const allocator = std.heap.direct_allocator; | |
| 639 | const allocator = std.heap.page_allocator; | |
| 640 | 640 | |
| 641 | 641 | var page = try allocator.alloc(u8, std.mem.page_size); |
| 642 | 642 | defer allocator.free(page); |
lib/std/segmented_list.zig+1-1| ... | ... | @@ -339,7 +339,7 @@ pub fn SegmentedList(comptime T: type, comptime prealloc_item_count: usize) type |
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | test "std.SegmentedList" { |
| 342 | var a = std.heap.direct_allocator; | |
| 342 | var a = std.heap.page_allocator; | |
| 343 | 343 | |
| 344 | 344 | try testSegmentedList(0, a); |
| 345 | 345 | try testSegmentedList(1, a); |
lib/std/special/build_runner.zig+1-1| ... | ... | @@ -17,7 +17,7 @@ pub fn main() !void { |
| 17 | 17 | // one shot program. We don't need to waste time freeing memory and finding places to squish |
| 18 | 18 | // bytes into. So we free everything all at once at the very end. |
| 19 | 19 | |
| 20 | var arena = std.heap.ArenaAllocator.init(std.heap.direct_allocator); | |
| 20 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
| 21 | 21 | defer arena.deinit(); |
| 22 | 22 | |
| 23 | 23 | const allocator = &arena.allocator; |
lib/std/unicode/throughput_test.zig+1-1| ... | ... | @@ -4,7 +4,7 @@ const std = @import("std"); |
| 4 | 4 | pub fn main() !void { |
| 5 | 5 | const stdout = &std.io.getStdOut().outStream().stream; |
| 6 | 6 | |
| 7 | const args = try std.process.argsAlloc(std.heap.direct_allocator); | |
| 7 | const args = try std.process.argsAlloc(std.heap.page_allocator); | |
| 8 | 8 | |
| 9 | 9 | @fence(.SeqCst); |
| 10 | 10 | var timer = try std.time.Timer.start(); |
src-self-hosted/dep_tokenizer.zig+1-1| ... | ... | @@ -837,7 +837,7 @@ test "error prereq - continuation expecting end-of-line" { |
| 837 | 837 | |
| 838 | 838 | // - tokenize input, emit textual representation, and compare to expect |
| 839 | 839 | fn depTokenizer(input: []const u8, expect: []const u8) !void { |
| 840 | var arena_allocator = std.heap.ArenaAllocator.init(std.heap.direct_allocator); | |
| 840 | var arena_allocator = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
| 841 | 841 | const arena = &arena_allocator.allocator; |
| 842 | 842 | defer arena_allocator.deinit(); |
| 843 | 843 |
test/cli.zig+1-1| ... | ... | @@ -8,7 +8,7 @@ const ChildProcess = std.ChildProcess; |
| 8 | 8 | var a: *std.mem.Allocator = undefined; |
| 9 | 9 | |
| 10 | 10 | pub fn main() !void { |
| 11 | var arena = std.heap.ArenaAllocator.init(std.heap.direct_allocator); | |
| 11 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
| 12 | 12 | defer arena.deinit(); |
| 13 | 13 | |
| 14 | 14 | var arg_it = process.args(); |
test/stage1/behavior/async_fn.zig+13-10| ... | ... | @@ -410,8 +410,8 @@ test "heap allocated async function frame" { |
| 410 | 410 | var x: i32 = 42; |
| 411 | 411 | |
| 412 | 412 | fn doTheTest() !void { |
| 413 | const frame = try std.heap.direct_allocator.create(@Frame(someFunc)); | |
| 414 | defer std.heap.direct_allocator.destroy(frame); | |
| 413 | const frame = try std.heap.page_allocator.create(@Frame(someFunc)); | |
| 414 | defer std.heap.page_allocator.destroy(frame); | |
| 415 | 415 | |
| 416 | 416 | expect(x == 42); |
| 417 | 417 | frame.* = async someFunc(); |
| ... | ... | @@ -671,7 +671,7 @@ fn testAsyncAwaitTypicalUsage( |
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | fn amain() !void { |
| 674 | const allocator = std.heap.direct_allocator; // TODO once we have the debug allocator, use that, so that this can detect leaks | |
| 674 | const allocator = std.heap.page_allocator; // TODO once we have the debug allocator, use that, so that this can detect leaks | |
| 675 | 675 | var download_frame = async fetchUrl(allocator, "https://example.com/"); |
| 676 | 676 | var download_awaited = false; |
| 677 | 677 | errdefer if (!download_awaited) { |
| ... | ... | @@ -935,12 +935,12 @@ fn recursiveAsyncFunctionTest(comptime suspending_implementation: bool) type { |
| 935 | 935 | _ = async amain(&result); |
| 936 | 936 | return result; |
| 937 | 937 | } else { |
| 938 | return fib(std.heap.direct_allocator, 10) catch unreachable; | |
| 938 | return fib(std.heap.page_allocator, 10) catch unreachable; | |
| 939 | 939 | } |
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | fn amain(result: *u32) void { |
| 943 | var x = async fib(std.heap.direct_allocator, 10); | |
| 943 | var x = async fib(std.heap.page_allocator, 10); | |
| 944 | 944 | result.* = (await x) catch unreachable; |
| 945 | 945 | } |
| 946 | 946 | }; |
| ... | ... | @@ -1132,7 +1132,9 @@ test "await used in expression after a fn call" { |
| 1132 | 1132 | async fn add(a: i32, b: i32) i32 { |
| 1133 | 1133 | return a + b; |
| 1134 | 1134 | } |
| 1135 | fn foo() i32 { return 1; } | |
| 1135 | fn foo() i32 { | |
| 1136 | return 1; | |
| 1137 | } | |
| 1136 | 1138 | }; |
| 1137 | 1139 | _ = async S.atest(); |
| 1138 | 1140 | } |
| ... | ... | @@ -1147,7 +1149,9 @@ test "async fn call used in expression after a fn call" { |
| 1147 | 1149 | async fn add(a: i32, b: i32) i32 { |
| 1148 | 1150 | return a + b; |
| 1149 | 1151 | } |
| 1150 | fn foo() i32 { return 1; } | |
| 1152 | fn foo() i32 { | |
| 1153 | return 1; | |
| 1154 | } | |
| 1151 | 1155 | }; |
| 1152 | 1156 | _ = async S.atest(); |
| 1153 | 1157 | } |
| ... | ... | @@ -1201,14 +1205,13 @@ test "correctly spill when returning the error union result of another async fn" |
| 1201 | 1205 | resume S.global_frame; |
| 1202 | 1206 | } |
| 1203 | 1207 | |
| 1204 | ||
| 1205 | 1208 | test "spill target expr in a for loop" { |
| 1206 | 1209 | const S = struct { |
| 1207 | 1210 | var global_frame: anyframe = undefined; |
| 1208 | 1211 | |
| 1209 | 1212 | fn doTheTest() void { |
| 1210 | 1213 | var foo = Foo{ |
| 1211 | .slice = [_]i32{1, 2}, | |
| 1214 | .slice = [_]i32{ 1, 2 }, | |
| 1212 | 1215 | }; |
| 1213 | 1216 | expect(atest(&foo) == 3); |
| 1214 | 1217 | } |
| ... | ... | @@ -1239,7 +1242,7 @@ test "spill target expr in a for loop, with a var decl in the loop body" { |
| 1239 | 1242 | |
| 1240 | 1243 | fn doTheTest() void { |
| 1241 | 1244 | var foo = Foo{ |
| 1242 | .slice = [_]i32{1, 2}, | |
| 1245 | .slice = [_]i32{ 1, 2 }, | |
| 1243 | 1246 | }; |
| 1244 | 1247 | expect(atest(&foo) == 3); |
| 1245 | 1248 | } |
test/standalone/brace_expansion/main.zig+1-1| ... | ... | @@ -182,7 +182,7 @@ pub fn main() !void { |
| 182 | 182 | const stdin_file = io.getStdIn(); |
| 183 | 183 | const stdout_file = io.getStdOut(); |
| 184 | 184 | |
| 185 | var arena = std.heap.ArenaAllocator.init(std.heap.direct_allocator); | |
| 185 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
| 186 | 186 | defer arena.deinit(); |
| 187 | 187 | |
| 188 | 188 | global_allocator = &arena.allocator; |
tools/merge_anal_dumps.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ const fieldIndex = std.meta.fieldIndex; |
| 6 | 6 | const TypeId = builtin.TypeId; |
| 7 | 7 | |
| 8 | 8 | pub fn main() anyerror!void { |
| 9 | var arena = std.heap.ArenaAllocator.init(std.heap.direct_allocator); | |
| 9 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
| 10 | 10 | defer arena.deinit(); |
| 11 | 11 | |
| 12 | 12 | const allocator = &arena.allocator; |
tools/process_headers.zig+45-45| ... | ... | @@ -56,113 +56,113 @@ const MultiAbi = union(enum) { |
| 56 | 56 | const glibc_targets = [_]LibCTarget{ |
| 57 | 57 | LibCTarget{ |
| 58 | 58 | .name = "aarch64_be-linux-gnu", |
| 59 | .arch = MultiArch {.specific = Arch.aarch64_be}, | |
| 60 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 59 | .arch = MultiArch{ .specific = Arch.aarch64_be }, | |
| 60 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 61 | 61 | }, |
| 62 | 62 | LibCTarget{ |
| 63 | 63 | .name = "aarch64-linux-gnu", |
| 64 | .arch = MultiArch {.specific = Arch.aarch64}, | |
| 65 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 64 | .arch = MultiArch{ .specific = Arch.aarch64 }, | |
| 65 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 66 | 66 | }, |
| 67 | 67 | LibCTarget{ |
| 68 | 68 | .name = "armeb-linux-gnueabi", |
| 69 | .arch = MultiArch {.specific = Arch.armeb}, | |
| 70 | .abi = MultiAbi {.specific = Abi.gnueabi}, | |
| 69 | .arch = MultiArch{ .specific = Arch.armeb }, | |
| 70 | .abi = MultiAbi{ .specific = Abi.gnueabi }, | |
| 71 | 71 | }, |
| 72 | 72 | LibCTarget{ |
| 73 | 73 | .name = "armeb-linux-gnueabihf", |
| 74 | .arch = MultiArch {.specific = Arch.armeb}, | |
| 75 | .abi = MultiAbi {.specific = Abi.gnueabihf}, | |
| 74 | .arch = MultiArch{ .specific = Arch.armeb }, | |
| 75 | .abi = MultiAbi{ .specific = Abi.gnueabihf }, | |
| 76 | 76 | }, |
| 77 | 77 | LibCTarget{ |
| 78 | 78 | .name = "arm-linux-gnueabi", |
| 79 | .arch = MultiArch {.specific = Arch.arm}, | |
| 80 | .abi = MultiAbi {.specific = Abi.gnueabi}, | |
| 79 | .arch = MultiArch{ .specific = Arch.arm }, | |
| 80 | .abi = MultiAbi{ .specific = Abi.gnueabi }, | |
| 81 | 81 | }, |
| 82 | 82 | LibCTarget{ |
| 83 | 83 | .name = "arm-linux-gnueabihf", |
| 84 | .arch = MultiArch {.specific = Arch.arm}, | |
| 85 | .abi = MultiAbi {.specific = Abi.gnueabihf}, | |
| 84 | .arch = MultiArch{ .specific = Arch.arm }, | |
| 85 | .abi = MultiAbi{ .specific = Abi.gnueabihf }, | |
| 86 | 86 | }, |
| 87 | 87 | LibCTarget{ |
| 88 | 88 | .name = "i686-linux-gnu", |
| 89 | .arch = MultiArch {.specific = Arch.i386}, | |
| 90 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 89 | .arch = MultiArch{ .specific = Arch.i386 }, | |
| 90 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 91 | 91 | }, |
| 92 | 92 | LibCTarget{ |
| 93 | 93 | .name = "mips64el-linux-gnu-n32", |
| 94 | .arch = MultiArch {.specific = Arch.mips64el}, | |
| 95 | .abi = MultiAbi {.specific = Abi.gnuabin32}, | |
| 94 | .arch = MultiArch{ .specific = Arch.mips64el }, | |
| 95 | .abi = MultiAbi{ .specific = Abi.gnuabin32 }, | |
| 96 | 96 | }, |
| 97 | 97 | LibCTarget{ |
| 98 | 98 | .name = "mips64el-linux-gnu-n64", |
| 99 | .arch = MultiArch {.specific = Arch.mips64el}, | |
| 100 | .abi = MultiAbi {.specific = Abi.gnuabi64}, | |
| 99 | .arch = MultiArch{ .specific = Arch.mips64el }, | |
| 100 | .abi = MultiAbi{ .specific = Abi.gnuabi64 }, | |
| 101 | 101 | }, |
| 102 | 102 | LibCTarget{ |
| 103 | 103 | .name = "mips64-linux-gnu-n32", |
| 104 | .arch = MultiArch {.specific = Arch.mips64}, | |
| 105 | .abi = MultiAbi {.specific = Abi.gnuabin32}, | |
| 104 | .arch = MultiArch{ .specific = Arch.mips64 }, | |
| 105 | .abi = MultiAbi{ .specific = Abi.gnuabin32 }, | |
| 106 | 106 | }, |
| 107 | 107 | LibCTarget{ |
| 108 | 108 | .name = "mips64-linux-gnu-n64", |
| 109 | .arch = MultiArch {.specific = Arch.mips64}, | |
| 110 | .abi = MultiAbi {.specific = Abi.gnuabi64}, | |
| 109 | .arch = MultiArch{ .specific = Arch.mips64 }, | |
| 110 | .abi = MultiAbi{ .specific = Abi.gnuabi64 }, | |
| 111 | 111 | }, |
| 112 | 112 | LibCTarget{ |
| 113 | 113 | .name = "mipsel-linux-gnu", |
| 114 | .arch = MultiArch {.specific = Arch.mipsel}, | |
| 115 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 114 | .arch = MultiArch{ .specific = Arch.mipsel }, | |
| 115 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 116 | 116 | }, |
| 117 | 117 | LibCTarget{ |
| 118 | 118 | .name = "mips-linux-gnu", |
| 119 | .arch = MultiArch {.specific = Arch.mips}, | |
| 120 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 119 | .arch = MultiArch{ .specific = Arch.mips }, | |
| 120 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 121 | 121 | }, |
| 122 | 122 | LibCTarget{ |
| 123 | 123 | .name = "powerpc64le-linux-gnu", |
| 124 | .arch = MultiArch {.specific = Arch.powerpc64le}, | |
| 125 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 124 | .arch = MultiArch{ .specific = Arch.powerpc64le }, | |
| 125 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 126 | 126 | }, |
| 127 | 127 | LibCTarget{ |
| 128 | 128 | .name = "powerpc64-linux-gnu", |
| 129 | .arch = MultiArch {.specific = Arch.powerpc64}, | |
| 130 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 129 | .arch = MultiArch{ .specific = Arch.powerpc64 }, | |
| 130 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 131 | 131 | }, |
| 132 | 132 | LibCTarget{ |
| 133 | 133 | .name = "powerpc-linux-gnu", |
| 134 | .arch = MultiArch {.specific = Arch.powerpc}, | |
| 135 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 134 | .arch = MultiArch{ .specific = Arch.powerpc }, | |
| 135 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 136 | 136 | }, |
| 137 | 137 | LibCTarget{ |
| 138 | 138 | .name = "riscv64-linux-gnu-rv64imac-lp64", |
| 139 | .arch = MultiArch {.specific = Arch.riscv64}, | |
| 140 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 139 | .arch = MultiArch{ .specific = Arch.riscv64 }, | |
| 140 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 141 | 141 | }, |
| 142 | 142 | LibCTarget{ |
| 143 | 143 | .name = "s390x-linux-gnu", |
| 144 | .arch = MultiArch {.specific = Arch.s390x}, | |
| 145 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 144 | .arch = MultiArch{ .specific = Arch.s390x }, | |
| 145 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 146 | 146 | }, |
| 147 | 147 | LibCTarget{ |
| 148 | 148 | .name = "sparc64-linux-gnu", |
| 149 | .arch = MultiArch {.specific = Arch.sparc}, | |
| 150 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 149 | .arch = MultiArch{ .specific = Arch.sparc }, | |
| 150 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 151 | 151 | }, |
| 152 | 152 | LibCTarget{ |
| 153 | 153 | .name = "sparcv9-linux-gnu", |
| 154 | .arch = MultiArch {.specific = Arch.sparcv9}, | |
| 155 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 154 | .arch = MultiArch{ .specific = Arch.sparcv9 }, | |
| 155 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 156 | 156 | }, |
| 157 | 157 | LibCTarget{ |
| 158 | 158 | .name = "x86_64-linux-gnu", |
| 159 | .arch = MultiArch {.specific = Arch.x86_64}, | |
| 160 | .abi = MultiAbi {.specific = Abi.gnu}, | |
| 159 | .arch = MultiArch{ .specific = Arch.x86_64 }, | |
| 160 | .abi = MultiAbi{ .specific = Abi.gnu }, | |
| 161 | 161 | }, |
| 162 | 162 | LibCTarget{ |
| 163 | 163 | .name = "x86_64-linux-gnu-x32", |
| 164 | .arch = MultiArch {.specific = Arch.x86_64}, | |
| 165 | .abi = MultiAbi {.specific = Abi.gnux32}, | |
| 164 | .arch = MultiArch{ .specific = Arch.x86_64 }, | |
| 165 | .abi = MultiAbi{ .specific = Abi.gnux32 }, | |
| 166 | 166 | }, |
| 167 | 167 | }; |
| 168 | 168 | |
| ... | ... | @@ -258,7 +258,7 @@ const LibCVendor = enum { |
| 258 | 258 | }; |
| 259 | 259 | |
| 260 | 260 | pub fn main() !void { |
| 261 | var arena = std.heap.ArenaAllocator.init(std.heap.direct_allocator); | |
| 261 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
| 262 | 262 | const allocator = &arena.allocator; |
| 263 | 263 | const args = try std.process.argsAlloc(allocator); |
| 264 | 264 | var search_paths = std.ArrayList([]const u8).init(allocator); |
tools/update_glibc.zig+1-1| ... | ... | @@ -131,7 +131,7 @@ const Function = struct { |
| 131 | 131 | }; |
| 132 | 132 | |
| 133 | 133 | pub fn main() !void { |
| 134 | var arena = std.heap.ArenaAllocator.init(std.heap.direct_allocator); | |
| 134 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
| 135 | 135 | const allocator = &arena.allocator; |
| 136 | 136 | const args = try std.process.argsAlloc(allocator); |
| 137 | 137 | const in_glibc_dir = args[1]; // path to the unzipped tarball of glibc, e.g. ~/downloads/glibc-2.25 |