code
stringlengths
38
801k
repo_path
stringlengths
6
263
const std = @import("std"); const builtin = @import("builtin"); const expect = std.testing.expect; const minInt = std.math.minInt; test "@bitReverse large exotic integer" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; if ...
test/behavior/bitreverse.zig
const std = @import("std"); const assertOrPanic = std.debug.assertOrPanic; const minInt = std.math.minInt; test "@bitreverse" { comptime testBitReverse(); testBitReverse(); } fn testBitReverse() void { // using comptime_ints, unsigned assertOrPanic(@bitreverse(u0, 0) == 0); assertOrPanic(@bitrever...
test/stage1/behavior/bitreverse.zig
const std = @import("std"); const winzigo = @import("winzigo"); var core: winzigo = undefined; var window: winzigo.Window = undefined; var gpa = std.heap.GeneralPurposeAllocator(.{}){}; pub fn init() !void { const allocator = gpa.allocator(); core = try winzigo.init(allocator); errdefer core.deinit(); ...
examples/events.zig
/// composite maps the code points `a` and `b` to their composite if any. pub fn composite(a: u21, b: u21) ?u21 { if (a == 0x0041 and b == 0x0300) return 0x00C0; if (a == 0x0041 and b == 0x0301) return 0x00C1; if (a == 0x0041 and b == 0x0302) return 0x00C2; if (a == 0x0041 and b == 0x0303) return 0x00C...
src/components/autogen/Canonicals.zig
const print = @import("std").debug.print; pub fn main() void { // Here's a zero-terminated array of u32 values: var nums = [_:0]u32{ 1, 2, 3, 4, 5, 6 }; // And here's a zero-terminated many-item pointer: var ptr: [*:0]u32 = &nums; // For fun, let's replace the value at position 3 with the // ...
exercises/076_sentinels.zig
const std = @import("std"); const panic = std.debug.panic; const builtin = @import("builtin"); const warn = std.debug.warn; const join = std.fs.path.join; const pi = std.math.pi; const sin = std.math.sin; const cos = std.math.cos; usingnamespace @import("c.zig"); const Camera = @import("camera.zig").Camera; const Sha...
src/2_6_multiple_lights.zig
const c = @import("../../c_global.zig").c_imp; const std = @import("std"); const zigimg = import("zigimg"); // dross-zig const InternalTexture = @import("../texture.zig").InternalTexture; const TextureErrors = @import("../texture.zig").TextureErrors; const apis = @import("../renderer.zig").BackendApi; const fs = @impor...
src/renderer/backend/texture_opengl.zig
const __floatuntitf = @import("floatuntitf.zig").__floatuntitf; const testing = @import("std").testing; fn test__floatuntitf(a: u128, expected: f128) void { const x = __floatuntitf(a); testing.expect(x == expected); } test "floatuntitf" { test__floatuntitf(0, 0.0); test__floatuntitf(1, 1.0); test...
lib/std/special/compiler_rt/floatuntitf_test.zig
const std = @import("../std.zig"); const CpuFeature = std.Target.Cpu.Feature; const CpuModel = std.Target.Cpu.Model; pub const Feature = enum { deflate_conversion, dfp_packed_conversion, dfp_zoned_conversion, distinct_ops, enhanced_dat_2, enhanced_sort, execution_hint, fast_serializatio...
lib/std/target/systemz.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/day12.zig
const std = @import("std"); const zelda = @import("zelda"); // NOTE: this test will fail if ziglang.org is down! test "fetch status code of ziglang.org" { defer zelda.cleanup(); var response = try zelda.get(std.testing.allocator, "https://ziglang.org"); defer response.deinit(); try std.testing.expectE...
src/tests.zig
const std = @import("std"); const curses = @import("curses.zig"); const core = @import("core.zig"); pub const Characters = struct { horiz_line: []const u8, // - vert_line: []const u8, // | crossing_up: []const u8, // _|_ crossing_down: []const u8, // T crossing_left: [...
src/cursesui.zig
const std = @import("std"); const builtin = @import("builtin"); pub fn getCookie(path: ?[]const u8) ![16]u8 { const xauth_file = blk: { if (path) |p| { break :blk try std.fs.openFileAbsolute(p, .{ .read = true, .write = false }); } else if (builtin.os.tag == .windows) { cons...
didot-zwl/zwl/src/x11/auth.zig
const std = @import("std"); const ascii = std.ascii; const event = std.event; const fs = std.fs; const log = std.log; const math = std.math; const mem = std.mem; const os = std.os; const process = std.process; const Message = @import("../message.zig").Message; pub fn bspwm(channel: *event.Channel(Message)) void { ...
src/producer/bspwm.zig
const builtin = @import("builtin"); const endian = builtin.cpu.arch.endian(); const testing = @import("std").testing; const ptr_size = @sizeOf(usize); test "type pun signed and unsigned as single pointer" { if (builtin.zig_backend == .stage1) return error.SkipZigTest; if (builtin.zig_backend == .stage2_aarch64...
test/behavior/comptime_memory.zig
//-------------------------------------------------------------------------------- // Section: Types (1) //-------------------------------------------------------------------------------- pub const REGISTER_APPLICATION_RESTART_FLAGS = enum(u32) { CRASH = 1, HANG = 2, PATCH = 4, REBOOT = 8, _, p...
deps/zigwin32/win32/system/recovery.zig
const std = @import("std"); const u = @import("util.zig"); const File = @import("File.zig"); const IR = @import("IR.zig"); const Wat = @import("Wat.zig"); const Wasm = @import("Wasm.zig"); allocator: std.mem.Allocator, trace: std.ArrayListUnmanaged(u.Txt) = .{}, errAt: fn (arg: ErrArg) void, const Self = @This(); pub...
src/Loader.zig
const combn = @import("../combn/combn.zig"); const Result = combn.Result; const Parser = combn.Parser; const Error = combn.Error; const Context = combn.Context; const ParserPosKey = combn.ParserPosKey; const ParserPath = combn.ParserPath; const Sequence = combn.Sequence; const SequenceValue = combn.SequenceValue; const...
src/dsl/compiler.zig
const std = @import("std"); const zloppy = @import("zloppy.zig"); const usage = \\Usage: zloppy [options] [command] [file]... \\ \\ Modifies the input files in-places to silence errors about \\ unused variable/parameters and unreachable code. \\ Arguments can be files or directories, which a...
src/main.zig
const std = @import("std"); const pike = @import("pike.zig"); const posix = @import("os/posix.zig"); const PackedWaker = @import("waker.zig").PackedWaker; const os = std.os; const system = os.system; const mem = std.mem; const meta = std.meta; const builtin = @import("builtin"); pub const SignalType = packed struct {...
signal_posix.zig
const std = @import("std"); const print = std.debug.print; const SIZE = 100; const Grid = std.ArrayList([SIZE]u8); pub fn main() anyerror!void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer _ = gpa.deinit(); var allocator = &gpa.allocator; var file = try std.fs.cwd().openFile( "....
src/day18.zig
const OpcodeEnum = @import("enum.zig").OpcodeEnum; const AddressingModeEnum = @import("enum.zig").AddressingModeEnum; pub const Opcode = struct { name: OpcodeEnum, addressing_mode: AddressingModeEnum, code: u8, size: u16, cycles: u8, pub fn init(name: OpcodeEnum, code: u8, addressing_mode: Add...
src/opcode.zig
const std = @import("std"); const ecs = @import("ecs"); const math = @import("math.zig"); const sokol = @import("sokol"); const main = @import("main.zig"); const Texture = main.Texture; pub const _GRAVITY = struct { x: f32, y: f32 }; pub const Position = struct { x: f32, y: f32 }; pub const Velocity = struct { x: f32,...
src/definition.zig
const std = @import("std"); const mem = std.mem; const log = std.log; const testing = std.testing; const Allocator = mem.Allocator; const AutoHashMap = std.AutoHashMap; const readInput = @import("parser.zig").readInput; const Instruction = @import("instruction.zig").Instruction; // for testing const Deck = @import("de...
day22/src/solve.zig
const std = @import("std"); const mem = std.mem; const math = std.math; const warn = std.debug.warn; const futexNs = @import("futex.zig"); const futex_wait = futexNs.futex_wait; const futex_wake = futexNs.futex_wake; const builtin = @import("builtin"); const AtomicOrder = builtin.AtomicOrder; const AtomicRmwOp = buil...
actor_model.zig
// for more info see: 'http://soundfile.sapp.org/doc/WaveFormat/' const builtin = @import("builtin"); const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; pub const Format = enum { U8, I16le, I24le, I32le, }; pub const Header = struct { format: Forma...
src/wav.zig
const std = @import("std"); const Step = std.build.Step; const Builder = std.build.Builder; builder: *Builder, step: Step, exe: *std.build.LibExeObjStep, files: std.ArrayList([]const u8), deps: std.ArrayList([]const u8), path: []const u8, const ZigValaStep = @This(); pub fn init(b: *Builder, name: []const u8) *ZigVa...
ZigValaStep.zig
const std = @import("std"); usingnamespace (@import("../machine.zig")); usingnamespace (@import("../util.zig")); test "80486" { const m32 = Machine.init(.x86_32); const m64 = Machine.init(.x64); const rm8 = Operand.memoryRm(.DefaultSeg, .BYTE, .EAX, 0); const rm16 = Operand.memoryRm(.DefaultSeg, .WORD...
src/x86/tests/80486.zig
const std = @import("std"); const utils = @import("utils.zig"); const AttributeInfo = @import("attributes.zig").AttributeInfo; const ConstantPool = @import("ConstantPool.zig"); const MethodInfo = @This(); pub const AccessFlags = struct { public: bool = false, private: bool = false, protected: bool = false...
src/MethodInfo.zig
pub const cgltf_size = usize; pub const cgltf_float = f32; pub const cgltf_int = c_int; pub const cgltf_uint = c_uint; pub const cgltf_bool = c_int; pub const cgltf_file_type_invalid: c_int = 0; pub const cgltf_file_type_gltf: c_int = 1; pub const cgltf_file_type_glb: c_int = 2; pub const enum_cgltf_file_type = c_uint;...
src/deps/gltf/c.zig
const std = @import("std"); const io = std.io; const FFT = @import("fft.zig").FFT; const DCT = @import("dct.zig").DCT; pub const MelOpts = struct { const Self = @This(); frame_length: u16 = 256, sample_rate: u32 = 16000, remove_dc_offset: bool = true, preemph_coeff: f32 = 0.97, liftering_coe...
src/dsp/melfreq.zig
/// `composite` maps the code points `a` and `b` to their canonical composition, if any. pub fn composite(a: u21, b: u21) ?u21 { if (a == 0x41 and b == 0x300) return 0xC0; if (a == 0x41 and b == 0x301) return 0xC1; if (a == 0x41 and b == 0x302) return 0xC2; if (a == 0x41 and b == 0x303) return 0xC3; ...
.gyro/ziglyph-jecolon-github.com-c37d93b6/pkg/src/autogen/canonicals.zig
const std = @import("../std.zig"); const wasi = std.os.wasi; const FDFLAG = wasi.FDFLAG; extern threadlocal var errno: c_int; pub fn _errno() *c_int { return &errno; } pub const fd_t = wasi.fd_t; pub const pid_t = c_int; pub const uid_t = u32; pub const gid_t = u32; pub const off_t = i64; pub const ino_t = wasi....
lib/std/c/wasi.zig
const builtin = @import("builtin"); const std = @import("std"); const Allocator = std.mem.Allocator; // ---------------------------------------------------------------------------- const TCThreadCreateInfo = @import("ffi.zig").TCThreadCreateInfo; const log = @import("debug.zig").log; const options = @import("options.z...
src/monitor/shadowstack.zig
const std = @import("std"); const fs = std.fs; const Image = @import("../../image.zig").Image; const upaya = @import("../../upaya_cli.zig"); const math = upaya.math; const stb = upaya.stb; pub const PyxelEdit = struct { name: []const u8, canvas: CanvasJSON, version: []const u8, layers: []Layer, ani...
src/utils/importers/pyxeledit.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/day04.txt"); p...
src/day04.zig
const std = @import("std"); const vk = @import("vulkan"); const c = @import("c.zig"); const resources = @import("resources"); const GraphicsContext = @import("graphics_context.zig").GraphicsContext; const Swapchain = @import("swapchain.zig").Swapchain; const Allocator = std.mem.Allocator; const za = @import("zalgebra")...
src/triangle.zig
const std = @import("std"); const builtin = @import("builtin"); const panic = std.debug.panic; usingnamespace @import("c.zig"); // settings const SCR_WIDTH: u32 = 1920; const SCR_HEIGHT: u32 = 1080; pub fn main() void { const ok = glfwInit(); if (ok == 0) { panic("Failed to initialise GLFW\n", .{}); ...
src/1_1_hello_window.zig
const std = @import("std"); const root = @import("root"); const Request = @import("Request.zig"); const Response = @import("Response.zig"); const MimeType = @import("MimeType.zig"); const net = std.net; const Allocator = std.mem.Allocator; const atomic = std.atomic; /// Scoped logging, prepending [lemon_pie] to our l...
src/server.zig
const View = @import("View.zig"); pub const AttachMode = enum { top, bottom, }; /// A specialized doubly-linked stack that allows for filtered iteration /// over the nodes. T must be View or *View. pub fn ViewStack(comptime T: type) type { if (!(T == View or T == *View)) { @compileError("ViewStac...
source/river-0.1.0/river/view_stack.zig
const std = @import("std"); const builtin = @import("builtin"); const assert = std.debug.assert; const ast = std.zig.ast; const Token = std.zig.Token; usingnamespace @import("clang.zig"); pub const Mode = enum { import, translate, }; // TODO merge with Type.Fn.CallingConvention const CallingConvention = buil...
src-self-hosted/translate_c.zig
const x86_64 = @import("../index.zig"); const bitjuggle = @import("bitjuggle"); const std = @import("std"); const port = x86_64.structures.port.Portu8; /// Command sent to begin PIC initialization. const CMD_INIT: u8 = 0x11; /// Command sent to acknowledge an interrupt. const CMD_END_INTERRUPT: u8 = 0x20; /// The m...
src/additional/pic8259.zig
const std = @import("std"); const webgpu = @import("./webgpu.zig"); pub const Instance = struct { pub const VTable = struct { destroy_fn: fn(*Instance) void, create_surface_fn: fn(*Instance, webgpu.SurfaceDescriptor) CreateSurfaceError!*Surface, request_adapter_fn: fn(*Instance, webgpu.Requ...
src/instance.zig
const std = @import("std"); const streql = std.ascii.eqlIgnoreCase; var byte_num : u16 = 0; pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = gpa.allocator(); const args = try std.process.argsAlloc(allocator); defer std.process.argsFree(allocator, args); ...
assem/src/main.zig
const std = @import("std"); const generator = @import("./generator.zig"); const extractFn = @import("./_.zig").extractFn; fn initializer(comptime Self: type, comptime G: type, comptime F: type, comptime stateful: bool) type { return if (stateful) struct { pub const Mapper = F; pub fn init(inner: G...
src/map.zig
const std = @import("std"); const stdx = @import("stdx"); const ft = @import("freetype"); const stbtt = @import("stbtt"); const graphics = @import("graphics.zig"); const FontId = graphics.FontId; const OpenTypeFont = graphics.OpenTypeFont; const log = std.log.scoped(.font); pub const FontType = enum(u1) { /// Sca...
graphics/src/font.zig
const Liveness = @This(); const std = @import("std"); const trace = @import("tracy.zig").trace; const log = std.log.scoped(.liveness); const assert = std.debug.assert; const Allocator = std.mem.Allocator; const Air = @import("Air.zig"); const Log2Int = std.math.Log2Int; /// This array is split into sets of 4 bits per ...
src/Liveness.zig
const root = @import("@build"); const std = @import("std"); const builtin = @import("builtin"); const io = std.io; const fmt = std.fmt; const Builder = std.build.Builder; const mem = std.mem; const process = std.process; const ArrayList = std.ArrayList; const warn = std.debug.warn; const File = std.fs.File; pub fn mai...
lib/std/special/build_runner.zig
const std = @import("std"); const fs = std.fs; const io = std.io; const info = std.log.info; const print = std.debug.print; const fmt = std.fmt; const utils = @import("utils.zig"); var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const SEEBACK: usize = 25; const sort_by = std.sort.asc(usize); pub fn main() !void...
day_10/src/main.zig
const rl = @import("raylib"); const print = @import("std").debug.print; const disco = @import("disco"); pub fn main() anyerror!void { // Initialization //-------------------------------------------------------------------------------------- const screenWidth = 1366; const screenHeight = 768; rl.I...
src/client/main.zig
const clap = @import("../clap.zig"); const std = @import("std"); const debug = std.debug; const heap = std.heap; const io = std.io; const mem = std.mem; const testing = std.testing; /// Deprecated: Use `parseEx` instead pub fn ComptimeClap( comptime Id: type, comptime params: []const clap.Param(Id), ) type { ...
clap/comptime.zig
const std = @import("std"); const math = std.math; const meta = std.meta; const mem = std.mem; const expectEqual = std.testing.expectEqual; const root = @import("main.zig"); const generic_vector = @import("generic_vector.zig"); const quat = @import("quaternion.zig"); const Vec3 = generic_vector.Vec3; const Vec3_f64 = ...
src/mat4.zig
pub const ED_BASE = @as(i32, 4096); pub const DEV_PORT_SIM = @as(u32, 1); pub const DEV_PORT_COM1 = @as(u32, 2); pub const DEV_PORT_COM2 = @as(u32, 3); pub const DEV_PORT_COM3 = @as(u32, 4); pub const DEV_PORT_COM4 = @as(u32, 5); pub const DEV_PORT_DIAQ = @as(u32, 6); pub const DEV_PORT_ARTI = @as(u32, 7); pub const DE...
win32/devices/device_access.zig
const std = @import("../std.zig"); const meta = std.meta; const testing = std.testing; const mem = std.mem; const assert = std.debug.assert; const Type = std.builtin.Type; /// This is useful for saving memory when allocating an object that has many /// optional components. The optional objects are allocated sequential...
lib/std/meta/trailer_flags.zig
const std = @import("std"); const abort = std.os.abort; const assert = std.debug.assert; const expect = std.testing.expect; // defined in C as: // typedef unsigned int gcc_word __attribute__((mode(word))); const gcc_word = usize; comptime { assert(std.builtin.link_libc); } /// public entrypoint for generated c...
lib/std/special/compiler_rt/emutls.zig
const std = @import("std"); const assert = std.debug.assert; const vk = @import("vk"); const vma_config = @import("vma_config.zig"); pub const config = if (std.builtin.mode == .Debug) vma_config.debugConfig else vma_config.releaseConfig; // callbacks use vk.CallConv, but the vma functions may not. pub const CallConv ...
vma.zig
const std = @import("std"); const allocator = std.heap.page_allocator; const usage = \\Usage: touch [options] <file...> \\ \\Options: \\ -h, --help Print this help and exit \\ -a Change only the access time \\ -c, --no-create Do not create any file \\ -m ...
src/touch.zig
const Wwise = @import("../wwise.zig").Wwise; const ImGui = @import("../imgui.zig").ImGui; const DemoInterface = @import("demo_interface.zig").DemoInterface; const std = @import("std"); pub const LocalizationDemo = struct { allocator: std.mem.Allocator = undefined, isVisibleState: bool = false, bankID: u32 ...
src/demos/localization_demo.zig
const std = @import("std"); const math = std.math; fn assertIsFloat(comptime T: type) void { if (@typeInfo(T) != .Float and @typeInfo(T) != .ComptimeFloat) @compileError("Expected float type, found `" ++ @typeName(T) ++ "`!"); } pub fn toRadians(degrees: anytype) @TypeOf(degrees) { comptime assertIsFl...
src/float.zig
const zwl = @import("zwl/src/zwl.zig"); pub const WindowError = error { InitializationError }; const std = @import("std"); const zlm = @import("zlm"); const Vec2 = zlm.Vec2; // TODO: more inputs and a more efficient way to do them pub const Input = struct { nativeId: u32, lastMousePos: Vec2 = Vec2.zero,...
didot-zwl/window.zig
const std = @import("std"); /// Represents a single DNS domain-name, which is a slice of strings. /// /// The "www.google.com" friendly domain name can be represented in DNS as a /// sequence of labels: first "www", then "google", then "com", with a length /// prefix for all of them, ending in a null byte. /// /// Kee...
src/pkg2/names.zig
const std = @import("std"); const builtin = @import("builtin"); const expect = std.testing.expect; test "@byteSwap integers" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; if (builtin.zig_backend == .stage2_arm) retu...
test/behavior/byteswap.zig
const std = @import("std"); const info = std.log.info; const warn = std.log.warn; const bus = @import("bus.zig"); const rdp = @import("rdp.zig"); const RDPStatus = rdp.RDPStatus; const mi = @import("mi.zig"); const InterruptSource = mi.InterruptSource; const rcpROM = @import("rsptable.zig").rcpROM; const rsqROM ...
src/core/rsp.zig
pub const GUID_DEVINTERFACE_SENSOR = Guid.initString("ba1bb692-9b7a-4833-9a1e-525ed134e7e2"); pub const SENSOR_EVENT_STATE_CHANGED = Guid.initString("bfd96016-6bd7-4560-ad34-f2f6607e8f81"); pub const SENSOR_EVENT_DATA_UPDATED = Guid.initString("2ed0f2a4-0087-41d3-87db-6773370b3c88"); pub const SENSOR_EVENT_PROPERTY_CHA...
deps/zigwin32/win32/devices/sensors.zig
const std = @import("std"); const utils = @import("utils.zig"); const epsilonEq = @import("utils.zig").epsilonEq; const vector = @import("vector.zig"); const Vec4 = vector.Vec4; pub const Mat2 = struct { const Self = @This(); pub const Size = 2; mat: [Size][Size]f64 = undefined, pub fn eql(self: Self...
matrix.zig
const std = @import("std"); const interpreter = @import("interpreter.zig"); const intrinsics = @import("intrinsics.zig"); const mem = @import("gc.zig"); const sourcelocation = @import("sourcelocation.zig"); const SourceLocation = sourcelocation.SourceLocation; pub const ExprErrors = error{ AlreadyReported, MissingRigh...
src/ast.zig
const std = @import("std"); const stdx = @import("stdx"); const gl = @import("gl"); const graphics = @import("../../graphics.zig"); const Color = graphics.Color; const log = stdx.log.scoped(.mesh); const StartVertexBufferSize = 10000; const StartIndexBufferSize = StartVertexBufferSize * 4; const MaxVertexBufferSize ...
graphics/src/backend/gpu/mesh.zig
const std = @import("std"); const Random = std.rand.Random; const math = std.math; const Xoshiro256 = @This(); s: [4]u64, pub fn init(init_s: u64) Xoshiro256 { var x = Xoshiro256{ .s = undefined, }; x.seed(init_s); return x; } pub fn random(self: *Xoshiro256) Random { return Random.init...
lib/std/rand/Xoshiro256.zig
const Allocator = std.mem.Allocator; const ClientSM = @import("state_machines/client.zig").ClientSM; const Event = @import("events/events.zig").Event; const ServerSM = @import("state_machines/server.zig").ServerSM; const SMError = @import("state_machines/errors.zig").SMError; const std = @import("std"); pub fn Client(...
src/connection.zig
const std = @import("std"); const draw = @import("pixel_draw.zig"); // === Windows definitions ==================================================== const WS_OVERLAPEDWINDOW: u64 = 0x00C00000 | 0x00080000 | 0x00040000 | 0x00020000 | 0x00010000; const WS_VISIBLE: u64 = 00200000; extern "user32" fn GetClientRect(hWnd: wi...
src/win32_plataform.zig
const std = @import("std"); const debug = std.log.debug; const testing = std.testing; //IDEAS: consider maybe json serialization but prefer binnary serialization //READ: read into Google Protocol Buffers ,Thrift and Avro in I want to use well established serialization tools //Serialization takes an in-memory data str...
src/serializer.zig
const std = @import("std"); const assert = std.debug.assert; const approxEq = std.math.approxEq; pub const MixedNumber = struct { whole: i32, fraction: Fraction, }; pub const Fraction = struct { numerator: i32, denominator: i32, }; pub fn mediantInPlace(result: *Fraction, a: Fraction, b: Fraction) vo...
farey.zig
const std = @import("std"); const helper = @import("helper.zig"); const Allocator = std.mem.Allocator; const input = @embedFile("../inputs/day07.txt"); pub fn run(alloc: Allocator, stdout_: anytype) !void { const parsed = try parseInput(alloc); defer alloc.free(parsed); const res1 = try part1(alloc, pars...
src/day07.zig
const std = @import("std"); const fs = std.fs; const mem = std.mem; const print = std.debug.print; const assert = std.debug.assert; pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const allocator = &gpa.allocator; const input = try fs.cwd().readFileAlloc(allocator, "data/input_22...
2020/src/day_22.zig
const std = @import("std"); const assert = std.debug.assert; const warn = std.debug.warn; const Queue = std.atomic.Queue; /// ActorInterface is a member of all Actor's and /// every Actor must implement processMessage who's /// address is saved in this interface when an Actor /// is initialized by calling Actor(BodyTy...
actor.zig
const std = @import("std"); const math = std.math; const expect = std.testing.expect; pub fn __trunch(x: f16) callconv(.C) f16 { // TODO: more efficient implementation return @floatCast(f16, truncf(x)); } pub fn truncf(x: f32) callconv(.C) f32 { const u = @bitCast(u32, x); var e = @intCast(i32, ((u >...
lib/compiler_rt/trunc.zig
const std = @import("std"); const mem = std.mem; const AesBlock = std.crypto.core.aes.Block; pub const Ponteil = struct { const State = [8]AesBlock; pub const block_length: usize = 32; pub const key_length: usize = 32; pub const digest_length = 32; s: State, ctx_segments: u64 = 0, m_segme...
zig/src/main.zig
const std = @import("std"); const wlr = @import("wlroots"); const server = &@import("../main.zig").server; const Direction = @import("../command.zig").Direction; const PhysicalDirectionDirection = @import("../command.zig").PhysicalDirection; const Error = @import("../command.zig").Error; const Output = @import("../...
source/river-0.1.0/river/command/output.zig
const std = @import("std"); const os = @import("windows.zig"); const dxgi = @import("dxgi.zig"); const dcommon = @import("dcommon.zig"); pub const RESOURCE_BARRIER_ALL_SUBRESOURCES = 0xffffffff; pub const GPU_VIRTUAL_ADDRESS = u64; pub const HEAP_TYPE = extern enum { DEFAULT = 1, UPLOAD = 2, READBACK = 3...
src/windows/d3d12.zig
const builtin = @import("builtin"); const TypeId = builtin.TypeId; const std = @import("std"); const math = std.math; const assert = std.debug.assert; const warn = std.debug.warn; const matrix = @import("matrix.zig"); const Matrix = matrix.Matrix; const M44f32 = matrix.M44f32; const mulM44f32 = matrix.mulM44f32; con...
rotation.zig
const std = @import("std"); const util = @import("util.zig"); const data = @embedFile("../data/day03.txt"); fn parseInput(input_text: []const u8) std.ArrayList([]const u8) { var list = std.ArrayList([]const u8).init(std.testing.allocator); var lines = std.mem.tokenize(u8, input_text, "\r\n"); while (lines...
src/day03.zig
const std = @import("std"); const assert = std.debug.assert; const ArrayList = std.ArrayList; const Mutex = std.Thread.Mutex; const page_alloc = std.heap.page_allocator; const AdmaAllocator = @import("adma").AdmaAllocator; const debug_print = false; const print = if (debug_print) std.debug.print else fakeprint; fn f...
src/externs.zig
const std = @import("std"); const mem = std.mem; usingnamespace @import("vector_types.zig"); usingnamespace @import("llvm_intrinsics.zig"); const main = @import("main.zig"); const CharUtils = @import("string_parsing.zig").CharUtils; const dom = @import("dom.zig"); const Iterator = dom.Iterator; const TapeBuilder = dom....
src/number_parsing.zig
pub const ASN_UNIVERSAL = @as(u32, 0); pub const ASN_APPLICATION = @as(u32, 64); pub const ASN_CONTEXT = @as(u32, 128); pub const ASN_PRIVATE = @as(u32, 192); pub const ASN_PRIMITIVE = @as(u32, 0); pub const ASN_CONSTRUCTOR = @as(u32, 32); pub const SNMP_ACCESS_NONE = @as(u32, 0); pub const SNMP_ACCESS_NOTIFY = @as(u32...
deps/zigwin32/win32/network_management/snmp.zig
const std = @import("std"); const prot = @import("protocols.zig"); const renderer = @import("renderer.zig"); const compositor = @import("compositor.zig"); const Client = @import("client.zig").Client; const Rectangle = @import("rectangle.zig").Rectangle; const Region = @import("region.zig").Region; const Positioner = @i...
src/window.zig
const std = @import("std"); const stdx = @import("stdx"); const build_options = @import("build_options"); const v8 = @import("v8"); const t = stdx.testing; const uv = @import("uv"); const runtime = @import("../runtime/runtime.zig"); const RuntimeContext = runtime.RuntimeContext; const main = @import("../runtime/main.z...
test/behavior_test.zig
const std = @import("std"); const api = @import("api.zig"); const cache = @import("cache.zig"); const Engine = @import("Engine.zig"); const Dependency = @import("Dependency.zig"); const Project = @import("Project.zig"); const utils = @import("utils.zig"); const local = @import("local.zig"); const Allocator = std.mem.A...
src/github.zig
const std = @import("std"); const c = @import("c.zig"); const vt100 = @import("vt100.zig"); const fmt = std.fmt; const fs = std.fs; const mem = std.mem; const os = std.os; var old_tc_attr: ?os.termios = null; pub fn clear(stream: var) !void { try stream.writeAll(vt100.erase.inDisplay(vt100.erase.all) ++ vt100.c...
src/terminal.zig
const std = @import("std"); const assert = std.debug.assert; const allocator = std.heap.page_allocator; pub const Pos = struct { x: usize, y: usize, pub fn encode(self: Pos) usize { return self.x * 10000 + self.y; } }; pub const Hull = struct { cells: std.AutoHashMap(usize, Color), cu...
2019/p11/ship.zig
const std = @import("std"); const assert = std.debug.assert; const tools = @import("tools"); const Vec2 = tools.Vec2; fn getParens(line: []const u8) []const u8 { assert(line[0] == '('); var nb: usize = 0; for (line) |c, i| { if (c == '(') nb += 1; if (c == ')') { nb -= 1; ...
2020/day18.zig
const sf = @import("../sfml.zig"); pub const CircleShape = struct { const Self = @This(); // Constructor/destructor /// Inits a circle shape with a radius. The circle will be white and have 30 points pub fn init(radius: f32) !Self { var circle = sf.c.sfCircleShape_create(); if (circl...
src/sfml/graphics/circle_shape.zig
const os = @import("root").os; const fmt = @import("std").fmt; const arch = @import("builtin").arch; const range = os.lib.range.range; const Printer = struct { pub fn writeAll(self: *const Printer, str: []const u8) !void { try @call(.{ .modifier = .never_inline }, print_str, .{str}); } pub fn pri...
src/lib/logger.zig
const gmath = @import("gmath.zig").gmath(f64); pub const Pos01 = struct { x: f64, y: f64, }; pub const PosI = struct { const Self = @This(); x: isize, y: isize, pub fn toPosU(self: Self) ?PosU { if (self.x >= 0 and self.y >= 0) { return PosU{ .x = self.x, .y = self.y }; ...
lib/unitbounds.zig
const std = @import("std"); const zap = @import("zap"); const hyperia = @import("hyperia"); const Reactor = hyperia.Reactor; const AsyncSocket = hyperia.AsyncSocket; const AsyncWaitGroupAllocator = hyperia.AsyncWaitGroupAllocator; const os = std.os; const net = std.net; const mem = std.mem; const builtin = std.builtin...
example_tcp_server.zig
const std = @import("std"); const Arena = std.heap.ArenaAllocator; const Allocator = std.mem.Allocator; const eql = std.meta.eql; const panic = std.debug.panic; const assert = std.debug.assert; const init_codebase = @import("init_codebase.zig"); const initCodebase = init_codebase.initCodebase; const MockFileSystem = @...
src/codegen.zig
const std = @import("std"); const wren = @import("wren"); pub var alloc = std.testing.allocator; pub fn main() anyerror!void { // Initialize the data structures for the wrapper wren.init(alloc); defer wren.deinit(); // Set up a VM configuration using the supplied default bindings // You can overr...
example/value_passing.zig
const std = @import("std"); pub fn Bitset(num_bits: usize) type { const num_bytes = @divTrunc(num_bits + 7, 8); return struct { pub fn set(self: *@This(), idx: usize) void { self.data[idx / 8] |= (@as(u8, 1) << @intCast(u3, idx % 8)); } pub fn unset(self: *@This(), idx: us...
lib/util/bitset.zig
const std = @import("std"); const sqlite = @import("sqlite"); const manage_main = @import("main.zig"); const http = @import("apple_pie"); const ManageContext = manage_main.Context; const SqlGiver = @import("./find_main.zig").SqlGiver; const magick = @import("./magick.zig"); const Context = struct { manage: *Manage...
src/hydrus_api_main.zig
const ffs = @import("count0bits.zig"); const testing = @import("std").testing; fn test__ffsti2(a: u128, expected: i32) !void { var x = @bitCast(i128, a); var result = ffs.__ffsti2(x); try testing.expectEqual(expected, result); } test "ffsti2" { try test__ffsti2(0x00000000_00000000_00000000_00000001, 1...
lib/std/special/compiler_rt/ffsti2_test.zig
const std = @import("std"); const assert = std.debug.assert; const io = std.io; const fs = std.fs; const mem = std.mem; const process = std.process; const Allocator = mem.Allocator; const ArrayList = std.ArrayList; const ast = std.zig.ast; const warn = std.log.warn; const Compilation = @import("Compilation.zig"); cons...
src/main.zig