code stringlengths 38 801k | repo_path stringlengths 6 263 |
|---|---|
pub fn main() !void {
const file_name = std.fs.path.basename(@src().file);
print(" file: {}\n", .{file_name});
}
test "string concat at comptime" {
const str1 = "one";
const str2: []const u8 = "two";
const str3 = str1 ++ " " ++ str2;
print("str3={}\n", .{str3});
expect(eql(u8, str3, "one ... | 11_strings.zig |
const std = @import("std");
pub fn build(b: *std.build.Builder) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for rest... | build.zig |
const std = @import("std");
const os = @import("root").os;
const Order = std.math.Order;
const rb = os.lib.rbtree;
const sbrk = os.memory.vmm.sbrk;
const Mutex = os.thread.Mutex;
const min_materialize_size = 64 * 1024;
const node_block_size = 0x1000 * @sizeOf(Range) / 16;
const debug = false;
const rb_features: rb... | src/lib/range_alloc.zig |
const sf = struct {
pub usingnamespace @import("../sfml.zig");
pub usingnamespace sf.system;
};
const math = @import("std").math;
pub fn Rect(comptime T: type) type {
return packed struct {
const Self = @This();
/// The CSFML vector type equivalent
const CsfmlEquivalent = switch (... | src/sfml/graphics/rect.zig |
pub const std = @import("std");
pub const lir = @import("ir.zig");
pub const LufType = @import("Value.zig").Type;
const Allocator = std.mem.Allocator;
const leb = std.leb;
const testing = std.testing;
const Op = enum(u8) {
@"unreachable" = 0x00,
nop = 0x01,
block = 0x02,
loop = 0x03,
@"if" = 0x04,
... | src/wasm.zig |
const std = @import("std");
const ast = @import("ast.zig");
const interpreter = @import("interpreter.zig");
const mem = @import("gc.zig");
const SourceLocation = @import("sourcelocation.zig").SourceLocation;
const Env = ast.Env;
const Expr = ast.Expr;
const ExprValue = ast.ExprValue;
const ExprType = ast.ExprType;
cons... | src/intrinsics.zig |
const std = @import("std");
const aoc = @import("aoc-lib.zig");
fn indexOf(h: []const u8, n: u8, o: usize) ?usize {
var i = o;
while (i < h.len) : (i += 1) {
if (h[i] == n) {
return i;
}
}
return null;
}
fn flood(l: []u8, p: usize, w: usize, h: usize) anyerror!usize {
v... | 2021/09/aoc.zig |
const kernel = @import("../../kernel.zig");
const x86_64 = @import("../x86_64.zig");
const DescriptorTable = @import("descriptor_table.zig");
const TSS = @import("tss.zig");
const log = kernel.log.scoped(.GDT);
pub const Table = packed struct {
null_entry: Entry = 0, // 0x00
code_16: Entry = 0x00009a000000ffff... | src/kernel/arch/x86_64/gdt.zig |
const std = @import("std");
const bytecode = @import("bytecode.zig");
const Value = @import("value.zig").Value;
const Str = []const u8;
pub fn disassemble(chunk: bytecode.Chunk, name: Str) void {
print("== {s} ==\n", .{name});
var offset: usize = 0;
while (offset < chunk.code.items.len) {
offset... | src/debug.zig |
//--------------------------------------------------------------------------------
// Section: Types (6)
//--------------------------------------------------------------------------------
const CLSID_WaaSAssessor_Value = Guid.initString("098ef871-fa9f-46af-8958-c083515d7c9c");
pub const CLSID_WaaSAssessor = &CLSID_Waa... | win32/system/update_assessment.zig |
const std = @import("std");
const ArrayList = std.ArrayList;
const V5 = [5]i64;
const num_teaspoons: u32 = 100;
fn addV5(u: V5, v: V5) V5 {
return V5{
u[0] + v[0],
u[1] + v[1],
u[2] + v[2],
u[3] + v[3],
u[4] + v[4],
};
}
fn scaleV5(c: i64, v: V5) V5 {
return V5{ v[... | src/day15.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const nitori = @import("nitori");
const communication = nitori.communication;
const interface = nitori.interface;
const EventChannel = communication.EventChannel;
//;
// TODO maybe have a *const System in the contexts?
pub const modules = struct {
... | src/module.zig |
const std = @import("../std.zig");
const Cpu = std.Target.Cpu;
pub const Feature = enum {
@"64bit",
a,
c,
d,
e,
f,
m,
relax,
};
pub usingnamespace Cpu.Feature.feature_set_fns(Feature);
pub const all_features = blk: {
const len = @typeInfo(Feature).Enum.fields.len;
std.debug.as... | lib/std/target/riscv.zig |
const std = @import("std");
const warn = std.debug.warn;
const c = @cImport({
@cInclude("string.h");
@cInclude("stdio.h");
@cInclude("ui.h");
});
extern fn onClosing(w: ?*c.uiWindow, data: ?*c_void) c_int {
c.uiQuit();
return 1;
}
extern fn onShouldQuit(data: ?*c_void) c_int {
var mainwin2: ?... | src/main.zig |
const std = @import("std");
const unicode = @import("unicode");
const io = std.io;
const mem = std.mem;
const utf8 = unicode.utf8;
const warn = std.debug.warn;
const Allocator = mem.Allocator;
pub const WriteError = io.BufferOutStream.Error;
/// WriterCommon returns a csv Writer that can write OutStream initialized ... | src/encoding/csv/csv.zig |
const std = @import("std");
const builtin = @import("builtin");
const argsParser = @import("args");
const ihex = @import("ihex");
const spu = @import("spu-mk2");
const common = @import("shared.zig");
extern "kernel32" fn SetConsoleMode(hConsoleHandle: std.os.windows.HANDLE, dwMode: std.os.windows.DWORD) callconv(.Stdc... | tools/emulator/pc-main.zig |
const inputFile = @embedFile("./input/day08.txt");
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const assert = std.debug.assert;
// 0(6): abcefg
// 1(2): cf
// 2(5): acdeg
// 3(5): acdfg
// 4(4): bcdf
// 5(5): abdfg
// 6(6): abdefg
// 7(3): acf
// 8(7): abcdefg
// 9... | src/day08.zig |
const Cpu = @import("cpu.zig").Cpu;
const Keypad = @import("keypad.zig").Keypad;
usingnamespace @import("std").testing;
fn testUpdateFrame(frame: []u1) void {}
test "Next opcode" {
var cpu = Cpu.init(.{});
cpu.memory[0x200] = 0xA2;
cpu.memory[0x201] = 0xF0;
expect(cpu.fetchOpcode() == 0xA2F0);
}
t... | src/tests.zig |
const std = @import("std");
const utils = @import("utils.zig");
const AttributeInfo = @import("attributes.zig").AttributeInfo;
const ClassFile = @import("ClassFile.zig");
const ConstantPool = @import("ConstantPool.zig");
const FieldInfo = @This();
pub const AccessFlags = struct {
public: bool = false,
private... | src/FieldInfo.zig |
const NULL = @import("std").zig.c_translation.cast(?*anyopaque, @as(c_int, 0));
pub const wchar_t = c_int;
const xlib = @import("Xlib.zig");
const keys = @import("keysym.zig");
pub usingnamespace keys;
pub const struct__XkbStateRec = extern struct {
group: u8,
locked_group: u8,
base_group: c_ushort,
... | modules/platform/src/linux/X11/XKBlib.zig |
const std = @import("std");
const builtin = @import("builtin");
const compiler_rt = @import("../compiler_rt.zig");
pub fn __multf3(a: f128, b: f128) callconv(.C) f128 {
return mulXf3(f128, a, b);
}
pub fn __muldf3(a: f64, b: f64) callconv(.C) f64 {
return mulXf3(f64, a, b);
}
pub fn __mulsf3(a: f32, b: f32) c... | lib/std/special/compiler_rt/mulXf3.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const ines = @import("../ines.zig");
const console_ = @import("../console.zig");
const Config = console_.Config;
const Console = console_.Console;
const Cpu = @import("../cpu.zig").Cpu;
const GenericMapper = @import("../mapper.zig").GenericMapper;
con... | src/mapper/mmc1.zig |
const ser = @import("../../../lib.zig").ser;
/// Struct serialization interface.
///
/// Getty structs are only partially serialized by `getty.Serializer`
/// implementations due to the fact that there are many different ways to
/// iterate over and access the fields of a struct. As such, this interface is
/// provide... | src/ser/interface/structure.zig |
const std = @import("std");
const utils = @import("utils");
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const print = utils.print;
const Fold = union(enum) {
Horizontal: i32,
Vertical: i32,
};
const Folding = struct {
points: [][2]i32,
folds: []Fold,
};
fn re... | day13/src/main.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const ValueTree = std.json.ValueTree;
const Value = std.json.Value;
const stdout = std.io.getStdOut().outStream();
const args = @import("args");
const BUFFSIZE = 2048;
var arena = ArenaAllocator.init(std.... | src/main.zig |
const std = @import("std");
const mem = std.mem;
const OtherSymbol = @This();
allocator: *mem.Allocator,
array: []bool,
lo: u21 = 166,
hi: u21 = 129994,
pub fn init(allocator: *mem.Allocator) !OtherSymbol {
var instance = OtherSymbol{
.allocator = allocator,
.array = try allocator.alloc(bool, 12... | src/components/autogen/DerivedGeneralCategory/OtherSymbol.zig |
const std = @import("std");
const Request = @import("request.zig").Request;
const Response = @import("response.zig").Response;
const MimeType = @import("mime_type.zig").MimeType;
const url = @import("url.zig");
const Allocator = std.mem.Allocator;
const fs = std.fs;
pub const FileServer = @This();
var dir: fs.Dir = u... | src/fs.zig |
const wasm4 = @import("wasm4.zig");
const w4 = @import("wrapper4.zig");
const std = @import("std");
const smiley_data = [8]u8{
0b11000011,
0b10000001,
0b00100100,
0b00100100,
0b00000000,
0b00100100,
0b10011001,
0b11000011,
};
var pitch: i16 = 0;
var duty_index: u2 = 0;
var channel_ind... | src/main.zig |
const std = @import("std");
const states = @import("state.zig");
const State = states.State;
const ScoreMap = std.StringHashMap(f32);
fn doCount(haystack: []u8, needle: []u8) usize {
var count: usize = 0;
var idx: usize = 0;
while (true) {
var newidx_opt = std.mem.indexOfPos(u8, haystack, idx, ne... | src/search.zig |
const std = @import("std");
pub const Type = enum {
@"void",
number,
string,
boolean,
array,
object,
pub fn format(value: @This(), comptime fmt: []const u8, options: std.fmt.FormatOptions, writer: anytype) !void {
_ = fmt;
_ = options;
try writer.writerAll(@tagName(... | src/library/compiler/typeset.zig |
const assert = std.debug.assert;
const builtin = @import("builtin");
const expect = std.testing.expect;
/// Many reader, many writer, non-allocating, thread-safe
/// Uses a spinlock to protect push() and pop()
/// When building in single threaded mode, this is a simple linked list.
pub fn Stack(comptime T: type) type ... | lib/std/atomic/stack.zig |
const std = @import("std");
const c = @import("c.zig");
pub const Error = error{
OutOfMemory,
InvalidMode,
InvalidChannelIndex,
NoChange,
Unknown,
};
fn translateErr(ret: c_int) Error!void {
return switch (ret) {
0 => {},
c.EBUR128_ERROR_NOMEM => error.OutOfMemory,
c.EB... | src/main.zig |
const std = @import("../std.zig");
const CpuFeature = std.Target.Cpu.Feature;
const CpuModel = std.Target.Cpu.Model;
pub const Feature = enum {
duplex,
hvx,
hvx_length128b,
hvx_length64b,
hvxv60,
hvxv62,
hvxv65,
hvxv66,
long_calls,
mem_noshuf,
memops,
noreturn_stack_elim... | lib/std/target/hexagon.zig |
const std = @import("std");
const server = &@import("../main.zig").server;
const Error = @import("../command.zig").Error;
const Direction = @import("../command.zig").Direction;
const Seat = @import("../Seat.zig");
const View = @import("../View.zig");
const ViewStack = @import("../view_stack.zig").ViewStack;
/// Swa... | source/river-0.1.0/river/command/swap.zig |
const std = @import("std");
const mem = std.mem;
const io = std.io;
const fs = std.fs;
const fmt = std.fmt;
const testing = std.testing;
const Target = std.Target;
const CrossTarget = std.zig.CrossTarget;
const assert = std.debug.assert;
const SparcCpuinfoImpl = struct {
model: ?*const Target.Cpu.Model = null,
... | lib/std/zig/system/linux.zig |
const std = @import("std");
const assert = std.debug.assert;
const log = std.log;
const cuda = @import("cudaz");
const cu = cuda.cu;
const png = @import("png.zig");
const Image = png.Image;
const builtin = @import("builtin");
const CallingConvention = @import("std").builtin.CallingConvention;
pub const is_nvptx = bu... | CS344/src/utils.zig |
const std = @import("std");
/// DCT computes discrete cosine transform.
pub const DCT = struct {
const Self = @This();
allocator: *std.mem.Allocator,
size: usize,
workspace: []f32,
dft_sin: []f32,
dft_cos: []f32,
pub fn init(allocator: *std.mem.Allocator, input_size: usize) !Self {
... | src/dsp/dct.zig |
const std = @import("std");
const Vec = std.meta.Vector(16, u8);
fn reverse_mask(n: u8) Vec {
// global constant is not used to workaround a compiler bug
var v = Vec { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
var i: u8 = 0;
while (i < n) : (i += 1) v[i] = n - i - 1;
return v;
}
fn ... | bench/algorithm/fannkuch-redux/2.zig |
const std = @import("std");
const flip_vertically_on_write = false;
// Expects a writer which implements std.io.OutStream.
pub fn writeToStream(writer: var, w: usize, h: usize, comp: usize, data: []const u8, quality: i32) !void {
try writeToStreamCore(writer, w, h, comp, data, quality);
}
pub fn writeToFile(fil... | jpeg_writer.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const log = std.log.scoped(.codegen);
const spec = @import("spirv/spec.zig");
const Module = @import("../Module.zig");
const Decl = Module.Decl;
const Type = @import("../type.zig").Type;
pub const TypeMap = std.HashMap(Type, u32, Type.hash, Type.eql, st... | src/codegen/spirv.zig |
const std = @import("std");
const aoc = @import("aoc-lib.zig");
fn part1(in: [][]const u8) u64 {
const dt = std.fmt.parseUnsigned(u64, in[0], 10) catch unreachable;
var min: u64 = std.math.maxInt(u64);
var mbus: u64 = undefined;
var bit = std.mem.split(u8, in[1], ",");
while (bit.next()) |ts| {
... | 2020/13/aoc.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const build_options = @import("build_options");
const console_ = @import("console.zig");
const Console = console_.Console;
const Precision = console_.Precision;
const IoMethod = console_.IoMethod;
const sdl_bindings = @import("sdl/bindings.zig");
const... | src/main.zig |
const std = @import("std");
const builtin = @import("builtin");
const runtime_safety = std.debug.runtime_safety;
const is_64: bool = switch (builtin.cpu.arch) {
.riscv64 => true,
.riscv32 => false,
else => |arch| @compileError("only riscv64 and riscv32 targets supported, found target: " ++ @tagName(arch))... | sbi.zig |
const std = @import("std");
const input = @embedFile("data/input18");
usingnamespace @import("util.zig");
pub fn main() !void {
var part1: u64 = 0;
var part2: u64 = 0;
var reader = lines(input);
while (reader.next()) |line| {
part1 += eval(line);
part2 += try evalV2(line);
}
p... | src/day18.zig |
const std = @import("std");
const print = std.debug.print;
pub fn main() anyerror!void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
var allocator = &gpa.allocator;
var arena = std.heap.ArenaAllocator.init(allocator);
defer arena.deinit();
var file = try std.fs.... | src/day19.zig |
const std = @import("std");
const builtin = @import("builtin");
const fun = @import("fun");
const debug = std.debug;
const mem = std.mem;
const compare = fun.generic.compare;
pub const Offset = struct {
start: usize,
end: usize,
};
pub fn findStructs(comptime Struct: type, comptime ignored_fields: []const []... | tools/offset-finder/search.zig |
const assert = @import("std").debug.assert;
const builtin = @import("std").builtin;
const math = @import("std").math;
const mem = @import("std").mem;
pub const block_size: u8 = 8;
const ip = [64]u8{
6, 14, 22, 30, 38, 46, 54, 62,
4, 12, 20, 28, 36, 44, 52, 60,
2, 10, 18, 26, 34, 42, 50, 58,
0, 8, 16,... | src/des.zig |
const std = @import("std");
const print = std.debug.print;
const List = std.ArrayList;
const util = @import("util.zig");
const gpa = util.gpa;
const data = @embedFile("../data/day17.txt");
const Target = struct {
x_min: i32,
x_max: i32,
y_min: i32,
y_max: i32,
};
fn parseTarget(d: []const u8) !Targe... | 2021/src/day17.zig |
const std = @import("std");
const zriscv = @import("zriscv");
const clap = @import("clap");
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = &gpa.allocator;
const stdin = std.io.getStdIn();
const stdin_reader = stdin.reader();
const stdout_writer = std.io.getStdOut().writer();
const stderr_writer ... | runner/main.zig |
const std = @import("std");
usingnamespace (@import("../machine.zig"));
usingnamespace (@import("../util.zig"));
const imm = Operand.immediate;
const mem = Operand.memory;
const memRm = Operand.memoryRm;
const reg = Operand.register;
test "reserved opcodes" {
const m16 = Machine.init(.x86_16);
const m32 = Mac... | src/x86/tests/reserved.zig |
const std = @import("std");
const getty = @import("getty");
const Deserializer = @import("deserializer.zig").Deserializer;
const Token = @import("common/token.zig").Token;
const allocator = std.testing.allocator;
const assert = std.debug.assert;
const expect = std.testing.expect;
const expectEqual = std.testing.expec... | src/tests/de/tests.zig |
const std = @import("std");
const os = std.os;
const mem = std.mem;
const net = std.net;
const testing = std.testing;
const assert = std.debug.assert;
// For testing slow and fast clients.
const delay_time = std.time.ns_per_ms * 0;
var bytes_sent: usize = 0;
var bytes_read: usize = 0;
test "socket sends small data a... | poc/nonblocking_io.zig |
const std = @import("std");
const stdx = @import("stdx");
const Vec3 = stdx.math.Vec3;
const ma = @import("miniaudio");
const log = stdx.log.scoped(.audio);
pub const AudioEngine = struct {
const Self = @This();
engine: ma.ma_engine,
pub fn init(self: *Self) void {
const res = ma.ma_engine_init(... | runtime/audio.zig |
const std = @import("std");
const uv = @import("uv");
const ssl = @import("openssl");
const c = @cImport({
@cDefine("H2O_USE_LIBUV", "1");
@cInclude("h2o.h");
@cInclude("h2o/http1.h");
@cInclude("h2o/http2.h");
});
// pub usingnamespace c;
const h2o_loop = uv.uv_loop_t;
pub extern fn h2o_config_init... | lib/h2o/h2o.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const nfd = @import("nfd");
const nvg = @import("nanovg");
const gui = @import("gui");
const icons = @import("icons.zig");
const geometry = @import("gui/geometry.zig");
const Point = geometry.Point;
const Rect = geometry.... | src/EditorWidget.zig |
const std = @import("std");
const c = @import("c.zig");
const key = @import("key.zig");
const pem = @import("pem.zig");
pub const Anchor = struct {
anchor: c.br_x509_trust_anchor,
const Self = @This();
pub fn init(der: []const u8, allocator: std.mem.Allocator) !Self
{
var state = X509State {... | src/crt.zig |
const utils = @import("utils");
const memory = @import("memory.zig");
const Allocator = memory.Allocator;
const MemoryError = memory.MemoryError;
const MappedList = @import("mapped_list.zig").MappedList;
const print = @import("print.zig");
const io = @import("georgios").io;
pub const File = io.File;
pub const FileErro... | kernel/io.zig |
const std = @import("std");
const allocator = std.heap.page_allocator;
const json = std.json;
const Gltf = @import("gltf.zig").Gltf;
const Program = @import("program.zig").Program;
const gl = @import("webgl.zig");
const wasm = @import("wasm.zig");
const vert_src = @embedFile("shaders/color.vert");
const frag_src = @... | src/game.zig |
// This uses procfs heavily, and while procfs lives in memory and works,
// maybe it isn't the most scalable solution. We could peek into netlink, but
// that can be done later.
const std = @import("std");
pub const Stats = struct {
cpu_usage: f64, memory_usage: u64
};
const StatsFile = struct {
utime: u32,... | src/process_stats.zig |
const std = @import("std");
const mem = std.mem;
const primes = []u64{
0xa0761d6478bd642f, 0xe7037ed1a0b428db,
0x8ebc6af09c88c6e3, 0x589965cc75374cc3,
0x1d8e4e27c47d124f, 0xeb44accab455d165,
};
fn read_bytes(comptime bytes: u8, data: []const u8) u64 {
return mem.readVarInt(u64, data[0..bytes], @impor... | src/main.zig |
const inputFile = @embedFile("./input/day13.txt");
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const Str = []const u8;
const BitSet = std.DynamicBitSet;
const StrMap = std.StringHashMap;
const assert = std.debug.assert;
const tokenize = std.mem.tokenize;
const prin... | src/day13.zig |
const std = @import("std");
const assert = std.debug.assert;
const math = std.math;
const mem = std.mem;
const bits = @import("./bits.zig");
pub const LZ_WND_SIZE = 32768;
const HASH_SIZE = 15;
const NO_POS = math.maxInt(usize);
const MIN_LEN = 4;
// Output a literal byte at dst_pos in dst.
pub inline fn lz77_outpu... | src/lz77.zig |
const std = @import("std");
const testing = std.testing;
const Allocator = std.mem.Allocator;
const io = std.io;
const OutError = io.SliceOutStream.Error;
const InError = io.SliceInStream.Error;
const dns = @import("../dns.zig");
const rdata = dns.rdata;
const Packet = dns.Packet;
test "convert domain string to dns n... | src/pkg/dns/test.zig |
const std = @import("std");
const Arena = std.heap.ArenaAllocator;
const expectEqual = std.testing.expectEqual;
const expectEqualStrings = std.testing.expectEqualStrings;
const ecs = @import("ecs.zig");
const ECS = ecs.ECS;
const Entity = ecs.Entity;
const Strings = @import("strings.zig").Strings;
const components = @... | src/init_codebase.zig |
align allowzero and anyframe asm async await break
callconv catch comptime const continue defer else
enum errdefer error export extern fn for if
inline noalias orelse or packed promise pub resume
return linksection struct suspend switch test
threadlocal try union unreachable usingnamespace var
volatile while
// specia... | bundles/zig/misc/example.zig |
const std = @import("std");
const Context = @import("Context.zig");
const Token = @import("Token.zig");
allocator: std.mem.Allocator,
ctx: Context,
offset: ?u16 = null,
const Lexer = @This();
// API
pub fn lex(self: *Lexer) !std.MultiArrayList(Token) {
var tokens = std.MultiArrayList(Token){};
errdefer toke... | src/Lexer.zig |
const std = @import("std");
const root = @import("root");
const liu = @import("./lib.zig");
const builtin = @import("builtin");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const wasm = @This();
pub const Obj = enum(u32) {
// These are kept up to date with src/wasm.ts
jsundefined,
... | src/liu/wasm.zig |
const std = @import("std.zig");
const StringHashMap = std.StringHashMap;
const mem = std.mem;
const Allocator = mem.Allocator;
const testing = std.testing;
/// BufMap copies keys and values before they go into the map, and
/// frees them when they get removed.
pub const BufMap = struct {
hash_map: BufMapHashMap,
... | lib/std/buf_map.zig |
const Atom = @This();
const std = @import("std");
const build_options = @import("build_options");
const aarch64 = @import("../../arch/aarch64/bits.zig");
const assert = std.debug.assert;
const commands = @import("commands.zig");
const log = std.log.scoped(.link);
const macho = std.macho;
const math = std.math;
const m... | src/link/MachO/Atom.zig |
const std = @import("std");
const input = @import("input.zig");
pub fn run(stdout: anytype) anyerror!void {
{
var input_ = try input.readFile("inputs/day18");
defer input_.deinit();
const result = try part1(&input_);
try stdout.print("18a: {}\n", .{ result });
std.debug.as... | src/day18.zig |
const std = @import("std");
const input = @import("input.zig");
pub fn run(stdout: anytype) anyerror!void {
{
var input_ = try input.readFile("inputs/day23");
defer input_.deinit();
const result = try part1(&input_);
try stdout.print("23a: {}\n", .{ result });
std.debug.as... | src/day23.zig |
const std = @import("../../std.zig");
const maxInt = std.math.maxInt;
pub fn S_ISCHR(m: u32) bool {
return m & S_IFMT == S_IFCHR;
}
// See:
// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/include/unistd.h
// - https://gitweb.dragonflybsd.org/dragonfly.git/blob/HEAD:/sys/sys/types.h
// TODO: mode_t s... | lib/std/os/bits/dragonfly.zig |
const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer if (gpa.deinit()) @panic("leaked");
const allocator = &gpa.allocator;
const files = .{
.{ "chapter-0.md", "test-c0.zig" },
.{ "chapter-1.md", "test-c1.zig" },
.{ "chapter-... | test-out.zig |
pub const ContentType = enum(u8) {
invalid = 0,
change_cipher_spec = 20,
alert = 21,
handshake = 22,
application_data = 23,
heartbeat = 24,
_,
};
pub const CompressedY = enum(u8) {
even = 2,
odd = 3,
_,
};
pub const HashAlgorithm = enum(u8) {
none = 0,
md5 = 1,
sha1... | src/enums.zig |
const std = @import("std");
/// Adds all BearSSL sources to the exeobj step
/// Allows simple linking from build scripts.
pub fn linkBearSSL(comptime path_prefix: []const u8, module: *std.build.LibExeObjStep, target: std.zig.CrossTarget) void {
module.linkLibC();
module.addIncludeDir(path_prefix ++ "/BearSSL/... | src/lib.zig |
// The MIT License (Expat)
//
// Copyright (c) 2019 dbandstra
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, co... | deps/zig_wav.zig |
const std = @import("std");
pub fn main() !u8 {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const argv = try std.process.argsAlloc(gpa.allocator());
defer std.process.argsFree(gpa.allocator(), argv);
if (argv.len != 3) {
return 1;
}
var src_dir = try std.fs.cwd().openDir(argv[... | src/benchmark/render.zig |
const Vector = @import("../Mathematics/Mathematics.zig").Vector;
const Matrix = @import("../Mathematics/Mathematics.zig").Matrix;
const wgi = @import("../WindowGraphicsInput/WindowGraphicsInput.zig");
const FrameBuffer = wgi.FrameBuffer;
const MeshRenderer = @import("MeshRenderer.zig").MeshRenderer;
const rtRenderEngin... | src/RTRenderEngine/Light.zig |
const std = @import("std");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const Compilation = @import("../Compilation.zig");
const llvm = @import("llvm/bindings.zig");
const link = @import("../link.zig");
const log = std.log.scoped(.codegen);
const math = std.math;
const Module = @import("../Mo... | src/codegen/llvm.zig |
const std = @import("std");
const wasm = @import("wasm.zig");
const Allocator = std.mem.Allocator;
const leb = std.leb;
const meta = std.meta;
pub const Result = struct {
module: wasm.Module,
arena: std.heap.ArenaAllocator.State,
/// Frees all memory that was allocated when parsing.
/// Usage of `modu... | src/parser.zig |
const std = @import("std");
const zp = @import("zplay");
const Camera = zp.graphics.@"3d".Camera;
const Light = zp.graphics.@"3d".Light;
const Mesh = zp.graphics.@"3d".Mesh;
const Material = zp.graphics.@"3d".Material;
const Texture2D = zp.graphics.texture.Texture2D;
const SimpleRenderer = zp.graphics.@"3d".SimpleRende... | examples/phong_lighting.zig |
const std = @import("std");
const sqlite = @import("sqlite");
const manage_main = @import("main.zig");
const Context = manage_main.Context;
const log = std.log.scoped(.awtfdb_watcher);
const VERSION = "0.0.1";
const HELPTEXT =
\\ awtfdb-watcher: watch the entire operating system for renames,
\\ updating the ... | src/rename_watcher_main.zig |
const std = @import("std");
const stdx = @import("../stdx.zig");
const t = stdx.testing;
const log = stdx.log.scoped(.dynamic_array_list);
/// ArrayList with variable sized items of multiple of @sizeOf(T).
/// TODO: Allow items that are not a multiple of @sizeOf(T).
pub fn DynamicArrayList(comptime Id: type, comptime... | stdx/ds/dynamic_array_list.zig |
const std = @import("std");
const fs = std.fs;
const lang = @import("lang.zig");
const mdown = @import("mdown.zig");
const util = @import("util.zig");
const str = []const u8;
const testing = std.testing;
const process = std.process;
const Dir = std.fs.Dir;
const EntryKind = Dir.Entry.Kind;
const Thread = std.Thread;
co... | lib/idot/src/main.zig |
const std = @import("std");
const c = @import("../c.zig");
const zupnp = @import("../lib.zig");
const Allocator = std.mem.Allocator;
const Headers = @This();
const HeaderItems = std.StringHashMap([:0]const u8);
const logger = std.log.scoped(.@"zupnp.web.Headers");
const ExtraHeadersIterator = struct {
header_list... | src/web/headers.zig |
const std = @import("std");
const dtb = @import("dtb.zig");
const pl011 = @import("pl011.zig");
const mailbox = @import("mailbox.zig");
const gpio = @import("gpio.zig");
const log = @import("log.zig");
const arm = @import("arm.zig");
const interrupt = @import("interrupt.zig");
const panic_ = @import("panic.zig");
cons... | kernel.zig |
const sabaton = @import("root").sabaton;
const pte = u64;
const table_ptr = [*]pte;
pub const Perms = enum {
none = 0,
x = 1,
w = 2,
r = 4,
rw = 6,
rwx = 7,
rx = 5,
};
pub const MemoryType = enum {
memory,
mmio,
};
pub const Root = struct {
ttbr0: table_ptr,
ttbr1: table_ptr,
};
fn make_tabl... | src/platform/paging.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/day15.txt");
co... | src/day15.zig |
const std = @import("std");
const sf = @import("sfml");
const allocator = std.heap.page_allocator;
// I only use things I've wrapped here, but the other csfml functions seem to work, just need to wrap them
pub fn main() anyerror!void {
// Create a window
var window = try sf.RenderWindow.init(.{ .x = 800, .y ... | src/examples/my_tests.zig |
const std = @import("std");
const zlm = @import("zlm");
const Renderer = @import("renderer.zig").Renderer;
const ROM = @import("../rom.zig").ROM;
const Track = @import("../track/track.zig").Track;
const Window = @import("window.zig").Window;
const CameraMoveMode = enum {
None,
Pan,
Rotate,
};
const PAN_... | src/render/viewer.zig |
use @import("./4_0_tokenization.zig");
// https://drafts.csswg.org/css-syntax/#parsing
// 5. Parsing
//
// The input to the parsing stage is a stream or list of tokens from the tokenization stage. The output depends on how the parser is invoked, as defined by the entry points listed later in this section. The parser o... | parser/5_0_parsing.zig |
const std = @import("std");
/// Uppermost four bits of a word. Can address all memory.
pub const GlobalOpcode = enum(u4) {
/// noopr — Skips instruction.
NoOp = 0x0,
/// pgjmp — Selects the highest four bits of the address as page and unconditionally continues execution at address.
PageAndJump = 0xa,
... | src/oidavm.zig |
const std = @import("std");
const assert = std.debug.assert;
// ----------------------- Public API -------------------------
/// Sorts the array in-place
pub fn sort(
comptime T: type,
array: []T,
context: anytype,
comptime lessThan: fn(context: @TypeOf(context), lhs: T, rhs: T) bool,
) void {
so... | src/grailsort.zig |
const std = @import("std");
const Server = @import("server.zig").Server;
const Config = @import("config.zig").Config;
const mimes = @import("mimes.zig");
pub const io_mode = .evented;
const Handler = struct {
const MAX_FILE_SIZE = 10 * 1024 * 1024;
config: *const Config,
context: *Server.Context,
pu... | src/main.zig |
const std = @import("std");
const debug = std.debug;
const mem = std.mem;
const fmt = std.fmt;
const testing = std.testing;
const heap = std.heap;
const fs = std.fs;
const log = std.log;
const network = @import("network");
const parsing = @import("./parsing.zig");
const example_data = @import("./example_data.zig");
co... | src/connection.zig |
const sf = @import("../sfml_import.zig");
const math = @import("std").math;
pub const Color = packed struct {
/// Converts a color from a csfml object
/// For inner workings
pub fn _fromCSFML(col: sf.c.sfColor) Color {
return @bitCast(Color, col);
}
/// Converts this color to a csfml one
... | src/sfml/graphics/color.zig |
const std = @import("std");
const argsParser = @import("args");
const ihex = @import("ihex");
const spu = @import("spu-mk2");
const FileFormat = enum { ihex, binary };
const DisasmError = error{EndOfStream} || std.os.WriteError || std.io.FixedBufferStream([]const u8).ReadError;
fn processRecord(out: *const std.io.Wr... | tools/disassembler/main.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 int_least8_t = i8;
pub const int_least16_t = i16;
pub const int_least32_t = i32;
pub const int_least64_t = i64;
pub const uint_least8_t = u8;
pub const uint_least16_... | vendor/shaderc.zig |
const std = @import("std");
const print = std.debug.print;
const util = @import("util.zig");
const gpa = util.gpa;
const data = @embedFile("../data/day11.txt");
const Octo = struct {
energy: usize = 0,
flashed: bool = false,
};
pub fn main() !void {
// init octo field (grown by 1 to make edges easier to... | 2021/src/day11.zig |
const std = @import("std");
const Builder = std.build.Builder;
const builtin = std.builtin;
const assert = std.debug.assert;
fn here() []const u8 {
return std.fs.path.dirname(@src().file) orelse ".";
}
fn cpu_features(arch: std.Target.Cpu.Arch, ctarget: std.zig.CrossTarget) std.zig.CrossTarget {
var disabled_... | build.zig |