code
stringlengths
38
801k
repo_path
stringlengths
6
263
const FrameBuffer = @import("framebuffer.zig").FrameBuffer; const Position = @import("framebuffer.zig").Position; const Color = @import("framebuffer.zig").Color; const assert = @import("std").debug.assert; pub const Direction = enum { Horizontal, Vertical }; const stdout = @import("std").io.getStdOut().writer(); //...
kernel/renderer.zig
const std = @import("std"); const DW = std.dwarf; const testing = std.testing; /// The condition field specifies the flags neccessary for an /// Instruction to be executed pub const Condition = enum(u4) { /// equal eq, /// not equal ne, /// unsigned higher or same cs, /// unsigned lower ...
src-self-hosted/codegen/arm.zig
const std = @import("std"); const expect = std.testing.expect; const Allocator = std.mem.Allocator; const Error = Allocator.Error; //Experiment with different degrees. //Exercise: why can't `t = 1`? const t = 2; pub fn Node(comptime T: type) type { return struct { n: usize, leaf: bool, key: [2 * t]T, c: [2 * t]?*...
search_trees/b_tree_search.zig
const std = @import("std"); var a: *std.mem.Allocator = undefined; const stdout = std.io.getStdOut().writer(); //prepare stdout to write in const Op = enum { acc, jmp, nop, invalid, pub fn init(op: []const u8) Op { if (std.mem.eql(u8, op, "acc")) { return Op.acc; } else...
day-08/part-2/lelithium.zig
pub nakedcc fn _aullrem() void { @setRuntimeSafety(false); asm volatile ( \\.intel_syntax noprefix \\ \\ push ebx \\ mov eax,dword ptr [esp+14h] \\ or eax,eax \\ jne L1a \\ mov ...
std/special/compiler_rt/aullrem.zig
const std = @import("std"); const res = @import("resources.zig"); const mem = std.mem; const Logo = res.Logo; const OsEnum = res.OsEnum; pub fn getlogo(allocator: *mem.Allocator, os_id: anytype, colorset: res.Colors) !Logo { const ansi: res.Colors = colorset; var id: OsEnum = undefined; if (@TypeOf(os_id...
src/logos.zig
const std = @import("std"); const time = @import("../time.zig"); const platform = @import("../platform.zig"); const vfs = @import("../vfs.zig"); const util = @import("../util.zig"); const RefCount = util.RefCount; const Node = vfs.Node; const File = vfs.File; const FileList = std.ArrayList(?File); // These **MUST**...
kernel/fs/tmpfs.zig
const std = @import("std"); const util = @import("util"); pub fn Grid(comptime grid: anytype) type { comptime std.debug.assert(grid.len > 0 and grid[0].len > 0); comptime std.debug.assert(@TypeOf(grid) == [grid.len][grid[0].len]u8); return struct { buf: [2][height][width]u8 = comptime blk: { ...
2020/seat_grid.zig
const std = @import("std"); const expect = std.testing.expect; // Try toggling these const simulate_fail_download = false; const simulate_fail_file = false; const suspend_download = true; const suspend_file = true; pub fn main() void { _ = async amainWrap(); // This simulates an event loop if (suspend_fil...
examples/async_functions/typical_async_await_original.zig
const std = @import("std"); const debug_enabled = std.meta.globalOption("zpng_debug", bool) orelse (@import("builtin").mode == .Debug); fn debug(comptime level: @TypeOf(.x), comptime format: []const u8, args: anytype) void { if (debug_enabled) { @field(std.log.scoped(.zpng), @tagName(level))(format, a...
zpng.zig
const std = @import("std"); const interop = @import("../interop.zig"); const iup = @import("../iup.zig"); const Impl = @import("../impl.zig").Impl; const CallbackHandler = @import("../callback_handler.zig").CallbackHandler; const debug = std.debug; const trait = std.meta.trait; const Element = iup.Element; const H...
src/elements/message_dlg.zig
pub const WCM_API_VERSION_1_0 = @as(u32, 1); pub const WCM_UNKNOWN_DATAPLAN_STATUS = @as(u32, 4294967295); pub const WCM_MAX_PROFILE_NAME = @as(u32, 256); pub const NET_INTERFACE_FLAG_NONE = @as(u32, 0); pub const NET_INTERFACE_FLAG_CONNECT_IF_NEEDED = @as(u32, 1); //---------------------------------------------------...
deps/zigwin32/win32/network_management/windows_connection_manager.zig
const std = @import("std"); const Client = @import("client.zig").Client; const MAX_SHM_POOLS = 512; var SHM_POOLS: [MAX_SHM_POOLS]ShmPool = undefined; pub const ShmPool = struct { index: usize, in_use: bool = false, fd: i32, data: []align(4096) u8, wl_shm_pool_id: u32, ref_count: usize, cl...
src/shm_pool.zig
const std = @import("std"); const getty = @import("../../../lib.zig"); pub fn Visitor(comptime Struct: type) type { return struct { const Self = @This(); pub usingnamespace getty.de.Visitor( Self, Value, undefined, undefined, undefined, ...
src/de/impl/visitor/struct.zig
/// The function fiatP448AddcarryxU28 is an addition with carry. /// Postconditions: /// out1 = (arg1 + arg2 + arg3) mod 2^28 /// out2 = ⌊(arg1 + arg2 + arg3) / 2^28⌋ /// /// Input Bounds: /// arg1: [0x0 ~> 0x1] /// arg2: [0x0 ~> 0xfffffff] /// arg3: [0x0 ~> 0xfffffff] /// Output Bounds: /// out1: [0x0 ~>...
fiat-zig/src/p448_solinas_32.zig
const std = @import("std"); const dbg = std.debug; pub fn main() void { var fuel_for_module_mass: i32 = 0; var fuel_for_total_mass: i32 = 0; for (input) |mass| { var module_mass_fuel = get_fuel(mass); var total_fuel = get_total_module_fuel(mass); fuel_for_module_mass += module_mass_...
2019/day01.zig
const builtin = @import("builtin"); const TypeId = builtin.TypeId; const std = @import("std"); const math = std.math; const assert = std.debug.assert; const warn = std.debug.warn; const bufPrint = std.fmt.bufPrint; const matrix = @import("matrix.zig"); const Matrix = matrix.Matrix; const M44f32 = matrix.M44f32; const...
src/vec.zig
const std = @import("std"); const TestData = struct { a: []const u8, b: []const u8, expected_result: bool }; const TestContext = struct { data: []const TestData, results: []bool }; const tests = [_]TestData{ createTestData("aab", "aa", false), createTestData("hello", "hello", true), createTestDat...
383_NecklaceMatching/main.zig
pub const InputKey = @import("protocols/simple_text_input_ex_protocol.zig").InputKey; pub const KeyData = @import("protocols/simple_text_input_ex_protocol.zig").KeyData; pub const KeyState = @import("protocols/simple_text_input_ex_protocol.zig").KeyState; pub const SimpleTextInputExProtocol = @import("protocols/simple_...
lib/std/os/uefi/protocols.zig
const psp = @import("Zig-PSP/src/psp/utils/psp.zig"); const gfx = @import("gfx.zig"); usingnamespace @import("Zig-PSP/src/psp/include/psprtc.zig"); usingnamespace @import("Zig-PSP/src/psp/include/pspdisplay.zig"); usingnamespace @import("Zig-PSP/src/psp/include/psploadexec.zig"); var current_time : u64 = 0; var tickRa...
src/main.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day06.txt"); const Input = struct { fish_ages: std.ArrayList(u8) = std.ArrayList(u8).init(std.testing.allocator), pub fn deinit(self: @This()) void { self.fish_ages.deinit(); } }; fn parseInput(input_te...
src/day06.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"); f...
src/day01.zig
const std = @import("std"); const parser = @import("parser.zig"); const Allocator = std.mem.Allocator; pub const log_level = .info; /// Value for the call stack to be limited at in order to avoid an actual stack overflow from whom Lunez doesn't know how to recover. /// It is implemented by throwing a 'stack overflow'...
src/main.zig
const Interface = @This(); ptr: *anyopaque, vtable: *const VTable, pub const VTable = struct { /// Read from memory. read: fn(ptr: *anyopaque, addr: u16) u8, /// Write to memory. write: fn(ptr: *anyopaque, addr: u16, value: u8) void, /// Read data for a maskable interrupt (address low byte for mod...
src/Interface.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const webgpu = @import("../../../webgpu.zig"); const vulkan = @import("../vulkan.zig"); const vk = @import("../vk.zig"); const QueueFamilies = @import("../QueueFamilies.zig"); const log = @import("../log.zig"); const Device = @This(); const DeviceDisp...
src/backends/vulkan/device/Device.zig
const windows = @import("windows.zig"); const UINT = windows.UINT; const IUnknown = windows.IUnknown; const GUID = windows.GUID; const HRESULT = windows.HRESULT; const WINAPI = windows.WINAPI; const LPCWSTR = windows.LPCWSTR; const FLOAT = windows.FLOAT; pub const MEASURING_MODE = enum(UINT) { NATURAL = 0, GDI...
modules/platform/vendored/zwin32/src/dwrite.zig
const windows = @import("windows.zig"); const IUnknown = windows.IUnknown; const UINT = windows.UINT; const UINT32 = windows.UINT32; const HRESULT = windows.HRESULT; const ULONG = windows.ULONG; const DWORD = windows.DWORD; const WINAPI = windows.WINAPI; const GUID = windows.GUID; const LPCWSTR = windows.LPCWSTR; const...
modules/platform/vendored/zwin32/src/mf.zig
const std = @import("std"); const zargo = @import("zargo"); const c = @cImport({ @cDefine("GLFW_INCLUDE_NONE", {}); @cInclude("GLFW/glfw3.h"); }); fn errorCallback(err: c_int, description: [*c]const u8) callconv(.C) void { std.debug.panic("Error: {s}\n", .{description}); } fn keyCallback(win: ?*c.GLFWwindow, ...
tests/test.zig
const std = @import("std"); const liu = @import("liu"); const wasm = liu.wasm; const gon = liu.gon; const util = @import("./util.zig"); const erlang = @import("./erlang.zig"); const ext = erlang.ext; const BBox = erlang.BBox; const EntityId = liu.ecs.EntityId; const Vec2 = liu.Vec2; const FrameInput = liu.gamescree...
src/routes/erlang/editor.zig
const std = @import("std"); const c = @import("../c.zig"); const zupnp = @import("../lib.zig"); const ClientResponse = @This(); const logger = std.log.scoped(.@"zupnp.web.ClientResponse"); /// HTTP status code. http_status: c_int, /// Content type. content_type: ?[:0]const u8, /// Content length. content_length: ?...
src/web/client_response.zig
const std = @import("std"); const aoc = @import("aoc-lib.zig"); test "examples" { const test1 = aoc.readChunks(aoc.talloc, aoc.test1file); defer aoc.talloc.free(test1); try aoc.assertEq(@as(usize, 11), part1(aoc.talloc, test1)); try aoc.assertEq(@as(usize, 6), part2(aoc.talloc, test1)); const inp ...
2020/06/aoc.zig
const std = @import("std"); const sql = @import("sqlite"); const Allocator = std.mem.Allocator; const log = std.log; const testing = std.testing; const print = std.debug.print; const expect = testing.expect; const shame = @import("shame.zig"); const Table = @import("queries.zig").Table; pub const Db = struct { con...
src/db.zig
const std = @import("std"); const assert = std.debug.assert; const Allocator = std.mem.Allocator; pub const tolerance = 1.0e-8; pub const Variable = struct { name: []const u8 = "", value: f32 = 0.0, context: ?usize = null, // ----------------------------------------------------------------------- ...
kiwi.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 int = i64; const util = @import("util.zig"); const gpa = util.gpa; const logging = false; const da...
src/day18.zig
const std = @import("std"); const log = std.log; const os = std.os; const process = std.process; const l2 = @import("./missing_syscalls.zig"); const kill = @import("./killer.zig"); const Killer = kill.Killer; const MemoryStats = kill.MemoryStats; const proc = @import("./proc.zig"); fn usage(exit_code: u8) void { ...
src/main.zig
pub const THIRTEEN = 13; pub const THIRTEEN_FUZZ = 0.5; pub const THIRTEEN_STRINGS = [][]u8{ "xiii", // Roman numeral 13 "1.3", // Basically 13, see proof in #420 "1️⃣3️⃣", // emoji sequence of 1 and 3 "https://en.wikipedia.org/wiki/This_Is_Thirteen", // Because it is thirteen "https://scontent.cdn...
src/consts.zig
// Two types of social contradictions - those between ourselves and the enemy // and those among the people themselves confront us. The two are totally // different in their nature. const std = @import("std"); const I_Instruction = @import("instruction.zig").I_Instruction; const C_Instruction = @import("instruction...
src/util.zig
pub const SpvId = c_uint; pub const SpvMagicNumber: c_uint = @bitCast(c_uint, @as(c_int, 119734787)); pub const SpvVersion: c_uint = @bitCast(c_uint, @as(c_int, 66816)); pub const SpvRevision: c_uint = @bitCast(c_uint, @as(c_int, 3)); pub const SpvOpCodeMask: c_uint = @bitCast(c_uint, @as(c_int, 65535)); pub const SpvW...
render/src/include/spirv.zig
const std = @import("std"); const Arena = std.heap.ArenaAllocator; const expectEqual = std.testing.expectEqual; const expectEqualStrings = std.testing.expectEqualStrings; const yeti = @import("yeti"); const initCodebase = yeti.initCodebase; const tokenize = yeti.tokenize; const parse = yeti.parse; const analyzeSemanti...
src/tests/test_import.zig
const std = @import("std"); const windows = @import("windows.zig"); const IUnknown = windows.IUnknown; const BYTE = windows.BYTE; const HRESULT = windows.HRESULT; const WINAPI = windows.WINAPI; const UINT32 = windows.UINT32; const BOOL = windows.BOOL; const FALSE = windows.FALSE; const L = std.unicode.utf8ToUtf16LeStri...
modules/platform/vendored/zwin32/src/xaudio2fx.zig
const builtin = @import("builtin"); const IsWasm = builtin.target.isWasm(); const stdx = @import("stdx"); const Vec2 = stdx.math.Vec2; const Mat4 = stdx.math.Mat4; const gl = @import("gl"); const graphics = @import("../../graphics.zig"); const Shader = graphics.gl.Shader; const Color = graphics.Color; const tex_vert ...
graphics/src/backend/gl/shaders.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArenaAllocator = std.heap.ArenaAllocator; const ArrayList = std.ArrayList; const Builder = std.build.Builder; const File = std.fs.File; const InstallDir = std.build.InstallDir; const LibExeObjStep = std.build.LibExeObjStep; const Step = std.build.S...
lib/std/build/emit_raw.zig
const CodeSignature = @This(); const std = @import("std"); const assert = std.debug.assert; const fs = std.fs; const log = std.log.scoped(.macho); const macho = std.macho; const mem = std.mem; const testing = std.testing; const Allocator = mem.Allocator; const Sha256 = std.crypto.hash.sha2.Sha256; const Zld = @import...
src/MachO/CodeSignature.zig
const std = @import("std"); pub fn __builtin_bswap16(val: u16) callconv(.Inline) u16 { return @byteSwap(u16, val); } pub fn __builtin_bswap32(val: u32) callconv(.Inline) u32 { return @byteSwap(u32, val); } pub fn __builtin_bswap64(val: u64) callconv(.Inline) u64 { return @byteSwap(u64, val); } pub fn __b...
lib/std/c/builtins.zig
const std = @import("std"); const assert = std.debug.assert; const Allocator = std.mem.Allocator; const Compilation = @import("../Compilation.zig"); const llvm = @import("llvm/bindings.zig"); const link = @import("../link.zig"); const log = std.log.scoped(.codegen); const math = std.math; const Module = @import("../Mo...
src/codegen/llvm.zig
const std = @import("std"); const mem = std.mem; usingnamespace @import("crypto.zig"); const Chacha20Poly1305 = std.crypto.aead.chacha_poly.ChaCha20Poly1305; const Aes128Gcm = std.crypto.aead.aes_gcm.Aes128Gcm; const main = @import("main.zig"); const alert_byte_to_error = main.alert_byte_to_error; const record_tag_le...
src/ciphersuites.zig
const std = @import("std"); const mem = std.mem; const Alphabetic = @This(); allocator: *mem.Allocator, array: []bool, lo: u21 = 65, hi: u21 = 201546, pub fn init(allocator: *mem.Allocator) !Alphabetic { var instance = Alphabetic{ .allocator = allocator, .array = try allocator.alloc(bool, 201482...
src/components/autogen/DerivedCoreProperties/Alphabetic.zig
const std = @import("std"); const debug = std.debug; const io = std.io; const mem = std.mem; const testing = std.testing; pub const args = @import("clap/args.zig"); test "clap" { testing.refAllDecls(@This()); } pub const ComptimeClap = @import("clap/comptime.zig").ComptimeClap; pub const StreamingClap = @import...
clap.zig
const std = @import("std"); const Context = @import("context.zig").Context; const SourceRange = @import("context.zig").SourceRange; const fail = @import("fail.zig").fail; const Token = @import("tokenize.zig").Token; const NumberLiteral = @import("parse.zig").NumberLiteral; const ParsedModuleInfo = @import("parse.zig")....
src/zangscript/codegen.zig
const std = @import("std"); const ecs = @import("ecs"); // override the EntityTraits used by ecs pub const EntityTraits = ecs.EntityTraitsType(.medium); pub const Velocity = struct { x: f32, y: f32 }; pub const Position = struct { x: f32, y: f32 }; /// logs the timing for views vs non-owning groups vs owning groups ...
examples/view_vs_group.zig
const std = @import("std"); const math = std.math; const glfw = @import("glfw"); const zgpu = @import("zgpu"); const gpu = zgpu.gpu; const c = zgpu.cimgui; const zm = @import("zmath"); const zmesh = @import("zmesh"); const znoise = @import("znoise"); const wgsl = @import("procedural_mesh_wgsl.zig"); const content_dir ...
samples/procedural_mesh_wgpu/src/procedural_mesh_wgpu.zig
const std = @import("std"); const generate = @import("vulkan/generator.zig").generate; const usage = "Usage: {s} [-h|--help] <spec xml path> <output zig source>\n"; pub fn main() !void { const stderr = std.io.getStdErr(); var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.dein...
generator/main.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 builtin = @import("builtin"); const is_test = builtin.is_test; const native_arch = builtin.cpu.arch; // AArch64 is the only ABI (at the moment) to support f16 arguments without the // need for extending them to wider fp types. pub const F16T = if (native_arch.isAARCH64()) f16 else u16...
lib/std/special/compiler_rt/extend_f80.zig
const std = @import("../../std.zig"); const builtin = @import("builtin"); const mem = std.mem; const assert = std.debug.assert; const fs = std.fs; const elf = std.elf; const native_endian = builtin.cpu.arch.endian(); const NativeTargetInfo = @This(); const Target = std.Target; const Allocator = std.mem.Allocator; cons...
lib/std/zig/system/NativeTargetInfo.zig
const std = @import("std"); const Type = @import("typeset.zig").Type; const TypeSet = @import("typeset.zig").TypeSet; /// A scope structure that can be used to manage variable /// allocation with different scopes (global, local). pub const Scope = struct { const Self = @This(); const Variable = struct { ...
src/library/compiler/scope.zig
const std = @import("std"); const assert = std.debug.assert; const mem = std.mem; const server = &@import("../main.zig").server; const util = @import("../util.zig"); const View = @import("../View.zig"); const ViewStack = @import("view_stack.zig").ViewStack; const Error = @import("../command.zig").Error; const Seat =...
source/river-0.1.0/river/command/filter.zig
const x86_64 = @import("../../index.zig"); const bitjuggle = @import("bitjuggle"); const std = @import("std"); const formatWithoutFields = @import("../../common.zig").formatWithoutFields; const PageSize = x86_64.structures.paging.PageSize; /// The number of entries in a page table. pub const PAGE_TABLE_ENTRY_COUNT: u...
src/structures/paging/page_table.zig
const std = @import("std"); const fmt = std.fmt; const mem = std.mem; const testing = std.testing; pub const HistogramResult = struct { pub const Bucket = struct { vmrange: []const u8, count: u64, }; pub const SumValue = struct { value: f64 = 0, pub fn format(self: @This()...
src/metric.zig
const std = @import("std"); const tls = @import("tls"); const use_gpa = @import("build_options").use_gpa; pub const log_level = .debug; const RecordingAllocator = struct { const Stats = struct { peak_allocated: usize = 0, total_allocated: usize = 0, total_deallocated: usize = 0, to...
bench/bench.zig
const std = @import("std"); const pike = @import("pike.zig"); const os = std.os; const mem = std.mem; const net = std.net; const log = std.log; const heap = std.heap; const atomic = std.atomic; pub const ClientQueue = atomic.Queue(*Client); pub const Client = struct { socket: pike.Socket, address: net.Addres...
example_tcp_server.zig
const builtin = @import("builtin"); const std = @import("../index.zig"); const math = std.math; const assert = std.debug.assert; pub fn sin(x: var) @typeOf(x) { const T = @typeOf(x); return switch (T) { f32 => sin32(x), f64 => sin64(x), else => @compileError("sin not implemented for " ...
std/math/sin.zig
const std = @import("std"); const Value = @import("value.zig").Value; /// Parses a list of values from the provided code slice. Destructively modifies code. /// No allocations are performed other than to create the returned values. pub fn parse(allocator: std.mem.Allocator, code: []u8) ParseError!*Value { var pars...
parse.zig
const util = @import("../sdf_util.zig"); pub const info: util.SdfInfo = .{ .name = "Quad", .data_size = @sizeOf(Data), .function_definition = function_definition, .enter_command_fn = util.surfaceEnterCommand(Data), .exit_command_fn = util.surfaceExitCommand(Data, exitCommand), .append_mat_chec...
src/sdf/surfaces/quad.zig
const std = @import("std"); const hapi = @cImport({ @cInclude("HAPI/HAPI.h"); @cInclude("raylib.h"); @cInclude("rlgl.h"); }); const ray = hapi; fn initMesh() ray.Mesh { return ray.Mesh{ .vertexCount = 0, .triangleCount = 0, .vertices = null, .texcoords = null, ...
src/main.zig
const std = @import("std"); pub const StreamFns = enum { XADD, XREAD, XREADGROUP, XRANGE, XREVRANGE, }; pub const SpecialIDs = struct { pub const NEW_MESSAGES = "$"; pub const ASSIGN_NEW_MESSAGES = "<"; pub const MIN = "-"; pub const MAX = "+"; pub const AUTO_ID = "*"; pub ...
src/commands/streams/_utils.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 Tree = opaque { pub fn deinit(self: *Tree) void { log.debug("Tree.deinit called", .{}); c.git_tree_free(@...
src/tree.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const log = std.log.scoped(.vr); const config = @import("config.zig"); /// TODO Use IO and callbacks: pub const Storage = struct { allocator: *Allocator, memory: []u8 align(config.sector_size), size: u64, ...
src/storage.zig
const std = @import("std"); const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; const testing = std.testing; const expect = testing.expect; const expectEqual = testing.expectEqual; const Encoding = @import("encoding.zig").Encoding; const getEncoding = @import("encoding.zig").getEncoding; const getEnc...
src/encode.zig
const std = @import("std"); const za = @import("zalgebra"); const Vec2 = za.vec2; // dross-zig // ----------------------------------------- // ----------------------------------------- // - Vector2 - // ----------------------------------------- pub const Vector2 = struct { data: Vec2, const Self = @This(...
src/core/vector2.zig
const std = @import("std"); const Answer = struct { @"0": u64, @"1": u64 }; const Counts = std.AutoHashMap(u8, u64); fn applyRulesAndCount(template: std.ArrayList(u8), iterated_rules: std.StringHashMap(Counts), counts: *Counts) !void { var i: usize = 0; while (i < template.items.len - 1) : (i += 1) { ...
src/day14.zig
const std = @import("std"); const georgios = @import("georgios"); const utils = @import("utils"); const Guid = utils.Guid; const ext2 = @import("ext2.zig"); const gpt = @import("gpt.zig"); const io = @import("io.zig"); const memory = @import("memory.zig"); const print = @import("print.zig"); const MappedList = @impo...
kernel/fs.zig
const std = @import("std"); const testing = std.testing; const Opaque = @OpaqueType(); pub const Dynamic = struct { v: *const Opaque, Type: type, pub fn init(comptime Type: type, v: *const Type) Dynamic { return Dynamic{ .v = @ptrCast(*const Opaque, v), .Type = Type, ...
fun/comptime_dynamic_typing.zig
const std = @import("std"); const nvg = @import("nanovg"); title: []const u8, artist: []const u8, album_art: []const u8, video: []const u8, image: ?nvg.Image = null, const Self = @This(); const Song = Self; pub fn loadSongs(allocator: std.mem.Allocator, pref_path: []const u8) ![]Song { var arr = std.ArrayList(So...
src/Song.zig
const std = @import("std"); const builtin = @import("builtin"); const root = @import("main.zig"); const req = @import("request.zig"); const Request = req.Request; const Response = req.Response; const libressl = root.libressl; const zuri = root.zuri; const hzzp = root.hzzp; fn initWindows() void { if (@import("bu...
src/client.zig
const Assertion = @import("parse.zig").Assertion; pub const Input = struct { bytes: []const u8, byte_pos: usize, currentFn: fn (input: Input) ?u8, advanceFn: fn (input: *Input) void, isNextWordCharFn: fn (input: Input) bool, isPrevWordCharFn: fn (input: Input) bool, pub fn advance(self: ...
src/input.zig
const DaisyChain = @import("DaisyChain.zig"); const PIO = @This(); ports: [NumPorts]Port = [_]Port{.{}} ** NumPorts, reset_active: bool = true, // reset state sticks until first control word received in_func: PortInput, // port-input callback out_func: PortOutput, // port-output callback // reset t...
src/emu/PIO.zig
const std = @import("std"); usingnamespace @import("common.zig"); const base64 = std.base64; const ascii = std.ascii; const math = std.math; const time = std.time; const rand = std.rand; const mem = std.mem; const assert = std.debug.assert; pub fn extractMaskByte(mask: u32, index: usize) u8 { return @truncate(u...
src/parser/client.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"); co...
src/day03.zig
const std = @import("std"); pub fn copy(comptime T: type, dest: []T, source: []const T) void { const n = 32; // TODO: Adjust based on bitSizeOf T const V = @Vector(n, T); if (source.len < n) return std.mem.copy(T, dest, source); var end: usize = n; while (end < source.len) { const start = e...
src/simd.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ines = @import("../ines.zig"); const console_ = @import("../console.zig"); const Config = console_.Config; const Console = console_.Console; const GenericMapper = @import("../mapper.zig").GenericMapper; const common = @import("common.zig"); pub ...
src/mapper/nrom.zig
const std = @import("std"); const ray = @import("translate-c/raylib.zig"); const PostProcessShader = enum { bloom, blur, cross_hatching, cross_stitching, dream_vision, fisheye, grayscale, pixelizer, posterization, predator_view, scanlines, sobel, }; pub fn loadShader(shad...
src/examples/postprocess.zig
const std = @import("std"); const expect = std.testing.expect; const test_allocator = std.testing.allocator; const Allocator = std.mem.Allocator; const Cell = struct { rowIdx: u64 = 0, colIdx: u64 = 0, value: u64, seen: bool = false, }; const Board = struct { const Self = @This(); allocator: A...
day04/src/main.zig
const std = @import("std"); fn root() []const u8 { return std.fs.path.dirname(@src().file) orelse unreachable; } const root_path = root() ++ "/"; pub const include_dir = root_path ++ "libgit2/include"; pub const Library = struct { step: *std.build.LibExeObjStep, pub fn link(self: Library, other: *std.bu...
.gyro/zig-libgit2-mattnite-github.com-0537beea/pkg/libgit2.zig
const std = @import("std"); const testing = std.testing; const zero_width_cf = @import("manual.zig").zero_width_cf; const wide_eastasian = @import("table_wide.zig").wide_eastasian; const zero_width = @import("table_zero.zig").zero_width; /// A simple binary search in a list containing lower and upper bounds fn tableB...
src/main.zig
const std = @import("std"); const Allocator = std.mem.Allocator; pub const TypeId = @TagType(TypeInfo); const TypeInfoSingleton = struct { resolved: bool = false, info: TypeInfo = .{ .Void = {} }, }; pub const TypeInfo = union(enum) { Type: void, Void: void, Bool: void, NoReturn: void, In...
src/runtime.zig
const sdtx = @import("sokol").debugtext; pub const fontdesc = sdtx.FontDesc{ .data = sdtx.asRange([_]u8{ 0b00000000, // ! 0b00000000, 0b00011000, 0b00011000, 0b00011000, 0b00000000, 0b00011000, 0b00000000, 0b00000000, // " 0b01101100,...
src/fontdata.zig
const std = @import("std"); // Command-line flags: // - part1 - output part 1 answer // - part2 - output part 2 answer // - jumps - print all possible jumps to stdout // - explain - run and print out operations to stderr // TODO: make an enum (see tagName) const ops = .{ "acc", "jmp", "nop" }; fn parseOp(candidate: ...
2020/08.zig
const std = @import("std"); const allocator = std.heap.page_allocator; const assert = std.debug.assert; const expect = std.testing.expect; const math = std.math; const mem = std.mem; const zip = @import("./zip.zig"); const time = @import("./time.zig"); const hamlet = @embedFile("../fixtures/hamlet.txt"); const UINT1...
src/zip_test.zig
const std = @import("std"); const pike = @import("pike"); const sync = @import("sync.zig"); const os = std.os; const net = std.net; const mem = std.mem; const meta = std.meta; const atomic = std.atomic; usingnamespace @import("socket.zig"); pub fn Server(comptime opts: Options) type { return struct { con...
server.zig
const std = @import("std.zig"); const debug = std.debug; const assert = debug.assert; const testing = std.testing; const math = std.math; const mem = std.mem; const meta = std.meta; const autoHash = std.hash.autoHash; const Wyhash = std.hash.Wyhash; const Allocator = mem.Allocator; const builtin = @import("builtin"); ...
std/hash_map.zig
const std = @import("../index.zig"); const mem = std.mem; pub const Token = struct { id: Id, start: usize, end: usize, pub const Keyword = struct { bytes: []const u8, id: Id, }; pub const keywords = []Keyword{ Keyword{ .bytes = "align", .id = Id.Keyword_align }, ...
std/zig/tokenizer.zig
const std = @import("std"); const TestContext = @import("../../src-self-hosted/test.zig").TestContext; // self-hosted does not yet support PE executable files / COFF object files // or mach-o files. So we do these test cases cross compiling for x86_64-linux. const linux_x64 = std.zig.CrossTarget{ .cpu_arch = .x86_6...
test/stage2/compare_output.zig
const builtin = @import("builtin"); const std = @import("../../std.zig"); const testing = std.testing; const math = std.math; const cmath = math.complex; const Complex = cmath.Complex; /// Returns the hyperbolic tangent of z. pub fn tanh(z: anytype) @TypeOf(z) { const T = @TypeOf(z.re); return switch (T) { ...
lib/std/math/complex/tanh.zig
const std = @import("std"); const builtin = std.builtin; const Scope = @import("scope.zig").Scope; const Compilation = @import("compilation.zig").Compilation; const Value = @import("value.zig").Value; const llvm = @import("llvm.zig"); const event = std.event; const Allocator = std.mem.Allocator; const assert = std.debu...
src-self-hosted/type.zig
const std = @import("std"); const DebugAllocator = @This(); const Stats = struct { mean: f64 = 0, mean_of_squares: f64 = 0, total: usize = 0, count: usize = 0, fn addSample(self: *Stats, value: usize) void { const count_f64 = @intToFloat(f64, self.count); self.mean = (self.mean *...
src/debug_allocator.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const log = std.log.scoped(.lexer); const Error = error{ InvalidToken, ReachedEof, }; pub const TokenId = enum(u16) { identifier = 255, literal_int, literal_uint, literal_float, literal_char, literal_string, literal...
src/lexer.zig
const std = @import("std"); const mem = std.mem; pub const Alphabetic = @import("components/autogen/DerivedCoreProperties/Alphabetic.zig"); pub const CccMap = @import("components/autogen/DerivedCombiningClass/CccMap.zig"); pub const Control = @import("components/autogen/DerivedGeneralCategory/Control.zig"); pub const ...
src/Context.zig
const print = @import("std").debug.print; // As mentioned before, we'll soon understand why these two // numbers don't need explicit types. Hang in there! const ingredients = 4; const foods = 4; const Food = struct { name: []const u8, requires: [ingredients]bool, }; // Chili Macaroni Tomato...
exercises/063_labels.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const StringHashMap = std.StringHashMap; const interface = @import("interface.zig"); //; // is there a way to use command ids, less error prone // dont really like the "stringly typed" aspect // its not so bad, i th...
src/cmd.zig