code
stringlengths
38
801k
repo_path
stringlengths
6
263
/// Construct a Fenwick type for the given numeric type. Note that this is an implicit tree, where /// an array is used to maintain prefix sums. Sum queries and point updates are done in log(n) time. pub fn Fenwick(comptime T: type) type { return struct { data: []T = undefined, /// Returns an a Fe...
src/main.zig
pub const MAX_COUNTER_PATH = @as(u32, 256); pub const PDH_MAX_COUNTER_NAME = @as(u32, 1024); pub const PDH_MAX_INSTANCE_NAME = @as(u32, 1024); pub const PDH_MAX_COUNTER_PATH = @as(u32, 2048); pub const PDH_MAX_DATASOURCE_PATH = @as(u32, 1024); pub const PDH_MAX_SCALE = @as(i32, 7); pub const PDH_MIN_SCALE = @as(i32, -7...
deps/zigwin32/win32/system/performance.zig
const std = @import("std"); const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const expectEqualStrings = std.testing.expectEqualStrings; const expectEqualSlices = std.testing.expectEqualSlices; const zigstr = @import("zigstr"); test "Zigstr README tests" { var allocator = std.testin...
src/main.zig
const std = @import("std"); const mem = std.mem; const assert = std.debug.assert; const Allocator = std.mem.Allocator; const ast = std.c.ast; const Node = ast.Node; const Type = ast.Type; const Tree = ast.Tree; const TokenIndex = ast.TokenIndex; const Token = std.c.Token; const TokenIterator = ast.Tree.TokenList.Iterat...
lib/std/c/parse.zig
const std = @import("../../std.zig"); const builtin = @import("builtin"); const linux = std.os.linux; const mem = std.mem; const elf = std.elf; const expect = std.testing.expect; const fs = std.fs; test "fallocate" { const path = "test_fallocate"; const file = try fs.cwd().createFile(path, .{ .truncate = true,...
lib/std/os/linux/test.zig
const Object = @This(); const std = @import("std"); const build_options = @import("build_options"); const assert = std.debug.assert; const dwarf = std.dwarf; const fs = std.fs; const io = std.io; const log = std.log.scoped(.link); const macho = std.macho; const math = std.math; const mem = std.mem; const sort = std.so...
src/link/MachO/Object.zig
const std = @import("std"); const mem = std.mem; const Allocator = mem.Allocator; const testing = std.testing; const builtin = @import("builtin"); const assert = std.debug.assert; /// An entity ID uniquely identifies an entity globally within an Entities set. pub const EntityID = u64; /// Represents the storage for a...
ecs/src/entities.zig
const fmath = @import("index.zig"); pub fn atanh(x: var) -> @typeOf(x) { const T = @typeOf(x); switch (T) { f32 => @inlineCall(atanhf, x), f64 => @inlineCall(atanhd, x), else => @compileError("atanh not implemented for " ++ @typeName(T)), } } // atanh(x) = log((1 + x) / (1 - x)) / ...
src/atanh.zig
const std = @import("std"); const mem = @import("./mem.zig"); const stdout = std.io.getStdOut().writer(); const stdin = std.io.getStdIn().reader(); const Traps = enum(u16) { GETC = 0x20, // 0: Read a single character OUT = 0x21, // Write character to console PUTS = 0x22, // Write string to console ...
src/traps.zig
const std = @import("std"); const csv = @import("csv"); pub const Converter = struct { const BufferedWriter = std.io.BufferedWriter(4096, std.fs.File.Writer); allocator: *std.mem.Allocator, csvBuf: []u8, hdrBuf: []u8, rowBuf: []u8, keys: [][]const u8, out: BufferedWriter, // Initializ...
src/converter.zig
const std = @import("std"); const stb_image = @import("stb"); const gk = @import("../gamekit.zig"); const imgui = @import("imgui"); const renderkit = @import("renderkit"); const renderer = renderkit.renderer; const fs = gk.utils.fs; pub const Texture = struct { img: renderkit.Image, width: f32 = 0, height:...
gamekit/graphics/texture.zig
const xcb = @import("../xcb.zig"); pub const id = xcb.Extension{ .name = "DAMAGE", .global_id = 0 }; pub const DAMAGE = u32; pub const ReportLevel = extern enum(c_uint) { @"RawRectangles" = 0, @"DeltaRectangles" = 1, @"BoundingBox" = 2, @"NonEmpty" = 3, }; /// Opcode for BadDamage. pub const BadDam...
src/auto/damage.zig
const build_ = @import("std").build; const Builder = build_.Builder; const LibExeObjStep = build_.LibExeObjStep; const builtin = @import("builtin"); const testNames = [_][]const u8{ "WindowGraphicsInput", "ModelFiles", "RTRenderEngine", "Mathematics", "Compress", "RGB10A2", "Assets", "S...
build.zig
const std = @import("std"); const math = std.math; const testing = std.testing; const __divtf3 = @import("divtf3.zig").__divtf3; fn compareResultLD(result: f128, expectedHi: u64, expectedLo: u64) bool { const rep = @bitCast(u128, result); const hi = @truncate(u64, rep >> 64); const lo = @truncate(u64, rep...
lib/std/special/compiler_rt/divtf3_test.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"); p...
src/day03.zig
const std = @import("std"); const parseInt = std.fmt.parseInt; const print = std.debug.print; const tokenize = std.mem.tokenize; const testing = std.testing; const input = @embedFile("./input.txt"); const rows = 100; const cols = 100; pub fn main() anyerror!void { print("--- Part One ---\n", .{}); print("Resu...
src/day09/day09.zig
extern "wapc" fn __guest_request(operation_ptr: [*]u8, payload_ptr: [*]u8) void; extern "wapc" fn __guest_response(ptr: [*]u8, len: usize) void; extern "wapc" fn __guest_error(ptr: [*]u8, len: usize) void; extern "wapc" fn __host_call(binding_ptr: [*]u8, binding_len: usize, namespace_ptr: [*]u8, namespace_len: usize, ...
wapc.zig
const std = @import("std"); const json = @import("../json.zig"); // Utils pub fn EnumStringify(comptime T: type) type { return struct { pub fn jsonStringify(value: T, options: json.StringifyOptions, out_stream: anytype) !void { try json.stringify(@enumToInt(value), options, out_stream); ...
src/types/common.zig
const std = @import("std"); const interop = @import("interop.zig"); const ascii = std.ascii; const testing = std.testing; pub const NativeType = enum { Void, Control, Canvas, Dialog, Image, Menu, Other }; pub const Error = error{ /// /// Open function must be called before any action NotInitialized, ...
src/commons.zig
const std = @import("std"); const mem = std.mem; const Allocator = mem.Allocator; pub const ScratchAllocator = struct { allocator: Allocator, backup_allocator: *Allocator, end_index: usize, buffer: []u8, pub fn init(allocator: *Allocator) ScratchAllocator { const scratch_buffer = allocator...
src/mem/scratch_allocator.zig
const std = @import("std"); const builtin = @import("builtin"); const tvg = @import("tvg"); extern "tinyvg" fn setResultSvg(svg_ptr: [*]const u8, svg_len: usize) void; extern "tinyvg" fn getSourceTvg(tvg_ptr: [*]u8, tvg_len: usize) void; extern "platform" fn platformPanic(ptr: [*]const u8, len: usize) void; extern "p...
src/polyfill/tinyvg.zig
const std = @import("std"); const os = std.os; const mem = std.mem; const testing = std.testing; const assert = std.debug.assert; test "communication via seqpacket unix domain socket" { const socket = try os.socket( os.AF_UNIX, os.SOCK_SEQPACKET | os.SOCK_CLOEXEC, os.PF_UNIX, ); def...
poc/ipc_seqpacket_socket.zig
const std = @import("std"); const c = @import("c.zig").c; const Interface = @import("Interface.zig"); const RequestAdapterOptions = Interface.RequestAdapterOptions; const RequestAdapterErrorCode = Interface.RequestAdapterErrorCode; const RequestAdapterError = Interface.RequestAdapterError; const RequestAdapterCallback...
gpu/src/NativeInstance.zig
const std = @import("std"); const tracy = @import("tracy.zig"); usingnamespace @import("threadpool"); usingnamespace @import("av-common.zig"); // we have to use 2 threads because sws_scale doesn't allow slicing in the middle for whatever reason const PoolSize = 2; pub fn FrameProcessor(comptime UserDataType: type) ty...
nativemap/src/frame-processor.zig
const std = @import("std"); const log = std.log; const sql = @import("sqlite"); const mem = std.mem; const print = std.debug.print; const process = std.process; const Allocator = std.mem.Allocator; const command = @import("cli.zig"); const Storage = @import("feed_db.zig").Storage; const Cli = command.Cli; const clap = ...
src/main.zig
const std = @import("std"); const Stream = std.net.Stream; const Allocator = std.mem.Allocator; const c = @cImport({ @cInclude("openssl/ssl.h"); @cInclude("openssl/err.h"); }); pub const SSLError = error { InitializationError, ConnectionError }; pub const SSLReadError = error { }; pub const SSLWrit...
openssl/ssl.zig
const ImageReader = zigimg.ImageReader; const ImageSeekStream = zigimg.ImageSeekStream; const PixelFormat = zigimg.PixelFormat; const assert = std.debug.assert; const color = zigimg.color; const errors = zigimg.errors; const png = zigimg.png; const std = @import("std"); const testing = std.testing; const zigimg = @impo...
tests/formats/png_test.zig
const std = @import("std"); const c = @import("internal/c.zig"); const bitjuggle = @import("internal/bitjuggle.zig"); const internal = @import("internal/internal.zig"); const log = std.log.scoped(.git); const git = @import("git.zig"); pub const Worktree = opaque { pub fn deinit(self: *Worktree) void { log...
src/worktree.zig
pub const std = @import("std"); pub const enable = if (std.builtin.is_test) false else @import("build_options").enable_tracy; extern fn ___tracy_emit_frame_mark_start(name: ?[*:0]const u8) void; extern fn ___tracy_emit_frame_mark_end(name: ?[*:0]const u8) void; //extern fn ___tracy_set_thread_name(name: ?[*:0]const u...
src/tracy.zig
const builtin = @import("builtin"); const io = @import("std").io; pub fn toMagicNumberNative(comptime magic: []const u8) u32 { var result: u32 = 0; inline for (magic) |character, index| { result |= (@as(u32, character) << (index * 8)); } return result; } pub fn toMagicNumberForeign(comptime ma...
src/utils.zig
const std = @import("std"); const warn = std.debug.warn; const Config = @import("config.zig").Config; const c = @import("c.zig"); const msg = @import("message.zig"); const strtok = msg.strtok; pub const CachedJValue = struct { path: []const u8, // value: ?[]const u8 = null, value: ?std.json.Value = null, }...
src/api.zig
const std = @import("std"); const unicode = std.unicode; const mem = std.mem; const warn = std.debug.warn; pub const List = std.ArrayList(Value); const Value = union(enum) { Null, Bool: bool, Float: float64, Int: int64, String: []const u8, Raw: []const u8, List: List, }; pub const Part = u...
src/db/pq/encoding.zig
const ReferenceCounter = @import("../RefCount.zig").ReferenceCounter; const wgi = @import("../WindowGraphicsInput/WindowGraphicsInput.zig"); const Tex2D = wgi.Texture2D; const Asset = @import("../Assets/Assets.zig").Asset; // Use the functions in the texture variable for uploading data, changing filtering, etc. pub co...
src/RTRenderEngine/Texture2D.zig
const std = @import("std"); usingnamespace @import("template.zig"); // ------------- // --- Tests --- // ------------- const t = std.testing; const allocator = t.allocator; fn t_expectEqual(actual: anytype, expected: @TypeOf(actual)) void { t.expectEqual(expected, actual); } fn expectNode(node: Node, comptime no...
src/tests.zig
const std = @import("std"); const tvg = @import("tinyvg.zig"); /// Renders a binary TinyVG into its text representation. /// - `allocator` will be used for temporary allocations in the TVG parser. /// - `tvg_buffer` provides a binary TinyVG file /// - `writer` will receive the UTF-8 encoded SVG text. pub fn renderBin...
src/lib/text.zig
const std = @import("std"); const os = std.os; const IO_Uring = linux.IO_Uring; const io_uring_sqe = linux.io_uring_sqe; pub fn recvmsg( self: *IO_Uring, user_data: u64, fd: os.fd_t, msg: *os.msghdr, flags: u32, ) !*io_uring_sqe { const sqe = try self.get_sqe(); io_uring_prep_recvmsg(sqe, f...
src/sendmsg.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 data = @embedFile("../dat...
src/day22.zig
const std = @import("std"); usingnamespace (@import("../machine.zig")); usingnamespace (@import("../util.zig")); const imm = Operand.immediate; const imm8 = Operand.immediate8; const imm16 = Operand.immediate16; const imm32 = Operand.immediate32; const imm64 = Operand.immediate64; const immSign = Operand.immediateSig...
src/x86/tests/cmp.zig
const std = @import("std"); const lib = @import("lib"); const io = std.io; const fs = std.fs; const mem = std.mem; const ArrayList = std.ArrayListUnmanaged; const Allocator = std.mem.Allocator; const Interpreter = lib.Interpreter; const FindContext = @This(); stream: Stream, line: u32 = 1, column: u32 = 1, stack: Sta...
src/FindContext.zig
pub const PspKernelErrorCodes = extern enum(c_int) { Ok = 0, Error = 2147614721, Notimp = 2147614722, IllegalExpcode = 2147614770, ExpHandlerNoUse = 2147614771, ExpHandlerUsed = 2147614772, SycallTableNoUsed = 2147614773, SycallTableUsed = 2147614774, IllegalSyscalltable = 2147614775...
src/psp/sdk/pspkerror.zig
pub const MAX_REASON_NAME_LEN = @as(u32, 64); pub const MAX_REASON_DESC_LEN = @as(u32, 256); pub const MAX_REASON_BUGID_LEN = @as(u32, 32); pub const MAX_REASON_COMMENT_LEN = @as(u32, 512); pub const SHUTDOWN_TYPE_LEN = @as(u32, 32); pub const POLICY_SHOWREASONUI_NEVER = @as(u32, 0); pub const POLICY_SHOWREASONUI_ALWAY...
deps/zigwin32/win32/system/shutdown.zig
const std = @import("std"); const ascii = std.ascii; const base64 = std.base64; const c = std.c; const debug = std.debug; const fs = std.fs; const heap = std.heap; const io = std.io; const math = std.math; const mem = std.mem; const os = std.os; const unicode = std.unicode; const Rune = u32; const ATTR_NULL = 0; con...
st.zig
const std = @import("std"); const root = @import("root"); const mem = std.mem; const assert = std.debug.assert; const Allocator = mem.Allocator; // const ArrayList = std.ArrayList; const ByteList = std.ArrayListAlignedUnmanaged([]u8, null); const GlobalAlloc = std.heap.GeneralPurposeAllocator(.{}); // general purpo...
src/liu/allocators.zig
const std = @import("std"); const Edge = @import("edge.zig").Edge; pub const Rect = struct { x: f32 = 0, y: f32 = 0, w: f32 = 0, h: f32 = 0, }; pub const RectI = struct { x: i32 = 0, y: i32 = 0, w: i32 = 0, h: i32 = 0, pub fn right(self: RectI) i32 { return self.x + self.w...
src/math/rect.zig
const std = @import("std"); const fs = std.fs; pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = &gpa.allocator; const input = try fs.cwd().readFileAlloc(allocator, "data/input_05_1.txt", std.math.maxInt(usize)); { // Solution 1 var lines = std.mem.tok...
2020/src/day_05.zig
const std = @import("std"); const gfx = @import("gfx.zig"); const renderkit = @import("renderkit"); const gk = @import("gamekit.zig"); const math = gk.math; const Texture = gfx.Texture; pub const draw = struct { pub var batcher: gfx.Batcher = undefined; pub var fontbook: *gfx.FontBook = undefined; var qu...
gamekit/draw.zig
const std = @import("std"); const assert = debug.assert; fn escape(comptime literal: []const u8) -> []const u8 { "\x1b[" ++ literal } pub const ResetAll = escape("c"); pub const Color = enum { Simple: u8, Ansi: u8, TrueColor: struct { r: u8, g: u8, b: u8 }, }; pub const Black = Color.Simple {...
ansiz.zig
const std = @import("std"); const print = std.debug.print; const input_file = @embedFile("input.txt"); const Passport = std.StringHashMap([]const u8); fn parseInput(allocator: *std.mem.Allocator) ![]Passport { var passports = std.ArrayList(Passport).init(allocator); errdefer passports.deinit(); var input ...
2020/04/main.zig
const std = @import("std"); const debug = std.debug; const mem = std.mem; const net = std.net; const os = std.os; const IO_Uring = std.os.linux.IO_Uring; const logger = std.log.scoped(.io_helpers); // TODO(vincent): make this dynamic const max_connections = 128; /// Manages a set of registered file descriptors. ///...
src/io.zig
const ctz = @import("count0bits.zig"); const testing = @import("std").testing; fn test__ctzdi2(a: u64, expected: i32) !void { var x = @bitCast(i64, a); var result = ctz.__ctzdi2(x); try testing.expectEqual(expected, result); } test "ctzdi2" { try test__ctzdi2(0x00000000_00000001, 0); try test__ctz...
lib/std/special/compiler_rt/ctzdi2_test.zig
const builtin = @import("builtin"); const std = @import("../std.zig"); const mem = std.mem; const assert = std.debug.assert; const math = std.math; const maxInt = std.math.maxInt; pub const advapi32 = @import("windows/advapi32.zig"); pub const kernel32 = @import("windows/kernel32.zig"); pub const ntdll = @import("win...
lib/std/os/windows.zig
const std = @import("std"); const expect = std.testing.expect; const expectEqual = std.testing.expectEqual; const expectEqualSlices = std.testing.expectEqualSlices; const maxInt = std.math.maxInt; const minInt = std.math.minInt; const mem = std.mem; test "division" { if (@import("builtin").arch == .riscv64) { ...
test/stage1/behavior/math.zig
const std = @import("std"); const offsets = @import("offsets.zig"); const DocumentStore = @import("document_store.zig"); const analysis = @import("analysis.zig"); const ast = std.zig.ast; usingnamespace @import("ast.zig"); pub const TokenType = enum(u32) { type, parameter, variable, enumMember, fie...
src/semantic_tokens.zig
const std = @import("../std.zig"); const builtin = std.builtin; const io = std.io; const assert = std.debug.assert; const testing = std.testing; const trait = std.meta.trait; const meta = std.meta; const math = std.math; /// Creates a stream which allows for reading bit fields from another stream pub fn BitReader(endi...
lib/std/io/bit_reader.zig
const std = @import("../../index.zig"); const builtin = @import("builtin"); const os = std.os; const unicode = std.unicode; const windows = std.os.windows; const assert = std.debug.assert; const mem = std.mem; const BufMap = std.BufMap; const cstr = std.cstr; // > The maximum path of 32,767 characters is approximate, ...
std/os/windows/util.zig
const aoc = @import("../aoc.zig"); const std = @import("std"); const Allocator = std.mem.Allocator; const ArenaAllocator = std.heap.ArenaAllocator; const Player = struct { const Deck = std.ArrayList(u8); deck: Deck, player2: bool, last_card: u8 = undefined, fn fromGroup(allocator: Allocator, grou...
src/main/zig/2020/day22.zig
const std = @import("std"); const c = @import("../c.zig"); const gui = @import("../gui.zig"); pub const Color = struct { const Self = @This(); r: f32, g: f32, b: f32, fn encode(self: Self, buf: *std.ArrayList(c.vec4)) !void { try buf.append(.{ .x = self.r, .y = self.g, .z = self.b, .w = ...
src/scene/material.zig
const std = @import("std"); const testing = std.testing; pub const Sector = packed struct { // Sectors are 4KiB in size. comptime { std.debug.assert(@sizeOf(Sector) == 0x1000); } // The relevant size of this data depends on the id, and can range from 2000 to 3968 bytes. The rest // is just...
src/save/sector.zig
const builtin = @import("builtin"); const math = @import("index.zig").math; pub fn doClientRequest(default: usize, request: usize, a1: usize, a2: usize, a3: usize, a4: usize, a5: usize) usize { if (!builtin.valgrind_support) { return default; } switch (builtin.arch) { builtin.Arch.i386 => ...
lib/std/valgrind.zig
const std = @import("std"); pub const IterationContext = struct { pub const StackInfo = struct { index: usize, material: i32, // Negative indexes are used for generated materials }; pub const EnterInfo = struct { enter_index: usize, enter_stack: usize, }; value_ind...
src/sdf/iteration_context.zig
const builtin = @import("builtin"); const std = @import("std"); const debug = std.debug; const io = std.io; const math = std.math; const mem = std.mem; const meta = std.meta; const time = std.time; const Decl = builtin.TypeInfo.Declaration; pub fn benchmark(comptime B: type) !void { const args = if (@hasDecl(B, ...
src/bench.zig
const std = @import("std"); pub fn build(b: *std.build.Builder) void { const mode = b.standardReleaseOptions(); const target = b.standardTargetOptions(.{}); const cOptions = &[_][]const u8 { "-Wall", "-Wextra", "-Werror", }; const brsslToolSources = [_][]const u8 { ...
build.zig
const clap = @import("clap"); const format = @import("format"); const std = @import("std"); const ston = @import("ston"); const util = @import("util"); const debug = std.debug; const fmt = std.fmt; const fs = std.fs; const heap = std.heap; const io = std.io; const math = std.math; const mem = std.mem; const os = std.o...
src/randomizers/tm35-rand-names.zig
pub const WCM_SETTINGS_ID_FLAG_REFERENCE = @as(u32, 0); pub const WCM_SETTINGS_ID_FLAG_DEFINITION = @as(u32, 1); pub const LINK_STORE_TO_ENGINE_INSTANCE = @as(u32, 1); pub const LIMITED_VALIDATION_MODE = @as(u32, 1); pub const WCM_E_INTERNALERROR = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2145255424)); pub c...
win32/system/settings_management_infrastructure.zig
const std = @import("std"); const Builder = std.build.Builder; const builtin = @import("builtin"); pub fn build(b: *Builder) void { // Each tutorial stage, its source file, and description const targets = [_]Target{ .{ .name = "hello_window", .src = "src/1_1_hello_window.zig", .description = "Hello GLF...
build.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const Entry = @import("entry.zig").Entry; const Options = @import("Options.zig"); const PathDepthPair = struct { path: []const u8, depth: usize, }; pub const BreadthFirstWalker = struct { start_path: []const...
src/breadth_first.zig
const std = @import("std"); const ignore = @import("ignore.zig"); const warn = std.debug.warn; const testing = std.testing; const FileInfo = @import("path/file_info").FileInfo; test "parse" { const rules = \\#ignore \\#ignore \\foo \\bar/* \\baz/bar/foo.txt \\one/mor...
src/ignore/ignore_test.zig
//! Futex is a mechanism used to block (`wait`) and unblock (`wake`) threads using a 32bit memory address as hints. //! Blocking a thread is acknowledged only if the 32bit memory address is equal to a given value. //! This check helps avoid block/unblock deadlocks which occur if a `wake()` happens before a `wait()`. /...
lib/std/Thread/Futex.zig
const std = @import("std"); const builtin = std.builtin; const arch = std.Target.current.cpu.arch; const linkage: builtin.GlobalLinkage = if (builtin.is_test) .Internal else .Weak; // This parameter is true iff the target architecture supports the bare minimum // to implement the atomic load/store intrinsics. // Some...
lib/std/special/compiler_rt/atomics.zig
const std = @import("std"); const Allocator = std.mem.Allocator; const system_bus_address = "unix:path=/var/run/dbus/system_bus_socket"; pub const Connection = struct { socket: std.net.Stream, pub fn connectSystemBus() !Connection { const address = std.os.getenv("DBUS_SYSTEM_BUS_ADDRESS") orelse ...
src/dbus.zig
const std = @import("std"); const TinyCC = @import("./tcc.zig").TinyCC; const js = @import("./quickjs.zig"); const GlobalContext = @import("./context.zig"); const purl = @import("./url.zig"); const catom = js.JsAtom.comptimeAtom; const scoped = std.log.scoped(.main); pub const enable_segfault_handler = false; fn s...
src/main.zig
pub const WasiHandle = i32; pub const Char8 = u8; pub const Char32 = u32; pub fn WasiPtr(comptime T: type) type { return [*c]const T; } pub fn WasiMutPtr(comptime T: type) type { return [*c]T; } pub const WasiStringBytesPtr = WasiPtr(Char8); pub const WasiString = extern struct { ptr: WasiStringBytesPtr, ...
src/zigly/wasm.zig
const gen3 = @import("../gen3.zig"); const rom = @import("../rom.zig"); const std = @import("std"); const io = std.io; const mem = std.mem; // TODO: Replace with Replacing/Escaping streams pub const en_us = [_]rom.encoding.Char{ .{ " ", "\x00" }, .{ "À", "\x01" }, .{ "Á", "\x02" }, .{ "Â", "\x03" }, ...
src/core/gen3/encodings.zig
const std = @import("std"); const assert = std.debug.assert; const Allocator = std.mem.Allocator; const testing = std.testing; const Node = struct { x: u32, y: u32, width: u32, }; pub const Error = error{ /// Atlas cannot fit the desired region. You must enlarge the atlas. AtlasFull, }; /// A re...
examples/gkurve/atlas.zig
const std = @import("std"); const os = std.os; const io = std.io; /// ReadMode defines the read behaivour when using raw mode pub const ReadMode = enum { blocking, nonblocking, }; pub fn enableRawMode(handle: os.system.fd_t, blocking: ReadMode) !RawTerm { // var original_termios = try os.tcgetattr(handle)...
src/term.zig
const std = @import("std"); const builtin = @import("builtin"); const testing = std.testing; const root = @import("root"); pub const UnicodeMode = enum { ansi, wide, unspecified }; // WORKAROUND: https://github.com/ziglang/zig/issues/7979 // using root.UNICODE causes an erroneous dependency loop, so I'm hardcoding to ...
win32/zig.zig
const std = @import("std"); const builtin = @import("builtin"); const Allocator = std.mem.Allocator; const meta_size = 2 * @sizeOf(usize); const min_payload_size = meta_size; const min_frame_size = meta_size + min_payload_size; const jumbo_index = 0; const page_index = 1; pub const ZeeAllocDefaults = ZeeAlloc(Config...
src/main.zig
const std = @import("std"); const testing = std.testing; const expect = testing.expect; const expectError = testing.expectError; test "dereference pointer" { comptime try testDerefPtr(); try testDerefPtr(); } fn testDerefPtr() !void { var x: i32 = 1234; var y = &x; y.* += 1; try expect(x == 12...
test/behavior/pointers.zig
const root = @import("root"); const std = @import("std"); const config = @import("config.zig"); const io = std.io; const os = std.os; const system = os.system; const assert = std.debug.assert; const expect = std.testing.expect; const print = std.debug.print; const tcflag = system.tcflag_t; const Allocator = *std.mem.A...
libs/term.zig
const std = @import("std"); const allocators = @import("allocators.zig"); const languages = @import("languages.zig"); const processor = @import("processor.zig"); const lua = @import("lua.zig"); const zlib = @import("zlib.zig"); const help_common = @embedFile("help-common.txt"); const help_verbose = @embedFile("help-ve...
limp/main.zig
const chipz = @import("chipz"); const std = @import("std"); const test_allocator = std.testing.allocator; const expect_equal = std.testing.expectEqual; const expect_equal_slices = std.testing.expectEqualSlices; const expect = std.testing.expect; test "clear screen" { var emu = chipz.ChipZ.init(test_allocator); ...
tests/tests.zig
const std = @import("./index.zig"); const debug = std.debug; /// Given the first byte of a UTF-8 codepoint, /// returns a number 1-4 indicating the total length of the codepoint in bytes. /// If this byte does not match the form of a UTF-8 start byte, returns Utf8InvalidStartByte. pub fn utf8ByteSequenceLength(first_b...
std/unicode.zig
const std = @import("std"); const process = std.process; const debug = @import("debug.zig"); const vm = @import("vm.zig"); const Allocator = std.mem.Allocator; const ArrayList = std.ArrayList; const Chunk = @import("chunk.zig").Chunk; const OpCode = @import("chunk.zig").OpCode; pub fn main() anyerror!void { var ...
src/main.zig
const sg = @import("gfx.zig"); // helper function to convert "anything" to a Range struct pub fn asRange(val: anytype) Range { const type_info = @typeInfo(@TypeOf(val)); switch (type_info) { .Pointer => { switch (type_info.Pointer.size) { .One => return .{ .ptr = val, .size...
src/sokol/shape.zig
const std = @import("std"); const wayland = @import("wayland.zig"); pub const Object = opaque {}; pub const Message = extern struct { name: [*:0]const u8, signature: [*:0]const u8, types: ?[*]const ?*const Interface, }; pub const Interface = extern struct { name: [*:0]const u8, version: c_int, ...
src/common_core.zig
const bssl = @import("bearssl"); // brssl ta var TA0_DN = [_]u8 { 0x30, 0x14, 0x31, 0x12, 0x30, 0x10, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0C, 0x09, 0x6C, 0x6F, 0x63, 0x61, 0x6C, 0x68, 0x6F, 0x73, 0x74 }; var TA0_RSA_N = [_]u8 { 0xBA, 0x68, 0x49, 0x23, 0xBF, 0xD1, 0xF2, 0x63, 0x42, 0x5D, 0x45, 0x0E, 0xDE,...
test/localhost.zig
const std = @import("std"); const builtin = @import("builtin"); const Builder = std.build.Builder; const Arch = std.Target.Cpu.Arch; const CrossTarget = std.zig.CrossTarget; const deps = @import("deps.zig"); pub fn build(b: *Builder) !void { // const arch = b.option(Arch, "arch", "The CPU architecture to build fo...
build.zig
const std = @import("std"); const builtin = @import("builtin"); const native_endian = builtin.target.cpu.arch.endian(); const mem = std.mem; const math = std.math; const random = std.crypto.random; const assert = std.debug.assert; const expectEqual = std.testing.expectEqual; const expectError = std.testing.expectError;...
lib/std/x/net/bpf.zig
const std = @import("std"); const unicode = std.unicode; const mem = std.mem; const warn = std.debug.warn; const builtin = @import("builtin"); const path = std.fs.path; const is_windows = builtin.os == .windows; pub const MatchError = error{BadPattern}; /// reports whether name matches the shell file name pattern. //...
src/path/filepath/match.zig
const std = @import("std"); const json = @import("../json.zig"); const common = @import("common.zig"); const general = @import("general.zig"); const language_features = @import("language_features.zig"); /// A request message to describe a request between the client and the server. /// Every processed request must sen...
src/types/requests.zig
const std = @import("std"); const pkmn = @import("pkmn"); const protocol = pkmn.protocol; const Tool = enum { markdown, protocol, layout, }; pub fn main() !void { var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer arena.deinit(); const allocator = arena.allocator(); ...
src/tools/protocol.zig
pub const CompositorOutput = backends.BackendOutput(Output); pub var OUTPUTS: Stalloc(void, CompositorOutput, 16) = undefined; pub const OUTPUT_BASE: usize = 1000; pub const Output = struct { views: [4]View, const Self = @This(); pub fn deinit(self: *Self) !void { var parent = @fieldParentPtr(Com...
src/output.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/day10.txt"); co...
src/day10.zig
//*************************************************************** // library imports //*************************************************************** const std = @import("std"); const stdin = std.io.getStdIn(); const warn = std.debug.warn; const fmt = std.fmt; //******************************************************...
zig/lr.zig
const std = @import("std"); const assert = std.debug.assert; pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); const allocator = gpa.allocator(); var input_file = try std.fs.cwd().openFile("input/09.txt", .{}); defer input_file.close(); var buffe...
src/09.zig
const std = @import("std"); const builtin = @import("builtin"); const os = @import("../os.zig"); const system = os.system; const errno = system.getErrno; const fd_t = system.fd_t; const mode_t = system.mode_t; const pid_t = system.pid_t; const unexpectedErrno = os.unexpectedErrno; const UnexpectedError = os.Unexpected...
lib/std/os/posix_spawn.zig
const std = @import("std"); const print = std.debug.print; const data = @embedFile("../inputs/day11.txt"); pub fn main() anyerror!void { const grid = parse(data[0..]).?; print("Part 1: {d}\n", .{part1(grid)}); print("Part 2: {d}\n", .{part2(grid)}); } const Size = 10; const Octopus = struct { energy...
src/day11.zig
const x86_64 = @import("../../../index.zig"); const bitjuggle = @import("bitjuggle"); const std = @import("std"); pub const OffsetPageTable = @import("mapped_page_table.zig").OffsetPageTable; pub const MappedPageTable = @import("mapped_page_table.zig").MappedPageTable; pub const RecursivePageTable = @import("recursive...
src/structures/paging/mapping/mapping.zig
const std = @import("std"); const math = std.math; const assert = std.debug.assert; const warn = std.debug.warn; const ae = @import("../modules/zig-approxeql/approxeql.zig"); const DBG = false; pub const Mat4x4 = struct { const Self = @This(); data: [4][4]f32, /// matrix multiplication pub fn mult(m...
deprecated/math3d.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day04.txt"); const BingoBoard = struct { mask: u25 = 0, is_winner: bool = false, cells: [5][5]u8 = undefined, }; const BoardLoc = struct { board: usize, row: u5, col: u5, }; const NumLocsMap = struc...
src/day04.zig