This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [nix-shell:~/Downloads/zig/build-memprof]$ /home/andy/Downloads/zig/build-memprof/zig build-exe /home/andy/Downloads/zig/src-self-hosted/main.zig --pkg-begin build_options /home/andy/Downloads/zig/zig-cache/zig_build_options.zig --pkg-end --cache-dir /home/andy/Downloads/zig/zig-cache --name zig --cache on -fmem-report | |
| LLVM Emit Output... | |
| --- MEMORY PROFILE REPORT [ArenaAllocator]: pass1 --- | |
| ZigValue: 88 bytes each, alloc{ 11598748 calls, 12201639 objects, total 1.000 GiB }, dealloc{ 0 calls, 0 objects, total 0.000 bytes }, remain{ 11598748 calls, 12201639 objects, total 1.000 GiB } | |
| Total bytes allocated: 1.000 GiB, deallocated: 0.000 bytes, remaining: 1.000 GiB | |
| Total calls alloc: 11598748, dealloc: 0, remain: 11598748 | |
| /home/andy/Downloads/zig/zig-cache/o/otcooWOP9TnG_gnFACLXE_743NOny6YBSAPQTDX5Rd7qC2swx_yDtkMjVzxxqjWB | |
| --- IR INTERNING REPORT --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @noreturn = primitive(noreturn) | |
| @void = primitive(void) | |
| @usize = primitive(usize) | |
| @0 = int(0) | |
| @1 = int(1) | |
| @2 = int(2) | |
| @3 = int(3) | |
| @syscall_array = str("syscall") | |
| @sysoutreg_array = str("={rax}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| test "benchmark" { | |
| var timer = try std.time.Timer.start(); | |
| const start = timer.lap(); | |
| var i: usize = 0; | |
| var hash: usize = 0; | |
| while (i < 1000000) : (i += 1) { | |
| const src = "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>."; | |
| var output: [100]u8 = undefined; | |
| var bf: BrainFuckInterpreter = undefined; | |
| bf.init(src, "", &output, 500); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn entry(start_index: usize, slice: []usize, value: usize) ?usize { | |
| var i: usize = start_index; | |
| while (i >= 0) : (i -= 1) { | |
| if (slice[i] == value) { | |
| return i; | |
| } | |
| } | |
| return null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @0 = str("Hello, world!\n") | |
| @1 = primitive(noreturn) | |
| @2 = primitive(usize) | |
| @3 = fntype([], @1, cc=Naked) | |
| @4 = int(0) | |
| @5 = int(1) | |
| @6 = int(231) | |
| @7 = str("len") | |
| @8 = fn(@3, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| const need_auto_promoting = @sizeOf(usize) > 4; | |
| const SmallInt = if (need_auto_promoting) u32 else usize; | |
| pub fn AutoPromotingArrayList(comptime T: type) type { | |
| return struct { | |
| pointer: [*]T, | |
| small_len: SmallInt, | |
| small_capacity: SmallInt, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //! To get started, run this tool with no args and read the help message. | |
| //! | |
| //! The build systems of musl-libc and glibc require specifying a single target | |
| //! architecture. Meanwhile, Zig supports out-of-the-box cross compilation for | |
| //! every target. So the process to create libc headers that Zig ships is to use | |
| //! this tool. | |
| //! First, use the musl/glibc build systems to create installations of all the | |
| //! targets in the `glibc_targets`/`musl_targets` variables. | |
| //! Next, run this tool to create a new directory which puts .h files into | |
| //! <arch> subdirectories, with `generic` being files that apply to all architectures. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Based on source here: | |
| // https://www.reddit.com/r/programming/comments/fxswxe/c_needs_better_syntax_and_macros/fmx4f0y/ | |
| // (plant "far-field" "Old McDonald's Farm") | |
| // (harvest "Old McDonald's Farm") | |
| // (grind "stone-mill") | |
| // (prepare-dough "sea-salt" "white-sugar" "ev-olive-oil") | |
| // (make-base) | |
| // (add-toppings "rosa-tomatoes" "mozzarella" "ham") | |
| // (bake "stone oven") | |
| // (enjoy)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /nix/store/qbn4f7k7yj5dj8ay292hr2nv0q8854vq-cmake-3.16.3/bin/cmake -S/home/andy/Downloads/llvm-project-10/libcxx -B/home/andy/Downloads/llvm-project-10/libcxx/build --check-build-system CMakeFiles/Makefile.cmake 0 | |
| /nix/store/qbn4f7k7yj5dj8ay292hr2nv0q8854vq-cmake-3.16.3/bin/cmake -E cmake_progress_start /home/andy/Downloads/llvm-project-10/libcxx/build/CMakeFiles /home/andy/Downloads/llvm-project-10/libcxx/build/CMakeFiles/progress.marks | |
| make -f CMakeFiles/Makefile2 all | |
| make[1]: Entering directory '/home/andy/Downloads/llvm-project-10/libcxx/build' | |
| make -f src/CMakeFiles/cxx_shared.dir/build.make src/CMakeFiles/cxx_shared.dir/depend | |
| make[2]: Entering directory '/home/andy/Downloads/llvm-project-10/libcxx/build' | |
| cd /home/andy/Downloads/llvm-project-10/libcxx/build && /nix/store/qbn4f7k7yj5dj8ay292hr2nv0q8854vq-cmake-3.16.3/bin/cmake -E cmake_depends "Unix Makefiles" /home/andy/Downloads/llvm-project-10/libcxx /home/andy/Downloads/llvm-project-10/libcxx/src /home/andy/Downloads/llvm-project-10/libcxx/build /hom |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const std = @import("std"); | |
| const net = std.net; | |
| const fs = std.fs; | |
| const os = std.os; | |
| pub const io_mode = .evented; | |
| pub fn main() anyerror!void { | |
| var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){}; | |
| const allocator = &general_purpose_allocator.allocator; |