code stringlengths 38 801k | repo_path stringlengths 6 263 |
|---|---|
const std = @import("std");
const mem = std.mem;
usingnamespace @import("primitive_types.zig");
const PrimitiveReader = @import("primitive/reader.zig").PrimitiveReader;
const testing = @import("testing.zig");
pub const GlobalTableSpec = struct {
keyspace: []const u8,
table: []const u8,
};
fn readOptionID(p... | src/metadata.zig |
const std = @import("std");
const kernel = @import("root");
const printk = kernel.printk;
const lib = kernel.lib;
const logger = @TypeOf(@import("../x86.zig").logger).childOf(@typeName(@This())){};
const mm = kernel.mm;
const PhysicalAddress = kernel.mm.PhysicalAddress;
const RSDP = extern struct {
// "RSD PTR "
... | kernel/arch/x86/acpi.zig |
const std = @import("std");
const math = std.math;
const log = std.log;
const fs = std.fs;
const os = std.os;
const proc = @import("./proc.zig");
const match = @import("./glob.zig").globMatch;
const l2 = @import("./missing_syscalls.zig");
// Constants obtained from RF Jakob's earlyoom.
const ram_fill_rate = 6000;
cons... | src/killer.zig |
const std = @import("std");
const common = @import("../common/data.zig");
const DEBUG = @import("../common/debug.zig").print;
const options = @import("../common/options.zig");
const protocol = @import("../common/protocol.zig");
const rng = @import("../common/rng.zig");
const data = @import("data.zig");
const helpers ... | src/lib/gen1/test.zig |
const std = @import("std");
const info = std.log.info;
const warn = std.log.warn;
const bus = @import("bus.zig");
const rsp = @import("rsp.zig");
const mi = @import("mi.zig");
const InterruptSource = mi.InterruptSource;
pub const RDPStatus = packed struct {
x : bool = false,
f : bool = false,
fl: bool... | src/core/rdp.zig |
const utils = @import("main.zig").utils;
const std = @import("std");
pub const print = struct {
/// Returns the ANSI sequence as a []const u8
pub const reset = utils.comptimeCsi("0m", .{});
/// Returns the ANSI sequence to set bold mode
pub const bold = utils.comptimeCsi("1m", .{});
pub const no_... | src/style.zig |
pub const QOS_MAX_OBJECT_STRING_LENGTH = @as(u32, 256);
pub const QOS_TRAFFIC_GENERAL_ID_BASE = @as(u32, 4000);
pub const SERVICETYPE_NOTRAFFIC = @as(u32, 0);
pub const SERVICETYPE_BESTEFFORT = @as(u32, 1);
pub const SERVICETYPE_CONTROLLEDLOAD = @as(u32, 2);
pub const SERVICETYPE_GUARANTEED = @as(u32, 3);
pub const SER... | deps/zigwin32/win32/network_management/qo_s.zig |
const std = @import("std");
const mem = std.mem;
const Allocator = mem.Allocator;
const assert = std.debug.assert;
const Compilation = @import("Compilation.zig");
const Source = @import("Source.zig");
const Tokenizer = @import("Tokenizer.zig");
const Preprocessor = @import("Preprocessor.zig");
const Tree = @import("Tre... | src/Parser.zig |
const std = @import("std");
pub fn unwrapPtr(comptime SomeType: type) type {
const ti = @typeInfo(SomeType);
const T = if (ti == .Pointer and ti.Pointer.size == .One) SomeType.Child else SomeType;
return T;
}
pub fn isString(comptime SomeT: type) bool {
const ti = @typeInfo(SomeT);
if (ti == .Point... | src/main.zig |
const std = @import("std");
const sys = @import("sys.zig");
const CLONE = std.os.linux.CLONE;
const MS = std.os.linux.MS;
const MNT = std.os.linux.MNT;
const EPOLL = std.os.linux.EPOLL;
pub fn IOStreams(comptime Stdin: type, comptime Stdout: type, comptime Stderr: type) type {
return struct {
stdin: Stdin... | src/container.zig |
const GPUData = extern union(enum) {
/// The ACPI path of this GPU device,
/// if possible to construct.
///
/// Aliases: `acpiPath`
ACPI: ?[]const u8,
/// The ACPI path of this GPU device,
/// if possible to construct.
///
/// Aliases: `acpiPath`
acpiPath: ?[]const u8,
///... | lib/core/gpu.zig |
const std = @import("std");
usingnamespace @import("zalgebra");
pub const Aabb = struct {
const Self = @This();
position: vec3,
half_extent: vec3,
pub fn init(pos: vec3, extent: vec3) Self {
return Self {
.position = pos,
.half_extent = extent,
};
}
pu... | src/collision/aabb.zig |
const std = @import("std");
const with_trace = true;
const assert = std.debug.assert;
fn trace(comptime fmt: []const u8, args: anytype) void {
if (with_trace) std.debug.print(fmt, args);
}
fn findoradd(cities: [][]const u8, nb: *u32, name: []const u8) u32 {
var i: u32 = 0;
while (i < nb.*) : (i += 1) {
... | 2015/day9.zig |
const std = @import("std");
const fs = std.fs;
const hm = std.hash_map;
const mem = std.mem;
const print = std.debug.print;
const assert = std.debug.assert;
const IngredientMap = hm.HashMap([]const u8, Ingredient, hm.hashString, hm.eqlString, 80);
const AllergenMap = hm.HashMap([]const u8, Allergen, hm.hashString, hm... | 2020/src/day_21.zig |
const std = @import("../std.zig");
const builtin = @import("builtin");
const Mutex = @This();
const os = std.os;
const assert = std.debug.assert;
const testing = std.testing;
const Atomic = std.atomic.Atomic;
const Futex = std.Thread.Futex;
impl: Impl = .{},
/// Tries to acquire the mutex without blocking the calle... | lib/std/Thread/Mutex.zig |
const std = @import("std");
usingnamespace (@import("../machine.zig"));
usingnamespace (@import("../util.zig"));
test "bit manipulation" {
const m32 = Machine.init(.x86_32);
const m64 = Machine.init(.x64);
const reg = Operand.register;
const regRm = Operand.registerRm;
const imm = Operand.immediat... | src/x86/tests/bit_manipulation.zig |
const Audio = @This();
const SDL = @import("sdl2");
const std = @import("std");
const ROM = @import("ROM.zig");
const SAMPLE_RATE = 48000;
const SAMPLE_CHUNK_SIZE = SAMPLE_RATE / 60;
const AMP_FACTOR = 64; // arbitrary value so sound isn't so quiet
const Wave = [32]u8;
fn setVoiceNybble(value: u20, index: u3, nybb... | src/Audio.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const Value = @import("./value.zig").Value;
const VM = @import("./vm.zig").VM;
const Chunk = @import("./chunk.zig").Chunk;
const debug = @import("./debug.zig");
const Table = @import("./table.zig").Table;
pub const Obj = struct {
next: ?*Obj,
obj... | src/object.zig |
const std = @import("std");
const builtin = @import("builtin");
const stdx = @import("stdx");
const Timer = stdx.time.Timer;
const sdl = @import("sdl");
const log = std.log.scoped(.fps);
pub const DefaultFpsLimiter = FpsLimiter(20);
pub fn FpsLimiter(comptime NumSamples: u32) type {
return struct {
const... | graphics/src/fps.zig |
const std = @import("../std.zig");
const math = std.math;
const mem = std.mem;
const assert = std.debug.assert;
const testing = std.testing;
const maxInt = math.maxInt;
const Vector = std.meta.Vector;
const Poly1305 = std.crypto.onetimeauth.Poly1305;
// Vectorized implementation of the core function
const ChaCha20Vec... | lib/std/crypto/chacha20.zig |
const std = @import("std.zig");
const builtin = @import("builtin");
const assert = std.debug.assert;
const net = @This();
const mem = std.mem;
const os = std.os;
const fs = std.fs;
test "" {
_ = @import("net/test.zig");
}
const has_unix_sockets = @hasDecl(os, "sockaddr_un");
pub const Address = extern union {
... | lib/std/net.zig |
const std = @import("std");
const builtin = @import("builtin");
const Arch = builtin.Arch;
const Abi = builtin.Abi;
const Os = builtin.Os;
const assert = std.debug.assert;
const LibCTarget = struct {
name: []const u8,
arch: MultiArch,
abi: MultiAbi,
};
const MultiArch = union(enum) {
aarch64,
arm... | tools/process_headers.zig |
const std = @import("std");
const builtin = std.builtin;
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const ines = @import("ines.zig");
const console_ = @import("console.zig");
const Config = console_.Config;
const Console = console_.Console;
/// Avoids recursion in GenericMapper
fn MapperIn... | src/mapper.zig |
const std = @import("std");
const global_gc = &@import("main.zig").global_gc;
const Allocator = std.mem.Allocator;
const Collectible = struct {
freeFn: fn() void,
};
pub const GarbageCollector = struct {
child_allocator: Allocator,
collectibles: std.ArrayList(Collectible),
pub fn init(child_allocator... | src/gc.zig |
const std = @import("../std.zig");
const builtin = @import("builtin");
const maxInt = std.math.maxInt;
const iovec = std.os.iovec;
const iovec_const = std.os.iovec_const;
const timezone = std.c.timezone;
extern "c" fn ___errno() *c_int;
pub const _errno = ___errno;
pub const dl_iterate_phdr_callback = fn (info: *dl_p... | lib/std/c/solaris.zig |
const std = @import("std");
const json = @import("../json.zig");
const PathToken = union(enum) {
index: u32,
key: []const u8,
fn tokenize(string: []const u8) Tokenizer {
return .{ .string = string, .index = 0 };
}
const Tokenizer = struct {
string: []const u8,
index: usize... | src/json/path.zig |
const std = @import("std");
const mem = @import("./mem.zig");
const traps = @import("./traps.zig");
const Registers = mem.Registers;
const ConditionFlags = mem.ConditionFlags;
pub const Opcodes = enum(u16) {
BR, // 0: branch
ADD, // 1: add
LD, // 10: load
ST, // 11: store
JSR, // 100: jump... | src/ops.zig |
const std = @import("std");
const assert = std.debug.assert;
const tools = @import("tools");
const Registers = [4]u32;
const Opcode = enum { addi, addr, muli, mulr, bani, banr, bori, borr, setr, seti, gtir, gtri, gtrr, eqir, eqri, eqrr };
fn eval(op: Opcode, par: [3]u32, r: Registers) Registers {
var o = r;
sw... | 2018/day16.zig |
const std = @import("std");
const tools = @import("tools");
const with_trace = true;
const assert = std.debug.assert;
fn trace(comptime fmt: []const u8, args: anytype) void {
if (with_trace) std.debug.print(fmt, args);
}
pub fn main() anyerror!void {
const stdout = std.io.getStdOut().writer();
var arena... | 2016/day17.zig |
const std = @import("std");
const Pkg = std.build.Pkg;
const pkgs = struct {
const util = Pkg {
.name = "util",
.path = "src/util/_.zig",
};
const compile = Pkg {
.name = "compile",
.path = "src/compile/_.zig",
.dependencies = &.{ util },
};
const cli... | build.zig |
const vk = @import("vk.zig");
pub const GLFWmonitor = @OpaqueType();
pub const GLFWwindow = @OpaqueType();
pub const GLFWcursor = @OpaqueType();
pub const GLFWglproc = ?extern fn () void;
pub const GLFWvkproc = ?extern fn () void;
pub const GLFWerrorfun = ?extern fn (c_int, ?[*:0]const u8) void;
pub const GLFWwindowp... | src/glfw.zig |
const std = @import("std");
const string = []const u8;
const http = @import("apple_pie");
const files = @import("self/files");
const pek = @import("pek");
const uri = @import("uri");
const zfetch = @import("zfetch");
const json = @import("json");
const extras = @import("extras");
pub const Provider = struct {
id: ... | src/lib.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const print = std.debug.print;
const data = @embedFile("data/day17.txt");
const EntriesList = std.ArrayList(Record);
const Record = struct {
x: usize = 0,
};
const Pos = struct {
x: i32, y: i32, z: i32, w: i32
... | src/day17.zig |
const Types = @import("json_grammar.types.zig");
const Errors = @import("json_grammar.errors.zig");
const Tokens = @import("json_grammar.tokens.zig");
usingnamespace Types;
usingnamespace Errors;
usingnamespace Tokens;
pub const StackItem = struct {
item: usize,
state: i16,
value: StackValue,
};
pub con... | json/json_grammar.actions.zig |
const std = @import("std");
const builtin = @import("builtin");
const math = std.math;
const native_os = builtin.os.tag;
const long_double_is_f128 = builtin.target.longDoubleIsF128();
comptime {
// When the self-hosted compiler is further along, all the logic from c_stage1.zig will
// be migrated to this file... | lib/std/special/c.zig |
const std = @import("std");
const crypto = std.crypto;
const mem = std.mem;
const Sha512 = crypto.hash.sha2.Sha512;
const Curve = crypto.ecc.Edwards25519;
const Scalar = Curve.scalar.Scalar;
const Ed25519 = crypto.sign.Ed25519;
const CompressedScalar = Curve.scalar.CompressedScalar;
/// Ed25519 signatures with blind k... | src/main.zig |
const std = @import("std");
const mem = std.mem;
const Builder = std.build.Builder;
const LibExeObjStep = std.build.LibExeObjStep;
const Pkg = std.build.Pkg;
const RunStep = std.build.RunStep;
const Step = std.build.Step;
const Target = std.zig.CrossTarget;
const core_exes = [_][]const u8{
"tm35-apply",
"tm3... | build.zig |
pub const PspUtilityDialogCommon = extern struct {
size: c_uint,
language: c_int,
buttonSwap: c_int,
graphicsThread: c_int,
accessThread: c_int,
fontThread: c_int,
soundThread: c_int,
result: c_int,
reserved: [4]c_int,
};
pub const PspUtilityMsgDialogMode = extern enum(c_int) {
... | src/psp/sdk/psputility.zig |
const std = @import("std");
const api = @import("./buzz_api.zig");
export fn abs(vm: *api.VM) c_int {
const n = api.Value.bz_valueToNumber(vm.bz_peek(0));
vm.bz_pushNum(std.math.absFloat(n));
return 1;
}
export fn acos(vm: *api.VM) c_int {
const n = api.Value.bz_valueToNumber(vm.bz_peek(0));
vm... | lib/buzz_math.zig |
const mesh_common =
\\ struct DrawUniforms {
\\ object_to_world: mat4x4<f32>,
\\ basecolor_roughness: vec4<f32>,
\\ }
\\ @group(1) @binding(0) var<uniform> draw_uniforms: DrawUniforms;
\\
\\ struct FrameUniforms {
\\ world_to_clip: mat4x4<f32>,
\\ camera_position: vec3<f32>,
\\ }
\\ @group(0) ... | samples/bullet_physics_test_wgpu/src/bullet_physics_test_wgsl.zig |
const Coff = @This();
const std = @import("std");
const log = std.log.scoped(.link);
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const fs = std.fs;
const trace = @import("../tracy.zig").trace;
const Module = @import("../Module.zig");
const codegen = @import("../codegen.zig");
const link = @i... | src-self-hosted/link/Coff.zig |
const std = @import("std");
const utils = @import("utils");
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const print = utils.print;
const Rule = struct {
pair: [2]u8,
inserted: u8,
};
const Input = struct {
template: []u8,
rules: []Rule,
};
fn readInput(arena:... | day14/src/main.zig |
const std = @import("std");
const c = @import("c.zig");
const shaderc = @import("shaderc.zig");
const Viewport = @import("viewport.zig").Viewport;
pub const Blit = struct {
const Self = @This();
initialized: bool = false,
device: c.WGPUDeviceId,
queue: c.WGPUQueueId,
bind_group_layout: c.WGPUB... | src/blit.zig |
pub const _MM_HINT_T0 = @as(u32, 1);
pub const _MM_HINT_T1 = @as(u32, 2);
pub const _MM_HINT_T2 = @as(u32, 3);
pub const _MM_HINT_NTA = @as(u32, 0);
pub const ANYSIZE_ARRAY = @as(u32, 1);
pub const MEMORY_ALLOCATION_ALIGNMENT = @as(u32, 16);
pub const X86_CACHE_ALIGNMENT_SIZE = @as(u32, 64);
pub const ARM_CACHE_ALIGNME... | win32/system/system_services.zig |
const std = @import("std");
const ascii = std.ascii;
const base32 = @import("base32.zig");
const crc16 = @import("crc16.zig");
const crypto = std.crypto;
const Ed25519 = crypto.sign.Ed25519;
const mem = std.mem;
const testing = std.testing;
pub const InvalidPrefixByteError = error{InvalidPrefixByte};
pub const Invalid... | src/main.zig |
const std = @import("std");
const assert = std.debug.assert;
const zwin32 = @import("zwin32");
const w32 = zwin32.base;
const dwrite = zwin32.dwrite;
const dxgi = zwin32.dxgi;
const d3d11 = zwin32.d3d11;
const d3d12 = zwin32.d3d12;
const d3d12d = zwin32.d3d12d;
const d2d1 = zwin32.d2d1;
const d3d11on12 = zwin32.d3d11on... | libs/zd3d12/src/zd3d12.zig |
// DO NOT MODIFY. This is not actually a source file; it is a textual representation of generated code.
// Use only for debugging purposes.
// Auto-generated constructor
// Access: public
Method <init> : V
(
// (no arguments)
) {
ALOAD 0
// Method descriptor: ()V
INVOKESPECIAL java/lang/Object#<init>... | localproxyservice/target/generated-sources/gizmo/io/quarkus/runner/AutoFeature.zig |
const pokemon = @import("pokemon");
const search = @import("search.zig");
const std = @import("std");
const utils = @import("utils");
const constants = @import("gen3-constants.zig");
const fun = @import("../../lib/fun-with-zig/index.zig");
const os = std.os;
const debug = std.debug;
const mem = std.mem;
const math = s... | tools/offset-finder/gen3.zig |
const std = @import("../index.zig");
const math = std.math;
const expect = std.testing.expect;
const maxInt = std.math.maxInt;
pub fn isInf(x: var) bool {
const T = @typeOf(x);
switch (T) {
f16 => {
const bits = @bitCast(u16, x);
return bits & 0x7FFF == 0x7C00;
},
... | std/math/isinf.zig |
const midi = @import("../midi.zig");
const std = @import("std");
const mem = std.mem;
pub const Header = struct {
chunk: Chunk,
format: u16,
tracks: u16,
division: u16,
pub const size = 6;
};
pub const Chunk = struct {
kind: [4]u8,
len: u32,
pub const file_header = "MThd";
pub c... | midi/file.zig |
const Archive = @This();
const std = @import("std");
const assert = std.debug.assert;
const elf = std.elf;
const fs = std.fs;
const log = std.log.scoped(.elf);
const mem = std.mem;
const Allocator = mem.Allocator;
const Object = @import("Object.zig");
file: fs.File,
name: []const u8,
/// Parsed table of contents.
/... | src/Elf/Archive.zig |
const expect = std.testing.expect;
const std = @import("std");
const Allocator = std.mem.Allocator;
const FixedHeader = @import("../packet.zig").Packet.FixedHeader;
pub const ReturnCode = enum(u8) {
ok = 0,
unacceptable_protocol_version,
invalid_client_id,
server_unavailable,
malformed_credentials,... | src/mqtt4/packet/connack.zig |
const graphics = @import("didot-graphics");
const objects = @import("didot-objects");
const glfw = @import("glfw");
const gl = @import("gl");
const std = @import("std");
const single_threaded = @import("builtin").single_threaded;
const Allocator = std.mem.Allocator;
const Window = graphics.Window;
pub const Scene = obj... | didot-app/app.zig |
const std = @import("std");
const DirectoryEntryMetadata = @import("DirectoryEntryMetadata.zig");
const PathComponents = @import("PathComponents.zig");
pub const DirectoryEntry = struct {
path_components: PathComponents,
metadata: DirectoryEntryMetadata,
};
pub fn Iterator(comptime ReaderType: type) type {
... | src/vpk/iterator.zig |
const std = @import("std");
const expect = std.testing.expect;
const cstd = @cImport({
@cInclude("stdlib.h");
});
pub fn envtpl(writer: anytype, line: []const u8) !void {
var opening_brace_pos: ?usize = null;
var closing_brace_pos: ?usize = null;
for (line) |c, i| {
switch (c) {
'$... | src/envtpl.zig |
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const GeneralPurposeAllocator = std.heap.GeneralPurposeAllocator(.{});
const tb = @import("tigerbeetle/src/tigerbeetle.zig");
const StateMachine = @import("tigerbeetle/src/state_machine.zig").StateMachine;
const Operat... | src/libtigerbeetle/src/lib.zig |
const c = @import("c.zig");
const utils = @import("utils.zig");
const std = @import("std");
usingnamespace @import("log.zig");
// DEF
/// Buffer bits
pub const BufferBit = enum {
depth, stencil, colour
};
/// Buffer types
pub const BufferType = enum {
array, elementarray
};
/// Draw types
pub const Dra... | src/kiragine/kira/gl.zig |
const std = @import("std");
const print = std.debug.print;
pub const Case = enum { lower, upper };
fn isUtf8ControlCode(c: []const u8) bool {
return c.len == 2 and c[0] == '\xC2' and c[1] >= '\x80' and c[1] <= '\x9F';
}
/// Like std.unicode.Utf8Iterator, but handles invalid UTF-8 without panicing
pub const Inval... | src/util.zig |
const std = @import("std");
var a: *std.mem.Allocator = undefined;
const stdout = std.io.getStdOut().writer(); //prepare stdout to write in
//const LENGTH = 5; // testing
const LENGTH = 12; // prod
//const MAJORITY_THRESHOLD = 6; // testing
const MAJORITY_THRESHOLD = 500; // prod
fn run(input: [:0]u8) u32 {
// ... | day-03/part-1/lelithium.zig |
const std = @import("std");
const fun = @import("fun");
const debug = std.debug;
const heap = std.heap;
const io = std.io;
const math = std.math;
const mem = std.mem;
const os = std.os;
const scan = fun.scan.scan;
pub fn main() !void {
const stdin = &(try io.getStdIn()).inStream().stream;
const stdout = &(tr... | src/day9.zig |
const std = @import("std");
const zargo = @import("zargo.zig");
export fn zargo_engine_init(backend: zargo.Backend, window_width: u32, window_height: u32, debug: bool) ?*zargo.Engine {
var e = std.heap.c_allocator.create(zargo.Engine) catch return null;
errdefer std.heap.c_allocator.free(e);
e.init(std.heap.c_al... | src/libzargo.zig |
const std = @import("std");
const string = []const u8;
// LSP types
// https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/
pub const Position = struct {
line: i64,
character: i64,
};
pub const Range = struct {
start: Position,
end: Position,
};
pub const Location ... | src/types.zig |
const std = @import("std");
const debug = std.debug;
const fmt = std.fmt;
const mem = std.mem;
/// 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 c... | lib/std/crypto/25519/edwards25519.zig |
const builtin = @import("builtin");
const std = @import("std.zig");
const io = std.io;
const os = std.os;
const math = std.math;
const mem = std.mem;
const debug = std.debug;
const InStream = std.stream.InStream;
pub const AT_NULL = 0;
pub const AT_IGNORE = 1;
pub const AT_EXECFD = 2;
pub const AT_PHDR = 3;
pub const ... | std/elf.zig |
const kernel = @import("../../kernel.zig");
const arch = kernel.arch;
const Physical = kernel.arch.Physical;
const page_size = kernel.arch.page_size;
const AddressPair = kernel.Memory.AddressPair;
/// Kernel pagetable before KPTI enabled
pub var kernel_init_pagetable: [*]usize = undefined; // use optional type
const l... | src/kernel/arch/riscv64/virtual.zig |
const std = @import("std");
const shared = @import("../shared.zig");
const lib = @import("../../main.zig");
const js = @import("js.zig");
const lasting_allocator = lib.internal.lasting_allocator;
const EventType = shared.BackendEventType;
pub const GuiWidget = struct {
userdata: usize = 0,
object: usize = 0,
... | src/backends/wasm/backend.zig |
const is_test = @import("builtin").is_test;
const std = @import("std");
const math = std.math;
const Log2Int = std.math.Log2Int;
const maxInt = std.math.maxInt;
const minInt = std.math.minInt;
const DBG = false;
pub fn fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t) fixint_t {
@setRuntimeSafety(is_t... | lib/std/special/compiler_rt/fixint.zig |
const Object = @This();
const std = @import("std");
const assert = std.debug.assert;
const dwarf = std.dwarf;
const fs = std.fs;
const io = std.io;
const log = std.log.scoped(.object);
const macho = std.macho;
const mem = std.mem;
const reloc = @import("reloc.zig");
const Allocator = mem.Allocator;
const Relocation =... | src/link/MachO/Object.zig |
const fmath = @import("index.zig");
pub fn log(x: var) -> @typeOf(x) {
const T = @typeOf(x);
switch (T) {
f32 => @inlineCall(logf, x),
f64 => @inlineCall(logd, x),
else => @compileError("log not implemented for " ++ @typeName(T)),
}
}
fn logf(x_: f32) -> f32 {
const ln2_hi: f32... | src/log.zig |
pub const SDDL_REVISION_1 = @as(u32, 1);
pub const SDDL_REVISION = @as(u32, 1);
pub const SDDL_ALIAS_SIZE = @as(u32, 2);
pub const INHERITED_ACCESS_ENTRY = @as(u32, 16);
pub const INHERITED_PARENT = @as(u32, 268435456);
pub const INHERITED_GRANDPARENT = @as(u32, 536870912);
pub const TRUSTEE_ACCESS_ALLOWED = @as(i32, 1... | win32/security/authorization.zig |
const std = @import("std");
const assert = std.debug.assert;
const tools = @import("tools");
const Vec2 = tools.Vec2;
const Map = tools.Map(u1, 400, 400, true);
pub fn run(input_text: []const u8, allocator: std.mem.Allocator) ![2][]const u8 {
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.de... | 2020/day24.zig |
const subo = @import("subo.zig");
const testing = @import("std").testing;
fn test__subosi4(a: i32, b: i32) !void {
var result_ov: c_int = undefined;
var expected_ov: c_int = undefined;
var result = subo.__subosi4(a, b, &result_ov);
var expected: i32 = simple_subosi4(a, b, &expected_ov);
try testing... | lib/std/special/compiler_rt/subosi4_test.zig |
const std = @import("std");
const mem = std.mem;
const net = std.net;
const os = std.os;
const IO = @import("tigerbeetle-io").IO;
const http = @import("http");
const Client = struct {
io: IO,
sock: os.socket_t,
address: std.net.Address,
send_buf: []u8,
recv_buf: []u8,
allocator: mem.Allocator,
... | examples/tcp_echo_client.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
pub const png = @cImport({
@cDefine("LODEPNG_NO_COMPILE_CPP", "1");
@cDefine("LODEPNG_COMPILE_ERROR_TEXT", "1");
// TODO remove libc dependency
// @cDefine("LODEPNG_NO_COMPILE_DISK", "1");
// @cDefine("LODEPNG_NO_COMPILE_ALLOCATORS", "... | CS344/src/png.zig |
pub const c = @cImport({ @cInclude("SFML/System.h"); });
pub fn sleep(time: Time) void {
c.sfSleep(time.internal);
}
pub const InputStream = struct {
readFn: fn (*InputStream, []u8) anyerror!i64,
seekFn: fn (*InputStream, i64) anyerror!i64,
tellFn: fn (*InputStream) anyerror!i64,
getSizeFn: fn (*... | src/system.zig |
const std = @import("std");
const trait = std.meta.trait;
pub const api = @import("api.zig");
pub const build_util = @import("build_util.zig");
pub const hot_reload = @import("hot_reload.zig");
pub const audio_io = @import("audio_io.zig");
pub const helper = @import("helper.zig");
pub const Info = struct {
/// Th... | src/main.zig |
const rl = @import("raylib");
const rlm = @import("raylib-math");
const MAX_BUILDINGS = 100;
pub fn main() anyerror!void
{
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800;
const screenHeight = 450;
rl.InitWindow(s... | examples/core/2d_camera.zig |
const std = @import("std");
const utils = @import("utils.zig");
const vector = @import("vector.zig");
const Vec4 = vector.Vec4;
const Mat4 = @import("matrix.zig").Mat4;
const Shape = @import("shape.zig").Shape;
const initPoint = vector.initPoint;
const initVector = vector.initVector;
pub const Ray = struct {
c... | ray.zig |
const std = @import("std");
const builtin = @import("builtin");
const CrossTarget = std.zig.CrossTarget;
pub fn build(b: *std.build.Builder) !void {
b.setPreferredReleaseMode(.ReleaseFast);
const target = b.standardTargetOptions(.{});
const mode = b.standardReleaseOptions();
const lib_only: bool = b.o... | build.zig |
const std = @import("std");
const Surface = @import("Surface.zig");
const Adapter = @import("Adapter.zig");
const PowerPreference = @import("enums.zig").PowerPreference;
const Interface = @This();
/// The type erased pointer to the Interface implementation
ptr: *anyopaque,
vtable: *const VTable,
pub const VTable = ... | gpu/src/Interface.zig |
const std = @import("std");
const builtin = @import("builtin");
const mem = std.mem;
const meta = std.meta;
/// Provides generic hashing for any eligible type.
/// Only hashes `key` itself, pointers are not followed.
pub fn autoHash(hasher: var, key: var) void {
const Key = @typeOf(key);
switch (@typeInfo(Key)... | std/hash/auto_hash.zig |
const std = @import("std");
const utils = @import("utils");
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const print = utils.print;
const Values = struct {
all_digits: [10]u8,
output: [4]u8,
};
fn readInput(arena: *ArenaAllocator, lines_it: *utils.FileLineIterator) any... | day8/src/main.zig |
const std = @import("std");
const expect = std.testing.expect;
pub const Vec3 = Vector3(f32);
pub const Point3 = Vector3(f32);
pub const Color = Vector3(f32);
fn Vector3(comptime T: type) type {
return struct {
const Self = @This();
x: T,
y: T,
z: T,
pub const zero = Vec... | src/vec.zig |
const std = @import("std");
const SDL = @import("sdl2");
const target_os = @import("builtin").os;
pub fn main() !void {
if (SDL.SDL_Init(SDL.SDL_INIT_VIDEO | SDL.SDL_INIT_EVENTS | SDL.SDL_INIT_AUDIO) < 0)
sdlPanic();
defer SDL.SDL_Quit();
var window = SDL.SDL_CreateWindow(
"SDL.zig Basic D... | examples/native.zig |
const std = @import("std");
const RingBuffer = @import("ring_buffer.zig").RingBuffer;
const Message = @import("Message.zig");
const fd_t = std.os.fd_t;
const Buffer = @This();
pub const Error = error{BufferFull};
bytes: RingBuffer(u8, 4096),
fds: RingBuffer(fd_t, 512),
pub fn init() Buffer {
return .{
.... | src/common/Buffer.zig |
const std = @import("std");
const Image = @import("image.zig").Image;
const printError = @import("../application/print_error.zig").printError;
const Chunk = struct {
length: u32,
chunk_type: [4]u8,
chunk_data: []u8,
crc: u32,
pub fn read(reader: anytype, allocator: std.mem.Allocator) !Chunk {
... | src/image/png.zig |
//--------------------------------------------------------------------------------
// Section: Types (15)
//--------------------------------------------------------------------------------
// TODO: this type has a FreeFunc 'HcsCloseOperation', what can Zig do with this information?
pub const HCS_OPERATION = isize;
//... | win32/system/host_compute_system.zig |
const std = @import("std");
const assert = std.debug.assert;
const tools = @import("tools");
const Vec2 = tools.Vec2;
const Fabric = tools.Map(u8, 1024, 1024, false);
pub fn run(input: []const u8, allocator: std.mem.Allocator) ![2][]const u8 {
var fabric = Fabric{ .default_tile = 0 };
{
var it = std.me... | 2018/day03.zig |
const sdl = @import("sdl.zig");
const SDL_RWops = sdl.SDL_RWops;
pub const SDL_IMAGE_MAJOR_VERSION = 2;
pub const SDL_IMAGE_MINOR_VERSION = 0;
pub const SDL_IMAGE_PATCHLEVEL = 4;
pub fn SDL_IMAGE_VERSION(vers: *sdl.SDL_version) void {
vers.major = SDL_IMAGE_MAJOR_VERSION;
vers.minor = SDL_IMAGE_MINOR_VERSION... | src/binding/sdl_image.zig |
const std = @import("std");
const Blo = @import("blo.zig").Blo;
const process = std.process;
const mem = std.mem;
const fs = std.fs;
const io = std.io;
const log = std.log;
const help_output =
\\Usage: blo [OPTION]... [FILE]...
\\With no FILE, read standard input.
\\
\\Options:
\\-n, --number ... | src/main.zig |
const std = @import("std");
const Rect = @import("./ui.zig").Rect;
const math = std.math;
const RowLayoutMode = enum { RowFlex, RowFixed, RowFixedArray };
const LayoutOptions = struct {
spacing: f32,
vert_pad: f32,
hori_pad: f32,
};
/// Layout.
pub const Layout = struct {
/// Parent region (egual to ... | src/layout.zig |
const std = @import("std");
const aoc = @import("aoc-lib.zig");
test "examples" {
try aoc.assertEq(@as(usize, 2), part1(aoc.test1file));
try aoc.assertEq(@as(usize, 1), part2(aoc.test1file));
try aoc.assertEq(@as(usize, 454), part1(aoc.inputfile));
try aoc.assertEq(@as(usize, 649), part2(aoc.inputfile)... | 2020/02/aoc.zig |
const aoc = @import("../aoc.zig");
const std = @import("std");
const Fold = union(enum) { x: u16, y: u16 };
pub fn run(problem: *aoc.Problem) !aoc.Solution {
var dots = blk: {
var dots = std.AutoHashMap(aoc.Coord2D, void).init(problem.allocator);
const group = problem.group().?;
var tokens... | src/main/zig/2021/day13.zig |
const std = @import("std");
const utils = @import("utils");
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const print = utils.print;
fn readInput(arena: *ArenaAllocator, lines_it: *utils.FileLineIterator) anyerror![][]u8 {
var lines = try std.ArrayList([]u8).initCapacity(&ar... | day10/src/main.zig |
const std = @import("std");
const gen = @import("gen.zig");
const base = @import("base.zig");
const logic = @import("logic.zig");
const RADIX = 10;
const MAX_LIST_LEN = 32;
pub fn validNameList(
cal: *const base.Cal,
raw_nlist: ?*const base.NameList,
) bool {
const nlist = raw_nlist orelse return true;
... | src/format.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const assert = std.debug.assert;
const print = std.debug.print;
const input = @embedFile("../input/day07.txt");
const Content = struct {
count: usize,
color: []const u8,
pub fn init(string: []const u8) !Conte... | src/day07.zig |
export var vector_table linksection(".vector_table") = packed struct {
initial_sp: u32 = model.memory.ram.stack_bottom,
reset: EntryPoint = reset,
system_exceptions: [14]EntryPoint = [1]EntryPoint{exception} ** 14,
interrupts: [model.number_of_peripherals]EntryPoint = [1]EntryPoint{exception} ** model.n... | main.zig |
const Texture = @import("Texture.zig");
const Buffer = @import("Buffer.zig");
const RenderBundle = @import("RenderBundle.zig");
const BindGroup = @import("BindGroup.zig");
const RenderPipeline = @import("RenderPipeline.zig");
const IndexFormat = @import("enums.zig").IndexFormat;
const RenderBundleEncoder = @This();
/... | gpu/src/RenderBundleEncoder.zig |
const std = @import("std");
/// An entry in a ini file. Each line that contains non-whitespace text can
/// be categorized into a record type.
pub const Record = union(enum) {
/// A section heading enclosed in `[` and `]`. The brackets are not included.
section: [:0]const u8,
/// A line that contains a ke... | src/ini.zig |
const std = @import("std");
const arrayIt = @import("src/arrayIterator.zig").iterator;
const iterator = @import("src/iterator.zig").iterator;
const enumerateIt = @import("src/enumerate.zig").iterator;
const TypeId = @import("builtin").TypeId;
const mem = std.mem;
const info = @import("src/info.zig");
pub fn init(obj: ... | index.zig |