This is from the live coding stream: https://youtu.be/aDd0BexKWps
This version of zig should be good: 0.5.0+913f7d04
| [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 |
| 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(); |
| 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 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 |
This is from the live coding stream: https://youtu.be/aDd0BexKWps
This version of zig should be good: 0.5.0+913f7d04
| # The directory that contains `stdlib.h`. | |
| # On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null` | |
| include_dir=C:\Program Files (x86)\Windows Kits\10\\Include\10.0.18362.0\ucrt | |
| # The system-specific include directory. May be the same as `include_dir`. | |
| # On Windows it's the directory that includes `vcruntime.h`. | |
| # On POSIX it's the directory that includes `sys/errno.h`. | |
| sys_include_dir=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.15.26726\lib\x64\\..\..\include | |
| # The directory that contains `crt1.o` or `crt2.o`. | |
| # On POSIX, can be found with `cc -print-file-name=crt1.o`. |
| .text | |
| .globl _start | |
| _start: | |
| movl $1, %eax | |
| movl $1, %edi | |
| movl $msg, %esi | |
| movl $12, %edx | |
| syscall | |
| movl $60, %eax | |
| xorl %edi, %edi |
| const std = @import("std"); | |
| const Allocator = std.mem.Allocator; | |
| const suspending_implementation = true; // try flipping this to false | |
| fn fib(allocator: *Allocator, x: u32) error{OutOfMemory}!u32 { | |
| if (x <= 1) return x; | |
| if (suspending_implementation) { | |
| suspend { |
| var x: i32 = 1; | |
| export fn entry() void { | |
| const p = async simpleAsyncFn(); | |
| } | |
| fn simpleAsyncFn() void { | |
| x += 1; | |
| suspend; | |
| x += 1; | |
| } |
| fn simpleAsyncFn() void { | |
| x += 1; | |
| suspend; | |
| x += 1; | |
| } | |
| // implementation with switch | |
| const Frame = struct { | |
| index: u2, | |
| }; | |
| fn simpleAsyncFn(locals: *Frame) void { |