code
stringlengths
38
801k
repo_path
stringlengths
6
263
const std = @import("std"); const network = @import("network"); pub const io_mode = .evented; pub fn main() !void { // Make sure async is on if (!std.io.is_async) return error.NO_ASYNC; const allocator = std.heap.page_allocator; // Start the network (only executes code under Windows) try ...
examples/async.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); } //const Grid = @Vector(25, u1); // marche pas vraiment vu les operations qu'on veut f...
2019/day24.zig
const sf = @import("../sfml.zig"); pub const RenderWindow = struct { const Self = @This(); // Constructor/destructor // TODO : choose style of window /// Inits a render window with a size, a bits per pixel (most put 32) and a title /// The window will have the default style pub fn init(size:...
src/sfml/graphics/render_window.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"); p...
src/day02.zig
const std = @import("std"); const lua = @import("lua.zig").lua; const sqlite = @import("sqlite.zig").sqlite; const base16 = @import("base16.zig").standard_base16; const c = @import("card.zig"); const Card = c.Card; const CardSchema = c.CardSchema; const e = @import("engine.zig"); const Engine = e.Engine; const Engine...
engine/src/util.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/12.txt", .{}); defer input_file.close(); var buffe...
src/12_2.zig
const std = @import("std"); const pokemon = @import("pokemon"); const utils = @import("utils"); const constants = @import("gen2-constants.zig"); const search = @import("search.zig"); const fun = @import("../../lib/fun-with-zig/index.zig"); const debug = std.debug; const mem = std.mem; const math = std.math; const comm...
tools/offset-finder/gen2.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const HashMap = std.AutoHashMap(u36, u36); const eql = std.mem.eql; const tokenize = std.mem.tokenize; const parseUnsigned = std.fmt.parseUnsigned; const Mask = struct { on: u36, off: u36, float: u36 }; const u36_max = ~@as(u36, 0); fn parseMask(str: []c...
2020/zig/src/14.zig
const std = @import("std"); const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; test "compile time recursion" { try expect(some_data.len == 21); } var some_data: [@intCast(usize, fibonacci(7))]u8 = undefined; fn fibonacci(x: i32) i32 { if (x <= 1) return 1; return fibonacci(x - ...
test/behavior/eval.zig
const builtin = @import("builtin"); const build_options = @import("build_options"); const std = @import("std"); const json = std.json; const log = std.log; const fs = std.fs; const Sha1 = std.crypto.hash.Sha1; const Base64 = std.base64.url_safe_no_pad.Encoder; // Foilz Archive Util const foilz = @import("archiver.zi...
src/wrapper.zig
const std = @import("std"); const os = std.os; const warn = std.debug.warn; const syspect = @import("syspect"); /// Syscall only points to memory address, instead of directly containing values. /// To edit the ip/port, we need to edit the other process' memory. const sockaddr_rw = @import("memory_rw_netaddress.zig");...
examples/connect_redirector/main.zig
const std = @import("std"); const ini = @import("ini.zig"); const c = @cImport({ @cInclude("ini.h"); }); const Record = extern struct { type: Type, value: Data, const Type = extern enum { nul = 0, section = 1, property = 2, enumeration = 3, }; const Data = ext...
src/lib.zig
const std = @import("std"); const c = @cImport(@cInclude("ed25519.h")); const crypto = std.crypto; const testing = std.testing; export fn @"ed25519_randombytes_unsafe"(ptr: *c_void, len: usize) callconv(.C) void { crypto.random.bytes(@ptrCast([*]u8, ptr)[0..len]); } export fn @"ed25519_hash_init"(ctx: *crypto.ha...
ed25519_donna/ed25519.zig
const std = @import("std"); const builtin = @import("builtin"); const win32 = @import("win32"); const foundation = win32.foundation; const windows = win32.ui.windows_and_messaging; const mem = std.mem; const Allocator = mem.Allocator; const c = @import("c.zig"); const nvg = @import("nanovg"); const gui = @import("gui"...
src/main.zig
pub const WNV_API_MAJOR_VERSION_1 = @as(u32, 1); pub const WNV_API_MINOR_VERSION_0 = @as(u32, 0); //-------------------------------------------------------------------------------- // Section: Types (11) //-------------------------------------------------------------------------------- pub const WNV_NOTIFICATION_TYPE ...
deps/zigwin32/win32/network_management/windows_network_virtualization.zig
const std = @import("std"); const io = std.io; const os = std.os; const Buffer = std.Buffer; const allocator = std.heap.c_allocator; const util = @import("stringUtil.zig"); const TokenizerErrors = error { EndOfStream, StreamTooLong, }; pub const Tokenizer = struct { const Self = this; const delimiter...
src/tokenizer.zig
const std = @import("std"); const os = std.os; const fs = std.fs; const io = std.io; const Allocator = std.mem.Allocator; const XAuth = @This(); family: Family, address: []const u8, number: []const u8, name: []const u8, data: []const u8, pub const Family = enum(u16) { ip_address = 0, localhost = 252, krb...
src/XAuth.zig
const build_options = @import("build_options"); const std = @import("std"); const fs = std.fs; const io = std.io; const os = std.os; const wlr = @import("wlroots"); const flags = @import("flags"); const c = @import("c.zig"); const util = @import("util.zig"); const Server = @import("Server.zig"); const usage: []cons...
source/river-0.1.0/river/main.zig
const std = @import("std"); const fmt = std.fmt; const testing = std.testing; const P384 = @import("../p384.zig").P384; test "p384 ECDH key exchange" { const dha = P384.scalar.random(.Little); const dhb = P384.scalar.random(.Little); const dhA = try P384.basePoint.mul(dha, .Little); const dhB = try P3...
lib/std/crypto/pcurves/tests/p384.zig
const std = @import("std"); const Barr = std.BoundedArray; const fmt = std.fmt; const log = std.log; const mem = std.mem; const os = std.os; const process = std.process; const stdout = std.io.getStdOut(); // 1. ensure test_folders existence // 2. control_sequences 0x00..0x31 and 0x7F // 3. bad_patterns like ' filename...
src/testfolder_gen.zig
const __floatdidf = @import("floatdidf.zig").__floatdidf; const testing = @import("std").testing; fn test__floatdidf(a: i64, expected: f64) !void { const r = __floatdidf(a); try testing.expect(r == expected); } test "floatdidf" { try test__floatdidf(0, 0.0); try test__floatdidf(1, 1.0); try test__...
lib/std/special/compiler_rt/floatdidf_test.zig
const ResultStream = @import("result_stream.zig").ResultStream; const Iterator = @import("result_stream.zig").Iterator; const ParserPath = @import("parser_path.zig").ParserPath; const std = @import("std"); const testing = std.testing; const mem = std.mem; pub const Error = error{OutOfMemory}; pub const ResultTag = e...
src/combn/engine/parser.zig
const kernel = @import("../kernel/kernel.zig"); const log = kernel.log.scoped(.PCI); const TODO = kernel.TODO; const Controller = @This(); const PrivilegeLevel = kernel.PrivilegeLevel; const x86_64 = @import("../kernel/arch/x86_64.zig"); devices: []Device, bus_scan_states: [256]BusScanState, pub var controller: Contr...
src/drivers/pci.zig
const std = @import("std"); const glfw = @import("../mach-glfw/build.zig"); const gpu_dawn = @import("../mach-gpu-dawn/build.zig"); pub const Options = struct { glfw_options: glfw.Options = .{}, gpu_dawn_options: gpu_dawn.Options = .{}, }; fn buildLibrary( exe: *std.build.LibExeObjStep, options: Optio...
libs/zgpu/build.zig
const c = @import("c.zig"); const std = @import("std"); const panic = std.debug.panic; const ArrayList = std.ArrayList; const GeneralPurposeAllocator: type = std.heap.GeneralPurposeAllocator(.{}); fn glfwErrorCallback(err: c_int, description: [*c]const u8) callconv(.C) void { panic("Error: {}\n", .{@as([*:0]con...
src/glfw_platform.zig
const utils = @import("utils"); const georgios = @import("georgios"); const kernel = @import("kernel.zig"); const print = @import("print.zig"); const Allocator = @import("memory.zig").Allocator; const MemoryError = @import("memory.zig").MemoryError; const io = @import("io.zig"); const fs = @import("fs.zig"); pub con...
kernel/ext2.zig
const std = @import("std"); const tenet = @import("tenet.zig"); const Array = tenet.Array; const Tensor = tenet.Tensor; fn readIdx(comptime T: type, alc: *std.mem.Allocator, dirpath: []const u8, filename: []const u8, magic_number: i32, comptime num_dims: comptime_int) !Tensor { // check for the already e...
src/main.zig
const std = @import("std"); const encoder = @import("encoder.zig"); const decoder = @import("decoder.zig"); var globalAllocator: std.mem.Allocator = undefined; var exception: std.ArrayList([]const u8) = undefined; const scoped = std.log.scoped(.WasmBottomProgram); const buffer_size = 128 * 1024; const RestartState = en...
src/wasm-example.zig
const std = @import("std"); const pipe = struct { usingnamespace @import("pipes"); usingnamespace @import("filters"); }; // two context structs (must be pub for cross file access) pub const x = struct { pub var xxx: u16 = 5; pub var aaa: u16 = 50; pub var ar = [_]u64{ 11, 22, 33, 44 }; pub ...
main.zig
const std = @import("std"); const testing = std.testing; const mem = std.mem; const TapeType = dom.TapeType; const simdjzon = @import("simdjzon.zig"); const dom = simdjzon.dom; const ondemand = simdjzon.ondemand; const cmn = @import("common.zig"); const allr = testing.allocator; test "tape build" { const input = ...
src/tests.zig
const std = @import("std"); const deps = @import("./deps.zig"); pub fn build(b: *std.build.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 n...
build.zig
const std = @import("std"); const debug = std.debug; const testing = std.testing; const mem = std.mem; const Allocator = mem.Allocator; const ArrayList = std.ArrayList; const StringHashMap = std.StringHashMap; fn trimStart(slice: []const u8, ch: u8) []const u8 { var i: usize = 0; for (slice) |b| { if ...
src-self-hosted/arg.zig
const builtin = @import("builtin"); const std = @import("std"); const maxInt = std.math.maxInt; fn floatsiXf(comptime T: type, a: i32) T { @setRuntimeSafety(builtin.is_test); const bits = @typeInfo(T).Float.bits; const Z = std.meta.Int(.unsigned, bits); const S = std.meta.Int(.unsigned, bits - @clz(Z,...
lib/std/special/compiler_rt/floatsiXf.zig
const std = @import("std"); const builtin = @import("builtin"); const clap = @import("clap"); const zfetch = @import("zfetch"); const build_options = @import("build_options"); const Dependency = @import("Dependency.zig"); usingnamespace @import("commands.zig"); //pub const io_mode = .evented; pub const zfetch_use_buff...
src/main.zig
const std = @import("std"); const aoc = @import("aoc-lib.zig"); test "validate year" { try aoc.assert(validYear("2002", 1920, 2002)); try aoc.assert(!validYear("2003", 1920, 2002)); } test "validate height" { try aoc.assert(validHeight("60in")); try aoc.assert(validHeight("190cm")); try aoc.assert...
2020/04/aoc.zig
const std = @import("std"); const svd = @import("svd.zig"); const xml = @import("xml.zig"); const assert = std.debug.assert; const ArenaAllocator = std.heap.ArenaAllocator; const Allocator = std.mem.Allocator; const Self = @This(); const Range = struct { begin: u32, end: u32, }; const PeripheralUsesInterrup...
src/Database.zig
const builtin = @import("builtin"); const std = @import("std"); const Os = builtin.Os; const darwin = std.os.darwin; const linux = std.os.linux; const mem = std.mem; const warn = std.debug.warn; const assert = std.debug.assert; const windows = std.os.windows; pub const Location = struct { name: []const u8, ...
src/time.zig
const std = @import("std"); const c = @cImport(@cInclude("vulkan/vulkan.h")); const Result = enum(i32) { Success = @enumToInt(c.VkResult.VK_SUCCESS), NotReady = @enumToInt(c.VkResult.VK_NOT_READY), Timeout = @enumToInt(c.VkResult.VK_TIMEOUT), EventSet = @enumToInt(c.VkResult.VK_EVENT_SET), EventRe...
src/main.zig
const std = @import("std"); const hw = @import("hw/hw.zig"); const mem = std.mem; const Allocator = mem.Allocator; const ArrayList = std.ArrayList; const Cart = @import("cart.zig").Cart; const Reg = @import("cpu/regs.zig").Reg; const Vip = @import("hw/vip.zig").Vip; const Vsu = @import("hw/vsu.zig").Vsu; const MIRRO...
src/bus.zig
const std = @import("std"); usingnamespace @import("../module.zig").prelude; const SampleBuffer = @import("../sample_buffer.zig").SampleBuffer; //; // note: // anti-click is a needless expense if used for a game, // so anti-click defaults to be off // just, dont stop or play sounds from a point that will click ...
src/modules/sample_player.zig
const std = @import("std"); const Handle = windows.HANDLE; const windows = std.os.windows; pub const Layer = enum(c_int) { network = 0, network_forward = 1, flow = 2, socket = 3, reflect = 4, _, }; pub const Flags = enum(u64) { sniff = 0x0001, drop = 0x0002, /// aka read_only r...
src/bindings.zig
const Self = @This(); const std = @import("std"); const assert = std.debug.assert; const wlr = @import("wlroots"); const wl = @import("wayland").server.wl; const server = &@import("main.zig").server; const util = @import("util.zig"); const Box = @import("Box.zig"); const Output = @import("Output.zig"); const Subsur...
source/river-0.1.0/river/LayerSurface.zig
const Self = @This(); const build_options = @import("build_options"); const std = @import("std"); const mem = std.mem; const ascii = std.ascii; const wlr = @import("wlroots"); const wl = @import("wayland").server.wl; const server = &@import("main.zig").server; const util = @import("util.zig"); const InputConfig = @...
source/river-0.1.0/river/InputManager.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day13.txt"); const Coord2 = struct { x: usize, y: usize, }; const Fold = struct { axis: u8, value: usize, }; const Input = struct { dots: std.ArrayList(Coord2), folds: std.ArrayList(Fold), max_x:...
src/day13.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day24.txt"); const Reg = enum(u2) { W = 0, X = 1, Y = 2, Z = 3, }; const Arg = enum(i64) { RW = 100, RX = 101, RY = 102, RZ = 103, _, }; const Opcode = enum(u3) { inp = 0, add = 1...
src/day24.zig
const std = @import("std"); usingnamespace (@import("../machine.zig")); usingnamespace (@import("../util.zig")); const reg = Operand.register; const pred = Operand.registerPredicate; const predRm = Operand.rmPredicate; const sae = Operand.registerSae; const regRm = Operand.registerRm; const imm = Operand.immediate; t...
src/x86/tests/xop.zig
const math = @import("std").math; const fmt = @import("std").fmt; const gmath = @import("gmath.zig").gmath(f64); const invSqrt2 = 0.7071067811865475244008443621; const almostOne = 1.0 - math.f64_epsilon; pub var srgbHighlightClipping = true; pub var srgbDesaturateBlacksAndWhites = true; pub fn Jazbz(comptime T_: typ...
lib/jabz.zig
const std = @import("std"); const subcommands = @import("subcommands.zig"); const shared = @import("shared.zig"); const options = @import("options"); const builtin = @import("builtin"); const zsw = @import("zsw"); pub const enable_tracy = options.trace; pub const tracy_enable_callstack = true; const log = std.log.sco...
src/main.zig
const std = @import("std"); const testing = std.testing; const Regex = @import("libpcre").Regex; const Error = error{OutOfMemory}; const MemoizedRegexes = struct { atxHeadingStart: ?Regex = null, thematicBreak: ?Regex = null, setextHeadingLine: ?Regex = null, autolinkUri: ?Regex = null, autolinkEm...
src/scanners.zig
usingnamespace @import("root").preamble; pub var bsp_task: os.thread.Task = .{ .name = "BSP task", }; const TPIDR_EL1 = os.platform.msr(*os.platform.smp.CoreData, "TPIDR_EL1"); pub const CoreData = struct { pub fn start_monitoring(self: *@This()) void {} pub fn wait(self: *@This()) void { os.pla...
subprojects/flork/src/platform/aarch64/thread.zig
const Garmin = @This(); const std = @import("std"); const mem = std.mem; const testing = std.testing; const Allocator = std.mem.Allocator; const FlightPlan = @import("../FlightPlan.zig"); const Waypoint = @import("../Waypoint.zig"); const format = @import("../format.zig"); const testutil = @import("../test.zig"); con...
src/format/garmin.zig
const std = @import("std"); const io = std.io; const mem = std.mem; const Range = @import("record.zig").Range; const Record = @import("record.zig").Record; const Collection = @This(); const comp_path = "components/autogen"; allocator: *mem.Allocator, kind: []const u8, lo: u21, hi: u21, records: []Record, pub fn ini...
src/Collection.zig
const c = @import("c.zig"); const std = @import("std"); pub const Frame = struct { name: [*c]const u8, pub fn mark(name: ?[*c]const u8) void { c.___tracy_emit_frame_mark(name); } pub fn image(image_ptr: ?*const anyopaque, width: u16, height: u16, offset: u8, flip: c_int) void { c.___t...
src/tracy.zig
const std = @import("std"); /// Counts the amount of `{` tokens insi fn countCaptures(buffer: []const u8) usize { var result: usize = 0; for (buffer) |c| { if (c == '{') result += 1; } return result; } /// Creates a new Template engine based on the given input pub fn Template(comptime fmt: []c...
src/template.zig
const std = @import("std"); const testing = std.testing; const allocator = std.testing.allocator; pub const Bingo = struct { const Board = struct { const SIZE = 5; const Pos = struct { row: usize, col: usize, hit: bool, pub fn init(row: usize, col:...
2021/p04/bingo.zig
const std = @import("std"); /// A First In/First Out ring buffer holding at most `size` elements. pub fn RingBuffer(comptime T: type, comptime size: usize) type { return struct { const Self = @This(); buffer: [size]T = undefined, /// The index of the slot with the first item, if any. ...
src/ring_buffer.zig
const std = @import("std"); const assert = std.debug.assert; const tools = @import("tools"); const MarbleCircle = tools.CircularBuffer(u32); pub fn run(input: []const u8, allocator: std.mem.Allocator) ![2][]const u8 { //const input = "9 players; last marble is worth 25 points"; //const input = "10 players; la...
2018/day09.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); } fn add(p: usize, d: isize) usize { return @intCast(usize, @intCast(isize, p) + d); } pu...
2017/day19.zig
const ImageReader = zigimg.ImageReader; const ImageSeekStream = zigimg.ImageSeekStream; const PixelFormat = zigimg.PixelFormat; const assert = std.debug.assert; const color = zigimg.color; const errors = zigimg.errors; const png = zigimg.png; const std = @import("std"); const testing = std.testing; const zigimg = @impo...
tests/formats/png_basn_test.zig
const std = @import("std"); const assert = std.debug.assert; const image = @import("image.zig"); var alloctr: *std.mem.Allocator = undefined; pub var stdout: std.fs.File.Writer = undefined; pub const ArgError = error{ OpInvalid, NotEnoughArgs, BytesInvalid, FormatInvalid, }; const Op = enum(u8) { ...
src/main.zig
const std = @import("std"); const glfw = @import("glfw.zig"); const vk = @import("vulkan.zig"); const builtin = std.builtin; const fs = std.fs; const math = std.math; const mem = std.mem; const Allocator = mem.Allocator; const ArrayList = std.ArrayList; const BufSet = std.BufSet; const max_frames_in_flight = 2; const...
src/main.zig
const std = @import("std"); const mecha = @import("mecha"); const Parser = mecha.Parser; const oneOf = mecha.oneOf; const discard = mecha.discard; const combine = mecha.combine; const many = mecha.many; const map = mecha.map; const utf8 = mecha.utf8; const ascii = mecha.ascii; const opt = mecha.opt; const ref = mecha....
src/parser.zig
const std = @import("std"); pub const Color = std.debug.TTY.Color; /// Basic output-wrapper with console-escape-codes for supported platforms. /// Convenience-oriented with regards to enabling different levels of output /// API: <stream>Print(), <stream>Colored(), with <stream> being std, debug, error or verbose....
src/console.zig
const macro = @import("pspmacros.zig"); comptime { asm (macro.import_module_start("IoFileMgrForUser", "0x40010000", "36")); asm (macro.import_function("IoFileMgrForUser", "0x3251EA56", "sceIoPollAsync")); asm (macro.import_function("IoFileMgrForUser", "0xE23EEC33", "sceIoWaitAsync")); asm (macro.import...
src/psp/nids/pspiofilemgr.zig
const gpio = @import("gpio.zig"); const mmio = @import("mmio.zig"); const mbox = @import("mbox.zig"); const Registers = struct { data_reg: u32, rsrecr: u32, reserved0: [14]u8, flag_reg: u32, reserved1: [8]u8, integer_bound_rate_divisor: u32, fractal_bound_rate_divisor: u32, line_contro...
src/arm/io/uart.zig
const std = @import("std"); const build_options = @import("build_options"); pub const c = @cImport({ @cInclude("SDL2/SDL.h"); @cInclude("SDL2/SDL_audio.h"); @cInclude("SDL2/SDL_opengl.h"); if (build_options.imgui) { @cDefine("CIMGUI_DEFINE_ENUMS_AND_STRUCTS", ""); @cInclude("cimgui.h")...
src/sdl/bindings.zig
const std = @import("std"); const fs = std.fs; const io = std.io; const info = std.log.info; const print = std.debug.print; const fmt = std.fmt; const utils = @import("utils.zig"); const InputState = enum { rules, my_ticket, other_tickets }; var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const Rules = struc...
day_16/src/main.zig
pub const ComponentTypeEnforcementClientSoH = @as(u32, 1); pub const ComponentTypeEnforcementClientRp = @as(u32, 2); //-------------------------------------------------------------------------------- // Section: Types (22) //-------------------------------------------------------------------------------- pub const Iso...
win32/security/network_access_protection.zig
const std = @import("std"); const testing = std.testing; const allocator = std.testing.allocator; pub const Map = struct { pub const Mode = enum { TEST, RUN }; // what a cheat const State = enum { ALGO, DATA }; const Pos = struct { x: isize, y: isize, pub fn init(x: isize, y: isi...
2021/p20/map.zig
const std = @import("std"); const testing = std.testing; const allocator = std.testing.allocator; pub const Fish = struct { pub const AGE_CYCLE = 7; pub const EXTRA_CYCLE = 2; pub const TOTAL_CYCLE = AGE_CYCLE + EXTRA_CYCLE; count_at_age: [TOTAL_CYCLE]usize, pub fn init() Fish { var self ...
2021/p06/fish.zig
const MessageDB = @import("message-db"); const std = @import("std"); test "Connect, Raw, Default Values" { var pg_connection = try MessageDB.Connect.Raw.PQconnectdb(null); var status = MessageDB.Connect.Raw.PQstatus(pg_connection); try std.testing.expect(status == MessageDB.Connect.Raw.ConnStatusType.CO...
test/automated/connect/raw.zig
const std = @import("std"); const config = @import("config.zig"); const MessageBus = @import("test_message_bus.zig").MessageBus; const vr = @import("vr.zig"); const Replica = vr.Replica; const Journal = vr.Journal; const Storage = vr.Storage; const StateMachine = @import("state_machine.zig").StateMachine; const log ...
src/test_main.zig
const std = @import("std"); const assert = std.debug.assert; const tools = @import("tools"); const Vec2 = tools.Vec2; pub fn run(input_text: []const u8, allocator: std.mem.Allocator) ![2][]const u8 { const ans1 = ans: { var p = Vec2{ .x = 0, .y = 0 }; var d = Vec2{ .x = 1, .y = 0 }; var it...
2020/day12.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const nitori = @import("nitori"); const communication = nitori.communication; const Channel = communication.Channel; const EventChannel = communication.EventChannel; const ng = nitori.graph; const Graph = ng.Graph; cons...
src/audio_graph.zig
const __floattidf = @import("floattidf.zig").__floattidf; const testing = @import("std").testing; fn test__floattidf(a: i128, expected: f64) !void { const x = __floattidf(a); try testing.expect(x == expected); } test "floattidf" { try test__floattidf(0, 0.0); try test__floattidf(1, 1.0); try test...
lib/std/special/compiler_rt/floattidf_test.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day19.txt"); const Point3 = struct { x: i64, y: i64, z: i64, }; const Input = struct { scanners: std.BoundedArray(std.BoundedArray(Point3, 27), 39) = undefined, pub fn init(input_text: []const u8, allo...
src/day19.zig
const std = @import("std"); usingnamespace (@import("../machine.zig")); usingnamespace (@import("../util.zig")); const imm = Operand.immediate; const imm8 = Operand.immediate8; const imm16 = Operand.immediate16; const imm32 = Operand.immediate32; const imm64 = Operand.immediate64; const immSign = Operand.immediateSig...
src/x86/tests/call.zig
const std = @import("std"); const Atomic = std.atomic.Atomic; const utils = @import("../utils.zig"); pub const Lock = extern struct { pub const name = "NtKeyedEvent"; state: Atomic(u32) = Atomic(u32).init(UNLOCKED), const UNLOCKED = 0; const LOCKED = 1 << 0; const WAKING = 1 << 8; const WAIT...
locks/keyed_event_lock.zig
const std = @import("std"); const lib = @import("lib"); const io = std.io; const fs = std.fs; const assert = std.debug.assert; const Allocator = std.mem.Allocator; const ArrayList = std.ArrayListUnmanaged; const HashMap = std.AutoHashMapUnmanaged; const Interpreter = lib.Interpreter; const GraphContext = @This(); str...
src/GraphContext.zig
const std = @import("../../std.zig"); const maxInt = std.math.maxInt; // See https://svnweb.freebsd.org/base/head/sys/sys/_types.h?view=co // TODO: audit pid_t/mode_t. They should likely be i32 and u16, respectively pub const fd_t = c_int; pub const pid_t = c_int; pub const uid_t = u32; pub const gid_t = u32; pub cons...
lib/std/os/bits/freebsd.zig
const std = @import("std"); const fmt = std.fmt; /// Group operations over Edwards25519. pub const Ristretto255 = struct { /// The underlying elliptic curve. pub const Curve = @import("edwards25519.zig").Edwards25519; /// The underlying prime field. pub const Fe = Curve.Fe; /// Field arithmetic mod...
lib/std/crypto/25519/ristretto255.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const assert = std.debug.assert; const testing = std.testing; const leb = std.leb; const mem = std.mem; const wasm = std.wasm; const log = std.log.scoped(.codegen); const Module = @import("../../Module.zig"); const Decl =...
src/arch/wasm/CodeGen.zig
const std = @import("../../std.zig"); const elf = std.elf; const linux = std.os.linux; const mem = std.mem; const maxInt = std.math.maxInt; pub fn lookup(vername: []const u8, name: []const u8) usize { const vdso_addr = std.os.system.getauxval(std.elf.AT_SYSINFO_EHDR); if (vdso_addr == 0) return 0; const e...
lib/std/os/linux/vdso.zig
const std = @import("std"); const getty = @import("../../../lib.zig"); pub fn Visitor(comptime Tuple: type) type { return struct { const Self = @This(); pub usingnamespace getty.de.Visitor( Self, Value, undefined, undefined, undefined, ...
src/de/impl/visitor/tuple.zig
const std = @import("std"); const Src = std.builtin.SourceLocation; // check for a decl named tracy_enabled in root or build_options pub const enabled = blk: { var build_enable: ?bool = null; var root_enable: ?bool = null; const root = @import("root"); if (@hasDecl(root, "tracy_enabled")) { ro...
nativemap/src/tracy.zig
const std = @import("std"); const testing = std.testing; const secret_handshake = @import("secret_handshake.zig"); test "wink for 1" { const expected = &[_]secret_handshake.Signal{.wink}; var actual = try secret_handshake.calculateHandshake(testing.allocator, 1); defer testing.allocator.free(actual); ...
exercises/practice/secret-handshake/test_secret_handshake.zig
const std = @import("std"); const mem = std.mem; const Cased = @This(); allocator: *mem.Allocator, array: []bool, lo: u21 = 65, hi: u21 = 127369, pub fn init(allocator: *mem.Allocator) !Cased { var instance = Cased{ .allocator = allocator, .array = try allocator.alloc(bool, 127305), }; ...
src/components/autogen/DerivedCoreProperties/Cased.zig
const std = @import("std"); const builtin = @import("builtin"); const zwl = @import("zwl.zig"); usingnamespace @import("x11/types.zig"); const Allocator = std.mem.Allocator; const DisplayInfo = @import("x11/display_info.zig").DisplayInfo; const auth = @import("x11/auth.zig"); // A circular buffer for reply events tha...
didot-zwl/zwl/src/x11.zig
const std = @import("std"); const reg = @import("registry.zig"); const id_render = @import("../id_render.zig"); const cparse = @import("c_parse.zig"); const mem = std.mem; const Allocator = mem.Allocator; const CaseStyle = id_render.CaseStyle; const IdRenderer = id_render.IdRenderer; const preamble = \\// This fil...
generator/vulkan/render.zig
pub const MMC_VER = @as(u32, 512); pub const MMC_PROP_CHANGEAFFECTSUI = @as(u32, 1); pub const MMC_PROP_MODIFIABLE = @as(u32, 2); pub const MMC_PROP_REMOVABLE = @as(u32, 4); pub const MMC_PROP_PERSIST = @as(u32, 8); pub const MMCLV_AUTO = @as(i32, -1); pub const MMCLV_NOPARAM = @as(i32, -2); pub const MMCLV_NOICON = @a...
win32/system/mmc.zig
const std = @import("std"); const hzzp = @import("hzzp"); const ssl = @import("zig-bearssl"); const bot_agent = "zigbot9001/0.0.1"; pub const SslTunnel = struct { allocator: *std.mem.Allocator, trust_anchor: ssl.TrustAnchorCollection, x509: ssl.x509.Minimal, client: ssl.Client, tcp_conn: std.fs....
src/request.zig
const std = @import("std"); const print = std.debug.print; const c = @import("./postgres.zig").c; const helpers = @import("./helpers.zig"); const Parser = @import("./postgres.zig").Parser; const ColumnType = @import("./definitions.zig").ColumnType; const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList;...
src/result.zig
const Self = @This(); const std = @import("std"); const lookup_table = [256]u32{ 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, 0...
libs/utils/Cksum.zig
const FarPtr = @import("../far_ptr.zig").FarPtr; // TODO: Enforce descriptor usage rules with the type system. // // See: http://www.delorie.com/djgpp/doc/dpmi/descriptor-rules.html pub const Segment = struct { selector: u16, pub const Register = enum { cs, ds, es, fs, ...
src/dos/dpmi/segment.zig
const std = @import("std"); const display = @import("zbox"); const options = @import("build_options"); const page_allocator = std.heap.page_allocator; const ArrayList = std.ArrayList; pub usingnamespace @import("log_handler.zig"); const bad_char = '%'; const ship_char = '^'; const bullet_char = '.'; const bb_width =...
forks/zbox/examples/invaders.zig
const std = @import("std"); const ast = @import("ast.zig"); const intrinsics = @import("intrinsics.zig"); const mem = @import("gc.zig"); const linereader = @import("linereader.zig"); const SourceLocation = @import("sourcelocation.zig").SourceLocation; const Expr = ast.Expr; const ExprType = ast.ExprType; const ExprValu...
src/interpreter.zig
const testing = @import("std").testing; const xml = @import("xml"); const full = @import("full.zig"); test "full structure" { var doc = try xml.Document.fromString(full.file); defer doc.deinit(); var decode_result = try xml.decode(testing.allocator, full.TestStructure, doc); defer decode_result.deinit(...
test/test_decode.zig
const std = @import("std"); const print = std.debug.print; const math = std.math; const testing = std.testing; const root = @import("main.zig"); usingnamespace @import("vec4.zig"); usingnamespace @import("vec3.zig"); usingnamespace @import("quaternion.zig"); pub const mat4 = Mat4(f32); pub const mat4_f64 = Mat4(f64); ...
src/mat4.zig
const std = @import("std"); const assert = std.debug.assert; pub const Shift = struct { const allocator = std.heap.direct_allocator; // data{guard}{julian}{stamp} => asleep pub const SData = struct { asleep: bool, pub fn init() SData { return SData{ .asleep = ...
2018/p04/shift.zig
const std = @import("std"); const fs = std.fs; const Instruction = struct { op: u8, val: i32, const Self = @This(); pub fn fromString(str: []const u8) !Self { return Self{ .op = str[0], .val = try std.fmt.parseInt(i32, str[1..], 10) }; } }; // I assume som...
2020/src/day_12.zig