code
stringlengths
38
801k
repo_path
stringlengths
6
263
const std = @import("std"); const TypeId = @import("builtin").TypeId; const assert = std.debug.assert; const time = std.time; const warn = std.debug.warn; const Timer = time.Timer; const BenchFn = fn (*Context) void; pub const Context = struct { timer: Timer, iter: u32, count: u32, state: State, ...
bench.zig
const std = @import("std"); const Wat = @import("../wat.zig"); const Instance = @import("../instance.zig"); test "i32 math" { var fbs = std.io.fixedBufferStream( \\(module \\ (func (result i32) \\ i32.const 40 \\ i32.const 2 \\ i32.add) \\ (func (result i...
src/func/basic.zig
const std = @import("std"); const Type = @import("../type.zig").Type; const Allocator = std.mem.Allocator; pub const Node = extern union { /// If the tag value is less than Tag.no_payload_count, then no pointer /// dereference is needed. tag_if_small_enough: usize, ptr_otherwise: *Payload, pub con...
src/translate_c/ast.zig
const uefi = @import("std").os.uefi; const Guid = uefi.Guid; const TableHeader = uefi.tables.TableHeader; const Time = uefi.Time; const TimeCapabilities = uefi.TimeCapabilities; const Status = uefi.Status; /// Runtime services are provided by the firmware before and after exitBootServices has been called. /// /// As t...
lib/std/os/uefi/tables/runtime_services.zig
const std = @import("std"); const lola = @import("lola"); //// // Serialization API example: // This example shows how to save a whole-program state into a buffer // and restore that later to continue execution. // // NOTE: This example is work-in-progress! const example_source = \\for(i in Range(1, 100)) { ...
examples/host/serialization/main.zig
const std = @import("std.zig"); const builtin = @import("builtin"); const debug = std.debug; const mem = std.mem; const testing = std.testing; pub const line_sep = switch (builtin.os.tag) { .windows => "\r\n", else => "\n", }; pub fn cmp(a: [*:0]const u8, b: [*:0]const u8) i8 { var index: usize = 0; w...
lib/std/cstr.zig
test "var args macro functions" { try expectStr( \\#define foo(a,...) #__VA_ARGS__ \\foo(1,2,3,4,5,6) \\ \\#define bar(a,...) bar __VA_ARGS__ \\#define baz(a,...) baz bar(__VA_ARGS__) \\baz(1,2,3,4) , "\"2 , 3 , 4 , 5 , 6\" baz bar 3 , 4\n"); } test "X macro" { ...
test/preprocessor.zig
const std = @import("std"); const assert = std.debug.assert; const allocator = std.testing.allocator; pub const Factory = struct { rules: std.StringHashMap(Rule), ore_produced: usize, const Rule = struct { needed: std.StringHashMap(usize), material: []u8, amount: usize, pu...
2019/p14/factory.zig
const std = @import("std"); const Builder = std.build.Builder; const raylib = @import("lib.zig").Pkg("."); const Program = struct { name: []const u8, path: []const u8, desc: []const u8, }; pub fn build(b: *Builder) void { const mode = b.standardReleaseOptions(); const target = b.standardTargetOpt...
build.zig
const std = @import("std"); const assert = std.debug.assert; const tools = @import("tools"); pub fn run(input: []const u8, allocator: std.mem.Allocator) ![2][]const u8 { const Bag = struct { count: u8, items: [24]struct { n: u16, col: u16 }, }; var colors = std.StringHashMap(u16).init(alloc...
2020/day07.zig
const std = @import("std"); const tools = @import("tools"); const with_trace = false; fn trace(comptime fmt: []const u8, args: anytype) void { if (with_trace) std.debug.print(fmt, args); } const assert = std.debug.assert; pub const main = tools.defaultMain("2021/day14.txt", run); pub fn run(input: []const u8, gp...
2021/day14.zig
const std = @import("std"); const rk = @import("renderkit"); const gk = @import("../gamekit.zig"); const math = gk.math; const IndexBuffer = rk.IndexBuffer; const VertexBuffer = rk.VertexBuffer; pub const MultiVertex = extern struct { pos: math.Vec2, uv: math.Vec2 = .{ .x = 0, .y = 0 }, col: u32 = 0xFFFFF...
gamekit/graphics/multi_batcher.zig
const std = @import("std"); // There's just 256 different input valus - just use a table. const srgb8_to_f32_tab = [256]u32{ 0x00000000, 0x399f22b4, 0x3a1f22b4, 0x3a6eb40f, 0x3a9f22b4, 0x3ac6eb61, 0x3aeeb40f, 0x3b0b3e5e, 0x3b1f22b4, 0x3b33070b, 0x3b46eb61, 0x3b5b518d, 0x3b70f18d, 0x3b83e1c6, 0x3b8fe616, 0x3b9c...
src/math.zig
const std = @import("std"); const assert = std.debug.assert; pub const ArrayError = error { OutOfBounds, }; pub fn Array(comptime T: type) type { return struct { const Self = @This(); arr: []T, allocator: *std.mem.Allocator, pub fn init(allocator: *std.mem.Allocator) Self {...
array.zig
const builtin = @import("builtin"); const std = @import("std"); const mem = std.mem; const assert = std.debug.assert; const warn = std.debug.warn; const gl = @import("modules/zig-sdl2/src/index.zig"); pub const EventResult = enum { NoEvents, Continue, Quit, }; pub const EventInterface = struct { event...
src/input_events.zig
const std = @import("std"); const io = std.io; const rpc = @import("jsonrpc2.zig"); const warn = std.debug.warn; const testing = std.testing; const Buffer = std.Buffer; const json = std.json; const mem = std.mem; const Dump = @import("../json/json.zig").Dump; test "Conn.readRequestData" { const src = "Content-Leng...
src/lsp/jsonrpc2/jsonrpc2_test.zig
// TODO: Right now, this allocator only handles small allocations (at most 256 // bytes or so, which are the most common case for many programs) and defers // all others to the child allocator. If the child allocator is // DirectAllocator, this will mean that medium-sized allocations (e.g. 1024 // bytes) are very ine...
src/ziegfried/index.zig
const std = @import("std"); const Value = @import("value.zig").Value; const Type = @import("type.zig").Type; const Module = @import("Module.zig"); /// These are in-memory, analyzed instructions. See `zir.Inst` for the representation /// of instructions that correspond to the ZIR text format. /// This struct owns the `...
src-self-hosted/ir.zig
const std = @import("std"); const font = @import("font.zig"); const arch = @import("../arch.zig"); const hw = @import("../hw.zig"); const paging = @import("../paging.zig"); pub const CONSOLE_DIMENSION = u16; var fb: ?[*]u32 = null; var fb_vert: u32 = undefined; var fb_horiz: u32 = undefined; pub var console_height: ...
dainkrnl/src/console/fb.zig
const std = @import("std"); const print = std.debug.print; const data = @embedFile("../data/day06.txt"); pub fn main() !void { var timer = try std.time.Timer.start(); var lanternfishes = [_]u64{0} ** 9; var iterator = std.mem.tokenize(data, ", \r\n"); while (iterator.next()) |lanternfish| { lanternfish...
src/day06.zig
const std = @import("std"); const alka = @import("alka"); const m = alka.math; usingnamespace alka.log; pub const mlog = std.log.scoped(.app); pub const log_level: std.log.Level = .debug; const RectangleStore = alka.ecs.StoreComponent("Rectangle", m.Rectangle, maxent); const SpeedStore = alka.ecs.StoreComponent("Spee...
examples/ecs_benchmark.zig
const std = @import("std"); const String = @This(); const mem = std.mem; const Allocator = mem.Allocator; const bog = @import("bog.zig"); const Vm = bog.Vm; const Value = bog.Value; const Type = bog.Type; const default_dump_depth = 4; /// Memory used by the string contents. data: []const u8, /// If 0 memory is a cons...
src/String.zig
const __floattitf = @import("floattitf.zig").__floattitf; const testing = @import("std").testing; fn test__floattitf(a: i128, expected: f128) !void { const x = __floattitf(a); try testing.expect(x == expected); } test "floattitf" { try test__floattitf(0, 0.0); try test__floattitf(1, 1.0); try tes...
lib/std/special/compiler_rt/floattitf_test.zig
const __truncsfhf2 = @import("truncXfYf2.zig").__truncsfhf2; fn test__truncsfhf2(a: u32, expected: u16) void { const actual = __truncsfhf2(@bitCast(f32, a)); if (actual == expected) { return; } @panic("__truncsfhf2 test failure"); } test "truncsfhf2" { test__truncsfhf2(0x7fc00000, 0x7e00...
std/special/compiler_rt/truncXfYf2_test.zig
const std = @import("std"); const mem = std.mem; const ascii = std.ascii; const testing = std.testing; pub const Version = struct { epoch: isize, major: isize, minor: isize, patch: isize, // Some packages have MAJOR.MINOR.PATCH.EXTRA - just going to assume it stops there extra: isize, // ...
src/version.zig
const util = @import("../sdf_util.zig"); pub const info: util.SdfInfo = .{ .name = "Round Cone", .data_size = @sizeOf(Data), .function_definition = function_definition, .enter_command_fn = util.surfaceEnterCommand(Data), .exit_command_fn = util.surfaceExitCommand(Data, exitCommand), .append_ma...
src/sdf/surfaces/round_cone.zig
const Value = @import("../_common_utils.zig").Value; /// SET key value [EX seconds|PX milliseconds] [NX|XX] pub const SET = struct { //! Command builder for SET. //! //! Allows you to use both strings and numbers as values. //! ``` //! const cmd1 = SET.init("mykey", 42, .NoExpire, .NoConditions); ...
src/commands/strings/set.zig
const std = @import("std"); const target = @import("builtin").target; const arch = target.cpu.arch; const os_tag = target.os.tag; const builtin = @import("builtin"); const Atomic = std.atomic.Atomic; pub const Futex = std.Thread.Futex; pub const is_x86 = switch (arch) { .i386, .x86_64 => true, else => false...
utils.zig
const std = @import("std"); const mem = std.mem; const warn = std.debug.warn; const identStep = struct { ident: []const u8, rest: []const u8, }; pub fn nextIdent(x: []const u8) identStep { var i: usize = 0; while (i < x.len and x[i] != '.') : (i += 1) {} return identStep{ .ident = x[0..i], .rest ...
src/main.zig
const std = @import("std"); const CompileUnit = @import("CompileUnit.zig"); const Decoder = @import("Decoder.zig"); const ir = @import("ir.zig"); pub const DisassemblerOptions = struct { /// Prefix each line of the disassembly with the hexadecimal address. addressPrefix: bool = false, /// If set, a hexdu...
src/library/common/disassembler.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day21.txt"); const Input = struct { start1: u16, start2: u16, pub fn init(input_text: []const u8, allocator: std.mem.Allocator) !@This() { _ = allocator; var lines = std.mem.tokenize(u8, input_t...
src/day21.zig
const freetype = @import("freetype"); const c = @import("c"); const Face = @import("face.zig").Face; const Buffer = @import("buffer.zig").Buffer; const Feature = @import("common.zig").Feature; const SegmentProps = @import("buffer.zig").SegmentProps; pub const Font = struct { handle: *c.hb_font_t, pub fn init(...
freetype/src/harfbuzz/font.zig
pub const CLSID_SoftwareBitmapNativeFactory = Guid.initString("84e65691-8602-4a84-be46-708be9cd4b74"); //-------------------------------------------------------------------------------- // Section: Types (2) //-------------------------------------------------------------------------------- const IID_ISoftwareBitmapNat...
win32/system/win_rt/graphics/imaging.zig
/// The function fiatP256AddcarryxU64 is an addition with carry. /// Postconditions: /// out1 = (arg1 + arg2 + arg3) mod 2^64 /// out2 = ⌊(arg1 + arg2 + arg3) / 2^64⌋ /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [0x0 ~> 0xffffffffffffffff] /// arg3: [0x0 ~> 0xffffffffffffffff] /// Output Bounds: /...
fiat-zig/src/p256_64.zig
const kernel = @import("root").kernel; const print = kernel.print; const memory = kernel.memory; const platform = @import("platform.zig"); const pci = @import("pci.zig"); const interrupts = @import("interrupts.zig"); const segments = @import("segments.zig"); const timing = @import("timing.zig"); const ps2 = @import("...
kernel/platform/usb.zig
const escape = @import("details/escape.zig"); const fmt = @import("details/fmt.zig"); const std = @import("std"); const Formatter = @import("../../../lib.zig").ser.Formatter; pub fn CompactFormatter(comptime Writer: type) type { return struct { const Self = @This(); const impl = @"impl CompactForm...
src/ser/impl/formatter/compact.zig
const uefi = @import("std").os.uefi; const Event = uefi.Event; const Guid = uefi.Guid; const Handle = uefi.Handle; const Status = uefi.Status; const TableHeader = uefi.tables.TableHeader; const DevicePathProtocol = uefi.protocols.DevicePathProtocol; /// Boot services are services provided by the system's firmware unti...
lib/std/os/uefi/tables/boot_services.zig
const compiler = @import("compiler.zig"); const CompilerResult = @import("compiler.zig").CompilerResult; const Compilation = @import("Compilation.zig"); const Node = @import("Node.zig"); const CompilerContext = @import("CompilerContext.zig"); const combn = @import("../combn/combn.zig"); const Context = combn.Context;...
src/dsl/Program.zig
const aoc = @import("../aoc.zig"); const std = @import("std"); const Packet = struct { const Operation = enum (u3) { Sum = 0, Product = 1, Minimum = 2, Maximum = 3, Literal = 4, GreaterThan = 5, LessThan = 6, Equal = 7, }; const SubpacketPars...
src/main/zig/2021/day16.zig
const Archive = @This(); const std = @import("std"); const assert = std.debug.assert; const fs = std.fs; const log = std.log.scoped(.archive); const macho = std.macho; const mem = std.mem; const Allocator = mem.Allocator; const Object = @import("Object.zig"); const parseName = @import("Zld.zig").parseName; usingname...
src/link/MachO/Archive.zig
const std = @import("../std.zig"); const builtin = @import("builtin"); const event = std.event; const assert = std.debug.assert; const testing = std.testing; const os = std.os; const mem = std.mem; const windows = os.windows; const Loop = event.Loop; const fd_t = os.fd_t; const File = std.fs.File; const Allocator = mem...
lib/std/fs/watch.zig
const std = @import("std"); const mem = std.mem; const assert = std.debug.assert; pub fn Ast(comptime T: type) type { return struct { const Self = @This(); allocator: *mem.Allocator, data: T, parent: ?*Self = null, prev: ?*Self = null, next: ?*Self = null, ...
src/ast.zig
const Address = std.net.Address; const Allocator = std.mem.Allocator; const LinearFifo = std.fifo.LinearFifo; const network = @import("network"); const std = @import("std"); const tls = @import("iguanaTLS"); const Uri = @import("http").Uri; pub const TcpSocket = SocketWrapper(ZigNetwork); pub const SocketMock = Socket...
src/socket.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const objects = @import("objects.zig"); const GameObject = objects.GameObject; pub const Component = struct { data: usize, allocator: Allocator, name: []const u8, gameObject: *GameObject = undefined, // TODO: index into a scene array ...
didot-objects/components.zig
const Builder = @import("std").build.Builder; const builtin = @import("builtin"); const std = @import("std"); const CheckFileStep = std.build.CheckFileStep; pub fn build(b: *Builder) void { const target = .{ .cpu_arch = .thumb, .cpu_model = .{ .explicit = &std.Target.arm.cpu.cortex_m4 }, .o...
test/standalone/install_raw_hex/build.zig
const std = @import("std"); const tools = @import("tools"); 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...
2016/day22.zig
const idt = @import("idt.zig"); // Interrupt Service Routines defined externally in assembly. extern fn isr0()void; extern fn isr1()void; extern fn isr2()void; extern fn isr3()void; extern fn isr4()void; extern fn isr5()void; extern fn isr6()void; extern fn isr7()void; extern fn isr8()void; extern fn isr9()v...
kernel/isr.zig
const os = @import("root").os; const regs = @import("regs.zig"); const std = @import("std"); const builtin = @import("builtin"); const interrupts = @import("interrupts.zig"); // LAPIC fn lapic_ptr() ?*volatile[0x100]u32 { if(os.platform.thread.get_current_cpu().platform_data.lapic) |ptr| { return ptr.get_writeb...
src/platform/x86_64/apic.zig
usingnamespace @import("vulkan-l1.zig"); pub const ptrdiff_t = c_long; pub const wchar_t = c_int; const struct_unnamed_1 = extern struct { __clang_max_align_nonce1: c_longlong align(8), __clang_max_align_nonce2: c_longdouble align(16), }; pub const max_align_t = struct_unnamed_1; pub const __u_char = u8; pub c...
src/lib/vulkan.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const INITIAL_BUFFER_LEN = 2*1024; pub const LineReader = struct { const Self = @This(); buffer: []u8, reader: std.fs.File.Reader, allocator: *Allocator, nextLineStart: usize, len: usize, pub fn init(allocator: *Allocator, ...
src/LineReader.zig
const std = @import("std"); usingnamespace @import("kira").log; const kira_utils = @import("kira").utils; const kira_glfw = @import("kira").glfw; const kira_gl = @import("kira").gl; const kira_window = @import("kira").window; var window_running = false; var targetfps: f64 = 1.0 / 60.0; const vertex_source...
examples/primitive-triangle.zig
const std = @import("std"); var sqlite3: ?*std.build.LibExeObjStep = null; fn linkSqlite(b: *std.build.LibExeObjStep) void { b.linkLibC(); if (sqlite3) |lib| { b.linkLibrary(lib); } else { b.linkSystemLibrary("sqlite3"); } } fn getTarget(original_target: std.zig.CrossTarget, bundled:...
build.zig
bytes: []const u8, index: usize = 0, line: usize = 0, column: usize = 0, state: State = .start, /// This field is populated when `next` returns a `Token` with `Token.Tag.invalid`. error_note: ErrorNote = undefined, pub const Token = struct { tag: Tag, bytes: []const u8, pub const Tag = enum { ///...
Xml.zig
const FMS = @This(); const std = @import("std"); const mem = std.mem; const testing = std.testing; const Allocator = std.mem.Allocator; const format = @import("../format.zig"); const testutil = @import("../test.zig"); const time = @import("../time.zig"); const FlightPlan = @import("../FlightPlan.zig"); const Route = ...
src/format/xplane_fms_11.zig
const std = @import("std"); const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; const Value = @import("./value.zig").Value; pub const OpCode = enum(u8) { Return, Pop, GetLocal, SetLocal, GetGlobal, DefineGlobal, SetGlobal, GetUpvalue, SetUpvalue, GetProperty, ...
src/chunk.zig
const std = @import("std"); const stdout = std.io.getStdOut().writer(); const print = stdout.print; const prompt = @import("prompt.zig"); const os = std.os; const fmt = std.fmt; const repo_status = @import("repo_status/repo_status.zig"); const C = prompt.C; fn is_remote() bool { var tty = os.getenv("SSH_TTY"); ...
funcs.zig
const std = @import("std"); const print = std.debug.print; pub fn showType(comptime T: type, only_pub: bool) void { const info = @typeInfo(T); switch (info) { .Type => print("type \n\r", .{}), .Void => print("void \n\r", .{}), .Bool => print("bool \n\r", .{}), .NoReturn => print...
libs/reflect.zig
const std = @import("std"); usingnamespace @import("compile-unit.zig"); usingnamespace @import("decoder.zig"); usingnamespace @import("ir.zig"); pub const DisassemblerOptions = struct { /// Prefix each line of the disassembly with the hexadecimal address. addressPrefix: bool = false, /// If set, a hexdum...
src/library/common/disassembler.zig
usingnamespace @import("common.zig"); const mesh_vert_shader = @embedFile("shader_data/mesh_vert.spv"); const mesh_frag_shader = @embedFile("shader_data/mesh_frag.spv"); const fractal_vert_shader = @embedFile("shader_data/fractal_vert.spv"); const fractal_frag_shader = @embedFile("shader_data/fractal_frag.spv"); pub ...
src/pipelines.zig
const std = @import("std"); const mem = std.mem; const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const debug = std.debug; const parser = @import("parse.zig"); const Parser = parser.Parser; const ByteClass = parser.ByteClass; const Expr = parser.Expr; const Assertion = parser.Assertion; pub const...
src/compile.zig
//-------------------------------------------------------------------------------- // Section: Types (1) //-------------------------------------------------------------------------------- const IID_IDirect3DDxgiInterfaceAccess_Value = Guid.initString("a9b3d012-3df2-4ee3-b8d1-8695f457d3c1"); pub const IID_IDirect3DDxgi...
win32/system/win_rt/direct3d11.zig
//-------------------------------------------------------------------------------- // Section: Types (5) //-------------------------------------------------------------------------------- const IID_ILearningModelOperatorProviderNative_Value = Guid.initString("1adaa23a-eb67-41f3-aad8-5d984e9bacd4"); pub const IID_ILear...
win32/system/win_rt/ml.zig
const std = @import("std"); const testing = std.testing; const allocator = std.testing.allocator; pub const Octopus = struct { const SIZE = 10; width: usize, height: usize, cur: usize, grid: [2][SIZE][SIZE]usize, pub fn init() Octopus { var self = Octopus{ .width = 0, ...
2021/p11/octopus.zig
const builtin = @import("builtin"); const std = @import("std"); const print = std.debug.print; const VA_Errors = error{ CountUninitialized, NoMoreArgs, }; pub const VAFunc = *const opaque {}; pub const VAList = struct { first_arg: bool = true, count: ?usize = null, gp_offset: u8 = 0, fp_offs...
src/x86_64.zig
const std = @import("std"); const mem = std.mem; const Allocator = std.mem.Allocator; name: []const u8, fh: std.fs.File, allocator: *Allocator, objects: std.ArrayList(ObjectFile), const Header = extern struct { name: [16]u8, mtime: [12]u8, ownerid: [6]u8, groupid: [6]u8, mode: [8]u8, size: [10...
src/Archive.zig
const std = @import("std"); const hzzp = @import("hzzp"); const iguanatls = @import("iguanatls"); const wz = @import("wz"); const TLS = iguanatls.Client(std.net.Stream.Reader, std.net.Stream.Writer, iguanatls.ciphersuites.all, false); const WSS = wz.base.client.BaseClient(TLS.Reader, TLS.Writer); const HTTPS = hzzp.ba...
zigcord.zig
const std = @import("std"); const c_locale = @cImport(@cInclude("locale.h")); const argparser = @import("argparser.zig"); const core = @import("core.zig"); const curses = @import("curses.zig"); const cursesui = @import("cursesui.zig"); const help = @import("help.zig"); pub fn main() anyerror!void { const allocato...
src/main.zig
const std = @import("std"); const assert = std.debug.assert; const c = @import("c.zig"); pub const Mat4x4 = struct { data: [4][4]f32, pub const identity = Mat4x4{ .data = [_][4]f32{ [_]f32{ 1.0, 0.0, 0.0, 0.0 }, [_]f32{ 0.0, 1.0, 0.0, 0.0 }, [_]f32{ 0.0, 0.0, 1.0, 0...
src/math3d.zig
const std = @import("std"); const iup = @import("iup.zig"); var dlg_id: i32 = 0; var allocator: std.mem.Allocator = undefined; const MainLoop = iup.MainLoop; const Dialog = iup.Dialog; const Button = iup.Button; const MessageDlg = iup.MessageDlg; const Multiline = iup.Multiline; const Label = iup.Label; const Text = ...
src/mdi_example.zig
const std = @import("std"); const stdx = @import("stdx"); const gl = @import("gl"); const log = stdx.log.scoped(.shader); pub const Shader = struct { const Self = @This(); vert_id: gl.GLuint, frag_id: gl.GLuint, prog_id: gl.GLuint, // Vertex array object used to record vbo layout. vao_id: gl....
graphics/src/backend/gl/shader.zig
const std = @import("std"); const helper = @import("helper.zig"); const Allocator = std.mem.Allocator; const input = @embedFile("../inputs/day08.txt"); const digits: [10][7]bool = .{ .{ true, true, true, false, true, true, true }, .{ false, false, true, false, false, true, false }, .{ true, false, true, t...
src/day08.zig
const messageNs = @import("message.zig"); const Message = messageNs.Message; const MessageHeader = messageNs.MessageHeader; const messageQueueNs = @import("message_queue.zig"); const MessageQueue = messageQueueNs.MessageQueue; const SignalContext = messageQueueNs.SignalContext; //const futex_wait = @import("futex.zig...
message_allocator.zig
const std = @import("std"); const print = std.debug.print; const fs = std.fs; const c = @cImport({ @cInclude("linux/i2c.h"); @cInclude("linux/i2c-dev.h"); @cInclude("sys/ioctl.h"); @cInclude("sys/errno.h"); }); const i2c_msg = extern struct { addr: u16, flags: u16, len: u16, buf: *u8,...
src/bus/i2c.zig
// SPDX-License-Identifier: MIT // This file is part of the `termcon` project under the MIT license. const std = @import("std"); pub const key = @import("event/key.zig"); pub const mouse = @import("event/mouse.zig"); const view = @import("view.zig"); pub const Size = view.Size; pub const KeyCallback = fn (e: key.E...
src/event.zig
const std = @import("std"); /// replace characters in fmt to implement ansi sgr escape sequences /// any instance of `%(?)` with `\x1b[?m`, where `?` is any sequence of /// specifiers. any sequence matching `/[0-9 ;]*/` is allowed. /// specifier reference: /// https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select...
src/util/ansi.zig
const std = @import("std"); const print = std.debug.print; const util = @import("./util.zig"); const NumberCount = 100; const BoardCount = 100; const data = @embedFile("../data/day04.txt"); const BingoCell = struct { number: u8, marked: bool = false, }; const Board = struct { cells: [5][5]BingoCell = und...
src/day04.zig
const std = @import("std"); const utils = @import("../utils.zig"); const Atomic = std.atomic.Atomic; pub const Lock = extern struct { pub const name = "word_lock"; state: Atomic(usize) = Atomic(usize).init(UNLOCKED), const UNLOCKED = 0; const LOCKED = 1; const WAKING = 2; const WAITING = ~@a...
locks/word_lock.zig
const std = @import("std"); const spirv = @import("../spirv.zig"); const core = @import("core.zig"); pub const instructions = struct { pub fn round(self: *spirv.Builder, arg0: core.IdRef) !void { var operands = std.ArrayList(spirv.Operand).init(self.allocator); errdefer operands.deinit(); t...
src/gen/glsl.zig
const std = @import("std"); const use_test_input = false; const filename = if (use_test_input) "day-7_test-input" else "day-7_real-input"; const input_length = if (use_test_input) 10 else 1000; pub fn main() !void { std.debug.print("--- Day 7 ---\n", .{}); var file = try std.fs.cwd().openFile(filename, .{});...
day-7.zig
const std = @import("std"); const utils = @import("utils.zig"); const UniqueList = utils.UniqueList; const UniqueFixedList = utils.UniqueFixedList; pub const Error = error{ InvalidComponent, FailedtoAllocate, InvalidRegister } || utils.Error; /// Stores the component struct in a convenient way pub fn StoreComponent(...
src/core/ecs.zig
const std = @import("../std.zig"); const builtin = @import("builtin"); const root = @import("root"); const assert = std.debug.assert; const testing = std.testing; const mem = std.mem; const os = std.os; const windows = os.windows; const maxInt = std.math.maxInt; const Thread = std.Thread; const is_windows = std.Target...
lib/std/event/loop.zig
const std = @import("../std.zig"); const assert = std.debug.assert; const maxInt = std.math.maxInt; const State = enum { Complete, Value, ArrayStart, Array, ObjectStart, Object, }; /// Writes JSON ([RFC8259](https://tools.ietf.org/html/rfc8259)) formatted data /// to a stream. `max_depth` is a...
lib/std/json/write_stream.zig
const builtin = @import("builtin"); const std = @import("../std.zig"); const debug = std.debug; const assert = debug.assert; const testing = std.testing; const mem = std.mem; const fmt = std.fmt; const Allocator = mem.Allocator; const math = std.math; const windows = std.os.windows; const fs = std.fs; const process = s...
lib/std/fs/path.zig
// TODO // 1. Validation of input data in parser: slice ranges and object sizes/alignments // 2. Refactorings to simplify a bit where possible // 5. Optimization pass in encoder to speed up instances of reasonably packed // data? (slices, packed structs, etc) // 6. Make arrays less silly const std = @import("std...
src/liu/packed_asset.zig
const aoc = @import("../aoc.zig"); const std = @import("std"); const Ingredient = struct { capacity: i32, durability: i32, flavor: i32, texture: i32, calories: i32 }; const Params = struct { i: i32 = 0, j: i32 = 0, k: i32 = 0, l: i32 = 0, ingredients: [4]Ingredient = undefined, fn calcSubscore(self: ...
src/main/zig/2015/day15.zig
const std = @import("../std.zig"); const assert = std.debug.assert; const mem = std.mem; const Allocator = std.mem.Allocator; /// This allocator takes an existing allocator, wraps it, and provides an interface /// where you can allocate without freeing, and then free it all together. pub const ArenaAllocator = struct ...
lib/std/heap/arena_allocator.zig
const std = @import("std"); const builtin = @import("builtin"); const testing = std.testing; const dif = @import("dif.zig"); const dot = @import("dot.zig"); const sema = @import("sema.zig"); const ial = @import("indexedarraylist.zig"); pub const LIB_VERSION = blk: { if (builtin.mode != .Debug) { break :bl...
libdaya/src/main.zig
const std = @import("std"); const Sprite = struct { // `image_id` must be a unique identifier for the image a sprite references. // You must set this value! image_id: u64, // The `texture_id` can set to zero `spritebatch_push`. This value will be overwritten // with a valid texture id of a generated atlas befo...
src/cute_batcher.zig
const std = @import("std"); const TestContext = @import("../../src/test.zig").TestContext; // These tests should work with all platforms, but we're using linux_x64 for // now for consistency. Will be expanded eventually. const linux_x64 = std.zig.CrossTarget{ .cpu_arch = .x86_64, .os_tag = .linux, }; pub fn a...
test/stage2/cbe.zig
const std = @import("std"); const string = []const u8; const zigmod = @import("../lib.zig"); const u = @import("index.zig"); const yaml = @import("./yaml.zig"); // // const b = 1; const kb = b * 1024; const mb = kb * 1024; pub const ModFile = struct { const Self = @This(); id: string, name: string, ...
src/util/modfile.zig
const std = @import("std"); const v8 = @import("v8.zig"); // Demo js repl. pub fn main() !void { repl(); std.process.exit(0); } fn repl() void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const alloc = gpa.allocator(); var input_buf = std.ArrayList(u8).init(al...
src/shell.zig
const std = @import("std"); const unistd = @cImport(@cInclude("unistd.h")); fn matInit(alloc: *std.mem.Allocator, x: usize, y: usize) [][]f64 { var mat: [][]f64 = alloc.alloc([]f64, x) catch unreachable; for (mat) |*row| { row.* = alloc.alloc(f64, y) catch unreachable; std.mem.set(f64, row.*, 0...
matmul/matmul.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/day11.txt"); //...
src/day11.zig
const std = @import("std"); const testing = std.testing; const allocator = std.testing.allocator; const desc_usize = std.sort.desc(usize); pub const Navigation = struct { syntax_error_score: usize, completion_scores: std.ArrayList(usize), pub fn init() Navigation { var self = Navigation{ ...
2021/p10/navigation.zig
const builtin = @import("builtin"); const std = @import("std"); const mem = std.mem; const print = std.debug.print; const fs = std.fs; const ChildProcess = std.ChildProcess; const process = std.process; const render_utils = @import("render_utils.zig"); /// This struct bundles all the options necessary to run a snippe...
src/doctest/build.zig
const std = @import("std"); const SYS = @import("./consts.zig").SYS; inline fn syscall0(n: SYS) usize { return asm volatile ("svc #0" : [ret] "={r0}" (-> usize), : [n] "{r7}" (n), : "memory", "cc" ); } inline fn syscall1(n: SYS, arg1: usize) usize { return asm volatile ("svc #0" ...
src/linux/arm/calls.zig
const std = @import("std"); // const math = std.math; const math = @import("lib.zig"); const expect = std.testing.expect; /// Returns 2 raised to the power of x (2^x). /// /// Special Cases: /// - exp2(+inf) = +inf /// - exp2(nan) = nan pub fn exp2(x: anytype) @TypeOf(x) { const T = @TypeOf(x); return swit...
src/exp2.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); } // horrible -> O(n3) + sloppy floats.. const map_width = 36; const eps = 0.001; const Map ...
2019/day10a.zig
const std = @import("std"); const hash_map = std.hash_map; const testing = std.testing; const math = std.math; /// A comptime hashmap constructed with automatically selected hash and eql functions. pub fn AutoComptimeHashMap(comptime K: type, comptime V: type, comptime values: anytype) type { return ComptimeHashMa...
comptime_hash_map.zig
const std = @import("std"); const assert = std.debug.assert; const mem = std.mem; const testing = std.testing; const os = std.os; const Target = std.Target; /// Detect macOS version. /// `target_os` is not modified in case of error. pub fn detect(target_os: *Target.Os) !void { // Drop use of osproductversion sysc...
lib/std/zig/system/macos.zig