Skip to content

Instantly share code, notes, and snippets.

View marler8997's full-sized avatar

Jonathan Marler marler8997

  • Tuple
  • Idaho, United States
View GitHub Profile
fn pop(self: *RunQueue) ?*Runnable {
const runnable = self.head orelse return null;
self.head = runnable.next;
if (self.head == null) self.tail = null;
return runnable;
}
fn runWorker(self: *ThreadPool) void {
const old_pool = tls_current_pool;
tls_current_pool = self;
defer tls_current_pool = old_pool;
while (true) {
const held = self.mutex.acquire();
if (self.is_shutdown) {
held.release();
break;
const Bad = error { Bad };
fn foo() Bad!Bad {
return error.Bad;
}
pub fn main() !void {
@import("std").debug.print("{}\n", .{try foo()});
}
pub const ComptimeBuildOptions = struct {
openssl: std.build.ComptimeOption(bool, "openssl", "enable openssl backend");
wolfssl: std.build.ComptimeOption(bool, "wolfssl", "enable wolfssl backend"),
bearssl: std.build.ComptimeOption(bool, "bearssl", "enable bearssl backend"),
schannel: std.build.ComptimeOption(bool, "schannel", "enable schannel backend"),
};
pub fn build(b: *Builder) !void {
@marler8997
marler8997 / ZigBuildFlow.md
Last active February 25, 2021 08:48
Dyanamic Dependencies for build.zig
  • Run zig build -Dandroid
  • build.zig gets compiled
  • the resulting build executable is executed
  • build_runner.zig detects that there is a "needPackage" configured so it prints this error:
$ zig build -Dandroid
error: build.zig is missing needed package "androidbuild"
  • Run zig build -Dandroid
  • Zig generates the "buildpkgs" module with a list of the packages that are available

buildpkgs.zig

pub fn hasPackage(comptime name: []const u8) bool {
    return false;
}
thread 34584 panic: integer overflow
D:\git\zig\lib\std\Progress.zig:212:66: 0x7ff684d0221a in std.Progress.refreshWithHeldLock (zig.o)
const fill_chars = @intCast(windows.DWORD, info.dwSize.X * (info.dwSize.Y - info.dwCursorPosition.Y) - info.dwCursorPosition.X);
^
D:\git\zig\lib\std\Progress.zig:174:36: 0x7ff684c96dd1 in std.Progress.maybeRefresh (zig.o)
return self.refreshWithHeldLock();
^
D:\git\zig\lib\std\Progress.zig:100:34: 0x7ff684c969ba in std.Progress.Node::std.Progress.Node.end (zig.o)
self.context.maybeRefresh();
^
info is CONSOLE_SCREEN_BUFFER_INFO{ .dwSize = COORD{ .X = 192, .Y = 9001 }, .dwCursorPosition = COORD{ .X = 0, .Y = 182 }, .wAttributes = 7, .srWindow = SMALL_RECT{ .Left = 0, .Top = 153, .Right = 191, .Bottom = 182 }, .dwMaximumWindowSize = COORD{ .X = 192, .Y = 86 } }
thread 3700 panic: integer overflow
D:\git\zig2\lib\std\Progress.zig:213:66: 0x7ff7f404fc14 in Progress.refreshWithHeldLock (test.obj)
const fill_chars = @intCast(windows.DWORD, info.dwSize.X * (info.dwSize.Y - info.dwCursorPosition.Y) - info.dwCursorPosition.X);
^
D:\git\zig2\lib\std\Progress.zig:182:36: 0x7ff7f403d160 in Progress.refresh (test.obj)
return self.refreshWithHeldLock();
^
D:\git\zig2\lib\std\special\test_runner.zig:49:25: 0x7ff7f401d2b4 in std.special.main (test.obj)
progress.refresh();
@marler8997
marler8997 / gist:5a010dadbaeff2f6b83affb85277975d
Created March 11, 2021 23:00
wonky windows terminal output for LemonBoy
D:\git\zig2>.\zig-cache\bin\zig.exe build test-std -Dskip-release -Dskip-non-native
Test [1/1266] test "std-native-Debug-bare-multi "... Test [2/1266] builtin.test "std-native-Debug-bare-multi Version.parse"... Test [3/1266] target.test "std-native-Debug-bare-multi "... Test [4/1266] os.test "std-native-Debug-bare-multi "... Test [5/1266] math.test "std-native-Debug-bare-multi approxEqAbs and approxEqRel"... Test [6/1266] math.test "std-native-Debug-bare-multi "... Test [7/1266] math.test "std-native-Debug-bare-multi math.min"... Test [8/1266] math.test "std-native-Debug-bare-multi math.max"... Test [9/1266] math.test "std-native-Debug-bare-multi math.clamp"... Test [10/1266] math.test "std-native-Debug-bare-multi math.shl"... Test [11/1266] math.test "std-native-Debug-bare-multi math.shr"... Test [12/1266] math.test "std-native-Debug-bare-multi math.rotr"... Test [13/1266] math.test "std-native-Debug-bare-multi math.rotl"... Test [14/1266] math.test "std-native-Debug-bare-multi math.IntFittingRange"... Test
@marler8997
marler8997 / compileLogs
Last active March 17, 2021 19:23
Infinite semantic analysis loop
| *"formatType @TypeOf(value)=", StringTree, *" fmt=", "{any}"
| *"formatType @TypeOf(value)=", []const u8, *" fmt=", "any"
| *"formatType @TypeOf(value)=", []StringTree, *" fmt=", any
| *"formatType @TypeOf(value)=", u64, *" fmt=", d
| *"formatType @TypeOf(value)=", []const u8, *" fmt=", s
| *"formatType @TypeOf(value)=", u8, *" fmt=", any
| *"formatType @TypeOf(value)=", StringTree, *" fmt=", any
| *"formatType @TypeOf(value)=", []const u8, *" fmt=", s
| *"formatType @TypeOf(value)=", []const u8, *" fmt=", s
| *"formatType @TypeOf(value)=", []const u8, *" fmt=", any