code
stringlengths
38
801k
repo_path
stringlengths
6
263
const std = @import("std"); const StringHashMap = std.StringHashMap; pub fn buildNamedCharacterReferenceTable(allocator: *std.mem.Allocator) StringHashMap(u21) { @setEvalBranchQuota(3000); const pairs = .{ .{ "Aacute;", 0x000C1 }, .{ "Aacute", 0x000C1 }, .{ "aacute;", 0x000E1 }, ...
src/namedCharacterReference.zig
const os = @import("root").os; const builtin = @import("builtin"); const std = @import("std"); const paging = os.memory.paging; const pci = os.platform.pci; const libalign = os.lib.libalign; const range = os.lib.range; const RSDP = packed struct { signature: [8]u8, checksum: u8, oemid: [6]u8, revision:...
src/platform/acpi.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day09.txt"); pub const DijkstraMap = struct { const Self = @This(); values: []u8, width: u32, allocator: *util.Allocator, pub fn initFromSerializedData(allocator: *util.Allocator, serialized_data: []co...
src/day09.zig
const std = @import("std"); const zfetch = @import("zfetch"); const json = @import("json"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const alloc = &gpa.allocator; const f = try std.fs.cwd().createFile("src/lib.zig", .{}); const w = f.writer(); { std.log.in...
generate.zig
const std = @import("std"); const zp = @import("zplay.zig"); const sdl = zp.deps.sdl; /// event definitions pub const WindowEvent = @import("event/WindowEvent.zig"); pub const KeyboardEvent = @import("event/KeyboardEvent.zig"); pub const TextInputEvent = @import("event/TextInputEvent.zig"); pub const MouseEvent = @imp...
src/event.zig
const std = @import("std"); const testing = std.testing; pub fn RadixTree( comptime K: type, comptime V: type, comptime cmp: fn (K, K) bool, ) type { return struct { const Self = @This(); /// Represents a node within the tree /// Is possible a Leaf or else contains edges to ...
src/main.zig
pub const XINPUT_DEVTYPE_GAMEPAD = @as(u32, 1); pub const XINPUT_DEVSUBTYPE_GAMEPAD = @as(u32, 1); pub const XINPUT_DEVSUBTYPE_UNKNOWN = @as(u32, 0); pub const XINPUT_DEVSUBTYPE_WHEEL = @as(u32, 2); pub const XINPUT_DEVSUBTYPE_ARCADE_STICK = @as(u32, 3); pub const XINPUT_DEVSUBTYPE_FLIGHT_STICK = @as(u32, 4); pub const...
deps/zigwin32/win32/ui/xinput.zig
const std = @import("std"); const u = @import("../util.zig"); const Expr = @import("../Expr.zig"); const IR = @import("../IR.zig"); const Wasm = @import("../Wasm.zig"); const Opt = struct { ids: bool = false, }; pub fn emit(m: IR.Module, gpa: std.mem.Allocator, comptime opt: Opt) !Expr.Root { var n_top: usize ...
src/Wat/Emit.zig
const panic = @import("std").debug.panic; pub const c = @import("c.zig"); pub const event = @import("sdl/event.zig"); pub const hint = @import("sdl/hint.zig"); // Errors pub const SdlError = error{ WindowCreation, RendererCreation, GlContextCreation, NoOpenGlContext, NoOpenGlAttachedToWindow, }; pu...
sdl.zig
const std = @import("std"); const ArrayList = std.ArrayList; const fmt = std.fmt; const io = std.io; const mem = std.mem; const Collection = @import("Collection.zig"); const Record = @import("record.zig").Record; const ascii = @import("ascii.zig"); const UcdGenerator = struct { allocator: *mem.Allocator, pu...
src/ucd_gen.zig
const std = @import("std"); const assert = std.debug.assert; const allocator = std.testing.allocator; const TargetInfo = struct { angle: f64, x: usize, y: usize, dist: usize, shot: bool, }; fn cmpByAngle(_: void, l: TargetInfo, r: TargetInfo) bool { if (l.angle < r.angle) return true; if (l...
2019/p10/board.zig
const std = @import("std"); const with_trace = false; const with_dissassemble = true; const assert = std.debug.assert; fn trace(comptime fmt: []const u8, args: anytype) void { if (with_trace) std.debug.warn(fmt, args); } const Computer = struct { name: []const u8, memory: []Data, pc: usize = undefine...
2019/day20a.zig
const sf = @import("../sfml.zig"); pub const Sound = struct { const Self = @This(); // Constructor/destructor /// Inits an empty sound pub fn init() !Self { var sound = sf.c.sfSound_create(); if (sound == null) return sf.Error.nullptrUnknownReason; return Self{ .p...
src/sfml/audio/sound.zig
const std = @import("std"); const builtin = @import("builtin"); /// In concurrent programming, sometimes it is desirable to make sure commonly accessed pieces of /// data are not placed into the same cache line. Updating an atomic value invalidates the whole /// cache line it belongs to, which makes the next access to...
src/utils.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day25.txt"); const Input = struct { map: [140][140]u8 = undefined, dim_x: usize = 0, dim_y: usize = 0, pub fn init(input_text: []const u8, allocator: std.mem.Allocator) !@This() { _ = allocator; ...
src/day25.zig
const std = @import("std"); const print = std.debug.print; const util = @import("util.zig"); const gpa = util.gpa; const data = @embedFile("../data/day25.txt"); pub fn main() !void { const result = try part1(data); print("{}\n", .{result}); } fn part1(input : []const u8) !usize { var board = std.ArrayLi...
src/day25.zig
const std = @import("std"); const Builder = std.build.Builder; const builtin = std.builtin; const assert = std.debug.assert; const sabaton = @import("boot/Sabaton/build.zig"); const flork = @import("subprojects/flork/build.zig"); // zig fmt: off fn qemu_run_aarch64_sabaton(b: *Builder, board_name: []const u8, desc: [...
build.zig
pub const XK_MISCELLANY = ""; pub const XK_XKB_KEYS = ""; pub const XK_LATIN1 = ""; pub const XK_LATIN2 = ""; pub const XK_LATIN3 = ""; pub const XK_LATIN4 = ""; pub const XK_GREEK = ""; pub const XK_VoidSymbol = @import("std").zig.c_translation.promoteIntLiteral(c_int, 0xFFFFFF, .hexadecimal); pub const XK_BackSpace =...
modules/platform/src/linux/X11/keysym.zig
const std = @import("std"); const stdx = @import("stdx"); const v8 = @import("v8"); const api = @import("api.zig"); const api_graphics = @import("api_graphics.zig"); const log = stdx.log.scoped(.js_gen); pub fn generate(alloc: std.mem.Allocator, path: []const u8) !void { const src = genApiSupplementJs(alloc); ...
runtime/js_gen.zig
const std = @import("../std.zig"); const assert = std.debug.assert; const Allocator = std.mem.Allocator; const ast = std.zig.ast; const Node = ast.Node; const Tree = ast.Tree; const AstError = ast.Error; const TokenIndex = ast.TokenIndex; const Token = std.zig.Token; pub const Error = error{ParseError} || Allocator.Er...
lib/std/zig/parse.zig
const std = @import("std"); const expect = std.testing.expect; const maxInt = std.math.maxInt; const minInt = std.math.minInt; const builtin = @import("builtin"); test "uint128" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_x86_64) return error....
test/behavior/int128.zig
const Tokenizer = @This(); const std = @import("std"); const log = std.log.scoped(.tapi); const testing = std.testing; buffer: []const u8, index: usize = 0, pub const Token = struct { id: Id, start: usize, end: usize, pub const Id = enum { Eof, NewLine, DocStart, // --- ...
src/link/tapi/Tokenizer.zig
const std = @import("std"); const mem = std.mem; const ModifierSymbol = @This(); allocator: *mem.Allocator, array: []bool, lo: u21 = 94, hi: u21 = 127999, pub fn init(allocator: *mem.Allocator) !ModifierSymbol { var instance = ModifierSymbol{ .allocator = allocator, .array = try allocator.alloc(...
src/components/autogen/DerivedGeneralCategory/ModifierSymbol.zig
const std = @import("std"); const mem = std.mem; const crypto = std.crypto; fn fieldElement(comptime Field: type) type { const fiat = Field.fiat; return struct { const Self = @This(); limbs: Field.Limbs, pub const bytes = Field.bytes; pub fn invert(a: Self) Self { ...
inversion/zig/inversion.zig
const std = @import("std"); const fs = std.fs; const mem = std.mem; const xml = @import("xml.zig"); const gpa = &allocator_instance.allocator; var allocator_instance = std.heap.GeneralPurposeAllocator(.{}){}; pub fn scan(root_dir: fs.Dir, out_path: []const u8, wayland_xml: []const u8, protocols: []const []const u8) ...
src/scanner.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_09_1.txt", std.math.maxInt(usize)); var lines = std.mem.tokenize(input, "\n"); ...
2020/src/day_09.zig
const std = @import("std"); const util = @import("aoc_util"); const print = std.debug.print; const fmt = std.fmt; const mem = std.mem; //const input = @embedFile("../../input/day_02.txt"); const instruction = enum{fwd, up, down}; const forward = "forward"; const up = "up"; const down = "down"; const sub_cmd = struct...
src/day-02/dive.zig
const std = @import("std"); const print = std.debug.print; const assert = std.debug.assert; const threads = @import("threads.zig"); const config = @import("config.zig"); pub const Camera = struct { ctx: threads.CameraContext, child: std.ChildProcess, pub fn start(self: *Camera) bool {} pub fn stop(...
src/camera.zig
const uefi = @import("std").os.uefi; const Guid = uefi.Guid; /// UEFI Specification, Version 2.8, 12.9 pub const GraphicsOutputProtocol = extern struct { _query_mode: extern fn (*const GraphicsOutputProtocol, u32, *usize, **GraphicsOutputModeInformation) usize, _set_mode: extern fn (*const GraphicsOutputProtoc...
lib/std/os/uefi/protocols/graphics_output_protocol.zig
const std = @import("../std.zig"); const Cpu = std.Target.Cpu; pub const Feature = enum { atomics, bulk_memory, exception_handling, multivalue, mutable_globals, nontrapping_fptoint, sign_ext, simd128, tail_call, unimplemented_simd128, }; pub usingnamespace Cpu.Feature.feature_s...
lib/std/target/wasm.zig
const std = @import("std"); const assert = std.debug.assert; const warn = std.debug.warn; const Allocator = std.mem.Allocator; usingnamespace @import("../main/util.zig"); const system = @import("system.zig"); const EntityComponentDataList = struct { hash: Hash, tmp_ids: []Entity, data_list: Variant, }; co...
code/core/entity.zig
const std = @import("std"); const assert = std.debug.assert; const x86 = @import("machine.zig"); usingnamespace (@import("types.zig")); const ModRmResult = x86.operand.ModRmResult; const Immediate = x86.operand.Immediate; const Address = x86.operand.Address; const MOffsetDisp = x86.operand.MOffsetDisp; const Registe...
src/x86/instruction.zig
const std = @import("std"); const readIntLittle = std.mem.readIntLittle; const writeIntLittle = std.mem.writeIntLittle; const Error = std.crypto.Error; pub const Fe = struct { limbs: [5]u64, const MASK51: u64 = 0x7ffffffffffff; /// 0 pub const zero = Fe{ .limbs = .{ 0, 0, 0, 0, 0 } }; /// 1 ...
lib/std/crypto/25519/field.zig
const std = @import("std"); const ast = std.zig.ast; const util = @import("utils.zig"); const source_url = "https://github.com/ziglang/zig/blob/master/lib/std/"; const out_fname_html = "index.html"; const in_fname_head = "html_head.html"; const in_fname_entries = "entries.json"; const max_read_filesize = 20 * 1024 * 1...
gen.zig
const std = @import("std"); const print = std.debug.print; const eql = std.mem.eql; const expect = std.testing.expect; fn print_array(prefix: []const u8, array: []const u8) void { print("{}{}{}", .{ prefix, @typeName(@TypeOf(array)), "{" }); for (array) |n, i| { if (i < array.len - 1) { pri...
web/src/204_array/test.zig
const uefi = @import("../uefi.zig"); const Header = @import("header.zig").Header; const NotYetImplementedFn = uefi.NotYetImplementedFn; const Guid = uefi.Guid; const Status = uefi.Status; const ucs2 = uefi.ucs2; pub const BootServices = extern struct { pub const signature = 0x56524553544f4f42; hdr: Header, ...
src/uefi/tables/boot_services.zig
const std = @import("std"); const warn = std.debug.warn; const ZigParser = @import("zig/zig_parser.zig").Parser; const ZigNode = @import("zig/zig_parser.zig").Node; const ZigToken = @import("zig/zig_grammar.tokens.zig").Token; const ZigIr = struct { const Instruction = struct { id: Id, pub const ...
parser.zig
const Svg = @This(); const std = @import("std"); const mem = std.mem; const Allocator = mem.Allocator; pub const Element = struct { const Tag = enum { raw, group, path, line, rect, text, }; pub const Raw = struct { const base_tag: Svg.Element.Tag =...
src/Svg.zig
const builtin = @import("builtin"); const std = @import("std"); const crypto = std.crypto; /// Possible errors when generating a code pub const CodeGenError = error{ /// OutOfBounds is triggered when digits is smaller than 6 or higher than 8. OutOfBounds, /// UnsupportedAlgorithm is triggered when an algor...
src/otp.zig
const std = @import("std"); const iface = @import("interface"); const utility = @import("utility.zig"); // Import modules to reduce file size usingnamespace @import("value.zig"); usingnamespace @import("../common/compile-unit.zig"); usingnamespace @import("context.zig"); usingnamespace @import("vm.zig"); usingnamespa...
src/library/runtime/environment.zig
const aoc = @import("../aoc.zig"); const std = @import("std"); const Item = struct { cost: u16, atk: i8 = 0, def: i8 = 0 }; pub fn run(problem: *aoc.Problem) !aoc.Solution { const player_hp: u8 = 100; const weapons = [_]Item { .{ .cost = 8, .atk = 4 }, .{ .cost = 10, .atk = 5 }, .{ .co...
src/main/zig/2015/day21.zig
const kernel = @import("../../kernel.zig"); const log = kernel.log.scoped(.ACPI); const TODO = kernel.TODO; const Virtual = kernel.Virtual; const Physical = kernel.Physical; /// ACPI initialization. We should have a page mapper ready before executing this function pub fn init(rsdp_physical_address: kernel.Physical.Add...
src/kernel/arch/x86_64/acpi.zig
const expectEqual = @import("std").testing.expectEqual; const std = @import("std"); const expect = std.testing.expect; const minInt = std.math.minInt; test "@bitReverse" { comptime try testBitReverse(); try testBitReverse(); } fn testBitReverse() !void { // using comptime_ints, unsigned try expectEqua...
test/behavior/bitreverse.zig
const std = @import("std"); const zlm = @import("zlm"); const Vec3 = zlm.Vec3; const Allocator = std.mem.Allocator; const graphics = @import("didot-graphics"); const objects = @import("didot-objects"); const models = @import("didot-models"); const image = @import("didot-image"); //const physics = @import("didot-physic...
examples/kart-and-cubes/example-scene.zig
const wlr = @import("../wlroots.zig"); const std = @import("std"); const wl = @import("wayland").server.wl; pub const ForeignToplevelManagerV1 = extern struct { event_loop: *wl.EventLoop, global: *wl.Global, resources: wl.list.Head(wl.Resource, null), toplevels: wl.list.Head(ForeignToplevelHandleV1, "...
src/types/foreign_toplevel_management_v1.zig
const std = @import("std"); const cast = std.meta.cast; const mode = std.builtin.mode; // Checked arithmetic is disabled in non-debug modes to avoid side channels /// The function addcarryxU26 is an addition with carry. /// Postconditions: /// out1 = (arg1 + arg2 + arg3) mod 2^26 /// out2 = ⌊(arg1 + arg2 + arg3)...
fiat-zig/src/curve25519_32.zig
const std = @import("std"); const cli = @import("cli.zig"); var globalOT: ?std.os.termios = null; pub fn panic(msg: []const u8, stack_trace: ?*std.builtin.StackTrace) noreturn { const stdinF = std.io.getStdIn(); cli.stopCaptureMouse() catch {}; if (globalOT) |ot| cli.exitRawMode(stdinF, ot) catch {}; ...
src/escape_sequence_debug.zig
const std = @import("std"); const assert = std.debug.assert; const mem = std.mem; const window = @import("Window.zig"); const c = @import("c.zig").c; const expect = std.testing.expect; const image = @import("Image.zig"); const MinFilter = image.MinFilter; const image_type_base_internal_formats = image.image_type_base_i...
src/WindowGraphicsInput/CubeMap.zig
usingnamespace @import("enum.zig"); usingnamespace @import("struct.zig"); usingnamespace @import("../../types.zig"); pub const IAsynchronous = extern struct { const Interface = @This(); pub const VTable = extern struct { QueryInterface: extern fn (*Interface, *const GUID, *?*c_void) HRESULT, ...
directx11/core/interface.zig
const std = @import("std"); const builtin = @import("builtin"); const debug = std.debug; const TypeInfo = builtin.TypeInfo; /// A function for populating vtables with their implementation. /// /// VTable is the vtables type. It has to be a struct, which has only function fields. /// It is also required that VTable c...
src/vtable.zig
const std = @import("std"); const log = @import("log.zig"); const c = @cImport({ @cInclude("stdio.h"); }); const esp = @cImport({ @cInclude("sdkconfig.h"); @cInclude("esp_system.h"); @cInclude("led_strip.h"); }); const freertos = @cImport({ @cInclude("freertos/FreeRTOS.h"); @cInclude("freerto...
main/src/main.zig
const std = @import("std"); const pkgs = struct { const gemtext = std.build.Pkg{ .name = "gemtext", .path = .{ .path = "src/gemtext.zig" }, }; }; const example_list = [_][]const u8{ "gem2html", "gem2md", "streaming-parser", }; pub fn build(b: *std.build.Builder) void { const t...
build.zig
const macro = @import("pspmacros.zig"); comptime { asm (macro.import_module_start("UtilsForUser", "0x40010000", "26")); asm (macro.import_function("UtilsForUser", "0xBFA98062", "sceKernelDcacheInvalidateRange")); asm (macro.import_function("UtilsForUser", "0xC8186A58", "sceKernelUtilsMd5Digest")); asm ...
src/psp/nids/psputils.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const gui = @import("gui"); const nvg = @import("nanovg"); const Rect = @import("gui/geometry.zig").Rect; const col = @import("color.zig"); const ColorPaletteWidget = @This(); widget: gui.Widget, allocator: Allocator, colors: [4 * 256]u8 = undefined, s...
src/ColorPaletteWidget.zig
pub const ICW_MAX_ACCTNAME = @as(u32, 256); pub const ICW_MAX_PASSWORD = @as(u32, 256); pub const ICW_MAX_LOGONNAME = @as(u32, 256); pub const ICW_MAX_SERVERNAME = @as(u32, 64); pub const ICW_MAX_RASNAME = @as(u32, 256); pub const ICW_MAX_EMAILNAME = @as(u32, 64); pub const ICW_MAX_EMAILADDR = @as(u32, 128); pub const ...
win32/network_management/internet_connection_wizard.zig
const rl = @import("raylib"); pub fn main() anyerror!void { // Initialization //-------------------------------------------------------------------------------------- const screenWidth = 800; const screenHeight = 450; rl.InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic win...
examples/core/input_multitouch.zig
const std = @import("std"); const getty = @import("lib.zig"); const ArrayListSer = @import("ser/impl/ser/array_list.zig"); const BoolSer = @import("ser/impl/ser/bool.zig"); const ErrorSer = @import("ser/impl/ser/error.zig"); const EnumSer = @import("ser/impl/ser/enum.zig"); const FloatSer = @import("ser/impl/ser/flo...
src/ser.zig
const std = @import("std"); const aoc = @import("aoc-lib.zig"); fn fuel1(a: usize, b: usize) usize { return aoc.absCast(@intCast(isize, a) - @intCast(isize, b)); } test "fuel1" { try aoc.assertEq(@as(usize, 14), fuel1(16, 2)); try aoc.assertEq(@as(usize, 1), fuel1(1, 2)); try aoc.assertEq(@as(usize, 0...
2021/07/aoc.zig
pub const ProtCheckerRule = enum { /// Non-secure and non-privileged user access allowed. NsNonpriv = 0, /// Non-secure and privileged access allowed. NsPriv = 1, /// Secure and non-privileged user access allowed. SNonpriv = 2, /// Secure and privileged user access allowed. SPriv = 3,...
examples/drivers/lpc_protchecker.zig
const std = @import("std"); const os = std.os; const warn = std.debug.warn; const print = std.debug.print; const memory = @import("memory.zig"); const readMemMap = @import("read_map.zig").readMemMap; const input = @import("input.zig"); const Needle = @import("needle.zig").Needle; const call_fn_with_union_type = @impor...
src/main.zig
const std = @import("../../std.zig"); const net = @import("net.zig"); const os = std.os; const fmt = std.fmt; const mem = std.mem; const time = std.time; const builtin = std.builtin; /// A generic, cross-platform socket abstraction. pub const Socket = struct { /// A socket-address pair. pub const Connection ...
lib/std/x/os/socket.zig
const std = @import("std"); const testing = std.testing; const allocator = std.heap.page_allocator; pub const Decoder = struct { pub const Mode = enum { Value, Address, }; mode: Mode, mem: std.AutoHashMap(u64, u64), mask0: u64, mask1: u64, floats: [36]u6, fpos: usize, ...
2020/p14/decoder.zig
const std = @import("std"); const print = std.debug.print; const assert = std.debug.assert; // base is base of number system // mem[] is the number in the base number system // we do not need to use length of the buffer as function arguments // NOTE // - This pattern is, because mem_arrray is actually an array // ...
main.zig
const std = @import("std"); const g = @import("spirv/grammar.zig"); const Allocator = std.mem.Allocator; const ExtendedStructSet = std.StringHashMap(void); pub fn main() !void { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = arena.allocator(); ...
tools/gen_spirv_spec.zig
const layout = @import("layout.zig"); const x86 = @import("x86.zig"); const fmt = @import("std").fmt; // Screen size. const VGA_WIDTH = 80; const VGA_HEIGHT = 25; // Color codes. pub const Color = enum(u4) { Black = 0, Blue = 1, Green = 2, Cyan = 3, Red = 4,...
kernel/tty.zig
pub const Video = struct { const VI_BASE = @intToPtr([*]volatile u32, 0xA4400000); pub const VideoStatusFlags = struct { pub const BPP32 = 0x3; pub const INTERLACE = 0x40; pub const AA_MODE_2 = 0x200; }; pub fn setupNtsc(width: u32, height: u32, status: u32, origin: u32) void ...
src/video.zig
const std = @import("std"); // const builtin = @import("builtin"); const builtin = std.builtin; const fs = std.fs; const mem = std.mem; const path = fs.path; const ChildProcess = std.ChildProcess; pub const Package = struct { pub const Source = union(enum) { pub const Error = fs.Dir.AccessError || mem.Al...
build/sys.zig
const os = @import("root").os; const std = @import("std"); const kepler = os.kepler; /// InterruptObject is a source of interrupts of some kind /// InterruptObject will typically be embedded in the other /// object that contains info about the interrupt vector like /// gsi vector etc (depends on the interrupt source) ...
src/kepler/interrupts.zig
const std = @import("std"); const warn = std.debug.warn; const ZigParser = @import("zig/zig_parser.zig").Parser; const ZigNode = @import("zig/zig_parser.zig").Node; const Uri = @import("uri.zig"); usingnamespace @import("json/json.zig"); usingnamespace @import("errors.zig"); const allocator = std.heap.c_allocator; ...
server.zig
const std = @import("std"); const util = @import("util"); const vm = @import("vm.zig"); const input = @embedFile("8.txt"); const Interpreter = vm.Interpreter(input, Mixin); fn Mixin(comptime T: type) type { @setEvalBranchQuota(100 * T.bytecode_init.len); const instr_count = T.bytecode_init.len / 2; compti...
2020/8.zig
const std = @import("std"); const math = std.math; const max = math.max; const min = math.min; const abs = math.fabs; const hypot = math.hypot; const ln = math.ln; const exp = math.exp; const floor = math.floor; const ceil = math.ceil; const pi: f64 = math.pi; const tau: f64 = 6.28318530717958647; const sqrt3: f64 = ...
lib/sdf2.zig
const std = @import("std"); const mem = std.mem; const fs = std.fs; const Step = std.build.Step; const Builder = std.build.Builder; /// ScdocStep generates man pages using scdoc(1). /// /// It reads all the raw pages from src_path and writes them to out_path. /// src_path is typically "doc/" relative to the build root...
src-build/ScdocStep.zig
const std = @import("std"); const builtin = @import("builtin"); const expect = std.testing.expect; const maxInt = std.math.maxInt; test "@bitCast i32 -> u32" { testBitCast_i32_u32(); comptime testBitCast_i32_u32(); } fn testBitCast_i32_u32() void { expect(conv(-1) == maxInt(u32)); expect(conv2(maxInt(...
test/stage1/behavior/bitcast.zig
const std = @import("std"); const expect = std.testing.expect; const expectEqualSlices = std.testing.expectEqualSlices; const mem = std.mem; const builtin = @import("builtin"); const maxInt = std.math.maxInt; // normal comment /// this is a documentation comment /// doc comment line 2 fn emptyFunctionWithComments() v...
test/stage1/behavior/misc.zig
const std = @import("std"); const tests = @import("tests.zig"); const nl = std.cstr.line_sep; pub fn addCases(cases: *tests.RunTranslatedCContext) void { cases.add("array initializer", \\#include <stdlib.h> \\int main(int argc, char **argv) { \\ int a0[4] = {1}; \\ int a1[4] =...
test/run_translated_c.zig
const std = @import("std"); const mem = std.mem; const Allocator = mem.Allocator; const assert = std.debug.assert; const print = std.debug.print; const input = @embedFile("../in/day07.txt"); const AdjacencyList = std.hash_map.StringHashMap(Bag1); const List = std.ArrayList([]const u8); const Queue = s...
src/day07.zig
const std = @import("std"); const mem = std.mem; const Allocator = mem.Allocator; const ArenaAllocator = std.heap.ArenaAllocator; const StreamServer = std.net.StreamServer; const Address = std.net.Address; const File = std.fs.File; const builtin = @import("builtin"); const request = @import("http/request.zig"); const r...
src/routez/server.zig
const std = @import("std"); const mem = std.mem; const GraphemeExtend = @This(); allocator: *mem.Allocator, array: []bool, lo: u21 = 768, hi: u21 = 917999, pub fn init(allocator: *mem.Allocator) !GraphemeExtend { var instance = GraphemeExtend{ .allocator = allocator, .array = try allocator.alloc...
src/components/autogen/DerivedCoreProperties/GraphemeExtend.zig
const std = @import("std"); // Utility functions // /// Read a int from a file pub fn readIntFromFile(comptime T: type, file: std.fs.File) !T { var buf = [_]u8{0} ** @sizeOf(T); _ = try file.readAll(buf[0..]); return std.mem.readIntLittle(T, buf[0..]); } /// write a int n to a file pub fn writeIntToFile(f...
src/util.zig
const std = @import("std"); const mem = std.mem; const math = std.math; const io = std.io; const fs = std.fs; const platform = @import("platform.zig"); const util = @import("util.zig"); const c = @cImport({ @cInclude("signal.h"); // SIGINT }); const Trap = enum(u16) { GETC = 0x20, // get character from keybo...
src/main.zig
pub const WMT_VIDEOIMAGE_SAMPLE_INPUT_FRAME = @as(u32, 1); pub const WMT_VIDEOIMAGE_SAMPLE_OUTPUT_FRAME = @as(u32, 2); pub const WMT_VIDEOIMAGE_SAMPLE_USES_CURRENT_INPUT_FRAME = @as(u32, 4); pub const WMT_VIDEOIMAGE_SAMPLE_USES_PREVIOUS_INPUT_FRAME = @as(u32, 8); pub const WMT_VIDEOIMAGE_SAMPLE_MOTION = @as(u32, 1); pu...
win32/media/windows_media_format.zig
const std = @import("std"); const assert = std.debug.assert; const L = std.unicode.utf8ToUtf16LeStringLiteral; const zwin32 = @import("zwin32"); const w = zwin32.base; const xaudio2 = zwin32.xaudio2; const mf = zwin32.mf; const wasapi = zwin32.wasapi; const xapo = zwin32.xapo; const hrPanic = zwin32.hrPanic; const hrPa...
libs/zxaudio2/src/zxaudio2.zig
const std = @import("std"); const Builder = std.build.Builder; const Pkg = std.build.Pkg; const Day = struct { dir: []const u8, packages: ?[]const Pkg, }; // my packages const pkg_numtheory = Pkg{ .name = "numtheory", .path = .{ .path = "share/zig/numtheory.zig" } }; const pkg_combination = Pkg{ .name = "com...
build.zig
const std = @import("std"); const print = std.debug.print; var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const alloc = &gpa.allocator; const Pair = struct { first: usize, second: usize }; const DataList = std.ArrayList(Pair); pub fn main() !void { defer _ = gpa.deinit(); const inputData = try std.fs.cw...
Day13/day13.zig
const subo = @import("subo.zig"); const std = @import("std"); const testing = std.testing; const math = std.math; fn test__suboti4(a: i128, b: i128) !void { var result_ov: c_int = undefined; var expected_ov: c_int = undefined; var result = subo.__suboti4(a, b, &result_ov); var expected: i128 = simple_s...
lib/std/special/compiler_rt/suboti4_test.zig
const std = @import("std"); const pcx = @import("pcx.zig"); const argsParser = @import("args"); pub fn main() !u8 { const cli_args = argsParser.parseForCurrentProcess(struct { help: bool = false, output: ?[]const u8 = null, pub const shorthands = .{ .h = "help", .o ...
tools/bit-loader/main.zig
const x86_64 = @import("../../index.zig"); const bitjuggle = @import("bitjuggle"); const std = @import("std"); const PageTableIndex = x86_64.structures.paging.PageTableIndex; const SIZE_4KiB_STR: []const u8 = "4KiB"; const SIZE_2MiB_STR: []const u8 = "2MiB"; const SIZE_1GiB_STR: []const u8 = "1GiB"; pub const PageSi...
src/structures/paging/page.zig
const std = @import("std"); const assert = std.debug.assert; const glfw = @import("glfw"); const c = @cImport({ @cInclude("dawn/dawn_proc.h"); @cInclude("dawn_native_mach.h"); }); const objc = @cImport({ @cInclude("objc/message.h"); }); pub const cimgui = @cImport({ @cDefine("CIMGUI_DEFINE_ENUMS_AND_STR...
libs/zgpu/src/zgpu.zig
const std = @import("std"); pub const maxWindows = 8; pub const WindowManager = struct { activeScreenIndex: usize = 0, amountScreens: usize = 0, displayWidth: i32 = 0, displayHeight: i32 = 0, screens: [maxWindows]Screen = undefined, running: bool = false, fn getActiveScreen(self: *Window...
src/wm.zig
const std = @import("std"); const builtin = @import("builtin"); const assert = std.debug.assert; const clap = @import("clap"); const Parser = @import("parser.zig").Parser; const Options = @import("options.zig").Options; const nodes = @import("nodes.zig"); const html = @import("html.zig"); pub fn main() !void { /...
src/main.zig
const std = @import("std"); const mem = std.mem; // Credit to prime31's various zig projects, very useful allocator const ScratchAllocator = struct { allocator: mem.Allocator, backup_allocator: *mem.Allocator, end_index: usize, buffer: []u8, pub fn init(a: *mem.Allocator) ScratchAllocator { ...
src/zt/allocators.zig
const std = @import("std"); const uefi = std.os.uefi; const io = std.io; const Guid = uefi.Guid; const Time = uefi.Time; const Status = uefi.Status; pub const FileProtocol = extern struct { revision: u64, _open: fn (*const FileProtocol, **const FileProtocol, [*:0]const u16, u64, u64) callconv(.C) Status, _...
lib/std/os/uefi/protocols/file_protocol.zig
pub const GLFWglproc = ?fn () callconv(.C) void; pub const struct_GLFWmonitor = opaque {}; pub const GLFWmonitor = struct_GLFWmonitor; pub const struct_GLFWwindow = opaque {}; pub const GLFWwindow = struct_GLFWwindow; pub const struct_GLFWcursor = opaque {}; pub const GLFWcursor = struct_GLFWcursor; pub const GLFWerror...
src/pkg/glfw.zig
const std = @import("std"); const print = std.debug.print; usingnamespace @import("common.zig"); usingnamespace @import("value.zig"); pub const OpCode = enum(u8) { OP_CONSTANT, OP_NOT, OP_NEGATE, OP_NIL, OP_TRUE, OP_FALSE, OP_GET_LOCAL, OP_SET_LOCAL, OP_DEFINE_GLOBAL, OP_SET_GL...
vm/src/chunk.zig
const c = @import("c.zig"); const nk = @import("../nuklear.zig"); const std = @import("std"); const builtin = std.builtin; const debug = std.debug; const heap = std.heap; const math = std.math; const mem = std.mem; const meta = std.meta; const testing = std.testing; pub const Config = c.struct_nk_font_config; pub con...
src/atlas.zig
const std = @import("std"); const assert = std.debug.assert; pub const Computer = struct { rom: [4096]i32, ram: [4096]i32, pos: usize, const OP = enum(u32) { ADD = 1, MUL = 2, RDSV = 3, PRINT = 4, JIT = 5, JIF = 6, CLT = 7, CEQ = 8, ...
2019/p05/computer.zig
pub const Letter = enum { a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, const Self = @This(); pub fn fromChar(comptime c: u8) Self { return switch (c) { 'a','A' => .a, 'b','B' => .b, 'c','C' => .c, ...
src/alphabet.zig
const std = @import("std"); const wasmer = @import("wasmer"); const assert = std.debug.assert; var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); const wat = \\(module \\ (type $mem_size_t (func (result i32))) \\ (type $get_at_t (func (param i32) (result i32))) \...
examples/memory.zig
const std = @import("std"); const artc = @cImport({ @cInclude("art.h"); }); const clibart = @cImport({ @cInclude("src/clibart.c"); }); extern var show_debug: c_int; const art = @import("art.zig"); const Art = art.Art; const testing = std.testing; const a = std.heap.c_allocator; const Lang = enum { c, z, bot...
src/clibart.zig
const std = @import("std"); const assert = std.debug.assert; pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const allocator = gpa.allocator(); var input_file = try std.fs.cwd().openFile("input/10.txt", .{}); defer input_file.close(); var buffe...
src/10_2.zig