code stringlengths 38 801k | repo_path stringlengths 6 263 |
|---|---|
const std = @import("std");
const zang = @import("zang");
const zangscript = @import("zangscript");
const common = @import("common.zig");
const c = @import("common/c.zig");
const modules = @import("modules.zig");
pub const AUDIO_FORMAT: zang.AudioFormat = .signed16_lsb;
pub const AUDIO_SAMPLE_RATE = 44100;
pub const A... | examples/example_script_runtime_poly.zig |
const std = @import("std");
const assert = std.debug.assert;
const tools = @import("tools");
fn modpow(base: u64, exp: u64, m: u64) u64 {
var result: u64 = 1;
var e = exp;
var b = base;
while (e > 0) {
if ((e & 1) != 0) result = (result * b) % m;
e = e / 2;
b = (b * b) % m;
... | 2020/day25.zig |
const std = @import("std");
const fs = std.fs;
// NOTE(sam): I made the first version using a resizable dense map. I was wondering if using an HashMap would
// have been simpler.
// When I read part 2 and realise it was simular, but slightly different than part 1, I decided to try both versions.
// Part 2 uses a spars... | 2020/src/day_17.zig |
const std = @import("std");
const assert = std.debug.assert;
const mem = std.mem;
const Allocator = std.mem.Allocator;
// Implements the LZ77 sliding dictionary as used in decompression.
// LZ77 decompresses data through sequences of two forms of commands:
//
// * Literal insertions: Runs of one or more symbols are ... | lib/std/compress/deflate/dict_decoder.zig |
const std = @import("../std.zig");
pub const Status = enum(u10) {
@"continue" = 100, // RFC7231, Section 6.2.1
switching_protcols = 101, // RFC7231, Section 6.2.2
processing = 102, // RFC2518
early_hints = 103, // RFC8297
ok = 200, // RFC7231, Section 6.3.1
created = 201, // RFC7231, Section ... | lib/std/http/status.zig |
const std = @import("std");
const utils = @import("utils.zig");
const attributes = @import("attributes.zig");
const FieldInfo = @import("FieldInfo.zig");
const MethodInfo = @import("MethodInfo.zig");
const ConstantPool = @import("ConstantPool.zig");
const ClassFile = @This();
/// Denotes access permissions to and pr... | src/ClassFile.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const fmtIntSizeBin = std.fmt.fmtIntSizeBin;
const Module = @import("Module.zig");
const Value = @import("value.zig").Value;
const Air = @import("Air.zig");
const Liveness = @import("Liveness.zig");
pub fn dump(gpa: Allocator, air: Air, liveness: Livene... | src/print_air.zig |
const LE_LESS = c_int(-1);
const LE_EQUAL = c_int(0);
const LE_GREATER = c_int(1);
const LE_UNORDERED = c_int(1);
const rep_t = u128;
const srep_t = i128;
const typeWidth = rep_t.bit_count;
const significandBits = 112;
const exponentBits = (typeWidth - significandBits - 1);
const signBit = (rep_t(1) << (significandBi... | std/special/compiler_rt/comparetf2.zig |
/// https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
const mmio = @import("mmio.zig");
const cpu = @import("../../cpu.zig").Current;
const VideocoreMbox = struct {
read: u32,
reserved1: [12]u8,
poll: u32,
sender: u32,
status: u32,
config: u32,
write: u32,
fn is_... | src/arm/io/mbox.zig |
const std = @import("std");
const expect = std.testing.expect;
const builtin = @import("builtin");
const native_arch = builtin.target.cpu.arch;
var foo: u8 align(4) = 100;
test "global variable alignment" {
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
comptime try expect(@typeInfo(@TypeO... | test/behavior/align.zig |
const builtin = @import("builtin");
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;
... | test/behavior/pointers.zig |
const std = @import("std");
const mem = std.mem;
const primes = [_]u64{
0xa0761d6478bd642f,
0xe7037ed1a0b428db,
0x8ebc6af09c88c6e3,
0x589965cc75374cc3,
0x1d8e4e27c47d124f,
};
fn read_bytes(comptime bytes: u8, data: []const u8) u64 {
const T = std.meta.IntType(false, 8 * bytes);
return mem.... | lib/std/hash/wyhash.zig |
const Zld = @This();
const std = @import("std");
const assert = std.debug.assert;
const dwarf = std.dwarf;
const leb = std.leb;
const mem = std.mem;
const meta = std.meta;
const fs = std.fs;
const macho = std.macho;
const math = std.math;
const log = std.log.scoped(.zld);
const aarch64 = @import("../../codegen/aarch64... | src/link/MachO/Zld.zig |
pub const DRMHANDLE_INVALID = @as(u32, 0);
pub const DRMENVHANDLE_INVALID = @as(u32, 0);
pub const DRMQUERYHANDLE_INVALID = @as(u32, 0);
pub const DRMHSESSION_INVALID = @as(u32, 0);
pub const DRMPUBHANDLE_INVALID = @as(u32, 0);
pub const DRM_AL_NONSILENT = @as(u32, 1);
pub const DRM_AL_NOPERSIST = @as(u32, 2);
pub cons... | win32/data/rights_management.zig |
const std = @import("std");
const debug = std.debug;
const mem = std.mem;
const FixedBufferAllocator = std.heap.FixedBufferAllocator;
const parse = @import("parse.zig");
const Parser = parse.Parser;
const Expr = parse.Expr;
const ParseError = parse.ParseError;
// Note: Switch to OutStream
var global_buffer: [2048]u8 ... | src/parse_test.zig |
pub fn Register(comptime R: type) type {
return RegisterRW(R, R);
}
pub fn RegisterRW(comptime Read: type, comptime Write: type) type {
return struct {
raw_ptr: *volatile u32,
const Self = @This();
pub fn init(address: usize) Self {
return Self{ .raw_ptr = @intToPtr(*volat... | src/f303re.zig |
usingnamespace @import("raylib");
pub fn main() anyerror!void
{
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800;
const screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic wi... | examples/core/input_multitouch.zig |
const os = @import("root").os;
const std = @import("std");
const assert = std.debug.assert;
const platform = os.platform;
const lalign = os.lib.libalign;
const page_sizes = platform.paging.page_sizes;
var free_roots = [_]usize{0} ** page_sizes.len;
var pmm_mutex = os.thread.Mutex{};
const reverse_sizes = {... | src/memory/pmm.zig |
const std = @import("std");
const WriteFileStep = std.build.WriteFileStep;
const LibExeObjStep = std.build.LibExeObjStep;
const CSourceFile = std.build.CSourceFile;
const LogStep = std.build.LogStep;
const Builder = std.build.Builder;
const Step = std.build.Step;
pub fn build(b: *Builder) !void {
// Standard rele... | build.zig |
const std = @import("std");
const assert = std.debug.assert;
pub fn Rc(comptime T: type) type {
return struct {
const refSize = u16;
refs: std.atomic.Int(refSize),
ptr: ?*T,
allocator: *std.mem.Allocator,
pub const Self = @This();
pub fn init(alloc: *std.mem.Alloc... | src/rc.zig |
const std = @import("std");
const testing = std.testing;
const minInt = std.math.minInt;
const maxInt = std.math.maxInt;
pub fn encodeStrLen(len: u32, writer: anytype) @TypeOf(writer).Error!void {
if (len <= std.math.maxInt(u5)) {
return writer.writeIntBig(u8, 0xa0 | @truncate(u8, len));
}
if (len ... | src/encoder.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const vk = @import("../include/vk.zig");
const Render = @import("../lib.zig").Render;
const Context = @import("../backend/context.zig").Context;
const Framebuffer = @import("../backend/framebuffer.zig").Framebuffer;
pub const IObject = struct {
exe... | render/src/program/renderpass.zig |
pub const IMAPI_SECTOR_SIZE = @as(u32, 2048);
pub const IMAPI2_DEFAULT_COMMAND_TIMEOUT = @as(u32, 10);
pub const DISPID_DDISCMASTER2EVENTS_DEVICEADDED = @as(u32, 256);
pub const DISPID_DDISCMASTER2EVENTS_DEVICEREMOVED = @as(u32, 257);
pub const DISPID_IDISCRECORDER2_EJECTMEDIA = @as(u32, 256);
pub const DISPID_IDISCREC... | deps/zigwin32/win32/storage/imapi.zig |
const std = @import("std");
const ast = @import("ast.zig");
const Expr = ast.Expr;
const Env = ast.Env;
const ExprType = ast.ExprType;
pub var gpa = std.heap.GeneralPurposeAllocator(.{ .safety = true }){};
pub var allocator = gpa.allocator();
pub var interned_syms: std.StringArrayHashMapUnmanaged(void) = .{};
pub var ... | src/gc.zig |
const Span = @import("basics.zig").Span;
const addScalarInto = @import("basics.zig").addScalarInto;
// this is a struct to be used temporarily within a paint call.
pub const PaintState = struct {
buf: []f32,
i: usize,
sample_rate: f32,
pub inline fn init(buf: []f32, sample_rate: f32) PaintState {
... | src/zang/painter.zig |
//--------------------------------------------------------------------------------
// Section: Types (19)
//--------------------------------------------------------------------------------
pub const RAW_INPUT_DATA_COMMAND_FLAGS = enum(u32) {
HEADER = 268435461,
INPUT = 268435459,
};
pub const RID_HEADER = RAW_... | win32/ui/input.zig |
const std = @import("std");
const lex = @import("lexer.zig");
const Lexer = lex.Lexer;
const LexToken = lex.Token;
const Allocator = std.mem.Allocator;
const Label = []const u8;
const Constant = u16;
const Reference = struct {
symbol: Label,
indirect: bool,
};
const RefOrConst = union(enum) {
reference: ... | src/parser.zig |
const std = @import("std");
const testing = std.testing;
pub fn LinkedList(comptime T: type) type {
return struct {
head: ?*Node,
tail: ?*Node,
len: usize,
allocator: *std.mem.Allocator,
const Self = @This();
pub const Node = struct {
prev: ?*Node,
... | src/linked_list.zig |
const std = @import("std");
const builtin = @import("builtin");
const nvg = @import("nanovg");
const Song = @import("Song.zig");
songs: []Song = undefined,
song_selected: usize = 0,
select_origin: f32 = 0,
select_target: f32 = 0,
select_time: f32 = 0,
progress_alpha: f32 = 0,
font_regular: i32 = undefined,
font_bold... | src/Menu.zig |
pub usingnamespace @import("std").zig.c_builtins;
pub const ptrdiff_t = c_long;
pub const wchar_t = c_int;
pub const max_align_t = c_longdouble;
pub const __int8_t = i8;
pub const __uint8_t = u8;
pub const __int16_t = c_short;
pub const __uint16_t = c_ushort;
pub const __int32_t = c_int;
pub const __uint32_t = c_uint;
... | vendor/freetype.zig |
const std = @import("std");
usingnamespace @import("kiragine").kira.log;
const engine = @import("kiragine");
const windowWidth = 1024;
const windowHeight = 768;
const title = "Shapes";
const targetfps = 60;
fn draw() !void {
engine.clearScreen(0.1, 0.1, 0.1, 1.0);
// Push the pixel batch, it can't be mixed w... | examples/shapedraw.zig |
const std = @import("std");
const kira = @import("kira");
const check = kira.utils.check;
usingnamespace kira.log;
const clap = @import("zig-clap/clap.zig");
const fallback_output = "testbuf";
const fallback_actual_output = "actual-testbuf";
pub fn main() !void {
// First we specify what parameters our program c... | tools/assetpacker.zig |
const std = @import("std");
// Depending on the length of the input, we can easily determine
// the digit for some inputs and which segments are active
// Length 2 => 1: c, f
// Length 3 => 7: a, c, f
// Length 4 => 4: b, c, d, f
// Length 7 => 8: a, b, c, d, e, f, g
// For the other two cases, it's trickier but we c... | shritesh+zig/8b.zig |
const MachO = @This();
const std = @import("std");
const build_options = @import("build_options");
const builtin = @import("builtin");
const assert = std.debug.assert;
const fmt = std.fmt;
const fs = std.fs;
const log = std.log.scoped(.macho);
const macho = std.macho;
const math = std.math;
const mem = std.mem;
const ... | src/MachO.zig |
const windows = @import("windows.zig");
const BYTE = windows.BYTE;
const UINT = windows.UINT;
const UINT32 = windows.UINT32;
const IUnknown = windows.IUnknown;
const WINAPI = windows.WINAPI;
const GUID = windows.GUID;
const HRESULT = windows.HRESULT;
const DWORD = windows.DWORD;
const WORD = windows.WORD;
const PROPVAR... | modules/platform/vendored/zwin32/src/wasapi.zig |
const std = @import("std");
const utils = @import("utils");
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const sort = std.sort;
const print = utils.print;
const desc_i32 = sort.desc(i32);
const HeightMap = struct {
width: usize,
height: usize,
map: []i32,
visit... | day9/src/main.zig |
const std = @import("std");
const io = std.io;
const Allocator = std.mem.Allocator;
const BitSet = @import("nil").bits.BitSet;
const Part1 = struct {
const Self = @This();
bits: BitSet,
count: usize = 0,
last: u8 = 0,
fn init(allocator: *Allocator) !Self {
return Self{
.bits =... | day6/src/main.zig |
const std = @import("std");
const mem = std.mem;
const Diacritic = @This();
allocator: *mem.Allocator,
array: []bool,
lo: u21 = 94,
hi: u21 = 125258,
pub fn init(allocator: *mem.Allocator) !Diacritic {
var instance = Diacritic{
.allocator = allocator,
.array = try allocator.alloc(bool, 125165),
... | src/components/autogen/PropList/Diacritic.zig |
pub const MAX_MODULE_NAME32 = @as(u32, 255);
pub const HF32_DEFAULT = @as(u32, 1);
pub const HF32_SHARED = @as(u32, 2);
//--------------------------------------------------------------------------------
// Section: Types (9)
//--------------------------------------------------------------------------------
pub const C... | win32/system/diagnostics/tool_help.zig |
const ImageReader = zigimg.ImageReader;
const ImageSeekStream = zigimg.ImageSeekStream;
const PixelFormat = zigimg.PixelFormat;
const assert = std.debug.assert;
const qoi = zigimg.qoi;
const color = zigimg.color;
const errors = zigimg.errors;
const std = @import("std");
const testing = std.testing;
const zigimg = @impo... | tests/formats/qoi_test.zig |
const std = @import("std");
pub const ir_visited_t = u64;
pub const ir_label_t = u64;
pub const dbg_info = opaque {};
pub const type_dbg_info = opaque {};
pub const ir_node = opaque {};
pub const ir_op = opaque {};
pub const ir_mode = opaque {};
pub const ir_edge_t = opaque {};
pub const ir_heights_t = opaque {};
pub c... | src/firm-abi.zig |
const std = @import("std");
var a: *std.mem.Allocator = undefined;
const stdout = std.io.getStdOut().writer(); //prepare stdout to write in
test "simple" {
const input = "byr:1944 iyr:2010 eyr:2021 hgt:158cm hcl:#b6652a ecl:blu pid:093154719 gar:coucou";
var buf = input.*;
std.testing.expect(run(&buf) == ... | day-04/part-2/lelithium.zig |
const std = @import("std");
const cuda = @import("cuda.zig");
const assert = std.debug.assert;
const mem = std.mem;
const Allocator = std.mem.Allocator;
const log = std.log.scoped(.Cuda);
/// This allocator takes the cuda allocator, wraps it, and provides an interface
/// where you can allocate without freeing, and t... | cudaz/src/allocator.zig |
const std = @import("std");
const zlm = @import("zlm");
const Vec3 = zlm.Vec3;
const Allocator = std.mem.Allocator;
usingnamespace @import("didot-graphics");
const objects = @import("didot-objects");
const models = @import("didot-models");
const image = @import("didot-image");
const physics = @import("didot-physics");... | examples/kart-and-cubes/example-scene.zig |
const std = @import("std");
const c = @cImport({
@cInclude("sqlite3.h");
});
pub const SQLiteExtendedIOError = error{
SQLiteIOErrRead,
SQLiteIOErrShortRead,
SQLiteIOErrWrite,
SQLiteIOErrFsync,
SQLiteIOErrDirFsync,
SQLiteIOErrTruncate,
SQLiteIOErrFstat,
SQLiteIOErrUnlock,
SQLite... | errors.zig |
const std = @import("std");
const views = @import("view.zig");
const xkbcommon = @import("xkb.zig");
const Xkb = @import("xkb.zig").Xkb;
const Move = @import("move.zig").Move;
const Resize = @import("resize.zig").Resize;
const ClientCursor = @import("cursor.zig").ClientCursor;
const backend = @import("backend/backend.z... | src/compositor.zig |
pub const FnlGenerator = extern struct {
seed: i32 = 1337,
frequency: f32 = 0.01,
noise_type: NoiseType = .opensimplex2,
rotation_type3: RotationType3 = .none,
fractal_type: FractalType = .none,
octaves: i32 = 3,
lacunarity: f32 = 2.0,
gain: f32 = 0.5,
weighted_strength: f32 = 0.0,
... | libs/znoise/src/znoise.zig |
const std = @import("std");
const base64 = std.base64;
const ascii = std.ascii;
const time = std.time;
const rand = std.rand;
const fmt = std.fmt;
const mem = std.mem;
const http = std.http;
const Sha1 = std.crypto.hash.Sha1;
const assert = std.debug.assert;
usingnamespace @import("common.zig");
fn stripCarriageRet... | src/base/client.zig |
const std = @import("std");
const version = @import("version");
const zzz = @import("zzz");
const uri = @import("uri");
const Lockfile = @import("Lockfile.zig");
const DependencyTree = @import("DependencyTree.zig");
const api = @import("api.zig");
usingnamespace @import("common.zig");
const Self = @This();
const Alloc... | src/Dependency.zig |
const std = @import("std.zig");
const mem = std.mem;
const builtin = std.builtin;
/// TODO Nearly all the functions in this namespace would be
/// better off if https://github.com/ziglang/zig/issues/425
/// was solved.
pub const Target = union(enum) {
Native: void,
Cross: Cross,
pub const Os = enum {
... | lib/std/target.zig |
const std = @import("../std.zig");
const builtin = @import("builtin");
const build = std.build;
const fs = std.fs;
const Step = build.Step;
const Builder = build.Builder;
const GeneratedFile = build.GeneratedFile;
const LibExeObjStep = build.LibExeObjStep;
const FileSource = build.FileSource;
const OptionsStep = @This... | lib/std/build/OptionsStep.zig |
const c = @import("c.zig");
const utils = @import("utils.zig");
const Face = @import("freetype.zig").Face;
pub const Color = c.FT_Color;
pub const LayerIterator = c.FT_LayerIterator;
pub const ColorStopIterator = c.FT_ColorStopIterator;
pub const ColorIndex = c.FT_ColorIndex;
pub const ColorStop = c.FT_ColorStop;
pub ... | freetype/src/freetype/color.zig |
pub const CRYPTCAT_MAX_MEMBERTAG = @as(u32, 64);
pub const CRYPTCAT_MEMBER_SORTED = @as(u32, 1073741824);
pub const CRYPTCAT_ATTR_AUTHENTICATED = @as(u32, 268435456);
pub const CRYPTCAT_ATTR_UNAUTHENTICATED = @as(u32, 536870912);
pub const CRYPTCAT_ATTR_NAMEASCII = @as(u32, 1);
pub const CRYPTCAT_ATTR_NAMEOBJID = @as(u... | win32/security/cryptography/catalog.zig |
const std = @import("std");
const testing = std.testing;
const CircBufError = error{
InvalidParam,
Empty,
};
fn CircBuf(comptime T: type) type {
return struct {
head: usize = 0,
tail: usize = 0,
buf: [*]T = null,
buf_len: usize = 0,
pub fn init(buf: [*]T, buf_len: ... | circbuf/generic_circbuf.zig |
const std = @import("std");
const warn = std.debug.warn;
const Allocator = std.mem.Allocator;
const c = @cImport({
@cInclude("GL/gl3w.h");
});
fn readFile(allocator: *Allocator, filename: []const u8) ![]const u8 {
var file = try std.fs.cwd().openFile(filename, .{});
var stat = try file.stat();
// TODO... | common/shader.zig |
pub const PROGRESS_INDETERMINATE = @as(i32, -1);
pub const PHOTOACQ_ERROR_RESTART_REQUIRED = @import("../zig.zig").typedConst(HRESULT, @as(i32, -2147180543));
pub const PHOTOACQ_RUN_DEFAULT = @as(u32, 0);
pub const PHOTOACQ_NO_GALLERY_LAUNCH = @as(u32, 1);
pub const PHOTOACQ_DISABLE_AUTO_ROTATE = @as(u32, 2);
pub const... | win32/media/picture_acquisition.zig |
const std = @import("std");
const game = @import("game.zig");
const GameState = game.GameState;
const PurchasableCard = game.PurchasableCard;
const alwaysRollTwo = false; // Default: false
const alwaysActivateHarbor = false; // Default: false
const forceBuyLandmarks = false; // Default: false
pub fn shouldRollTwoDic... | src/bot_random.zig |
const std = @import("std");
const meta = std.meta;
const Allocator = std.mem.Allocator;
const assert = std.debug.assert;
const testing = std.testing;
/// All supported message types by the client
/// any others will be skipped
pub const Message = union(enum(u8)) {
/// Whether or not the remote peer has choked this... | src/net/message.zig |
const std = @import("std");
const testing = std.testing;
const Handshake = @This();
hash: [20]u8,
peer_id: [20]u8,
const p_str = "BitTorrent protocol";
const p_strlen = @intCast(u8, p_str.len);
/// Serializes a Handshake object into binary data and writes the result to the writer
pub fn serialize(self: Handshake, w... | src/net/Handshake.zig |
const std = @import("std");
const assert = std.debug.assert;
const crypto = std.crypto;
const mem = std.mem;
const rotl = std.math.rotl;
const AesBlock = std.crypto.core.aes.Block;
const AuthenticationError = std.crypto.errors.AuthenticationError;
const Lane = @Vector(4, u64);
pub const Morus = struct {
pub const ... | src/main.zig |
const kprint = @import("kprint.zig");
const util = @import("arch/aarch64/util.zig");
const arch_init = @import("arch/aarch64/arch_init.zig");
const std = @import("std");
const builtin = @import("std").builtin;
const debug = std.debug;
const assert = debug.assert;
const process = @import("proc.zig");
const thread = @i... | kernel/src/kernel.zig |
const std = @import("std");
const assert = std.debug.assert;
const c = @import("c.zig");
const helpers = @import("helpers.zig");
const enc = @import("encode.zig");
const dec = @import("decode.zig");
const seek_key = @import("seek_key.zig");
var alloc = std.heap.GeneralPurposeAllocator(.{}){};
var allocator = &alloc.al... | src/lib.zig |
const std = @import("std.zig");
const assert = std.debug.assert;
const mem = std.mem;
const testing = std.testing;
/// A structure with an array and a length, that can be used as a slice.
///
/// Useful to pass around small arrays whose exact size is only known at
/// runtime, but whose maximum size is known at compti... | lib/std/bounded_array.zig |
const std = @import("std");
/// NOTE: This function is probably missing some optimizations of some kind.
/// Feel free to tinker! Also this could easily be genericized by adding a base
/// param, but we only need this for octal, so that isn't necessary yet.
/// Benchmarks on my machine indicate this is twice as fast ... | src/utils/simd.zig |
const std = @import("std");
const string = []const u8;
const time = @import("time");
pub fn main() !void {
std.log.info("All your codebase are belong to us.", .{});
}
fn harness(comptime seed: u64, comptime expects: []const [2]string) void {
var i: usize = 0;
while (i < expects.len) : (i += 1) {
_... | lib/zig-time/main.zig |
const std = @import("std");
const Builder = std.build.Builder;
const LibExeObjStep = std.build.LibExeObjStep;
const Step = std.build.Step;
pub fn build(b: *std.build.Builder) void {
const target = .{
.cpu_arch = .i386,
.cpu_model = .{ .explicit = &std.Target.x86.cpu._i586 },
.os_tag = .fre... | build.zig |
const std = @import("std");
const print = std.debug.print;
const Happiness = std.StringArrayHashMap(std.StringHashMap(isize));
pub fn main() anyerror!void {
const global_allocator = std.heap.page_allocator;
var file = try std.fs.cwd().openFile(
"./inputs/day13.txt",
.{
.read = tru... | src/day13.zig |
const std = @import("std");
const print = std.debug.print;
const build_options = @import("build_options");
const Postgres = @import("postgres");
const Pg = Postgres.Pg;
const Result = Postgres.Result;
const Builder = Postgres.Builder;
const FieldInfo = Postgres.FieldInfo;
const Parser = Postgres.Parser;
const ArrayLi... | examples/custom_types.zig |
const std = @import("std");
const io = std.io;
const fs = std.fs;
const testing = std.testing;
const mem = std.mem;
const deflate = std.compress.deflate;
// Flags for the FLG field in the header
const FTEXT = 1 << 0;
const FHCRC = 1 << 1;
const FEXTRA = 1 << 2;
const FNAME = 1 << 3;
const FCOMMENT = 1 << 4;
pub fn G... | lib/std/compress/gzip.zig |
const std = @import("std");
const assert = std.debug.assert;
const c = @cImport({
@cInclude("SDL2/SDL.h");
});
const game = @import("../minesweeper/game.zig");
const GameState = game.GameState;
const event = @import("../minesweeper/event.zig");
const GameEventTag = event.GameEventTag;
const SpriteSheetTileExtent... | src/sdl2/sdl2_backend.zig |
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
/// Caller must free returned memory.
pub fn latin1ToUtf8Alloc(allocator: Allocator, latin1_text: []const u8) ![]u8 {
var buffer = try std.ArrayList(u8).initCapacity(allocator, latin1_text.len);
errdefer buffer.de... | src/latin1.zig |
const std = @import("std");
const minInt = std.math.minInt;
const maxInt = std.math.maxInt;
const assert = std.debug.assert;
pub const register = @import("register.zig");
pub const machine = @import("machine.zig");
pub const avx = @import("avx.zig");
usingnamespace(@import("types.zig"));
const Register = register.R... | src/x86/operand.zig |
const std = @import("std");
const CrossTarget = std.zig.CrossTarget;
const TestContext = @import("../../src/test.zig").TestContext;
const linux_aarch64 = CrossTarget{
.cpu_arch = .aarch64,
.os_tag = .linux,
};
const macos_aarch64 = CrossTarget{
.cpu_arch = .aarch64,
.os_tag = .macos,
};
pub fn addCase... | test/stage2/aarch64.zig |
const std = @import("std");
const print = std.debug.print;
const data = @embedFile("../data/day05.txt");
pub fn main() !void {
var timer = try std.time.Timer.start();
// I've vetted the input, which is at max 1000x1000.
const board_width = 1000;
// We need two boards - one for the first hit on the location,... | src/day05.zig |
const Elf = @This();
const std = @import("std");
const builtin = @import("builtin");
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 Archive = @import("Elf/Archive.zig");
const Atom = @import("Elf/At... | src/link/Elf.zig |
const std = @import("std");
const Arena = std.heap.ArenaAllocator;
const expectEqual = std.testing.expectEqual;
const expectEqualStrings = std.testing.expectEqualStrings;
const yeti = @import("yeti");
const initCodebase = yeti.initCodebase;
const tokenize = yeti.tokenize;
const parse = yeti.parse;
const analyzeSemanti... | src/tests/test_simd.zig |
const std = @import("std");
const fmt = std.fmt;
const mem = std.mem;
const print = std.debug.print;
const Mask = struct {
on: u36 = 0,
off: u36 = 0,
fn update(self: *Mask, mask: *const [36]u8) void {
var on: u36 = 0;
var off: u36 = 0;
var bit_mask: u36 = 1 << 35;
for (mask)... | 14/part1.zig |
const std = @import("std");
const Report = std.ArrayList(struct {
keep: bool,
code: u12,
});
fn calcRating(report: Report, op: std.math.CompareOperator, decider: u1) !u12 {
var total: usize = report.items.len;
var bit: u4 = 0;
return blk: while (bit < 12) : (bit += 1) {
var ones_count: usi... | src/03.zig |
const std = @import("std");
const Table = [1024]u32;
const BufferSize = 4;
pub const Hc256 = struct {
ptable: Table,
qtable: Table,
buffer: [BufferSize]u8 = [_]u8{0} ** BufferSize,
buffered: bool,
ctr: usize = 0,
/// Initialize the cipher with the key and iv
pub fn init(key: [32]u8, iv:... | hc256.zig |
const std = @import("std");
const testing = std.testing;
const c = @import("c/c.zig");
const windows = c.windows;
const utils = @import("utils.zig");
pub const types = @import("types.zig");
pub const Event = @import("events.zig").Event;
pub fn getCodepage() c_uint {
return c.GetConsoleOutputCP();
}
pub fn setCod... | src/main.zig |
const std = @import("std");
const immu = @import("mmu.zig");
const Mmu = immu.Mmu;
const A = immu.addresses;
const meta = @import("meta.zig");
// number of cycles to scan and vblank
pub const frame_cycle_time = 70224;
pub fn Gpu(comptime Window: type) type {
comptime {
std.debug.assert(meta.hasField(Wind... | src/gpu.zig |
const std = @import("std");
const argsParser = @import("args");
const ihex = @import("ihex");
extern fn configure_serial(fd: c_int) u8;
extern fn flush_serial(fd: c_int) void;
pub fn main() anyerror!u8 {
const cli_args = argsParser.parseForCurrentProcess(struct {
// This declares long options for double ... | tools/hex2bin/main.zig |
const std = @import("std");
const t = std.testing;
const Input = @This();
pub const Position = struct {
index: usize = 0,
label: ?[]const u8 = null,
line: usize = 1,
col: usize = 1,
pub fn format(
self: Position,
comptime fmt: []const u8,
options: std.fmt.FormatOptions,
... | src/input.zig |
const std = @import("std");
const zap = @import("zap");
const hyperia = @import("hyperia");
const picohttp = @import("picohttp");
const Reactor = hyperia.Reactor;
const AsyncSocket = hyperia.AsyncSocket;
const AsyncWaitGroupAllocator = hyperia.AsyncWaitGroupAllocator;
const os = std.os;
const net = std.net;
const mem ... | example_http_server.zig |
const std = @import("std");
const layout = @import("layout.zig");
const mem = @import("mem.zig");
const pmem = @import("pmem.zig");
const vmem = @import("vmem.zig");
const scheduler = @import("scheduler.zig");
const thread = @import("thread.zig");
const x86 = @import("x86.zig");
const HashMap = std.HashMap;
const Linke... | kernel/ipc.zig |
const std = @import("std");
pub fn Vec(comptime T: type, comptime size: u32) type {
if (@typeInfo(T) != .Float and @typeInfo(T) != .Int) {
@compileError("Unsupported Vec element type " ++ @typeName(T));
}
return struct {
data: [size]T = [_]T{0} ** size,
const Self = @This();
... | src/vec.zig |
const std = @import("std");
const tests = @import("tests.zig");
const nl = std.cstr.line_sep;
pub fn addCases(cases: *tests.RunTranslatedCContext) void {
cases.add("division of floating literals",
\\#define _NO_CRT_STDIO_INLINE 1
\\#include <stdio.h>
\\#define PI 3.14159265358979323846f
... | test/run_translated_c.zig |
const std = @import("../std.zig");
const builtin = @import("builtin");
const os = std.os;
const io = std.io;
const mem = std.mem;
const math = std.math;
const assert = std.debug.assert;
const windows = os.windows;
const Os = builtin.Os;
const maxInt = std.math.maxInt;
const is_windows = std.Target.current.os.tag == .wi... | lib/std/fs/file.zig |
const std = @import("std");
const person_module = @import("person.zig");
const family_module = @import("family.zig");
const json = std.json;
const util = @import("util.zig");
const Person = person_module.Person;
const Family = family_module.Family;
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.... | src/family_tree.zig |
const std = @import("../std.zig");
const math = std.math;
const expect = std.testing.expect;
const maxInt = std.math.maxInt;
/// Returns whether x is an infinity, ignoring sign.
pub fn isInf(x: var) bool {
const T = @typeOf(x);
switch (T) {
f16 => {
const bits = @bitCast(u16, x);
... | lib/std/math/isinf.zig |
const std = @import("std");
const math = @import("zlm.zig");
const assert = std.debug.assert;
const vec2 = math.vec2;
const vec3 = math.vec3;
const vec4 = math.vec4;
const Vec2 = math.Vec2;
const Vec3 = math.Vec3;
const Vec4 = math.Vec4;
const Mat3 = math.Mat3;
const Mat4 = math.Mat4;
test "default generic is f32" ... | test.zig |
const std = @import("std");
pub const QueueError = error{
/// Tried to add to a queue that is full.
FullQueue,
/// Tried to take from an empty queue.
EmptyQueue,
/// ThreadsafeQueue's "wait" function call has timed out.
TimedOut,
};
/// Threadsafe wrapper around our FIFO Queue
pub fn Thread... | static_queue.zig |
const std = @import("std");
const panic = std.debug.panic;
const assert = std.debug.assert;
const bufPrint = std.fmt.bufPrint;
const math = std.math;
usingnamespace @import("math3d.zig");
const pieces = @import("pieces.zig");
const Piece = pieces.Piece;
pub const Tetris = struct {
projection: Mat4x4,
prng: std... | src/tetris.zig |
const std = @import("std");
const lib = @import("../../main.zig");
const shared = @import("../shared.zig");
const EventType = shared.BackendEventType;
const win32 = @import("win32.zig");
const HWND = win32.HWND;
const HINSTANCE = win32.HINSTANCE;
const RECT = win32.RECT;
const MSG = win32.MSG;
const WPARAM = win32.WP... | src/backends/win32/backend.zig |
pub const WEB_SOCKET_MAX_CLOSE_REASON_LENGTH = @as(u32, 123);
//--------------------------------------------------------------------------------
// Section: Types (9)
//--------------------------------------------------------------------------------
pub const WEB_SOCKET_HANDLE = isize;
pub const WEB_SOCKET_CLOSE_STAT... | win32/networking/web_socket.zig |
const std = @import("std");
const game = @import("game.zig");
const Game = game.Game;
const GameError =game.GameError;
const dice = @import("dice.zig");
/// Get a generator for finished games that employs the given picking strategy
pub fn GameGenerator(comptime picking_strategy: anytype, game_count: usize) type {
... | src/simulate.zig |
const std = @import("std");
const mem = std.mem;
const testing = std.testing;
const log = std.log;
const ArrayList = std.ArrayList;
const TailQueue = std.TailQueue;
const intcode = @import("intcode.zig");
const IntcodeProgram = intcode.IntcodeProgram;
const Instruction = intcode.Instruction;
const ParamMode = intcode.... | share/zig/intcode_test.zig |
const sf = @import("../sfml.zig");
const math = @import("std").math;
pub fn Rect(comptime T: type) type {
return struct {
const Self = @This();
/// The CSFML vector type equivalent
const CsfmlEquivalent = switch (T) {
i32 => sf.c.sfIntRect,
f32 => sf.c.sfFloatRect,... | src/sfml/graphics/rect.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = 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/test/day18... | src/day18.zig |
const base = @import("base.zig");
const warn = @import("std").debug.warn;
pub fn is16(ranges: []const base.Range16, r: u16) bool {
if (ranges.len <= base.linear_max or r <= base.linear_max) {
for (ranges) |*range| {
if (r < range.lo) {
return false;
}
if ... | src/unicode/letter.zig |