code
stringlengths
38
801k
repo_path
stringlengths
6
263
const builtin = @import("builtin"); const TypeInfo = builtin.TypeInfo; const std = @import("std"); const testing = std.testing; fn testTypes(comptime types: []const type) void { inline for (types) |testType| { testing.expect(testType == @Type(@typeInfo(testType))); } } test "Type.MetaType" { test...
test/stage1/behavior/type.zig
const kernel = @import("../../kernel.zig"); const TODO = kernel.TODO; // TODO: make possible to instantiate more than one same-class virtio driver const page_size = kernel.arch.page_size; // **** VIRTIO DRIVER CONFORMANCE **** // A driver MUST conform to three conformance clauses: // - Clause 7.2 [ ] // - One of cla...
src/kernel/arch/riscv64/virtio.zig
const std = @import("std"); const SerialPortConsole = @import("console/SerialPortConsole.zig"); const TextConsole = @import("console/TextConsole.zig"); const Console = @This(); // I chose SerialPortConsole colors, since SerialPortConsole is going to be used even after entering graphics mode. // Also, after entering ...
kernel/Console.zig
const std = @import("std"); const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; const Checksum = @import("./checksum.zig").Checksum; /// A checksum implementation - using the Adler-32 algorithm. pub fn Adler32() type { return struct { const Self = @This(); const ChecksumType = u32...
src/adler32.zig
const std = @import("std"); // dross-zig const Color = @import("../core/color.zig").Color; const Vector2 = @import("../core/vector2.zig").Vector2; const tx = @import("texture.zig"); const TextureId = tx.TextureId; const Texture = tx.Texture; const TextureErrors = tx.TextureErrors; const TextureRegion = @import("texture...
src/renderer/sprite.zig
const std = @import("std"); const os = std.os; const irc = @import("client.zig"); fn initClient() !irc.Client { return try irc.Client.initFromConfig(.{ .server = os.getenv("IRC_SERVER") orelse return error.MissingEnv, .port = os.getenv("IRC_PORT") orelse return error.MissingEnv, .nickname...
src/main.zig
const std = @import("std"); const hyperia = @import("hyperia.zig"); const SpinLock = hyperia.sync.SpinLock; const math = std.math; const time = std.time; const testing = std.testing; pub const Options = struct { // max_concurrent_attempts: usize, // TODO(kenta): use a cancellable semaphore to limit max number of...
circuit_breaker.zig
const std = @import("std"); const print = std.debug.print; const data = @embedFile("../data/day08.txt"); pub fn count_overlap(haystack: []const u8, needle: []const u8) u8 { var count : u8 = 0; for (haystack) |h| { for (needle) |n| { if (h == n) { count += 1; } } } return count; } ...
src/day08.zig
const std = @import("std"); const warn = std.debug.print; const Allocator = std.mem.Allocator; const util = @import("../util.zig"); const c = @cImport({ @cInclude("lmdb.h"); }); var env: *c.MDB_env = undefined; const dbpath = "./db"; pub fn init(allocator: *Allocator) !void { var mdb_ret: c_int = 0; mdb_...
src/db/lmdb.zig
const std = @import("std"); const real_input = @embedFile("day-18_real-input"); const test_input_1 = @embedFile("day-18_test-input-1"); const test_input_2 = @embedFile("day-18_test-input-2"); var allocator: std.mem.Allocator = undefined; pub fn main() !void { std.debug.print("--- Day 18 ---\n", .{}); const t...
day-18.zig
usingnamespace @import("root").preamble; fn PtrCastPreserveCV(comptime T: type, comptime PtrToT: type, comptime NewT: type) type { return switch (PtrToT) { *T => *NewT, *const T => *const NewT, *volatile T => *volatile NewT, *const volatile T => *const volatile NewT, else =...
lib/util/bitfields.zig
const std = @import("std"); const bog = @import("../bog.zig"); const Value = bog.Value; const Vm = bog.Vm; pub fn parse(str: []const u8, vm: *Vm) !*Value { var tokens = std.json.TokenStream.init(str); const token = (try tokens.next()) orelse return error.UnexpectedEndOfJson; return parseInternal(vm, token,...
src/std/json.zig
pub const PR = extern enum(i32) { SET_PDEATHSIG = 1, GET_PDEATHSIG = 2, GET_DUMPABLE = 3, SET_DUMPABLE = 4, GET_UNALIGN = 5, SET_UNALIGN = 6, GET_KEEPCAPS = 7, SET_KEEPCAPS = 8, GET_FPEMU = 9, SET_FPEMU = 10, GET_FPEXC = 11, SET_FPEXC = 12, GET_TIMING = 13, ...
lib/std/os/bits/linux/prctl.zig
const std = @import("std"); const c = @cImport({ @cDefine("LIBXML_TREE_ENABLED", {}); @cDefine("LIBXML_SCHEMAS_ENABLED", {}); @cDefine("LIBXML_READER_ENABLED", {}); @cInclude("libxml/xmlreader.h"); }); const Allocator = std.mem.Allocator; pub const Node = c.xmlNode; pub const Doc = c.xmlDoc; pub const...
src/xml.zig
const std = @import("std"); const tga = @import("tga.zig"); test "" { std.testing.refAllDecls(@This()); std.testing.refAllDecls(Image); } /// Image defines a single image with 32-bit, non-alpha-premultiplied RGBA pixel data. pub const Image = struct { allocator: std.mem.Allocator, pixels: []u8, wi...
src/image.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const zua = @import("zua.zig"); const Lexer = @import("lex.zig").Lexer; const LexErrorContext = zua.lex.LexErrorContext; const Token = @import("lex.zig").Token; const Node = @import("ast.zig").Node; const Tree = @import("ast.zig").Tree; const AutoComptime...
src/parse.zig
const std = @import("std"); pub fn install(step: *std.build.LibExeObjStep, comptime prefix: []const u8) !void { step.subsystem = .Native; // step.linkSystemLibrary("glfw"); // step.linkSystemLibrary("GLESv2"); switch (step.target.getOsTag()) { .linux, .freebsd => { step.linkLibC();...
build.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const print = std.debug.print; const input = @embedFile("../in07.txt"); fn find_bag_def(bag: []const u8) []const u8 { var line_it = std.mem.tokenize(input, "\n"); while (line_it.next()) |line| { if (std.m...
src/day07.zig
const std = @import("std"); const c = @import("../c.zig"); const Global = @import("../global.zig"); const Application = @import("../application/application.zig").Application; const Config = @import("../application/config.zig"); const System = @import("../system/system.zig").System; const UIVulkanContext = @import("ui...
src/ui/ui.zig
pub const PROPSETFLAG_DEFAULT = @as(u32, 0); pub const PROPSETFLAG_NONSIMPLE = @as(u32, 1); pub const PROPSETFLAG_ANSI = @as(u32, 2); pub const PROPSETFLAG_UNBUFFERED = @as(u32, 4); pub const PROPSETFLAG_CASE_SENSITIVE = @as(u32, 8); pub const PROPSET_BEHAVIOR_CASE_SENSITIVE = @as(u32, 1); pub const PID_DICTIONARY = @a...
win32/system/com/structured_storage.zig
const std = @import("std"); const c = @import("internal/c.zig"); const internal = @import("internal/internal.zig"); const log = std.log.scoped(.git); const git = @import("git.zig"); pub const Remote = opaque { /// Free the memory associated with a remote. pub fn deinit(self: *Remote) !void { log.debug...
src/remote.zig
const std = @import("std"); const fs = std.fs; const Dir = fs.Dir; const File = fs.File; const Entry = fs.Dir.Entry; const io = std.io; const json = std.json; const mem = std.mem; const path = std.fs.path; const warn = std.debug.warn; pub const Export = struct { base: []const u8, arena: std.heap.ArenaAllocato...
src/pkg/exports/exports.zig
const msgpack = @import("fileformats/msgpack.zig"); const std = @import("std"); const main = @import("main.zig"); const math = @import("math.zig"); pub const ActorKinds = enum(u4) { Player, Puppet, Enemy }; pub const Vec3 = struct { x: f32 = 0, y: f32 = 0, z: f32 = 0, }; pub const Sprite = struct { ...
src/level.zig
const std = @import("std"); usingnamespace @import("imgui"); const ts = @import("tilescript.zig"); const upaya = @import("upaya"); const files = @import("filebrowser"); const stb = @import("stb"); // used to fill the ui while we are getting input for loading/resizing var temp_state = struct { tile_size: usize = 1...
tilescript/menu.zig
const std = @import("std"); pub const AdapterType = enum { discrete_gpu, integrated_gpu, cpu, unknown, }; pub const AddressMode = enum { repeat, mirror_repeat, clamp_to_edge, }; pub const BackendType = enum { webgpu, d3d11, d3d12, metal, vulkan, opengl, opengl_...
src/enums.zig
pub const GUID_DEVINTERFACE_PWM_CONTROLLER = Guid.initString("60824b4c-eed1-4c9c-b49c-1b961461a819"); pub const IOCTL_PWM_CONTROLLER_GET_INFO = @as(u32, 262144); pub const IOCTL_PWM_CONTROLLER_GET_ACTUAL_PERIOD = @as(u32, 262148); pub const IOCTL_PWM_CONTROLLER_SET_DESIRED_PERIOD = @as(u32, 294920); pub const IOCTL_PWM...
win32/devices/pwm.zig
const std = @import("../../std.zig"); const builtin = @import("builtin"); const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; const process = std.process; const mem = std.mem; const NativePaths = @This(); const NativeTargetInfo = std.zig.system.NativeTargetInfo; include_dirs: ArrayList([:0]u8), lib_...
lib/std/zig/system/NativePaths.zig
const std = @import("std"); const aoc = @import("aoc-lib.zig"); const HH = struct { pub const Op = enum(u8) { acc, jmp, nop }; const Inst = struct { op: Op, arg: i64 }; code: []Inst, ip: isize = 0, acc: i64 = 0, alloc: std.mem.Allocator, pub fn fromInput(inp: anytype, alloc: std.mem.Alloca...
2020/08/aoc.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/day03.txt"); //...
src/day03.zig
const game = @import("game.zig"); /// Simple analyzer which counts wins and losses pub const WinLossAnalyzer = struct { // number of total turns turns : usize , // number of games lost losses : usize , // number of games won wins : usize , pub fn init() @This() { return @This() {.w...
src/analyze.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/day01.txt"); p...
src/day01.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const print = std.debug.print; const input = @embedFile("../input/day18.txt"); const Operation = enum(u2) { None, Add, Multiply, }; const Calculator = struct { const Frame = struct { accum: u64 = ...
src/day18.zig
const std = @import("std"); const warn = std.debug.warn; const wgi = @import("WindowGraphicsInput/WindowGraphicsInput.zig"); const window = wgi.window; const input = wgi.input; const image = wgi.image; const c = wgi.c; const Constants = wgi.Constants; const vertexarray = wgi.vertexarray; const buffer = wgi.buffer; con...
src/Demo3.zig
const os = @import("root").os; pub const InterruptState = bool; pub fn get_and_disable_interrupts() InterruptState { // Get interrupt mask flag var daif = asm volatile("MRS %[daif_val], DAIF" : [daif_val] "=r" (-> u64)); // Set the flag asm volatile("MSR DAIFSET, 2" ::: "memory"); // Check if it was set...
src/platform/aarch64/interrupts.zig
const std = @import("std"); const math = std.math; const zp = @import("zplay"); const dig = zp.deps.dig; const nvg = zp.deps.nvg; const nsvg = zp.deps.nsvg; var font_normal: i32 = undefined; var font_bold: i32 = undefined; var font_icons: i32 = undefined; var font_emoji: i32 = undefined; var images: [12]nvg.Image = un...
examples/vector_graphics.zig
const std = @import("std"); const c = @import("c.zig").c; const glfw = @import("glfw"); const theme = @import("theme.zig"); pub fn main() !void { std.debug.print("-*- zig imgui template -*-\n", .{}); var font: *c.ImFont = undefined; var run: bool = true; var display_size = c.ImVec2{ .x = 1280...
src/main.zig
const stdx = @import("stdx"); const NodeRef = @import("ui.zig").NodeRef; const widget = @import("widget.zig"); const WidgetUserId = widget.WidgetUserId; const WidgetTypeId = widget.WidgetTypeId; const WidgetKey = widget.WidgetKey; const WidgetVTable = widget.WidgetVTable; pub const FrameId = u32; pub const NullFrame...
ui/src/frame.zig
const std = @import("std"); const build = std.build; const ArrayList = std.ArrayList; const fmt = std.fmt; const mem = std.mem; const fs = std.fs; const warn = std.debug.warn; pub const RunTranslatedCContext = struct { b: *build.Builder, step: *build.Step, test_index: usize, test_filter: ?[]const u8, ...
test/src/run_translated_c.zig
const std = @import("../std.zig"); const assert = std.debug.assert; const testing = std.testing; const mem = std.mem; const Token = std.zig.Token; pub const TokenIndex = usize; pub const NodeIndex = usize; pub const Tree = struct { /// Reference to externally-owned data. source: []const u8, token_ids: []c...
lib/std/zig/ast.zig
const builtin = @import("builtin"); const std = @import("../std.zig"); const io = std.io; const meta = std.meta; const trait = std.trait; const DefaultPrng = std.rand.DefaultPrng; const expect = std.testing.expect; const expectError = std.testing.expectError; const mem = std.mem; const fs = std.fs; const File = std.fs....
lib/std/io/test.zig
const aoc = @import("../aoc.zig"); const std = @import("std"); const Command = union(enum) { // RotateBased tables for password.len = 8 const rotate_based_table = [_]u8 { 7, 6, 5, 4, 2, 1, 0, 7 }; const inverse_rotate_based_table = [_]u8 { 1, 1, 6, 2, 7, 3, 0, 4 }; SwapPosition: struct { pos_x: u8, po...
src/main/zig/2016/day21.zig
const std = @import("std"); const mem = std.mem; const testing = std.testing; const c = @import("c.zig").c; const Error = @import("errors.zig").Error; const getError = @import("errors.zig").getError; const GammaRamp = @import("GammaRamp.zig"); const VideoMode = @import("VideoMode.zig"); const Monitor = @This(); han...
glfw/src/Monitor.zig
const testing = @import("std.zig").testing; /// Wasm instruction opcodes /// /// All instructions are defined as per spec: /// https://webassembly.github.io/spec/core/appendix/index-instructions.html pub const Opcode = enum(u8) { @"unreachable" = 0x00, nop = 0x01, block = 0x02, loop = 0x03, @"if" =...
lib/std/wasm.zig
const color = @import("./color/color.zig"); /// A Point is an X, Y coordinate pair. The axes increase right and down. pub const Point = struct { x: isize, y: isize, pub fn init(x: isize, y: isize) Point { return Point{ .x = x, .y = y }; } pub fn add(p: Point, q: Point) Point { ret...
src/image.zig
const sg = @import("sokol").gfx; // // #version:1# (machine generated, don't edit!) // // Generated by sokol-shdc (https://github.com/floooh/sokol-tools) // // Cmdline: sokol-shdc --input .\data\shaders\default.glsl --output .\src\default.glsl.zig --slang glsl330:hlsl5:metal_macos -f sokol_zig // // Overview: // //...
src/default.glsl.zig
const std = @import("std"); const expect = std.testing.expect; const math = std.math; const pi = std.math.pi; const e = std.math.e; const Vector = std.meta.Vector; const epsilon = 0.000001; test "floating point comparisons" { try testFloatComparisons(); comptime try testFloatComparisons(); } fn testFloatComp...
test/behavior/floatop.zig
const std = @import("std"); const Client = @import("../Client.zig"); const util = @import("../util.zig"); const log = std.log.scoped(.zCord); const Heartbeat = @This(); handler: union(enum) { thread: *ThreadHandler, callback: CallbackHandler, }, pub const Message = enum { start, ack, stop, deinit }; pub cons...
src/Client/Heartbeat.zig
const std = @import("std"); const std_json = @import("std-json.zig"); const debug_buffer = std.builtin.mode == .Debug; pub fn streamJson(reader: anytype) StreamJson(@TypeOf(reader)) { return .{ .reader = reader, .parser = std_json.StreamingParser.init(), .element_number = 0, ._ro...
src/util.zig
pub const DISPID_EVENT_ON_STATE_CHANGED = @as(u32, 5); pub const DISPID_EVENT_ON_TERMINATION = @as(u32, 6); pub const DISPID_EVENT_ON_CONTEXT_DATA = @as(u32, 7); pub const DISPID_EVENT_ON_SEND_ERROR = @as(u32, 8); //-------------------------------------------------------------------------------- // Section: Types (6) ...
win32/system/remote_assistance.zig
pub const WIA_DIP_DEV_ID = @as(u32, 2); pub const WIA_DIP_VEND_DESC = @as(u32, 3); pub const WIA_DIP_DEV_DESC = @as(u32, 4); pub const WIA_DIP_DEV_TYPE = @as(u32, 5); pub const WIA_DIP_PORT_NAME = @as(u32, 6); pub const WIA_DIP_DEV_NAME = @as(u32, 7); pub const WIA_DIP_SERVER_NAME = @as(u32, 8); pub const WIA_DIP_REMOT...
win32/devices/image_acquisition.zig
const Regex = @import("regex.zig").Regex; const debug = @import("std").debug; const Parser = @import("parse.zig").Parser; const re_debug = @import("debug.zig"); const std = @import("std"); const FixedBufferAllocator = std.heap.FixedBufferAllocator; const mem = std.mem; // Debug global allocator is too small for our t...
src/regex_test.zig
const std = @import("std"); const testing = std.testing; const allocator = std.heap.page_allocator; pub const Puzzle = struct { said: std.AutoHashMap(usize, usize), turn: usize, last: usize, progress: bool, pub fn init(progress: bool) Puzzle { var self = Puzzle{ .said = std.Au...
2020/p15/puzzle.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 addcarryxU64 is an addition with carry. /// Postconditions: /// out1 = (arg1 + arg2 + arg3) mod 2^64 /// out2 = ⌊(arg1 + arg2 + arg3)...
fiat-zig/src/p224_64.zig
const sf = @import("../sfml.zig"); pub const RectangleShape = struct { const Self = @This(); // Constructor/destructor /// Creates a rectangle shape with a size. The rectangle will be white pub fn init(size: sf.Vector2f) !Self { var rect = sf.c.sfRectangleShape_create(); if (rect == ...
src/sfml/graphics/rectangle_shape.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const game = @import("game.zig"); const bot_trivial = @import("bot_trivial.zig"); const bot_rand = @import("bot_random.zig"); fn playASingleGame(turnLimit: u32, alloc: *Allocator, rng: *std.rand.Xoroshiro128) !game.GameState { const bot = game.BotCo...
src/main.zig
const std = @import("std"); const Target = std.Target; const llvm = @import("llvm.zig"); pub const FloatAbi = enum { Hard, Soft, SoftFp, }; /// TODO expose the arch and subarch separately pub fn isArmOrThumb(self: Target) bool { return switch (self.getArch()) { .arm, .armeb, .a...
src-self-hosted/util.zig
const std = @import("std"); const TestContext = @import("../../src/test.zig").TestContext; const linux_arm = std.zig.CrossTarget{ .cpu_arch = .arm, .os_tag = .linux, }; pub fn addCases(ctx: *TestContext) !void { { var case = ctx.exe("linux_arm hello world", linux_arm); // Regular old hello...
test/stage2/arm.zig
const std = @import("std"); const File = @import("File.zig"); const Process = @import("Process.zig"); const Thread = @import("Thread.zig"); const P = @import("Memory.zig").P; const T = @import("types.zig"); pub const handler = switch (std.builtin.arch) { .powerpc => handlers.powerpc, .x86_64 => handlers.x86_6...
src/syscall.zig
usingnamespace @import("root").preamble; pub fn renderBitmapFont( comptime f: anytype, background_color: lib.graphics.color.Color, foreground_color: lib.graphics.color.Color, comptime pixel_format: lib.graphics.pixel_format.PixelFormat, ) renderedFontType(f, pixel_format) { var result: renderedFont...
lib/graphics/font_renderer.zig
const token = @import("./lang/token.zig"); const colors = @import("./term/colors.zig"); const Colors = colors.Color; const builtin = @import("builtin"); const parser = @import("./lang/parser.zig"); const cli = @import("./cli.zig"); const std = @import("std"); const w = Colors.white; const d = Colors.red; const c = Colo...
src/log.zig
pub const NSVG_PAINT_NONE: c_int = 0; pub const NSVG_PAINT_COLOR: c_int = 1; pub const NSVG_PAINT_LINEAR_GRADIENT: c_int = 2; pub const NSVG_PAINT_RADIAL_GRADIENT: c_int = 3; pub const enum_NSVGpaintType = c_uint; pub const NSVG_SPREAD_PAD: c_int = 0; pub const NSVG_SPREAD_REFLECT: c_int = 1; pub const NSVG_SPREAD_REPE...
src/deps/nanosvg/c.zig
const std = @import("std"); const mem = std.mem; const testing = std.testing; pub const generator = @import("generator.zig"); pub const parser = @import("parser.zig"); pub const tokenizer = @import("tokenizer.zig"); test { testing.refAllDecls(@This()); } const Allocator = mem.Allocator; const Generator = generat...
src/lib.zig
const c = @import("c.zig"); const mem = @import("std").mem; const math = @import("std").math; const debug = @import("std").debug; const builtin = @import("builtin"); const OpenGLHasDrawWithBaseVertex = @hasField(c, "IMGUI_IMPL_OPENGL_ES2") or @hasField(c, "IMGUI_IMPL_OPENGL_ES3"); // OpenGL Data var g_GlslVersion...
examples/imgui-dice-roller/src/gl3_impl.zig
const std = @import("std"); const testing = std.testing; const Allocator = std.mem.Allocator; /// Wrapping map over a map of keys and values /// that provides an easy way to free all its memory. pub const KeyValueMap = struct { /// inner map map: MapType, const MapType = std.StringHashMapUnmanaged([]const...
src/url.zig
const std = @import("std"); const io = std.io; pub fn length(sample_rate: u32, frame_length_msec: u8) u16 { return @intCast(u16, sample_rate / 1000) * frame_length_msec; } pub fn shift(sample_rate: u32, frame_shift_msec: u8) u16 { return @intCast(u16, sample_rate / 1000) * frame_shift_msec; } pub const Frame...
src/dsp/frame.zig
const std = @import("std"); const testing = std.testing; const zupnp = @import("zupnp"); const SUT = struct { const dest = "/endpoint"; const Endpoint = struct { last_message: []const u8, pub fn prepare(self: *Endpoint, _: void) !void { self.last_message = try testing.allocator.al...
test/web/test_post_requests.zig
const builtin = @import("builtin"); const std = @import("std"); const day24_compiled = @import("day24_compiled.zig"); const input = @import("input.zig"); pub fn run(stdout: anytype) anyerror!void { if (builtin.mode == .Debug) { var program = std.BoundedArray(Op, 252).init(0) catch unreachable; { ...
src/day24.zig
const std = @import("std"); const assert = std.debug.assert; const panic = std.debug.panic; const testing = std.testing; const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const ArenaAllocator = std.heap.ArenaAllocator; const AutoHashMap = std.AutoHashMap; /// Handle is like an uniq Id, which is use...
src/main.zig
const assert = std.debug.assert; const std = @import("std"); const testing = std.testing; const zigimg = @import("zigimg"); const image = zigimg.image; const Image = image.Image; const color = zigimg.color; const PixelFormat = zigimg.PixelFormat; const helpers = @import("helpers.zig"); test "Create Image Bpp1" { c...
tests/image_test.zig
const std = @import("std"); const builtin = @import("builtin"); const Builder = std.build.Builder; const Step = std.build.Step; pub fn addStaticLibrary( b: *Builder, app: *std.build.LibExeObjStep, comptime path: []const u8, use_vulkan_sdk: bool, enable_tracing: bool, ) *std.build.LibExeObjStep { ...
build.zig
const std = @import("std"); const builtin = @import("builtin"); const math = std.math; var gpa = std.heap.GeneralPurposeAllocator(.{}){}; var global_allocator = gpa.allocator(); const solar_mass = 4.0 * math.pi * math.pi; const year = 365.24; const Planet = struct { x: f64, y: f64, z: f64, vx: f64, ...
bench/algorithm/nbody/1.zig
pub const Entity = struct { name: []const u8, value: Value, pub const Value = union(enum) { Rune: usize, Rune2: [2]usize, }; pub fn init(name: []const u8, value: Value) Entity { return Entity{ .name = name, .value = value }; } }; /// we are defining all entity value on ...
src/html/entity.zig
const mem = @import("std").mem; const Allocator = mem.Allocator; const assert = @import("std").debug.assert; extern const __heap_start: usize; extern const __heap_phys_start: *usize; fn alignPageAllocLen(full_len: usize, len: usize, len_align: u29) usize { const aligned_len = mem.alignAllocLen(full_len, len, len...
kernel/src/vm/page_frame_manager.zig
usingnamespace @import("std").zig.c_builtins; pub const FMOD_BOOL = c_int; pub const struct_FMOD_SYSTEM = opaque {}; pub const FMOD_SYSTEM = struct_FMOD_SYSTEM; pub const struct_FMOD_SOUND = opaque {}; pub const FMOD_SOUND = struct_FMOD_SOUND; pub const struct_FMOD_CHANNELCONTROL = opaque {}; pub const FMOD_CHANNELCONT...
src/fmod.zig
const std = @import("std"); const string = []const u8; const zfetch = @import("zfetch"); const UrlValues = @import("UrlValues"); const extras = @import("extras"); const shared = @import("./shared.zig"); pub fn AllOf(comptime xs: []const type) type { var fields: []const std.builtin.TypeInfo.StructField = &.{}; ...
src/internal.zig
const std = @import("std"); const debug = std.debug; const assert = debug.assert; const mem = std.mem; const os = std.os; // used for sleep, and other, it may be removed // to relax libC needs const c = @cImport({ @cInclude("stdio.h"); @cInclude("unistd.h"); @cInclude("signal.h"); @cInclude("time.h");...
iotmonitor.zig
const std = @import("std"); const eql = std.meta.eql; const Allocator = std.mem.Allocator; const Arena = std.heap.ArenaAllocator; const assert = std.debug.assert; const panic = std.debug.panic; const init_codebase = @import("init_codebase.zig"); const initCodebase = init_codebase.initCodebase; const initBuiltins = ini...
src/semantic_analyzer.zig
const std = @import("std"); fn root() []const u8 { return std.fs.path.dirname(@src().file) orelse "."; } fn pathJoinRoot(comptime components: []const []const u8) []const u8 { var ret = root(); inline for (components) |component| ret = ret ++ std.fs.path.sep_str ++ component; return ret; } co...
libs/libgit2/libgit2.zig
const std = @import("std"); const c = @import("c.zig"); pub const snd = struct { /// log.crit({first}: {result}); pub fn check(log: anytype, first: []const u8, result: i32) void { log.crit("{s}: {s}", .{ first, snd.strerror(result) }); } /// snd_sterror pub fn strerror(errnum: i32) ?[]con...
src/native/alsalib.zig
const std = @import("std"); const debug = std.debug; const mem = std.mem; const testing = std.testing; const unicode = std.unicode; const WBP = @import("../components.zig").WordBreakProperty; const CodePoint = @import("CodePoint.zig"); const CodePointIterator = CodePoint.CodePointIterator; const Emoji = @import("../co...
src/segmenter/Word.zig
const std = @import("std"); const builtin = @import("builtin"); const assert = std.debug.assert; const mem = std.mem; const net = std.net; const os = std.os; const linux = os.linux; const testing = std.testing; const io_uring_params = linux.io_uring_params; const io_uring_sqe = linux.io_uring_sqe; const io_uring_cqe =...
src/v0/main.zig
const std = @import("std"); const testing = std.testing; const expect = testing.expect; const expectEqual = testing.expectEqual; const expectApproxEqRel = testing.expectApproxEqRel; pub const Vector2Int = packed struct { x: i32, y: i32, pub fn init(x: i32, y: i32) Vector2Int { return .{ .x = x, .y...
src/vector2_int.zig
const std = @import("std"); const math = @import("std").math; const Mat3 = @import("mat3.zig").Mat3; const Mat4 = @import("mat4.zig").Mat4; const utils = @import("utils.zig"); const Vec3 = @import("vec3.zig").Vec3; pub const quat_identity = Quat.create(0, 0, 0, 1); pub const quat_zero = Quat.create(0, 0, 0, 0); pub c...
src/quat.zig
pub const rune_error: u32 = 0xfffd; pub const max_rune: u32 = 0x10ffff; pub const rune_self: u32 = 0x80; const surrogate_min: u32 = 0xD800; const surrogate_max: u32 = 0xDFFF; const t1: u32 = 0x00; // 0000 0000 const tx: u32 = 0x80; // 1000 0000 const t2: u32 = 0xC0; // 1100 0000 const t3: u32 = 0xE0; // 1110 0000 con...
src/unicode/utf8/index.zig
const sg = @import("sokol").gfx; const sapp = @import("sokol").app; const sgapp = @import("sokol").app_gfx_glue; const stm = @import("sokol").time; const sdtx = @import("sokol").debugtext; const std = @import("std"); const fmt = @import("std").fmt; fn script() void { _ = say(.{ .o = "rack", .m = ...
src/dialogtest.zig
const builtin = @import("builtin"); const std = @import("std"); const os = @import("windows.zig"); const dxgi = @import("dxgi.zig"); const dcommon = @import("dcommon.zig"); const HRESULT = os.HRESULT; const ITextFormat = @import("dwrite.zig").ITextFormat; const IWICBitmapSource = @import("wincodec.zig").IBitmapSource; ...
src/windows/d2d1.zig
const inputFile = @embedFile("./input/day12.txt"); const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const Str = []const u8; const BitSet = std.DynamicBitSet; const StrMap = std.StringHashMap; const assert = std.debug.assert; const tokenize = std.mem.tokenize; const prin...
src/day12.zig
const std = @import("std"); const mem = std.mem; const net = std.net; const os = std.os; const time = std.time; const IO = @import("tigerbeetle-io").IO; const http = @import("http"); fn IoOpContext(comptime ResultType: type) type { return struct { frame: anyframe = undefined, result: ResultType = u...
examples/async_tcp_echo_client_timeout.zig
const std = @import("std"); const use_test_input = false; const filename = if (use_test_input) "day-10_test-input" else "day-10_real-input"; const line_count = if (use_test_input) 10 else 94; pub fn main() !void { std.debug.print("--- Day 10 ---\n", .{}); var scores_buffer: [1024 * 1024]u8 = undefined; v...
day-10.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArenaAllocator = std.heap.ArenaAllocator; const mustache = @import("../mustache.zig"); const Element = mustache.Element; const ParseError = mustache.ParseError; const ParseErrorDetail = mustache.ParseErrorDetail; const TemplateOptions = mustache.o...
src/parsing/parser.zig
const std = @import("std"); const reserved_chars = &[_]u8 { '!', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', ':', ';', '=', '?', '@', '[', ']', }; /// Returns a URI from a path, caller owns the memory allocated with `allocator` pub fn fromPath(allocator: *std.mem.Allocator, path: []const u8) ![]con...
src/uri.zig
const std = @import("std"); const builtin = @import("builtin"); const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const expectError = std.testing.expectError; var global_x: i32 = 1; test "simple coroutine suspend and resume" { var frame = async simpleAsyncFn(); expect(global_x ==...
test/stage1/behavior/async_fn.zig
const std = @import("std"); const expect = std.testing.expect; const Value = union(enum) { Int: u64, Array: [9]u8, }; const Agg = struct { val1: Value, val2: Value, }; const v1 = Value{ .Int = 1234 }; const v2 = Value{ .Array = [_]u8{3} ** 9 }; const err = @as(anyerror!Agg, Agg{ .val1 = v1, ...
test/stage1/behavior/union.zig
const std = @import("std"); const json_std = @import("json/std.zig"); pub const path = @import("json/path.zig"); const log = std.log.scoped(.zCord); const debug_buffer = std.builtin.mode == .Debug; pub fn Formatter(comptime T: type) type { return struct { data: T, pub fn format(self: @This(), com...
src/json.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const sokol = @import("sokol/sokol.zig"); const sg = sokol.gfx; const app = sokol.app; usingnamespace @import("math.zig"); const Texture = @import("texture.zig").Texture; const Vertex = @import("gfx.zig").Vertex; const shader = @import("default.glsl.zi...
src/sprite_batcher.zig
const std = @import("std"); pub fn main() void { // Take a good look at the array type to which we're coercing // the zen12 string (the REAL nature of strings will be // revealed when we've learned some additional features): const zen12: *const [21]u8 = "Memory is a resource."; // // It would...
exercises/054_manypointers.zig
const std = @import("std"); const fmt = std.fmt; const testing = std.testing; const P256 = @import("p256.zig").P256; test "p256 ECDH key exchange" { const dha = P256.scalar.random(.Little); const dhb = P256.scalar.random(.Little); const dhA = try P256.basePoint.mul(dha, .Little); const dhB = try P256...
lib/std/crypto/pcurves/tests.zig
const c = @import("c.zig"); const nk = @import("../nuklear.zig"); const std = @import("std"); const mem = std.mem; const testing = std.testing; /// Same as `beginTitled` but instead of taking a `name` which the caller needs to ensure /// is a unique string, this function generates a unique name for each unique type p...
src/window.zig
const std = @import("std"); //-------------------------------------------------------------------------------------------------- pub fn is_winning_board(board: [5][5]?u32) bool { // Check if entire row is cleared for (board) |row| { var is_row_empty = true; for (row) |cell| { if (ce...
src/day04.zig
const std = @import("std"); const assert = std.debug.assert; const L = std.unicode.utf8ToUtf16LeStringLiteral; const zwin32 = @import("zwin32"); const w = zwin32.base; const d3d12 = zwin32.d3d12; const d2d1 = zwin32.d2d1; const dwrite = zwin32.dwrite; const hrPanic = zwin32.hrPanic; const hrPanicOnFail = zwin32.hrPanic...
samples/vector_graphics_test/src/vector_graphics_test.zig