code
stringlengths
38
801k
repo_path
stringlengths
6
263
const std = @import("std"); const fs = std.fs; const mem = std.mem; const json = std.json; const assert = std.debug.assert; // All references to other features are based on "zig name" as the key. const FeatureOverride = struct { llvm_name: []const u8, /// If true, completely omit the feature; as if it does no...
tools/update_cpu_features.zig
const std = @import("std"); const expect = std.testing.expect; test "continue and break" { try runContinueAndBreakTest(); try expect(continue_and_break_counter == 8); } var continue_and_break_counter: i32 = 0; fn runContinueAndBreakTest() !void { var i: i32 = 0; while (true) { continue_and_brea...
test/behavior/while_stage1.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayListUnmanaged = std.ArrayListUnmanaged; const max_line_len = 4096; pub const History = struct { allocator: Allocator, hist: ArrayListUnmanaged([]const u8) = .{}, max_len: usize = 100, current: usize = 0, const Self = @Thi...
src/history.zig
const std = @import("std"); const builtin = @import("builtin"); const io = std.io; const Allocator = std.mem.Allocator; const deflate_const = @import("deflate_const.zig"); const hm_code = @import("huffman_code.zig"); const token = @import("token.zig"); // The first length code. const length_codes_start = 257; // Th...
lib/std/compress/deflate/huffman_bit_writer.zig
const std = @import("std"); const Type = @import("ElementType.zig").Enum; const Element = @This(); // TODO: There are some common types of attribute that aren't necessarily strings (e.g. class), // this should probably become a union of string, integer, and list of string. const AttributeMap = std.StringHashMap([]cons...
src/web/html/Element.zig
pub const SYS = enum(usize) { io_setup = 0x00, io_destroy = 0x01, io_submit = 0x02, io_cancel = 0x03, io_getevents = 0x04, setxattr = 0x05, lsetxattr = 0x06, fsetxattr = 0x07, getxattr = 0x08, lgetxattr = 0x09, fgetxattr = 0x0a, listxattr = 0x0b, llistxattr = 0x0c, ...
src/linux/aarch64/consts.zig
const std = @import("std"); const Builder = std.build.Builder; const LibExeObjStep = std.build.LibExeObjStep; // set this to true to link libc const should_link_libc = false; const test_files = [_][]const u8{ // list any zig files with tests here "src/day01.zig", "src/day02.zig", "src/day03.zig", }; ...
build.zig
const std = @import("std"); var prng: std.rand.Xoshiro256 = undefined; var prng_exists = false; const default_alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvexyz-"; const default_id_size = 21; const default_mask = 63; fn random() !void { // Instantiate a random seed from the os random gene...
nanoid.zig
const wlr = @import("wlroots.zig"); const wayland = @import("wayland"); const wl = wayland.server.wl; pub const Backend = extern struct { const Impl = opaque {}; impl: *const Impl, events: extern struct { destroy: wl.Signal(*Backend), new_input: wl.Signal(*wlr.InputDevice), new_ou...
src/backend.zig
const std = @import("std"); const builtin = @import("builtin"); const Vector = std.meta.Vector; pub const NativeVector = struct { len: u16, ChildType: type, const Self = @This(); /// Returns a native vector of type T. pub fn init(comptime T: type) NativeVector { return .{ .len ...
src/native_vector.zig
const w4 = @import("wasm4.zig"); const statemachine = @import("state-machine.zig"); const mainmenu = @import("screens/main-menu.zig"); const party = @import("screens/party.zig"); const presscon = @import("screens/press-conference.zig"); const startscreen = @import("screens/start-screen.zig"); const houseofcommons = @im...
src/main.zig
const std = @import("std"); const FileSource = std.build.FileSource; const builtin = @import("builtin"); const t_path = "tmp/"; const k_path = "kernel/"; const p_path = k_path ++ "platform/"; const root_path = t_path ++ "root/"; const boot_path = root_path ++ "boot/"; const bin_path = root_path ++ "bin/"; const utils...
build.zig
const std = @import("std"); const debug = std.debug; const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; const HashMap = std.HashMap; /// A TokenId represents a kind of token. It will also hold its associated data if present. const TokenId = enum { Ampersand, Arrow, AtSign, Bang, ...
src/tokenizer.zig
const std = @import("std"); const assert = std.debug.assert; const c = @cImport({ @cInclude("SDL2/SDL.h"); }); const chip8 = @import("../chip8/chip8.zig"); fn fill_image_buffer(imageOutput: []u8, state: *chip8.CPUState, palette: chip8.Palette, scale: u32) void { const pixelFormatBGRASizeInBytes: u32 = 4; ...
src/sdl2/sdl2_backend.zig
const std = @import("std"); const Arch = if (@hasField(std.builtin, "Arch")) std.builtin.Arch else std.Target.Cpu.Arch; pub const Context = enum { kernel, userlib, userspace, }; pub const TransformFileCommandStep = struct { step: std.build.Step, output_path: []const u8, fn run_command(s: *std...
buildutil/exec.zig
const std = @import("std"); const builtin = @import("builtin"); const vfs = @import("../vfs.zig"); const uefi = std.os.uefi; const time = std.time; const earlyprintf = @import("../platform.zig").earlyprintf; pub const klibc = @import("../klibc.zig"); pub const debugMalloc = false; const console = @import("uefi/conso...
kernel/platform/uefi.zig
const std = @import("std"); const config = @import("config.zig"); const tracer = @import("tracer.zig"); pub const WorkItem = struct { tracer: *tracer.Tracer, buffer: *[]u8, offset: usize, chunk_size: usize, }; pub const WorkerThread = struct { done: std.atomic.Atomic(bool) = std.atomic.Atomic(bool...
src/worker.zig
const std = @import("std"); // options is a json.Options, but since we're using our hacked json.zig we don't want to // specifically call this out pub fn serializeMap(map: anytype, key: []const u8, options: anytype, out_stream: anytype) !bool { if (map.len == 0) return true; // TODO: Map might be [][]struct{key...
codegen/src/json.zig
const std = @import("std"); const real_input = @embedFile("day-14_real-input"); const test_input = @embedFile("day-14_test-input"); pub fn main() !void { std.debug.print("--- Day 14 ---\n", .{}); const result = try execute(real_input, 40); std.debug.print("most common - least common = {}\n", .{ result });...
day-14.zig
const std = @import("std"); const deps = @import("deps.zig"); pub fn build(b: *std.build.Builder) void { const target = b.standardTargetOptions(.{}); const mode = b.standardReleaseOptions(); const exe = b.addExecutable("wala", "src/main.zig"); const exe_tests = b.addTest("src/main.zig"); const exe...
build.zig
const std = @import("std"); const mem = std.mem; const fs = std.fs; const CacheHash = std.cache_hash.CacheHash; /// Caller must free result pub fn testZigInstallPrefix(allocator: *mem.Allocator, test_path: []const u8) ![]u8 { { const test_zig_dir = try fs.path.join(allocator, &[_][]const u8{ test_path, "l...
src-self-hosted/introspect.zig
const std = @import("std"); const builtin = @import("builtin"); const log = std.log; const assert = std.debug.assert; const fs = @import("src/build/fs.zig"); const Builder = std.build.Builder; const LibExeObjStep = std.build.LibExeObjStep; const Step = std.build.Step; const RunStep = std.build.RunStep; const FileSourc...
build.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const assert = std.debug.assert; //; // TODO maybe make it so ptrs hold offsets rather than pointers, and cant be invalidated by pool resizes // maybe make it so this thing can be easier resized? // could further incre...
src/pool.zig
const std = @import("std"); const os = std.os; const testing = std.testing; const assert = std.debug.assert; const Time = @import("../time.zig").Time; const IO = @import("../io.zig").IO; test "write/fsync/read/close" { try struct { const Context = @This(); io: IO, done: bool = false, ...
src/io/test.zig
const std = @import("std"); const assert = std.debug.assert; const print = std.debug.print; const tools = @import("tools"); const VM = struct { const Word = u16; const OpCode = enum(Word) { halt, set, push, pop, eq, gt, jmp, jt, jf, add, mult, mod, band, bor, not, rmem, wmem, call, ret, out, in, noop }; ...
synacor/main.zig
const std = @import("std"); const assert = std.debug.assert; const cpu = @import("cpu.zig"); const memory = @import("memory.zig"); const keyboard = @import("keyboard.zig"); const display = @import("display.zig"); // Clear the display. pub fn execute_cls(state: *cpu.CPUState) void { for (state.screen) |*row| { ...
src/chip8/instruction.zig
const std = @import("std"); const c = @import("c.zig"); const pem = @import("pem.zig"); pub const RsaPublicKey = struct { allocator: std.mem.Allocator, key: c.br_rsa_public_key, const Self = @This(); pub fn init(key: *const c.br_rsa_public_key, allocator: std.mem.Allocator) !Self { var s...
src/key.zig
const std = @import("std"); const assert = std.debug.assert; const os = @import("windows/windows.zig"); const dxgi = @import("windows/dxgi.zig"); const d3d12 = @import("windows/d3d12.zig"); const d2d1 = @import("windows/d2d1.zig"); const dwrite = @import("windows/dwrite.zig"); const dcommon = @import("windows/dcommon.z...
src/main.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day15.txt"); const Input = struct { risks: [100][100]i64 = undefined, dim: usize = undefined, pub fn init(input_text: []const u8, allocator: std.mem.Allocator) !@This() { _ = allocator; var inpu...
src/day15.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_struct.zig
const std = @import("std"); const builtin = @import("builtin"); const build_options = @import("build_options"); const io = std.io; const mem = std.mem; const process = std.process; const Allocator = mem.Allocator; const CrossTarget = std.zig.CrossTarget; const Zld = @import("Zld.zig"); var gpa_allocator = std.heap.Ge...
src/main.zig
const std = @import("std"); const webgpu = @import("../../../webgpu.zig"); const vulkan = @import("../vulkan.zig"); const vk = @import("../vk.zig"); const Buffer = @This(); pub const vtable = webgpu.Buffer.VTable{ .destroy_fn = destroy, .get_const_mapped_range_fn = undefined, .get_mapped_range_fn = undef...
src/backends/vulkan/resource/Buffer.zig
const std = @import("std"); const builtin = @import("builtin"); const IsWasm = builtin.target.isWasm(); const stdx = @import("stdx"); const platform = @import("platform"); const graphics = @import("graphics"); const Color = graphics.Color; const ui = @import("ui"); const Row = ui.widgets.Row; const Text = ui.widgets.Te...
ui/examples/counter.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const print = std.debug.print; const input = @embedFile("../in04.txt"); const valid_ecls = .{ "amb", "blu", "brn", "gry", "grn", "hzl", "oth", }; fn in_range(comptime T: type, num: ?[]const u8, min: T, max: T) bool ...
src/day04.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArenaAllocator = std.heap.ArenaAllocator; const ArrayList = std.ArrayList; const fs = std.fs; const log = std.log; const parse = @import("parse.zig"); const http = @import("http.zig"); const Uri = @import("zuri").Uri; const url_util = @import("url.z...
src/cli.zig
const std = @import("std"); const helper = @import("helper.zig"); const Allocator = std.mem.Allocator; const HashMap = std.AutoHashMap; const input = @embedFile("../inputs/day17.txt"); pub fn run(alloc: Allocator, stdout_: anytype) !void { const area = try Area.parse(input); var stepnums = try getStepNums(al...
src/day17.zig
const std = @import("std"); const SDL = @import("sdl2"); const zgl = @import("zgl"); const rasterizer = @import("rasterizer.zig"); const quality: Quality = .fast; const multithreading: ?comptime_int = 8; const level_file = "assets/lost_empire"; const DepthType = u32; const PixelType = u8; const screen = struct { ...
src/main.zig
const std = @import("std"); const util = @import("util.zig"); // const Scanner = @import("scan.zig").Scanner; /// These are the delimiters that will be used as tokens. const DelimiterToken = enum(u8) { Percent = '%', // 0x25 37 OpenParen = '(', // 0x28 40 CloseParen = ')', // 0x29 41 Plus = '+', // ...
src/token.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"); c...
src/day02.zig
const std = @import("std"); const Arena = std.heap.ArenaAllocator; const Allocator = std.mem.Allocator; const assert = std.debug.assert; const panic = std.debug.panic; const yeti = @import("yeti"); const initCodebase = yeti.initCodebase; const analyzeSemantics = yeti.analyzeSemantics; const codegen = yeti.codegen; con...
src/main.zig
const std = @import("std"); const stdx = @import("stdx"); const Duration = stdx.time.Duration; const Function = stdx.Function; const platform = @import("platform"); const MouseDownEvent = platform.MouseDownEvent; const KeyDownEvent = platform.KeyDownEvent; const graphics = @import("graphics"); const Color = graphics.Co...
ui/src/widgets/text_field.zig
const std = @import("../index.zig"); const builtin = @import("builtin"); const Os = builtin.Os; const is_windows = builtin.os == Os.windows; const is_posix = switch (builtin.os) { builtin.Os.linux, builtin.Os.macosx => true, else => false, }; const os = this; test "std.os" { _ = @import("child_process.zig"...
std/os/index.zig
const std = @import("std"); const App = @import("app"); const Engine = @import("../Engine.zig"); const structs = @import("../structs.zig"); const enums = @import("../enums.zig"); const js = struct { extern fn machCanvasInit(width: u32, height: u32, selector_id: *u8) CanvasId; extern fn machCanvasDeinit(canvas:...
src/platform/wasm.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const zupnp = @import("../../lib.zig"); const xml = @import("xml"); const ActionRequest = zupnp.upnp.device.ActionRequest; const ActionResult = zupnp.upnp.device.ActionResult; const DeviceServiceDefinition = zupnp.upnp.definition.DeviceServiceDefinition; ...
src/upnp/device/media_server.zig
const std = @import("std"); const Assembunny = @This(); const Register = u2; const Operand = union(enum) { Immediate: i8, Register: Register, fn detect(str: []const u8) !Operand { return if (str[0] <= '9') Operand{ .Immediate = try std.fmt.parseInt(i8, str, 10) } else ...
src/main/zig/2016/assembunny.zig
const c = @cImport({ @cInclude("SDL.h"); }); const m = @cImport({ @cInclude("SDL_mixer.h"); }); const assert = @import("std").debug.assert; const warn = @import("std").log.warn; const SdlError = error{ InitializationFailed, CreateWindowFailed, CreateRendererFailed, LoadWavFailed, OpenAudioF...
src/sdl.zig
const std = @import("std"); const fmt = std.fmt; const io = std.io; const codes = @import("./codes.zig"); pub const Error = std.os.WriteError || std.fmt.BufPrintError; // TODO Is it ok to use global stdout (thread-safety)? // TODO consider passing a writer as argument (various possible sinks: stdout, stderr, membuf...
src/cursor.zig
// ┌───────────────────────────────────────────────────────────────────────────┐ // │ │ // │ Platform Constants │ // │ ...
cli/assets/templates/zig/src/wasm4.zig
const Allocator = std.mem.Allocator; const h11 = @import("h11"); const Method = @import("http").Method; const Socket = @import("socket.zig").Socket; const Request = @import("request.zig").Request; const Response = @import("response.zig").Response; const std = @import("std"); const StreamingResponse = @import("response....
src/connection.zig
pub const NLM_MAX_ADDRESS_LIST_SIZE = @as(u32, 10); pub const NLM_UNKNOWN_DATAPLAN_STATUS = @as(u32, 4294967295); //-------------------------------------------------------------------------------- // Section: Types (26) //-------------------------------------------------------------------------------- const CLSID_Netw...
win32/networking/network_list_manager.zig
const std = @import("std"); const zzz = @import("zzz"); const version = @import("version"); const Package = @import("Package.zig"); const Dependency = @import("Dependency.zig"); const Allocator = std.mem.Allocator; const ArenaAllocator = std.heap.ArenaAllocator; usingnamespace @import("common.zig"); const Self = @Thi...
src/Project.zig
const std = @import("std"); const mdct = @import("mdct.zig"); fn bench() !void { var timer = try std.time.Timer.start(); var n: usize = 0; while (n < 1) : (n += 1) { const data_1 = [_]f32{ 0, 0, 1, 2 }; const processed_1 = [_]f32{ mdct.mdct(f32, &data_1, 0), mdct.mdct(f32, &data_1, 1) }; ...
src/main.zig
const wlr = @import("wlroots.zig"); const os = @import("std").os; const wayland = @import("wayland"); const wl = wayland.server.wl; // Only bind enough to make binding wlr/xwayland.h possible // Consider full xcb bindings in the future if needed const xcb = struct { const GenericEvent = opaque {}; const Pixm...
src/xwayland.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"); const MessageBus = @import("../message_bus.zig").MessageBusReplica; const Message = @import("../message_bus.zig").Message; const Storage = @import...
src/vr/journal.zig
const std = @import("std"); const print = std.debug.print; const Allocator = std.mem.Allocator; const meta = std.meta; const Utf8View = std.unicode.Utf8View; const Self = @This(); allocator: *Allocator, pub fn init(allocator: *Allocator) Self { return Self{ .allocator = allocator, }; } pub fn parseJs...
src/parser.zig
const std = @import("std"); pub fn fmtValueLiteral(w: anytype, value: anytype, print_type_name: bool) !void { const TO = @TypeOf(value); const TI = @typeInfo(TO); if (comptime std.meta.trait.isZigString(TO)) { try w.print("\"{}\"", .{std.zig.fmtEscapes(value)}); return; } if (compti...
src/lib.zig
const Builder = @import("std").build.Builder; const z = @import("std").zig; const std = @import("std"); const builtin = @import("builtin"); //Optional customizations const icon0 = "ICON0.png"; //REPLACE WITH PATH TO ICON0.PNG 144 x 80 Thumbnail const icon1 = "NULL"; //REPLACE WITH PATH TO ICON1.PMF 144 x 80 animation ...
build.zig
const std = @import("std"); pub const EscapedStringIterator = struct { slice: []const u8, position: usize, pub fn init(slice: []const u8) @This() { return @This(){ .slice = slice, .position = 0, }; } pub fn next(self: *@This()) error{IncompleteEscapeSequenc...
src/library/compiler/string-escaping.zig
const xcb = @import("../xcb.zig"); pub const id = xcb.Extension{ .name = "SYNC", .global_id = 0 }; pub const ALARM = u32; pub const ALARMSTATE = extern enum(c_uint) { @"Active" = 0, @"Inactive" = 1, @"Destroyed" = 2, }; pub const COUNTER = u32; pub const FENCE = u32; pub const TESTTYPE = extern enum(...
src/auto/sync.zig
const std = @import("std"); pub const LissajousMode = enum { Lissajous2D, Lissajous3D, Heatmap, }; pub const FrequencyMode = enum { Flat, Waterfall, }; pub const OscilloscopeMode = enum { Combined, }; pub const Element = struct { id: []const u8, pane: Pane = Pane.identity, relati...
src/editor.zig
const std = @import("std"); const pi = std.math.pi; const cos = std.math.cos; const sin = std.math.sin; const glm = @import("glm.zig"); const Mat4 = glm.Mat4; const Vec3 = glm.Vec3; const vec3 = glm.vec3; const lookAt = glm.lookAt; usingnamespace @import("c.zig"); // Defines several possible options for camera movem...
src/camera.zig
usingnamespace @import("psptypes.zig"); pub const enum_IOAccessModes = extern enum(c_int) { FIO_S_IFMT = 61440, FIO_S_IFLNK = 16384, FIO_S_IFDIR = 4096, FIO_S_IFREG = 8192, FIO_S_ISUID = 2048, FIO_S_ISGID = 1024, FIO_S_ISVTX = 512, FIO_S_IRWXU = 448, FIO_S_IRUSR = 256, FIO_S_IWU...
src/psp/sdk/pspiofilemgr.zig
const aoc = @import("../aoc.zig"); const std = @import("std"); const Reindeer = struct { speed: u16, flying_duration: u16, resting_duration: u16, time_just_flew: u16 = 0, time_just_rested: u16 = 0, distance_flown: u16 = 0, points: u16 = 0, fn tick(self: *Reindeer) void { if (self.time_just_fle...
src/main/zig/2015/day14.zig
const std = @import("std"); const FixedBufferAllocator = std.heap.FixedBufferAllocator; // ---------------------------------------------------------------------------- const arm_m = @import("../drivers/arm_m.zig"); const arm_cmse = @import("../drivers/arm_cmse.zig"); // -------------------------------------------------...
src/monitor/threads.zig
const std = @import("std"); const main = @import("main.zig"); const bufwriter = @import("bufwriter.zig"); const utils = @import("utils.zig"); const printPrettify = utils.printPrettify; const testing = std.testing; const debug = std.debug.print; const dif = @import("dif.zig"); const DifNode = dif.DifNode; const DifNode...
libdaya/src/dot.zig
const bench = @import("bench"); const std = @import("std"); const builtin = std.builtin; const debug = std.debug; const heap = std.heap; const mem = std.mem; const testing = std.testing; pub const GcAllocator = struct { const PointerList = std.ArrayList(Pointer); start: [*]const u8, ptrs: PointerList, ...
gc.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const print = std.debug.print; const FieldName = enum(usize) { byr, iyr, eyr, hgt, hcl, ecl, pid, cid, }; fn yearInRange(y: ?usize, min: usize, max: usize) bool { return y != null and ...
src/day04.zig
pub const WINHTTP_FLAG_ASYNC = @as(u32, 268435456); pub const WINHTTP_FLAG_SECURE_DEFAULTS = @as(u32, 805306368); pub const SECURITY_FLAG_IGNORE_UNKNOWN_CA = @as(u32, 256); pub const SECURITY_FLAG_IGNORE_CERT_DATE_INVALID = @as(u32, 8192); pub const SECURITY_FLAG_IGNORE_CERT_CN_INVALID = @as(u32, 4096); pub const SECUR...
win32/networking/win_http.zig
const std = @import("std"); const testing = std.testing; const allocator = std.testing.allocator; const desc_usize = std.sort.desc(usize); pub const Map = struct { const Pos = struct { x: isize, y: isize, pub fn init(x: isize, y: isize) Pos { var self = Pos{ .x = x, .y = y }; ...
2021/p09/map.zig
const base = @import("../base.zig"); const gen = @import("../gen.zig"); const COMMON = [_:null]?base.Segment{ .{ .offset = 30 * 0, .month = 1, .day_start = 1, .day_end = 30 }, .{ .offset = 30 * 1, .month = 2, .day_start = 1, .day_end = 30 }, .{ .offset = 30 * 2, .month = 3, .day_start = 1, .day_end = 30 },...
src/cal/ancient_egyptian.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const Inst = union(enum) { forward: i32, down: i32, up: i32 }; const Day2Err = error{InvalidInstruction}; const input = @embedFile("../inputs/day02.txt"); pub fn run(alloc: Allocator, stdout_: anytype) !void { const...
src/day02.zig
const std = @import("std"); const fs = std.fs; const json = std.json; const assert = std.debug.assert; const Record = struct { timestamp: u64, benchmark_name: []const u8, allocator: WhichAllocator, commit_hash: [20]u8, error_message: []const u8 = &[0]u8{}, samples_taken: u64 = 0, wall_time_...
main.zig
const std = @import("std"); const total_eggnog: u32 = 150; fn solve_table(table: []u32, containers: []u32) !void { const table_width = total_eggnog + 1; const table_height = containers.len + 1; { // 1 way of making 0 eggnog using containers [0..num_containers] var num_containers: usize = 0...
src/day17.zig
const builtin = @import("builtin"); const std = @import("std"); extern fn InitializeConditionVariable(*c_void) void; extern fn SleepConditionVariableCS(*c_void, *c_void, u32) void; extern fn WakeConditionVariable(*c_void) void; extern fn InitializeCriticalSection(*c_void) void; extern fn EnterCriticalSection(*c_void)...
src/ConditionVariable.zig
const std = @import("std"); const leb = std.leb; const macho = std.macho; pub const Pointer = struct { offset: u64, segment_id: u16, dylib_ordinal: ?i64 = null, name: ?[]const u8 = null, }; pub fn pointerCmp(context: void, a: Pointer, b: Pointer) bool { if (a.segment_id < b.segment_id) return true...
src/link/MachO/bind.zig
const std = @import("std"); const testing = std.testing; const Hash = u64; const bits = 1; const width = 1 << bits; const mask = width - 1; const parts = @sizeOf(Hash) * 8 / bits; fn KeyValue(comptime KT: type, comptime VT: type) type { return struct { const Self = @This(); key: KT, value...
src/main.zig
const std = @import("std"); const Ring = @This(); allocator: *std.mem.Allocator, buffer: []f32, write_idx: usize = 0, read_idx: usize = 0, pub fn init(allocator: *std.mem.Allocator, size: usize) !Ring { var ring = Ring{ .allocator = allocator, .buffer = try allocator.alloc(f32, size), }; ...
src/util/ring.zig
const c = @cImport({ @cInclude("cfl_input.h"); }); const widget = @import("widget.zig"); const enums = @import("enums.zig"); pub const Input = struct { inner: ?*c.Fl_Input, pub fn new(x: i32, y: i32, w: i32, h: i32, title: [*c]const u8) Input { const ptr = c.Fl_Input_new(x, y, w, h, title); ...
src/input.zig
const Builder = @import("std").build.Builder; pub fn build(b: *Builder) void { const mode = b.standardReleaseOptions(); // libgc const gc = b.addStaticLibrary("gc", null); { // TODO(mitchellh): support more complex features that are usually on // with libgc like threading, parallelizat...
build.zig
const std = @import("std"); const mem = std.mem; const EmojiPresentation = @This(); allocator: *mem.Allocator, array: []bool, lo: u21 = 8986, hi: u21 = 129750, pub fn init(allocator: *mem.Allocator) !EmojiPresentation { var instance = EmojiPresentation{ .allocator = allocator, .array = try alloc...
src/components/autogen/emoji-data/EmojiPresentation.zig
const std = @import("std"); const Vector = std.meta.Vector; pub const Float4 = Vector(4, f32); pub const Float3 = [3]f32; // Vector(3, f32) is 16 byte aligned pub const VFloat3 = Vector(3, f32); pub const Float2 = Vector(2, f32); pub const Float4x4 = extern struct { rows: [4]Float4 = .{ Float4{ 1, 0, 0, 0...
src/simd.zig
const std = @import("std"); const testing = std.testing; const allocator = std.testing.allocator; pub const Vent = struct { pub const Mode = enum { HorVer, HorVerDiag, }; const Pos = struct { x: usize, y: usize, pub fn init(x: usize, y: usize) Pos { var...
2021/p05/vent.zig
pub const std = @import("std"); pub const enable = @import("build_options").enable_tracy; extern fn ___tracy_emit_zone_begin_callstack( srcloc: *const ___tracy_source_location_data, depth: c_int, active: c_int, ) ___tracy_c_zone_context; extern fn ___tracy_emit_zone_end(ctx: ___tracy_c_zone_context) void...
libs/ztracy/src/ztracy.zig
const std = @import("std"); const mem = std.mem; const warn = std.debug.warn; const c = @import("c.zig"); const irc = @import("client.zig"); const api = @import("api.zig"); const Config = @import("config.zig").Config; pub const Context = struct { config: Config, requests: std.StringHashMap(api.Request), }; pu...
src/message_handlers.zig
pub const cs_generate_mipmaps = \\ struct Uniforms { \\ src_mip_level: i32, \\ num_mip_levels: u32, \\ } \\ @group(0) @binding(0) var<uniform> uniforms: Uniforms; \\ \\ @group(0) @binding(1) var src_image: texture_2d<f32>; \\ @group(0) @binding(2) var dst_mipmap1: texture_storage_2d<rgba32float, write>; ...
libs/zgpu/src/common_wgsl.zig
const std = @import("std"); const sling = @import("sling.zig"); const fmod = @import("fmod.zig"); var sys: ?*fmod.FMOD_STUDIO_SYSTEM = null; var events = sling.util.HoleQueue(?*fmod.FMOD_STUDIO_EVENTINSTANCE).init(sling.alloc); var banks = std.ArrayList(Bank).init(sling.alloc); pub const Bank = struct { raw: ?*fm...
src/audio.zig
const bs = @import("./bitstream.zig"); const hm = @import("./huffman.zig"); const lz = @import("./lz77.zig"); const tables = @import("./tables.zig"); const bits_utils = @import("./bits.zig"); const std = @import("std"); const assert = std.debug.assert; const mem = std.mem; const math = std.math; const UINT8_MAX = ma...
src/implode.zig
const std = @import("std"); const assert = std.debug.assert; const zp = @import("../../zplay.zig"); const stb_image = zp.deps.stb.image; const Texture = zp.graphics.common.Texture; const Self = @This(); pub const Error = error{ LoadImageError, }; /// gpu texture tex: *Texture, /// format of image format: Texture...
src/graphics/texture/Texture2D.zig
const windows = @import("windows.zig"); const IUnknown = windows.IUnknown; const WINAPI = windows.WINAPI; const HRESULT = windows.HRESULT; const GUID = windows.GUID; const LPCWSTR = windows.LPCWSTR; const DWORD = windows.DWORD; const UINT = windows.UINT; const INT = windows.INT; const BYTE = windows.BYTE; pub const Pi...
modules/platform/vendored/zwin32/src/wincodec.zig
const std = @import("std"); const link = @import("link.zig"); const Compilation = @import("Compilation.zig"); const Allocator = std.mem.Allocator; const zir = @import("zir.zig"); const Package = @import("Package.zig"); const introspect = @import("introspect.zig"); const build_options = @import("build_options"); const e...
src/test.zig
const std = @import("index.zig"); const assert = std.debug.assert; const mem = std.mem; // For mem.Compare const Color = enum(u1) { Black, Red, }; const Red = Color.Red; const Black = Color.Black; const ReplaceError = error{NotEqual}; /// Insert this into your struct that you want to add to a red-black tree....
std/rb.zig
const std = @import("std"); const fmt = std.fmt; /// Group operations over Edwards25519. pub const Edwards25519 = struct { /// The underlying prime field. pub const Fe = @import("field.zig").Fe; /// Field arithmetic mod the order of the main subgroup. pub const scalar = @import("scalar.zig"); x: F...
lib/std/crypto/25519/edwards25519.zig
const std = @import("std"); const Type = @import("type.zig").Type; const Value = @import("value.zig").Value; const Module = @import("Module.zig"); const Allocator = std.mem.Allocator; const TypedValue = @This(); const Target = std.Target; ty: Type, val: Value, /// Memory management for TypedValue. The main purpose of...
src/TypedValue.zig
const std = @import("std"); const App = @import("app"); const Engine = @import("../Engine.zig"); const structs = @import("../structs.zig"); const enums = @import("../enums.zig"); const js = struct { extern fn machCanvasInit(width: u32, height: u32, selector_id: *u8) CanvasId; extern fn machCanvasDeinit(canvas:...
src/platform/wasm.zig
const std = @import("std"); const input = @import("input.zig"); pub fn run(stdout: anytype) anyerror!void { { var input_ = try input.readFile("inputs/day13"); defer input_.deinit(); var paper = Paper.init(0) catch unreachable; const result = try part1(&input_, &paper); tr...
src/day13.zig
const std = @import("std"); const helper = @import("helper.zig"); const Allocator = std.mem.Allocator; const HashMap = std.AutoHashMap; const input = @embedFile("../inputs/day14.txt"); pub fn run(alloc: Allocator, stdout_: anytype) !void { var polymer = try Polymer.init(alloc, input); defer polymer.deinit(); ...
src/day14.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const wcwidth = @import("zig-wcwidth/src/main.zig").wcwidth; const Style = @import("zig-ansi-term/src/style.zig").Style; pub const Cell = struct { ch: u21, style: Style, const Self = @This(); pub fn eql(self: Self, other: Self) bool { ...
src/cellbuffer.zig
const std = @import("std"); const ArrayList = std.ArrayList; const Allocator = std.mem.Allocator; const BufferedWriter = std.io.BufferedWriter; const File = std.fs.File; const Fifo = std.fifo.LinearFifo(u8, .{ .Static = 512 }); const bufferedWriter = std.io.bufferedWriter; const wcwidth = @import("zig-wcwidth/src/main...
src/main.zig
const std = @import("std"); 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 native. Other options // for rest...
build.zig
const Allocator = struct {}; const CompanyInfo = struct { name: []const u8, }; const TrainNetwork = struct { const Logistics = struct { const Station = struct {using allocator: *Allocator,}; const Train = struct {using allocator: *Allocator,}; const Scheduler = struct {using allocator:...
stringly.zig