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"); | |
/// The linker here is "preloaded" with all input object files / symbols. | |
/// After this function is run, the linker will resolve all symbol references | |
/// and print all unassigned symbols (\u2192 error) | |
pub fn link(l: *std.link.Linker) !void { | |
// Creates a new output section that will be loaded into the | |
// same address as its virtual address. It's also a (rx!w) section | |
const dot_text = l.createOutputSection(".text", .{ |
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
#!/bin/bash | |
TARGET="///INVALID///" | |
function die() | |
{ | |
if [ ! -z "${TARGET}" ]; then | |
rm -rf "${TARGET}" | |
fi | |
echo "$@" |
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"); | |
test "forwarding a value" { | |
const result = forth("value", .{ | |
.value = @as(u32, 42), | |
}); | |
std.testing.expectEqual(@as(u32, 42), result); | |
} |
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 WriterSpec = struct { | |
pub const write = fn(self: *@This(), msg: []const u8) error{IoError}!void; | |
pub const flush = fn(self: @This()) void; | |
}; | |
const Writer = Interface(WriterSpec); |
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"); | |
pub fn main() void { | |
std.log.info("mutable closure:",.{}); | |
runMutDemo(); | |
std.log.info("const closure:",.{}); | |
runConstDemo(); | |
} |
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"); | |
// usage: | |
fn asyncMain() !void { | |
// Start two interleaving tasks | |
var task_a = async waitUntilAndPrint(start + 1000, start + 1200, "task a"); | |
var task_b = async waitUntilAndPrint(start + 500, start + 1300, "task b"); | |
var task_c = async waitUntilAndPrint(start + 800, start + 1100, "task c"); | |
await task_a; |
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"); | |
// debug switch to print all found anagrams | |
const print_all_results = false; | |
pub fn main() !void { | |
// arena for fast allocations | |
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); | |
defer arena.deinit(); |
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
pub fn main() !void { | |
SysTick.init(1_000); | |
EventLoop.init(); | |
var serial_frame = async doSerialLoop(); | |
var blinky_frame = async doBlinkyLoop(); | |
EventLoop.run(); |
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 pkgs = struct { | |
const sdl2 = std.build.Pkg{ | |
.name = "sdl2", | |
.path = "./lib/SDL.zig/src/lib.zig", | |
}; | |
const zlm = std.build.Pkg{ | |
.name = "zlm", |
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
#include <GL/glx.h> | |
#include <unistd.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#include <X11/X.h> | |
#include <X11/Xlib.h> | |
#include <dlfcn.h> | |
#include <signal.h> |