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; |
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
[External Code] | |
test.exe!std.mutex.Mutex::std.mutex.Mutex.acquireSlow(std.mutex.Held * self, std.mutex.Mutex *) Line 128 | |
at C:\msys64\home\andy\dev\zig\lib\std\mutex.zig(128) | |
test.exe!std.mutex.Mutex::std.mutex.Mutex.acquire(std.mutex.Held * self, std.mutex.Mutex *) Line 100 | |
at C:\msys64\home\andy\dev\zig\lib\std\mutex.zig(100) | |
test.exe!std.debug.warn(std.os.windows.struct:1204:69 * args) Line 64 | |
at C:\msys64\home\andy\dev\zig\lib\std\debug.zig(64) | |
test.exe!std.os.windows.unexpectedError(std.builtin.StackTrace * err, std.os.windows.win32error.Win32Error) Line 1205 | |
at C:\msys64\home\andy\dev\zig\lib\std\os\windows.zig(1205) | |
test.exe!std.os.windows.WriteFile(std.os.windows.WriteFileError!usize * handle, std.builtin.StackTrace * bytes, c_void * offset, []u8 *) Line 486 |
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"); | |
var all_threads: [10]*std.Thread = undefined; | |
var next_thread_index: usize = 0; | |
pub fn main() anyerror!void { | |
_ = async asyncMain(); | |
var i: usize = 0; | |
while (i < next_thread_index) : (i += 1) { | |
all_threads[i].wait(); |
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 { | |
const allocator = std.heap.page_allocator; // TODO use a more appropriate allocator |
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
This was as far up as it let me scroll to copy-paste. | |
Thank you for being so helpful while I was coding this. | |
If your links got cut off, please feel free to comment on this gist and add those links. | |
daurnimator: So there are multiple forms for each instructions, you usally want to break up by arity | |
daurnimator: so you want e.g. 2-arity mov | |
daurnimator: e.g. ret is C2 for 1-arity or C3 for 0-arity | |
daurnimator: to steal from the dynasm instruction table: `mov_2 = "OR:A3o|RO:A1O|mr:89Rm|rm:8BrM|rib:nB0ri|ridw:B8ri|mi:C70mi",` Which is saying that 2-arity mov has 7 forms | |
daurnimator: integer register, fp register, index operand, immediate, jump taget |