code
stringlengths
38
801k
repo_path
stringlengths
6
263
const std = @import("std"); const Allocator = std.mem.Allocator; const Writer = std.io.Writer; const GPA = std.heap.GeneralPurposeAllocator(.{}); const art = @embedFile("../art.txt"); const Days = @import("days.zig").Days; const days: usize = std.meta.declarations(Days).len; pub fn main() !void { var ...
src/bench.zig
const std = @import("std"); const print = std.debug.print; const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; const helpers = @import("./helpers.zig"); const Definitions = @import("./definitions.zig"); const Error = Definitions.Error; const FieldInfo = @import("./result.zig").FieldInfo; pub const ...
src/sql_builder.zig
const std = @import("std"); const renderkit = @import("renderkit"); const gk = @import("../gamekit.zig"); const math = gk.math; const Vertex = gk.gfx.Vertex; const DynamicMesh = gk.gfx.DynamicMesh; pub const TriangleBatcher = struct { mesh: DynamicMesh(void, Vertex), draw_calls: std.ArrayList(i32), white_...
gamekit/graphics/triangle_batcher.zig
const std = @import("std"); const crypto = std.crypto; const debug = std.debug; const mem = std.mem; const meta = std.meta; const ArrayList = std.ArrayList; const FixedBufferAllocator = std.heap.FixedBufferAllocator; const BoundedArray = std.BoundedArray; const hpke_version = [7]u8{ 'H', 'P', 'K', 'E', '-', 'v', '1' }...
src/main.zig
const std = @import("std"); const array = @import("array.zig"); const Array = array.Array; const module = @import("module.zig"); pub const SGD = struct { parameters: []module.Parameter, momentums: []Array, momentum: f32, alc: *std.mem.Allocator, const Self = @This(); pub fn ini...
src/optim.zig
const std = @import("std"); usingnamespace (@import("../machine.zig")); usingnamespace (@import("../util.zig")); test "SSE" { const m32 = Machine.init(.x86_32); const m64 = Machine.init(.x64); const reg = Operand.register; const regRm = Operand.registerRm; const imm = Operand.immediate; debug...
src/x86/tests/sse.zig
const std = @import("std"); const mem = std.mem; const testing = std.testing; const expectEqual = @import("testutil.zig").expectEqual; // Note: Often, C return is non-const, but const is here to satisfy Zig. export fn strchr(str: [*:0]const u8, ch: c_int) ?*const u8 { const span = mem.span(str); for (span) ...
src/libc/string.zig
const std = @import("std"); const Cigar = @import("cigar.zig").Cigar; pub const HSP = struct { const Self = @This(); start_one: usize, end_one: usize, start_two: usize, end_two: usize, pub fn length(self: Self) usize { return std.math.max(self.end_one - self.start_one, self.end_two ...
src/hsp.zig
const std = @import("std"); const upaya = @import("upaya"); const parser = @import("parser.zig"); const my_fonts = @import("myscalingfonts.zig"); usingnamespace upaya.imgui; // . // Animation // . pub const frame_dt: f32 = 0.016; // roughly 16ms per frame pub const ButtonState = enum { none = 0, hovered, ...
src/uianim.zig
const std = @import("std"); const VTE = @import("vte"); const c = VTE.c; const gtk = VTE.gtk; const config = @import("config.zig"); const gui = @import("gui.zig"); const RGB = config.RGB; const allocator = std.heap.page_allocator; const fmt = std.fmt; const math = std.math; const mem = std.mem; var grad: ?Gradient = u...
src/gradient.zig
const Builder = @import("std").build.Builder; pub fn build(b: *Builder) void { // Standard target options allows the person running `zig build` to choose // what target to build for. Here we do not override the defaults, which // means any target is allowed, and the default is native. Other options // ...
build.zig
const std = @import("std"); const fs = std.fs; const json = std.json; const assert = std.debug.assert; const Record = struct { timestamp: u64, benchmark_name: []const u8, commit_hash: [20]u8, commit_timestamp: u64, zig_version: []const u8, error_message: []const u8 = &[0]u8{}, samples_taken...
collect-measurements.zig
const std = @import("std"); const GeneralPurposeAllocator = std.heap.GeneralPurposeAllocator; const mustache = @import("mustache"); // Mustache template const template_text = \\{{! This is a spec-compliant mustache template }} \\Hello {{name}} from Zig \\This template was generated with \\{{#env}} ...
samples/src/main.zig
const std = @import("../std.zig"); const math = std.math; const expect = std.testing.expect; const kernel = @import("__trig.zig"); const __rem_pio2 = @import("__rem_pio2.zig").__rem_pio2; const __rem_pio2f = @import("__rem_pio2f.zig").__rem_pio2f; /// Returns the cosine of the radian value x. /// /// Special Cases: ...
lib/std/math/cos.zig
const std = @import("std"); const builtin = @import("builtin"); const assert = std.debug.assert; const Sha256 = std.crypto.hash.sha2.Sha256; const zephyr = @import("zephyr.zig"); const image = @import("image.zig"); const tlv = @import("tlv.zig"); const Image = image.Image; const flashTest = @import("testing.zig").fla...
main.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const gui = @import("gui"); const nvg = @import("nanovg"); const geometry = @import("gui/geometry.zig"); const Point = geometry.Point; const Rect = geometry.Rect; const EditorWidget = @import("EditorWidget.zig"); const NewDocumentWidget = @This(); wid...
src/NewDocumentWidget.zig
const std = @import("std"); const panic = std.debug.panic; const Allocator = std.mem.Allocator; usingnamespace @import("backend.zig"); const List = std.ArrayList(Node); const Object = std.StringHashMap(Node); const String = []const u8; const ScalarType = enum { String, Integer, Float, Bool, }; cons...
src/yaml.zig
const std = @import("std"); const helper = @import("helper.zig"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const HashMap = std.AutoHashMap; const input = @embedFile("../inputs/day22.txt"); pub fn run(alloc: Allocator, stdout_: anytype) !void { var entries = ArrayList(Cuboid).init(allo...
src/day22.zig
const std = @import("std"); const root = @import("main.zig"); const meta = std.meta; const generic_vector = @import("generic_vector.zig"); const mat4 = @import("mat4.zig"); const math = std.math; const eps_value = math.floatEps(f32); const expectApproxEqAbs = std.testing.expectApproxEqAbs; const expectApproxEqRel = std...
src/quaternion.zig
const std = @import("std"); const hm = std.array_hash_map; const fs = std.fs; const BagFitIn = struct { name: []const u8, times: i32 = 0, }; const BagContains = struct { name: [] const u8, times: i32 = 0 }; const Bag = struct { in: [16]BagFitIn, contains: [16] BagContains, in_count: usize...
2020/src/day_07.zig
const std = @import("std"); const sdl = @import("sdl"); const samples_for_avg = 5; pub const Time = struct { fps_frames: u32 = 0, prev_time: u32 = 0, curr_time: u32 = 0, fps_last_update: u32 = 0, frames_per_seconds: u32 = 0, frame_count: u32 = 1, timestep: Timestep = undefined, pub fn...
gamekit/time.zig
const std = @import("std"); const ig = @import("imgui"); const zt = @import("../zt.zig"); const math = zt.math; /// Sets imgui style to be compact, does not affect colors. Recommended to follow this up /// with your own custom colors, or one from this file `styleColor*()` pub fn styleSizeCompact() void { var style...
src/zt/styler.zig
const aoc = @import("../aoc.zig"); const std = @import("std"); const Allocator = std.mem.Allocator; const VACANT: u8 = 'L'; const OCCUPIED: u8 = '#'; const FLOOR: u8 = '.'; const SeatIterator = struct { allocator: Allocator, seats: []u8, follow_blanks: bool, width: usize, height: usize, row: i...
src/main/zig/2020/day11.zig
const std = @import("../../std.zig"); const builtin = @import("builtin"); const assert = std.debug.assert; const mem = std.mem; const net = std.net; const os = std.os; const linux = os.linux; const testing = std.testing; const Socket = std.x.os.Socket; const io_uring_params = linux.io_uring_params; const io_uring_sqe...
src/io_uring-tcp-hasher/ring.zig
const sboxes = @import("sboxes.zig"); pub const InvalidKeySizeError = error{InvalidKeySizeError}; pub const Blowfish = struct { p: [18]u32 = sboxes.P, s: [4][256]u32 = sboxes.S, const Pair = packed struct { l: u32, r: u32 }; pub fn init(key: []const u8) InvalidKeySizeError!Blowfish { if (key...
src/lib.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const _p = std.fs.path; fn PackedSlice (comptime T: type, constant: bool) type { const Type = if (constant) [*]const T else [*] T; return packed struct { ptr: Type, len: usize, const Self = @This(); pub fn init(...
autopkg.zig
usingnamespace @import("zig-pdcurses.zig"); pub const code_yes = c.KEY_CODE_YES; pub const key_break = c.KEY_BREAK; pub const down = c.KEY_DOWN; pub const up = c.KEY_UP; pub const left = c.KEY_LEFT; pub const right = c.KEY_RIGHT; pub const home = c.KEY_HOME; pub const backspace = c.KEY_BACKSPACE; pub const f0 = c.KEY_...
src/keys.zig
const std = @import("std"); const log = std.log; const tokenizer = @import("tokenizer.zig"); const TokenKind = tokenizer.TokenKind; const Language = @import("code_chunks.zig").Language; const builtin = @import("builtin.zig"); const DFS = @import("utils.zig").DepthFirstIterator; const expect = std.testing.expect; /...
src/ast.zig
const std = @import("std"); const tools = @import("tools"); const with_trace = false; const assert = std.debug.assert; fn trace(comptime fmt: []const u8, args: anytype) void { if (with_trace) std.debug.print(fmt, args); } pub fn run(input: []const u8, allocator: std.mem.Allocator) ![2][]const u8 { const Laye...
2019/day08.zig
const builtin = @import("builtin"); const utils = @import("utils"); const platform = @import("platform.zig"); const vbe = @import("vbe.zig"); const kernel = @import("root").kernel; const print = kernel.print; const Range = kernel.memory.Range; export var multiboot_info: []u32 = undefined; const Error = error { ...
kernel/platform/multiboot.zig
const std = @import("std"); const TestContext = @import("../../src/test.zig").TestContext; pub fn addCases(ctx: *TestContext) !void { { var case = addPtx(ctx, "nvptx: simple addition and subtraction"); case.compiles( \\fn add(a: i32, b: i32) i32 { \\ return a + b; ...
test/stage2/nvptx.zig
const std = @import("std"); const bits = @import("bits.zig"); const mem = std.mem; const fmt = std.fmt; const debug = std.debug; const io = std.io; const assert = debug.assert; // TODO: Missing a few convinient features // * Short arguments that doesn't take values should probably be able to be // chain li...
src/clap.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const expectEqual = std.testing.expectEqual; const expectEqualSlices = std.testing.expectEqualSlices; const base_pattern = [_]isize{ 0, 1, 0, -1 }; fn getPattern(output_pos: usize, pos: usize) isize { const real_pos ...
zig/16.zig
const std = @import("std"); const Entity = @import("./Entity.zig"); const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; const Bitset = std.bit_set.StaticBitSet(MAX_ENTITIES); const expect = std.testing.expect; const benchmark = @import("benchmark"); const Entities = @This(); const MAX_ENTITIES = @i...
src/Entities.zig
const arduino = @import("arduino"); const gpio = arduino.gpio; // Necessary, and has the side effect of pulling in the needed _start method pub const panic = arduino.start.panicLogUart; // display 4 digits // using a kyx-3942bg and a 74hc595 shift register // pins: // 74hc595 pins in: const SHIFTREG_DS = 11; // dat...
examples/7seg_display.zig
usingnamespace @import("root").preamble; const rb = lib.containers.rbtree; const platform = os.platform; const PagingContext = platform.paging.PagingContext; const rb_features: rb.Features = .{ .enable_iterators_cache = true, .enable_kth_queries = false, .enable_not_associatve_augment = false, }; const a...
subprojects/flork/src/kernel/process/address_space.zig
const std = @import("std"); const s2s = @import("s2s"); const logger = std.log.scoped(.antiphony_rpc); /// The role of an EndPoint. `host` and `client` are arbitrary names that define both ends. /// The `host` role usually calls `EndPoint.acceptCalls()` and waits for incoming calls. pub const Role = enum { host, clien...
src/antiphony.zig
const std = @import("std"); const assert = std.debug.assert; pub usingnamespace @import("bits.zig"); comptime { assert(@alignOf(i8) == 1); assert(@alignOf(u8) == 1); assert(@alignOf(i16) == 2); assert(@alignOf(u16) == 2); assert(@alignOf(i32) == 4); assert(@alignOf(u32) == 4); // assert(@a...
lib/std/os/wasi.zig
const std = @import("std"); const arm_m = @import("arm_m"); const timer = @import("ports/" ++ @import("build_options").BOARD ++ "/timer.zig").timer0; const tzmcfi = @cImport(@cInclude("TZmCFI/Gateway.h")); const warn = @import("nonsecure-common/debug.zig").warn; const port = @import("ports/" ++ @import("build_options")...
examples/nonsecure-profile-rtos.zig
const format = @import("std").fmt.format; const OutStream = @import("std").io.OutStream; const arm_m = @import("arm_m"); const arm_cmse = @import("arm_cmse"); const an505 = @import("../../drivers/an505.zig"); pub const VTOR_NS = 0x00200000; extern var __nsc_start: usize; extern var __nsc_end: usize; /// Perform the ...
examples/ports/an505/secure.zig
const std = @import("../../std.zig"); const iovec = std.os.iovec; const iovec_const = std.os.iovec_const; const linux = std.os.linux; const SYS = linux.SYS; const uid_t = std.os.linux.uid_t; const gid_t = std.os.linux.gid_t; const pid_t = std.os.linux.pid_t; const sockaddr = linux.sockaddr; const socklen_t = linux.sock...
lib/std/os/linux/riscv64.zig
const std = @import("std"); const net = std.net; const Allocator = std.mem.Allocator; /// HTTP Status codes according to `rfc7231` /// https://tools.ietf.org/html/rfc7231#section-6 pub const StatusCode = enum(u16) { // Informational 1xx @"continue" = 100, // Successful 2xx switching_protocols = 101, ...
src/response.zig
const std = @import("std"); pub const pkg = std.build.Pkg{ .name = "zenet", .path = .{ .path = thisDir() ++ "/src/zenet.zig" }, }; pub fn build(b: *std.build.Builder) void { const build_mode = b.standardReleaseOptions(); const target = b.standardTargetOptions(.{}); const tests = buildTests(b, buil...
libs/zenet/build.zig
const std = @import("std"); const helper = @import("helper.zig"); const Allocator = std.mem.Allocator; const HashMap = std.AutoHashMap; const input = @embedFile("../inputs/day23.txt"); pub fn run(alloc: Allocator, stdout_: anytype) !void { const start2: State(2) = State(2).parse(input); const res1 = try findD...
src/day23.zig
const std = @import("std"); const fs = std.fs; pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = &gpa.allocator; const input = try fs.cwd().readFileAlloc(allocator, "data/input_04_1.txt", std.math.maxInt(usize)); { // Solution 1 var lines = std.mem.tok...
2020/src/day_04.zig
const builtin = @import("builtin"); const std = @import("std"); const math = std.math; // mulo - multiplication overflow // * return a*%b. // * return if a*b overflows => 1 else => 0 // - muloXi4_genericSmall as default // - muloXi4_genericFast for 2*bitsize <= usize inline fn muloXi4_genericSmall(comptime ST: type, ...
lib/std/special/compiler_rt/mulo.zig
const GBA = @import("gba").GBA; const Input = @import("gba").Input; const LCD = @import("gba").LCD; const Background = @import("gba").Background; export var gameHeader linksection(".gbaheader") = GBA.Header.setup("SCREENBLOCK", "ASBE", "00", 0); const CrossTX = 15; const CrossTY = 10; fn screenIndex(tx: u32, ty: u32...
examples/screenBlock/screenBlock.zig
const builtin = @import("builtin"); const std = @import("std"); const Builder = @import("std").build.Builder; // Mostly based on <https://github.com/andrewrk/clashos/blob/master/build.zig> pub fn build(b: *Builder) !void { const mode = b.standardReleaseOptions(); const want_gdb = b.option(bool, "gdb", "Build ...
build.zig
const std = @import("std"); const expect = std.testing.expect; const assert = std.debug.assert; ///References: https://en.wikipedia.org/wiki/Merge_sort ///A is the array to be sorted and B is extra storage required by merge sort. ///Responsibility for initialization of B is left to the calling side pub fn sort(A: []i3...
sorting/merge_sort.zig
pub const va_list = __builtin_va_list; pub const __gnuc_va_list = __builtin_va_list; pub const ptrdiff_t = c_long; pub const wchar_t = c_int; const struct_unnamed_1 = extern struct { __clang_max_align_nonce1: c_longlong, __clang_max_align_nonce2: c_longdouble, }; pub const max_align_t = struct_unnamed_1; pub co...
c_leveldb.zig
const std = @import("std"); const time = std.time; const math = std.math; const memory = @import("memory.zig"); const pressure = @import("pressure.zig"); const process = @import("process.zig"); const config = @import("config.zig"); const MemoryStatusTag = enum { ok, near_terminal, }; const MemoryStatus = uni...
src/monitor.zig
const std = @import("std"); const tvg = @import("tinyvg.zig"); pub fn create(writer: anytype) Builder(@TypeOf(writer)) { return .{ .writer = writer }; } // normal types: // style.type // uint(length - 1) // style // (line_width) // // outline types: // fill_style.type // line_style.type // // uint(...
src/lib/builder.zig
//! PCG32 - http://www.pcg-random.org/ //! //! PRNG const std = @import("std"); const Random = std.rand.Random; const Pcg = @This(); const default_multiplier = 6364136223846793005; random: Random, s: u64, i: u64, pub fn init(init_s: u64) Pcg { var pcg = Pcg{ .random = Random{ .fillFn = fill }, ...
lib/std/rand/Pcg.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const List = std.ArrayList; const Map = std.AutoHashMap; const StrMap = std.StringHashMap; const BitSet = std.DynamicBitSet; const Str = []const u8; const util = @import("util.zig"); const gpa = util.gpa; const data = @embedFile("../data/day02.txt"); c...
src/day02.zig
const std = @import("std"); const ArenaAllocator = std.heap.ArenaAllocator; const xml = @import("lib.zig"); const Writer = @This(); const logger = std.log.scoped(.@"xml.Writer"); usingnamespace @import("traverser.zig").StructTraverser(Writer); arena: ArenaAllocator, doc: xml.Document = undefined, pub fn init(allocat...
src/writer.zig
const std = @import("std"); const mem = std.mem; const math = std.math; const meta = std.meta; const trait = std.meta.trait; pub fn typed(comptime val_t: type) type { return struct { pub const func = @import("fn_deriv.zig"); pub const Float = val_t; // const LayerType = enum { // ...
src/nnet.zig
const ArgvIterator = @This(); const std = @import("std"); const mem = std.mem; const testing = std.testing; pub const RawArg = struct { name: []const u8, pub fn init(name: []const u8) RawArg { return RawArg{ .name = name }; } pub fn isShort(self: *RawArg) bool { return ...
src/ArgvIterator.zig
const std = @import("std"); const testing = std.testing; const allocator = std.heap.page_allocator; pub const Map = struct { const Color = enum { White, Black, pub fn flip(color: Color) Color { return switch (color) { Color.White => Color.Black, ...
2020/p24/map.zig
const std = @import("std"); const with_trace = true; const assert = std.debug.assert; fn trace(comptime fmt: []const u8, args: anytype) void { if (with_trace) std.debug.print(fmt, args); } pub fn main() anyerror!void { const stdout = std.io.getStdOut().writer(); var arena = std.heap.ArenaAllocator.init(...
2016/day7.zig
const std = @import("std"); const expect = std.testing.expect; pub const Value = union(enum) { int: i64, uint: u64, nil, bool: bool, float: f64, string: []const u8, binary: []const u8, array: std.ArrayList(Value), map: std.StringHashMap(Value), pub fn fromInt(val: i64) Value { ...
src/value.zig
const std = @import("std"); const tvg = @import("tvg"); const args = @import("args"); pub fn main() !u8 { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = &arena.allocator; const cli = args.parseForCurrentProcess(CliOptions, allocator) catch r...
src/tools/render.zig
const x86_64 = @import("../../../index.zig"); const bitjuggle = @import("bitjuggle"); const std = @import("std"); const paging = x86_64.structures.paging; const mapping = paging.mapping; const Mapper = mapping.Mapper; /// A recursive page table is a last level page table with an entry mapped to the table itself. /// ...
src/structures/paging/mapping/recursive_page_table.zig
const common = @import("../common.zig"); pub const StarterLocation = union(enum) { arm9: usize, overlay9: Overlay, pub const Overlay = struct { offset: usize, file: usize, }; }; pub const Info = struct { game_title: [11:0]u8, gamecode: [4]u8, version: common.Version, a...
src/core/gen4/offsets.zig
const std = @import("std"); const assert = std.debug.assert; const mem = std.mem; const parser = @import("parser.zig"); const tokenizer = @import("tokenizer.zig"); const Allocator = mem.Allocator; const Token = tokenizer.Token; const ParseNode = parser.Node; const ParseScope = parser.Scope; const ErrorMsg = struct { ...
src/generator.zig
const c = @cImport({ @cInclude("cfl_browser.h"); }); const widget = @import("widget.zig"); const valuator = @import("valuator.zig"); const enums = @import("enums.zig"); pub const Browser = struct { inner: ?*c.Fl_Browser, pub fn new(x: i32, y: i32, w: i32, h: i32, title: [*c]const u8) Browser { cons...
src/browser.zig
const std = @import("std"); const epsilonEq = @import("utils.zig").epsilonEq; pub fn initPoint(x: f64, y: f64, z: f64) Vec4 { return Vec4.init(x, y, z, 1.0); } pub fn initVector(x: f64, y: f64, z: f64) Vec4 { return Vec4.init(x, y, z, 0.0); } pub fn isPoint(vec: Vec4) bool { return epsilonEq(vec.w, 1.0);...
vector.zig
const std = @import("std"); const print = std.debug.print; usingnamespace @import("value.zig"); usingnamespace @import("chunk.zig"); usingnamespace @import("scanner.zig"); usingnamespace @import("compiler.zig"); usingnamespace @import("heap.zig"); pub var parser: Parser = undefined; // Lox’s precedence levels in ord...
zvm/src/parser.zig
const std = @import("std"); // this delay module is not able to handle changes in sample rate, or changes // in the delay time, so it's not quite ready for prime time. i need to figure // out how to deal with reallocating(?) the delay buffer when the sample rate // or delay time changes. pub fn Delay(comptime delay_sa...
src/zang/delay.zig
const std = @import("std"); const util = @import("util.zig"); fn abs(n: i32) i32 { if (n < 0) { return -n; } else { return n; } } pub fn part1(input: []const u8) !u64 { var positions = std.ArrayList(i32).init(std.heap.page_allocator); defer positions.deinit(); var numbers = st...
zig/src/day7.zig
const std = @import("std"); const indexOf = std.mem.indexOf; const indexOfScalar = std.mem.indexOfScalar; const tokenize = std.mem.tokenize; const SEP = " | "; pub fn main() !void { const file = try std.fs.cwd().openFile("../inputs/08.txt", .{}); defer file.close(); const reader = file.reader(); var ...
2021/zig/08.zig
const std = @import("std"); const Answer = struct { @"0": u32, @"1": u32 }; const V2 = [2]i32; const LineSeg = [2]V2; fn sign(x: i32) i32 { if (x > 0) { return 1; } else if (x < 0) { return -1; } else { return 0; } } // Direction of v from u fn dirV2(u: V2, v: V2) V2 { retu...
src/day05.zig
const std = @import("std"); const Mmu = @import("mmu.zig").Mmu; const assert = std.debug.assert; // 4.194304Mhz pub const clock_speed = 4194304; pub const FlagZ: u8 = 0x80; pub const FlagS: u8 = 0x40; pub const FlagH: u8 = 0x20; pub const FlagC: u8 = 0x10; pub const A = 0; pub const F = 1; pub const B = 2; pub const...
src/cpu.zig
const std = @import("std"); const c = @import("c.zig"); const helpers = @import("helpers.zig"); const varint = @import("varint.zig"); const constants = @import("constants.zig"); fn getType(env: c.napi_env, value: c.napi_value) u8 { if (helpers.isTypeof(env, value, c.napi_valuetype.napi_string)) return constants.ST...
src/encode.zig
const std = @import("std"); const bitjuggle = @import("bitjuggle"); const PrivilegeLevel = @import("types.zig").PrivilegeLevel; const IntegerRegister = @import("types.zig").IntegerRegister; const ExceptionCode = @import("types.zig").ExceptionCode; const ContextStatus = @import("types.zig").ContextStatus; const VectorMo...
lib/instruction.zig
const std = @import("std"); const Pkg = std.build.Pkg; const string = []const u8; pub const cache = ".zigmod/deps"; pub fn addAllTo(exe: *std.build.LibExeObjStep) void { @setEvalBranchQuota(1_000_000); for (packages) |pkg| { exe.addPackage(pkg.pkg.?); } inline for (std.meta.declarations(packag...
deps.zig
const std = @import("std"); const ast = std.zig.ast; const util = @import("utils.zig"); var tree: ast.Tree = undefined; const Md = struct { fields: std.ArrayList(AnalysedDecl), types: std.ArrayList(AnalysedDecl), funcs: std.ArrayList(AnalysedDecl), values: std.ArrayList(AnalysedDecl), pub fn in...
src/main.zig
const std = @import("std"); const stdx = @import("stdx"); const Vec2 = stdx.math.Vec2; const ui = @import("ui.zig"); const Layout = ui.Layout; const RenderContext = ui.RenderContext; const FrameId = ui.FrameId; /// Id can be an enum literal that is given a unique id at comptime. pub const WidgetUserId = usize; pub c...
ui/src/widget.zig
const std = @import("std"); const ir = @import("ir.zig"); const trace = @import("tracy.zig").trace; /// Perform Liveness Analysis over the `Body`. Each `Inst` will have its `deaths` field populated. pub fn analyze( /// Used for temporary storage during the analysis. gpa: *std.mem.Allocator, /// Used to tac...
src/liveness.zig
const std = @import("std"); const mem = std.mem; const Allocator = std.mem.Allocator; const fs = std.fs; const log = std.log.scoped(.link); const assert = std.debug.assert; const Compilation = @import("Compilation.zig"); const Module = @import("Module.zig"); const trace = @import("tracy.zig").trace; const Package = @i...
src/link.zig
const std = @import("std"); const builtin = @import("builtin"); const native_endian = builtin.target.cpu.arch.endian(); const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const expectEqualSlices = std.testing.expectEqualSlices; const maxInt = std.math.maxInt; top_level_field: i32, test "t...
test/behavior/struct.zig
const std = @import("std"); const mem = std.mem; const assert = std.debug.assert; const print = std.debug.print; const util = @import("utils.zig"); const input = @embedFile("../in/day01.txt"); /// Strategy: /// Store expenses in a hash set and query the set for existence of a complement /// fulfilling the sum. /// ...
src/day01.zig
const std = @import("std"); const builtin = @import("builtin"); const blake2 = crypto.hash.blake2; const crypto = std.crypto; const math = std.math; const mem = std.mem; const phc_format = pwhash.phc_format; const pwhash = crypto.pwhash; const Thread = std.Thread; const Blake2b512 = blake2.Blake2b512; const Blocks =...
lib/std/crypto/argon2.zig
const std = @import("../std.zig"); const io = std.io; const mem = std.mem; const testing = std.testing; /// Creates a stream which supports 'un-reading' data, so that it can be read again. /// This makes look-ahead style parsing much easier. /// TODO merge this with `std.io.BufferedReader`: https://github.com/ziglang/...
lib/std/io/peek_stream.zig
const std = @import("std"); const sabaton = @import("root").sabaton; const LoadType = enum { MakePageTables, LoadDataPages, }; const addr = u64; const off = u64; const half = u16; const word = u32; const xword = u64; pub const elf64hdr = packed struct { ident: [16]u8, elf_type: half, machine: half, versi...
src/lib/elf.zig
const std = @import("std"); const math = std.math; const mem = std.mem; const fmt = std.fmt; const Allocator = std.mem.Allocator; const ArenaAllocator = std.heap.ArenaAllocator; const ArrayList = std.ArrayList; const debug = std.debug; const range_set = @import("range_set.zig"); const ByteClassTemplates = range_set.By...
src/parse.zig
const std = @import("std"); /// Super simple "perfect hash" algorithm /// Only really useful for switching on strings // TODO: can we auto detect and promote the underlying type? pub fn Swhash(comptime max_bytes: comptime_int) type { const T = std.meta.Int(.unsigned, max_bytes * 8); return struct { pu...
src/util.zig
const main = @import("main.zig"); const vectors = @import("vectors.zig"); const uart = @import("uart.zig"); pub export fn _start() callconv(.Naked) noreturn { // At startup the stack pointer is at the end of RAM // so, no need to set it manually! // Reference this such that the file is analyzed and the ve...
src/start.zig
const std = @import("std"); pub fn Pkg(srcdir: []const u8) type { return struct { pub fn addRaylib(b: *std.build.Builder, target: std.zig.CrossTarget) *std.build.LibExeObjStep { // Standard release options allow the person running `zig build` to select // between Debug, Releas...
src/build.zig
pub const GPM_USE_PDC = @as(u32, 0); pub const GPM_USE_ANYDC = @as(u32, 1); pub const GPM_DONOTUSE_W2KDC = @as(u32, 2); pub const GPM_DONOT_VALIDATEDC = @as(u32, 1); pub const GPM_MIGRATIONTABLE_ONLY = @as(u32, 1); pub const GPM_PROCESS_SECURITY = @as(u32, 2); pub const RSOP_NO_COMPUTER = @as(u32, 65536); pub const RSO...
win32/system/group_policy.zig
const std = @import("std"); const utility = @import("utility.zig"); // Import modules to reduce file size // usingnamespace @import("value.zig"); /// A compiled piece of code, provides the building blocks for /// an environment. Note that a compile unit must be instantiated /// into an environment to be executed. pu...
src/library/common/CompileUnit.zig
const std = @import("std"); usingnamespace @import("common.zig"); usingnamespace @import("job.zig"); usingnamespace @import("location.zig"); usingnamespace @import("lexer.zig"); usingnamespace @import("ast.zig"); usingnamespace @import("parser.zig"); usingnamespace @import("error_handler.zig"); usingnamespace...
src/type_checker.zig
const std = @import("std"); /// Frame timing values. pub const Time = struct { /// Time elapsed since the last frame. delta_time: u64 = 0, /// Time elapsed since the last frame ignoring the time speed multiplier. delta_real_time: u64 = 0, /// Rate at which `State::fixed_update` is called. fixe...
src/time.zig
const std = @import("std"); usingnamespace @import("imgui"); const upaya = @import("upaya"); const ts = @import("../tilescript.zig"); const colors = @import("../colors.zig"); const processor = @import("../rule_processor.zig"); const object_editor = @import("object_editor.zig"); var dragged_obj_index: ?usize = null; va...
tilescript/windows/output_map.zig
const std = @import("std"); const Builder = std.build.Builder; const builtin = @import("builtin"); pub fn build(b: *Builder) void { // Each tutorial stage, its source file, and description const targets = [_]Target{ .{ .name = "base_code", .src = "src/00_base_code.zig", .description = "Base Code" }, ...
build.zig
const std = @import("std"); const assert = std.debug.assert; const Allocator = std.mem.Allocator; const params = @import("params.zig"); const hblock = @import("hblock.zig"); const FreeSpanList = hblock.FreeSpanList(STMHeap); const FreeSpanLists = hblock.FreeSpanLists(STMHeap); const Hyperblock = hblock.Hyperblock(STM...
src/ziegfried/stmheap.zig
const std = @import("std"); const expect = std.testing.expect; const print = std.debug.print; const heap = std.heap; const Bitmap = @import("roaring.zig").Bitmap; const allocForFrozen = @import("roaring.zig").allocForFrozen; pub fn main() void { } test "create + free" { var b = try Bitmap.create(); b.free();...
src/test.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const print = std.debug.print; const data = @embedFile("../inputs/day16.txt"); pub fn main() anyerror!void { var gpa_impl = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa_impl.deinit(); const gpa = gpa_impl.allocator(); return m...
src/day16.zig
// Code lengths for fixed Huffman coding of litlen and dist symbols. pub const fixed_litlen_lengths: [288]u8 = print_fixed_litlen_lengths(); pub const fixed_dist_lengths: [32]u8 = [_]u8{5} ** 32; fn print_fixed_litlen_lengths() [288]u8 { var ret: [288]u8 = undefined; // RFC 1951, 3.2.6 for (ret) |_, i| {...
src/tables.zig
const pc_keyboard = @import("../../pc_keyboard.zig"); const us104 = @import("us104.zig"); pub fn mapKeycode(keycode: pc_keyboard.KeyCode, modifiers: pc_keyboard.Modifiers, handle_ctrl: pc_keyboard.HandleControl) pc_keyboard.DecodedKey { const map_to_unicode = handle_ctrl == .MapLettersToUnicode; switch (keyc...
src/keycode/layouts/dvorak104.zig
const std = @import("std"); const use_test_input = false; const filename = if (use_test_input) "day-3_test-input" else "day-3_real-input"; const sample_count = if (use_test_input) 12 else 1000; const sample_length = if (use_test_input) 5 else 12; pub fn main() !void { std.debug.print("--- Day 3 ---\n", .{}); ...
day-3.zig