text stringlengths 32 314k | url stringlengths 93 243 |
|---|---|
const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target t... | https://raw.githubusercontent.com/huntears/adventOfCode2023/78f9faee45a7ee04363af510293848b3db3dc6c4/day01/build.zig |
const std = @import("std");
const Str = struct {
// null terminated string slice
data: [:0]const u8,
pub fn get(self: Str, idx: usize) ?u8 {
if (self.data.len > idx) {
return self.data[idx];
} else {
return null; // equivalent to None
}
}
pub fn split... | https://raw.githubusercontent.com/swarnimarun/learning-rust/ae768bfbf796b5633f9768fbec03547cbfff16ee/main.zig |
const std = @import("std");
const Step = std.Build.Step;
const StaticPluginStep = @This();
step: Step,
output_file: std.Build.GeneratedFile,
static_plugins: []const []const u8,
pub const base_id: Step.Id = .custom;
pub const Options = struct {
static_plugins: []const []const u8 = &.{},
};
pub fn create(owner: ... | https://raw.githubusercontent.com/Cold-Bytes-Games/wwise-zig/0b778cf0b8f26aa120415231052eba163a3e6785/build/StaticPluginStep.zig |
const std = @import("std");
const print = std.debug.print;
const Cli = @import("app.zig").Cli;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
{
var arena = std.heap.ArenaAllocator.init(gpa.allocator());
defer arena.deinit();
const writer = std.io.getStdOut().w... | https://raw.githubusercontent.com/last-arg/feedgaze/3c66d127344a18c02d25114dbf84dafd6cd75d91/src/main.zig |
const std = @import("std");
const objc = @import("objc");
const runtime_support = @import("Runtime-Support");
pub const NSDraggingSessionSelectors = struct {};
| https://raw.githubusercontent.com/ritalin/zig-7gui-macos/52ee58a27d60c90f48c9dc1025392bf977d01b8b/src/fw/AppKit/NSDraggingSession/selector.zig |
const std = @import("std");
const input = @embedFile("day11.input");
const size = 10;
const Offset = struct {
x: i64,
y: i64,
};
fn increase(flashed: *[size][size]bool, energy: *[size][size]u8, row_idx: i64, o_idx: i64) u64 {
if (row_idx < 0 or row_idx >= energy.len or o_idx < 0 or o_idx >= energy[0].le... | https://raw.githubusercontent.com/tschaei/advent-of-code-2021/b5edc1e35917e0d0266ced7d15bd2017a2ff1791/src/day11.zig |
const std = @import("std");
const vulkan = @import("vulkan");
const l0vk = @import("./vulkan.zig");
pub const VkSemaphore = vulkan.VkSemaphore;
pub const VkSemaphoreCreateFlags = packed struct(u32) {
_: u32 = 0,
};
pub const VkSemaphoreCreateInfo = extern struct {
pNext: ?*const anyopaque = null,
flags: ... | https://raw.githubusercontent.com/treemcgee42/r4-engine/3f503075e591ea2831a603dbf02a4f83a25f8eed/src/core/renderer/layer0/vulkan/sync.zig |
const std = @import("std");
const proto = @import("_proto.zig");
const Reader = proto.Reader;
// #4 - Server finalizes with this
const AuthenticationSASLFinal = @This();
data: []const u8,
pub fn parse(data: []const u8) !AuthenticationSASLFinal {
var reader = Reader.init(data);
if (try reader.int32() != 12) {
r... | https://raw.githubusercontent.com/karlseguin/pg.zig/4c43c24a42b886f2bbc9686a7323bed8cbf0ed4d/src/proto/AuthenticationSASLFinal.zig |
const std = @import("std");
const c = @import("c.zig");
const global = @import("global.zig");
const AssetIdHashMap = std.AutoHashMap(AssetId, Asset);
const AssetNameHashMap = std.StringHashMap(AssetId);
var asset_id: AssetId = 0;
var asset_id_table: AssetIdHashMap = undefined;
var asset_name_table: AssetNameHashMap ... | https://raw.githubusercontent.com/60fov/shoba/f34618136ef3aefac81da0ec153ed3fcfa6ba483/src/asset.zig |
// generated code
pub const GLenum = c_uint;
pub const GLboolean = c_uint;
pub const GLuint = c_uint;
pub const GLint = c_int;
pub const GLsizei = isize;
pub const GLfloat = f32;
pub const GLdouble = f64;
pub const GLbitfield = c_uint;
pub const GLubyte = u8;
pub const GLbyte = i8;
pub const GLushort = u16;
pub const G... | https://raw.githubusercontent.com/ikskuh/ZigPaint/d821f0a3fac66a29f6ee161b62e8be947d6a2823/gl/versions/GL_VERSION_1_2.zig |
const std = @import("std");
const stdx = @import("../stdx.zig");
const maybe = stdx.maybe;
const mem = std.mem;
const assert = std.debug.assert;
const constants = @import("../constants.zig");
const vsr = @import("../vsr.zig");
const Header = vsr.Header;
const MessagePool = @import("../message_pool.zig").MessagePool;
... | https://raw.githubusercontent.com/tigerbeetle/tigerbeetle/c9363f5ee82bbcee5dfd07bf0566d2b16511b579/src/vsr/client.zig |
//
// Loop bodies are blocks, which are also expressions. We've seen
// how they can be used to evaluate and return values. To further
// expand on this concept, it turns out we can also give names to
// blocks by applying a 'label':
//
// my_label: { ... }
//
// Once you give a block a label, you can use 'break' t... | https://raw.githubusercontent.com/trungducnguyenvn/Learn-Zig-with-ziglings/2a968a84982048624c91e6708daf4b2beda0fd5a/exercises/063_labels.zig |
// --- Day 3: Binary Diagnostic ---
// The submarine has been making some odd creaking noises, so you ask it to produce a diagnostic report just in case.
// The diagnostic report (your puzzle input) consists of a list of binary numbers which, when decoded properly, can tell you many useful things about the conditions ... | https://raw.githubusercontent.com/guerinoni/advent-of-code-2021/74ca90b9f37dc3acd7c33f0f1d74704923dedebe/src/day3.zig |
const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
const arr = try allocator.alloc(usize, 4);
allocator.free(arr);
allocator.free(arr);
std.debug.print("Это никогда не напечатается\n", .{});
}
| https://raw.githubusercontent.com/dee0xeed/learning-zig-rus/13b78318628fa85bc1cc8359e74e223ee506e6a9/src/examples/ex-ch06-01.zig |
const uart = @import("uart.zig");
const lcd = @import("vid.zig");
const std = @import("std");
extern const _binary_image_bmp_start: u8;
const WIDTH: usize = 640;
fn show_bmp(p: *u8, start_row: usize, start_col: usize) void {
var pp: [*]u8 = undefined;
var p_i: usize = @intFromPtr(p);
// 指针类型转换需要对齐,指针地址未... | https://raw.githubusercontent.com/XxChang/rt_embedded_os_zig/87119f411f8179c5593e136d1889643a134019a7/lcd_driver/main.zig |
// https://gitlab.com/x86-psABIs/x86-64-ABI/-/jobs/artifacts/master/raw/x86-64-ABI/abi.pdf?job=build
// Figure 3.4: Register Usage
pub const Context = extern struct {
rbx: usize = 0, // 0
r12: usize = 0, // 8
r13: usize = 0, // 16
r14: usize = 0, // 24
r15: usize = 0, // 32
rsp: usize = 0, // 40... | https://raw.githubusercontent.com/a1393323447/zcoroutine/bd850f7869c61f05c017b77d1692ba1b306ebf4a/src/arch/x86_64/linux/context.zig |
const std = @import("std");
const ascii = std.ascii;
const mem = std.mem;
/// Returns the counts of the words in `s`.
/// Caller owns the returned memory.
pub fn countWords(allocator: mem.Allocator, s: []const u8) !std.StringHashMap(u32) {
var word_count_map = std.StringHashMap(u32).init(allocator);
errdefer f... | https://raw.githubusercontent.com/binhtran432k/exercism-learning/7f52068bf630aa54226acc132464c9035669b4c4/zig/word-count/word_count.zig |
const std = @import("std");
fn pkgPath(comptime out: []const u8) std.build.FileSource {
const outpath = comptime std.fs.path.dirname(@src().file).? ++ std.fs.path.sep_str ++ out;
return .{ .path = outpath };
}
pub fn build(b: *std.build.Builder) void {
// Standard target options allows the person running ... | https://raw.githubusercontent.com/binarycraft007/gtk-examples-zig/2deafc01cbdede0abb8e13f8c1eda973a46aa21f/build.zig |
const std = @import("std");
const assert = std.debug.assert;
const wren = @import("./wren.zig");
const Vm = @import("./vm.zig").Vm;
const Configuration = @import("./vm.zig").Configuration;
const ErrorType = @import("./vm.zig").ErrorType;
const WrenError = @import("./error.zig").WrenError;
const EmptyUserData = struct... | https://raw.githubusercontent.com/koljakube/zapata/a9d2aea5144cdd0550a4ea5e051084902ff8ac85/src/zapata/call.zig |
const std = @import("std");
const seika = @cImport({
@cInclude("seika/seika.h");
});
const input = @cImport({
@cInclude("seika/input/input.h");
});
pub fn main() void {
const success = seika.ska_init_all("Zig Window", 800, 600, 800, 600);
if (!success) {
std.debug.print("Failed to initialize se... | https://raw.githubusercontent.com/Chukobyte/seika-examples/ae68bdbbc32dfb075a6dfec37ee1c65b5baa8798/examples/zig_example/src/main.zig |
const std = @import("std");
const all_targets = &[_]std.zig.CrossTarget{
.{ .os_tag = .macos, .cpu_arch = .aarch64 },
.{ .os_tag = .macos, .cpu_arch = .x86_64 },
.{ .os_tag = .linux, .cpu_arch = .aarch64 },
.{ .os_tag = .linux, .cpu_arch = .i386 },
.{ .os_tag = .linux, .cpu_arch = .x86_64 },
.{... | https://raw.githubusercontent.com/sepruko/lorem-zigsum/f5413712bc23b3c76547b6d7d27c6cea3da48875/build.zig |
// rabbit.zig
// Rabbit Cipher
pub const rabbit_instance = struct {
x: [8]u32,
c: [8]u32,
carry: u32,
x0: [4]u8,
x1: [4]u8,
x2: [4]u8,
x3: [4]u8,
x4: [4]u8,
x5: [4]u8,
x6: [4]u8,
x7: [4]u8,
};
// Left rotation of a 32-bit unsigned integer
fn rabbit_rotl(x: u32, rot: u32) u3... | https://raw.githubusercontent.com/BoundlessCarrot/thesis/4b9442d95ef8bda3d0c1e25cd16ac54dd465ffc4/Zig/rabbit_chatgpt.zig |
const std = @import("std");
const fmt = std.fmt;
/// A unique Discord ID which is chronologically sortable;
/// contains a timestamp and some other metadata
pub const Snowflake = []const u8;
const Allocator = std.mem.Allocator;
const allocPrint = fmt.allocPrint;
// Discord's "beginning of the universe", the first se... | https://raw.githubusercontent.com/imkunet/ziggycord/dfb3a679f7f503fd6c58d57b53ae8fdfc2e1b25b/src/ziggycord/snowflake.zig |
const std = @import("std");
const c = @cImport({
@cInclude("time.h"); // For `strftime`, `localtime_r`.
});
pub const std_options = .{
.log_level = .info,
};
pub const NetMessageKind = enum(u8) { MotionDetected, MotionStopped };
pub const NetMessage = packed struct {
kind: NetMessageKind,
duration_ms... | https://raw.githubusercontent.com/gaultier/camera-center/274a41f700c9f98aea284f231da055e8bf636881/server/src/main.zig |
const vm = @import("./machine.zig");
pub fn main() !void {
const program = [_]u8{
0x01, 0x01, 0x00, 0x00, // ensure that register 1 is empty
0x01, 0x00, 0x00, 0x48, // input 'H' in register 0
0x02, 0x01, 0x00, 0x00, // put 'H' on heap
0x05, 0x01, 0x00, 0x00, // increment register 1
... | https://raw.githubusercontent.com/cowboy8625/ender/1e0773d4f7c85495467731a50eba86257af552e2/libs/vm/src/main.zig |
const std = @import("std");
const stdx = @import("./stdx.zig");
const MAX_DIRS = 100_000;
const Dir = struct {
parent: usize,
size: u64,
};
var dirs = std.mem.zeroes([MAX_DIRS]Dir);
pub fn main() !void {
const stdin = std.io.getStdIn().reader();
const stdout = std.io.getStdOut().writer();
var buf:... | https://raw.githubusercontent.com/matklad/aoc2022/67800cfb0aa3dcb0103da06c0b6f2103f1494dc7/day7.zig |
const std = @import("std");
const builtin = @import("builtin");
const tests = @import("test/tests.zig");
const Build = std.Build;
const CompileStep = Build.CompileStep;
const Step = Build.Step;
const Child = std.process.Child;
const assert = std.debug.assert;
const join = std.fs.path.join;
const print = std.debug.pri... | https://raw.githubusercontent.com/konradmalik/zig-learn/eab1c31838bad962056d7376a89d8a314ce40b0e/build.zig |
// SPDX-License-Identifier: BSD 2-Clause "Simplified" License
//
// src/CPU.zig
//
// Created by: Aakash Sen Sharma, August 2023
// Copyright: (C) 2023, Aakash Sen Sharma & Contributors
const Self = @This();
const Bus = @import("Bus.zig");
const DRAM = @import("DRAM.zig");
registers: [32]u64, // 64-bit CPU with 32 r... | https://raw.githubusercontent.com/Shinyzenith/Zigemu-RISCV/934a91ebe4eb43cc9f6e86be6cd6827b3536e48f/src/CPU.zig |
const builtin = @import("builtin");
const std = @import("std");
const testing = std.testing;
// DateError enumerates possible Date-related errors.
const DateError = error{
InvalidArgument,
};
/// (Dominical)Letter classifies each year of the Gregorian calendar into
/// 10 classes: common and leap years starting w... | https://raw.githubusercontent.com/scento/zig-date/7890d8772a53a067cdc161802cc07852ffdc6310/src/date.zig |
// FNV1a - Fowler-Noll-Vo hash function
//
// FNV1a is a fast, non-cryptographic hash function with fairly good distribution properties.
//
// https://tools.ietf.org/html/draft-eastlake-fnv-14
const std = @import("std");
const testing = std.testing;
pub const Fnv1a_32 = Fnv1a(u32, 0x01000193, 0x811c9dc5);
pub const F... | https://raw.githubusercontent.com/ziglang/zig/d9bd34fd0533295044ffb4160da41f7873aff905/lib/std/hash/fnv.zig |
const std = @import("std");
const Func = struct {
name: []const u8,
args: []const Arg,
ret: []const u8,
js: []const u8,
};
const Arg = struct {
name: []const u8,
type: []const u8,
};
// TODO - i don't know what to put for GLboolean... i can't find an explicit
// mention anywhere on what size ... | https://raw.githubusercontent.com/leroycep/snake-game/9c578be67880f3f02ef25f5a96eb01ac27136a17/tools/webgl_generate.zig |
const std = @import("std");
const hyperia = @import("hyperia.zig");
const SpinLock = hyperia.sync.SpinLock;
const math = std.math;
const time = std.time;
const testing = std.testing;
pub const Options = struct {
// max_concurrent_attempts: usize, // TODO(kenta): use a cancellable semaphore to limit max number of... | https://raw.githubusercontent.com/lithdew/hyperia/c1d166f81b6f011d9a23ef818b620e68eee3f49a/circuit_breaker.zig |
const std = @import("std");
const utils = @import("utils");
pub fn main() !void {
try utils.main(&execute);
}
var known_springs: std.ArrayList([]const u8) = undefined;
var known_groups: std.ArrayList([]const i32) = undefined;
var known_matches: std.ArrayList(u64) = undefined;
fn execute(text: []const u8, allocat... | https://raw.githubusercontent.com/GigaGrunch/zig-advent-of-code/8f80de82aa525ea526fd87849d10e83dfe16d5dc/2023/day12/day12.zig |
const fmath = @import("index.zig");
pub fn nan(comptime T: type) -> T {
switch (T) {
f32 => @bitCast(f32, fmath.nan_u32),
f64 => @bitCast(f64, fmath.nan_u64),
else => @compileError("nan not implemented for " ++ @typeName(T)),
}
}
| https://raw.githubusercontent.com/tiehuis/zig-fmath/d563c833c7b6f49097de9f3dd1d14b82fead6a38/src/nan.zig |
const std = @import("std");
const Self = @This();
/// The $4010 register that sets the sample rate and loop.
const SampleRegister = packed struct {
send_irq: bool = false,
loop: bool = false,
_unused: u2 = 0,
rate: u4 = 0,
};
sample: SampleRegister = .{},
sample_rate: u32 = 0, // register $4010
sampl... | https://raw.githubusercontent.com/srijan-paul/nez/a07ab1121f256b4ce74a85bb94c87da9624a0c5e/src/apu.zig |
const std = @import("std");
const io = @import("../../bus/io.zig");
const Scheduler = @import("../../scheduler.zig").Scheduler;
const ToneSweep = @import("../ToneSweep.zig");
const Tone = @import("../Tone.zig");
const Self = @This();
pub const interval: u64 = (1 << 24) / (1 << 22);
pos: u3,
sched: *Scheduler,
timer:... | https://raw.githubusercontent.com/paoda/zba/b4830326ffa53f4361494eff8d3d07c0869eb67d/src/core/apu/signal/Square.zig |
const std = @import("std");
const zul = @import("zul");
const zuckdb = @import("zuckdb");
const logdk = @import("logdk.zig");
const json = std.json;
const Allocator = std.mem.Allocator;
const ParseOptions = json.ParseOptions;
pub const Event = struct {
map: std.StringHashMapUnmanaged(Value),
pub const List = struc... | https://raw.githubusercontent.com/karlseguin/logdk/3ddd23295bac2cd5441e9fcbffea2e204cbf9e72/src/event.zig |
// بسم الله الرحمن الرحيم وبه نستعين
const std = @import("std");
const print = std.debug.print;
fn sumNums(iterator: anytype) !f32 {
var sum: f32 = 0;
// The ".next()" method of the iterator ***modifies (mutates)*** the internal state of the iterator to advance it to the next element, hence, it has to be "va... | https://raw.githubusercontent.com/OSuwaidi/zig_intro/8fce69b42f2bcf36e4cd9d9247f2dc8f6609793a/src/stack_sum.zig |
const std = @import("std");
const Hkdf = std.crypto.kdf.hkdf.HkdfSha256;
/// Stored by the authenticator and used to derive all other secrets
pub const MasterSecret = [Hkdf.prk_length]u8;
/// Create a new, random master secret
pub fn create_master_secret(rand: *const fn ([]u8) void) MasterSecret {
var ikm: [32]u8... | https://raw.githubusercontent.com/r4gus/fido2/08eaea16d68dba6642d3f4da880fb4d3a4043314/src/crypto/master_secret.zig |
const std = @import("std");
const uv = @import("uv.zig");
const Buf = uv.Buf;
const Cast = uv.Cast;
const c = uv.c;
const utils = uv.utils;
/// Base handle
pub const Handle = extern struct {
/// Type of a base handle
pub const Type = c.uv_handle_type;
const Self = @This();
pub const UV = c.uv_handle_... | https://raw.githubusercontent.com/paveloom-z/zig-libuv/511e491c0fa03d7d68e50686277ff980341e21f7/src/handle.zig |
const c = @import("common.zig").c;
const m = @import("raymath.zig");
const builtin = @import("builtin");
const std = @import("std");
const assert = std.debug.assert;
const print = std.debug.print;
const clamp = std.math.clamp;
const is_web_target = (builtin.target.cpu.arch == .wasm32);
pub const screenWidth = 800;... | https://raw.githubusercontent.com/charles-l/toms-rock/43f7c3eafc7ea5d3ff9aa51976865f1690e29af5/game.zig |
const std = @import("std");
pub fn build(b: *std.Build) void {
// Grab target & optimization options
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Define main EXE entry point and install artifacts
const exe = b.addExecutable(.{
.name = "zkr... | https://raw.githubusercontent.com/Tythos/zkr/5920279953eb183000ce68e1e14f43a95f510a04/build.zig |
const std = @import("std");
const builtin = @import("builtin");
// const Pool: fn (comptime type) type = if (builtin.single_threaded) {
// @import("../fakepool.zig").Pool;
// } else {
// @compileError("multi-threaded not supported yet");
// };
pub fn HashMap(comptime K: type, comptime V: type, comptime Contex... | https://raw.githubusercontent.com/DanikVitek/monkey-lang/ae9ab1453190c79135b1352cd6a79afb0892a7a1/src/im/hash/map.zig |
const std = @import("std");
const dupe = @import("std");
const builtin = @import("builtin");
fn cool() void {
std.debug.print("{}", .{"cool"});
dupe.debug.print("{}", .{builtin.os});
}
| https://raw.githubusercontent.com/AnnikaCodes/ziglint/d77eb9ecdd02a65b8994bdeceb264b29a7ea1428/testcases/dupe_import/duplicated.zig |
//! Image data
//!
//!
//! This describes a single 2D image. See the documentation for each related function what the
//! expected pixel format is.
//!
//! see also: cursor_custom, window_icon
//!
//! It may be .owned (e.g. in the case of an image initialized by you for passing into glfw) or not
//! .owned (e.g. in the... | https://raw.githubusercontent.com/perky/ZigGraphics/f89b92f1a893c4df62d9287f376f53c8ea3cc9d1/lib/mach-glfw/src/Image.zig |
const std = @import("std");
const ast = @import("ast.zig");
const Node = ast.Node;
const Reporter = @import("Reporter.zig");
const Diagnostic = Reporter.Diagnostic;
const Extensions = @import("Extensions.zig");
const Self = @This();
const overloads = @import("overloads.zig");
const Overload = overloads.Overload;
pub c... | https://raw.githubusercontent.com/sno2/gpulse/cfbce883fbc88eeaf10d20979669b74ccd7a3d3b/src/Analyzer.zig |
const std = @import("std");
const expect = std.testing.expect;
//////////////////////////////////////////////////////////////////////////////////////// ALLOCATORS
test "allocation" {
const allocator = std.heap.page_allocator;
const memory = try allocator.alloc(u8, 100);
defer allocator.free(memory);
... | https://raw.githubusercontent.com/ewaldhorn/whatamess/ff94d4af6b435d30564d0e2eb5d25d6f571884fc/languages/zig/learning/ziglearn/chap2/chapter2.zig |
const Id = @import("../id.zig").Id;
const Host = @import("../host.zig").Host;
const Plugin = @import("../plugin.zig").Plugin;
const name_size = @import("../string_sizes.zig").name_size;
pub const note_ports_id: ?[*:0]const u8 = "clap.note-ports";
pub const NoteDialect = enum(u32) {
clap = 1 << 0,
midi = 1 << ... | https://raw.githubusercontent.com/TristanCrawford/zig-clap/f1a1616271ce7b5951429e4e6813cc6da1fd66a1/src/ext/note_ports.zig |
const std = @import("std");
pub const WidowPoint2D = struct {
x: i32,
y: i32,
};
// Shhhhhh.
pub const WidowAspectRatio = WidowPoint2D;
pub const WidowSize = struct {
// The width and hight are both i32 and not u32
// for best compatibility with the API functions
// that expects int data type for ... | https://raw.githubusercontent.com/eddineimad0/widow/10e82e84a71db1fbb4da7d88a8e15f736dc5eb73/src/common/geometry.zig |
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "opencl-gpgpu",
.root_source_file = b.path("src/main.zig"),
.target = target,
.... | https://raw.githubusercontent.com/holaguz/opencl-zig/a36e33c9d516251a41446a3d73077c5739a5825a/build.zig |
const DoubleStackAllocatorFlat = @import("../zigutils/src/DoubleStackAllocatorFlat.zig").DoubleStackAllocatorFlat;
const Draw = @import("draw.zig");
const Platform = @import("platform/index.zig");
const loadPcx = @import("load_pcx.zig").loadPcx;
const FONT_FILENAME = "../assets/font.pcx";
const FONT_CHAR_WIDTH = 8;
c... | https://raw.githubusercontent.com/bb010g/oxid/1314bc024d6394a629b0a85231ecb1187e708ff9/src/font.zig |
const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target t... | https://raw.githubusercontent.com/jmcph4/zig-cairo/11b9ba5ed80c87cdc1062aa4b93d94f2306d4030/build.zig |
// This file is part of zig-spoon, a TUI library for the zig language.
//
// Copyright © 2022 Leon Henrik Plickat
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 3 as published
// by the Free Software Foundation.
//
// This progr... | https://raw.githubusercontent.com/kristoff-it/zig-spoon/4a2862b0ac6a0551d83ba422755eeaa77114561b/import.zig |
const builtin = std.builtin;
const std = @import("std");
const io = std.io;
const meta = std.meta;
const native_endian = @import("builtin").target.cpu.arch.endian();
pub fn toMagicNumberNative(magic: []const u8) u32 {
var result: u32 = 0;
for (magic) |character, index| {
result |= (@as(u32, character)... | https://raw.githubusercontent.com/EspeuteClement/Untitled-Zig-Engine/372145abe8d3e7f1d3eef2c0dff813206d7d4eea/libs/zigimg/src/utils.zig |
//! Zig level of IRQ handler
const std = @import("std");
const Context = @import("../context.zig").Context;
const clock = @import("clock.zig");
const irq = @import("interrupt.zig");
const IRQ_BREAKPOINT: u64 = 3;
const IRQ_S_TIMER: u64 = (0b1 << 63) + 5;
export fn zig_handler(context: *Context, scause: usize, _: usi... | https://raw.githubusercontent.com/eastonman/zesty-core/b0fdb2f0a2f00737a97a1605289f3c6633558d6c/src/interrupt/handler.zig |
const std = @import("std");
const video = @import("video.zig");
var row: u8 = 0;
var col: u8 = 0;
pub fn print(comptime fmt: []const u8, args: anytype) void {
var print_buffer: [1024]u8 = undefined;
var buffer = std.io.fixedBufferStream(&print_buffer);
var writer = buffer.writer();
writer.print(fmt,... | https://raw.githubusercontent.com/ahrvojic/zrno/9fcded2199613239c1fc01f4c7caf0b1e1248a0b/kernel/src/dev/tty.zig |
const std = @import("std");
pub const ExampleMath = @import("examples/math.zig");
pub const BaseState = @import("UserState.zig").BaseState;
pub const MakeUserStateType = @import("UserState.zig").MakeUserStateType;
pub const Result = @import("Result.zig").Result;
pub const ParseError = @import("Result.zig").ParseError;
... | https://raw.githubusercontent.com/QuentinTessier/ZigParsec/c8a00cc2ec8d67a875e3ce11f8b98ff2d90cafa8/src/Parser.zig |
/// The parser for Sifu tries to make as few decisions as possible. Mostly, it
/// greedily lexes seperators like commas into their own ast nodes, separates
/// vars and vals based on the first character's case, and lazily lexes non-
/// strings. There are no errors, any utf-8 text is parsable.
///
const Parser = @This... | https://raw.githubusercontent.com/Rekihyt/Sifu/9625ad48a62dd6ea3cba0e6e7f0a14c246e779ce/src/sifu/parser.zig |
const std = @import("std");
const slotmap = @import("slotmap");
const Key = slotmap.Key;
const SlotMap = slotmap.SlotMap;
const print = std.debug.print;
pub fn main() void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
var persons = SlotMap([]const u8).new(&arena.allocator);
const... | https://raw.githubusercontent.com/mmstick/zig-slotmap/3e67e6a79c325388b9377c762ef9b47b4c11ef0f/examples/slotmap.zig |
const std = @import("std");
const win = @cImport({
@cInclude("conio.h");
});
pub fn main() !void {
var char : std.os.windows.UINT= @intCast(u8, win._getch() & 0xff);
if (char == 224 or char == 0) {
char = @intCast(u8, win._getch() & 0xff);
try std.io.getStdOut().writer().print("{x}{x}", .{... | https://raw.githubusercontent.com/DivergentClouds/batch-utils/9dce9d0af2e2f163c48d8a552cd4dfba0ed5079c/getch/src/main.zig |
//! Regular sound that can be played in the audio environment.
const sf = struct {
const sfml = @import("../sfml.zig");
pub usingnamespace sfml;
pub usingnamespace sfml.audio;
};
const Sound = @This();
// Constructor/destructor
/// Inits an empty sound
pub fn create() !Sound {
const sound = sf.c.sfS... | https://raw.githubusercontent.com/Guigui220D/zig-sfml-wrapper/b15365bf0622e7f42c13b711dbd637c6badc8492/src/sfml/audio/Sound.zig |
const std = @import("std");
const MMU = @import("memory.zig");
usingnamespace @import("instructions.zig");
const Self = @This();
const TileSide: u4 = 8;
const TileMapAddrs = [2]u16{
0x9800, // 0 = 9800 -> 9BFF
0x9C00, // 1 = 9C00 -> 9FFF
};
const Sprite = packed struct {
y_position: u8,
x_position... | https://raw.githubusercontent.com/mihnea-s/zig_gb_emu/9739db51e7dbbb2636b4f3f87b5ea54bd2510fce/src/graphics.zig |
const std = @import("std");
const Types = enum(u8) {
i32 = 0x7F,
};
const DecodeError = error{
InvalidMagicNumber,
UnsupportedVersionNumber,
UnknownSectionID,
DuplicateSection,
UnorderedSections,
InaccurateSectionSize,
MissingTypeSectionSeparator,
};
const SectionID = enum {
custo... | https://raw.githubusercontent.com/nafarlee/wasm-interpreter/0a1751883294055016dc981ac29fff67926960b9/src/main.zig |
const std = @import("std");
const compile = @import("compiler.zig").compile;
const Program = @import("compiler.zig").Program;
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
defer _ = gpa.deinit();
const args = try std.process.argsAlloc(alloca... | https://raw.githubusercontent.com/cowboy8625/ender/1e0773d4f7c85495467731a50eba86257af552e2/libs/assembler/src/main.zig |
const expect = @import("std").testing.expect;
test "defer" {
var x: i16 = 5;
{
defer x += 2;
try expect(x == 5);
}
try expect(x == 7);
}
test "multi defer" {
var x: f32 = 5;
{
defer x += 2;
defer x /= 2;
}
try expect(x == 4.5);
}
| https://raw.githubusercontent.com/UltiRequiem/ziglearn/31a38d294dc7e1bdf59ec348c3b9b94e44b224f5/defer.zig |
const std = @import("std");
pub fn build(b: *std.build.Builder) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "avrboot",
.root_source_file = .{
.path = "src/main.zig",
},
... | https://raw.githubusercontent.com/ZigEmbeddedGroup/avrboot/c41f8183c7f68552f7ceb1dc2e1670ac10e94b0c/build.zig |
const vk = @import("vulkan");
pub const Vertex = struct {
pub const binding_description = vk.VertexInputBindingDescription{
.binding = 0,
.stride = @sizeOf(Vertex),
.input_rate = .vertex,
};
pub const attribute_description = [_]vk.VertexInputAttributeDescription{
.{
... | https://raw.githubusercontent.com/MullerLucas/hellengine_zig/88e85801fb1002b683029c480c0c46af5ef3ba6d/src/math.zig |
const std = @import("std");
const print = std.debug.print;
const Distances = std.StringHashMap(std.StringHashMap(usize));
pub fn main() anyerror!void {
const global_allocator = std.heap.page_allocator;
var file = try std.fs.cwd().openFile(
"./inputs/day09.txt",
.{
.read = true,
... | https://raw.githubusercontent.com/basile-henry/aoc2015/76a8c255f0e7ea2f5b72f2f56f987a509030aacc/src/day09.zig |
const std = @import("std");
const testing = std.testing;
const fmt = std.fmt;
pub fn hexToBytes(comptime expected_hex: []const u8) []const u8 {
var expected_bytes: [expected_hex.len / 2]u8 = undefined;
for (&expected_bytes, 0..) |*r, i| {
r.* = fmt.parseInt(u8, expected_hex[2 * i .. 2 * i + 2], 16) cat... | https://raw.githubusercontent.com/zmovane/zjwt/74b615fbbcfc0f2cedb667c4ea6e4fbc1f6fe360/src/utils.zig |
const WorldRenderer = @This();
const Camera = @import("Camera.zig");
const tilemap = @import("tilemap.zig");
const Tilemap = tilemap.Tilemap;
const TileCoord = tilemap.TileCoord;
const TileLayer = tilemap.TileLayer;
const TileBank = tilemap.TileBank;
const TileRange = tilemap.TileRange;
const RenderServices = @import(... | https://raw.githubusercontent.com/jcmoyer/defense_of_ufeff/9a3dbc3b1166efd593410372dce6f99149839369/src/WorldRenderer.zig |
const std = @import("std");
const testing = std.testing;
const command = @import("./util/command.zig");
const Map = @import("./island.zig").Map;
pub fn main() anyerror!u8 {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const allocator = arena.allocator();
con... | https://raw.githubusercontent.com/gonzus/AdventOfCode/7e972b92a23db29461b2869713a3251998af5822/2023/p10/p10.zig |
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "algo-intro",
.root_source_file = .{ .src_path = .{ .owner = b, .sub_path = "src/main.zig" } },... | https://raw.githubusercontent.com/MatthewKandiah/algo-intro/8895aa621a43ab71436491269488f3f0c9fc8f87/build.zig |
//! Provides easy type-safe access and traversals of the nodes of a parse tree.
const syntax = @This();
const std = @import("std");
const parse = @import("parse.zig");
const Tree = parse.Tree;
const Tag = parse.Tag;
pub const File = ListExtractor(.file, null, ExternalDeclaration, null);
pub const AnyDeclaration = u... | https://raw.githubusercontent.com/nolanderc/glsl_analyzer/3514b232795858c6a1870832d2ff033eb54103ab/src/syntax.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const core = @import("./core.zig");
const Vec2i = @import("util").Vec2i;
pub const Frames = union(enum) {
WaitingForSize: void,
WaitingForData: struct {
buffer: []u8,
bytes_recevied: usize,
},
pub fn init() @This() {
... | https://raw.githubusercontent.com/leroycep/hexagonal-chess/ebc60fe485830eccebab5641b0d0523231f40bc5/core/protocol.zig |
const std = @import("std");
const nexus = @import("nexus");
// Required for pulling symbols.
pub const os = nexus.os;
comptime {
_ = @import("nexus").os;
}
const gfx = nexus.gfx.Graphics;
const gfx_mode = nexus.gfx.GraphicsModes;
const stdout = std.io.getStdOut().writer();
// Simple 32 bit vector
const Vec2 = ... | https://raw.githubusercontent.com/Rexicon226/neon-nexus/449bbf00446b864b4d983b85c16748ae528eabb4/programs/game.zig |
const std = @import("std");
const io = @import("io");
pub fn main(args: *std.process.ArgIterator, _: std.mem.Allocator) !u8 {
try io.stdOutPrint("{s}\n", .{process(args.next().?, args.next())});
return 0;
}
fn process(string: []const u8, suffix: ?[]const u8) []const u8 {
if (string.len == 0) {
re... | https://raw.githubusercontent.com/amusingimpala75/zigix/2f90b5ac1772aaab7da5c8701828b99a1c2cae9c/src/basename/main.zig |
const std = @import("std");
fn Unit(comptime T: type) type {
const Hack = struct {
var runtime: T = undefined;
};
return @TypeOf(.{Hack.runtime});
}
fn Actor(comptime T: type) type {
const F = std.builtin.TypeInfo.StructField;
comptime var fields: []const F = &[_]F{};
inline for (@typ... | https://raw.githubusercontent.com/tauoverpi/scratch/b39cda8b3cc49461e1cd270c09e740e850999de8/zig/actor.zig |
const std = @import("std");
const tools = @import("tools");
const Computer = struct {
const Data = i32;
boot_image: []const Data,
memory_bank: []Data,
const insn_halt = 99;
const insn_add = 1;
const insn_mul = 2;
const insn_input = 3;
const insn_output = 4;
const insn_jne = 5; // ... | https://raw.githubusercontent.com/xxxbxxx/advent-of-code/2ad3f7c928b559a2e0e5667693c73a544e89dc42/2019/day05.zig |
//! This tool generates SPIR-V features from the grammar files in the SPIRV-Headers
//! (https://github.com/KhronosGroup/SPIRV-Headers/) and SPIRV-Registry (https://github.com/KhronosGroup/SPIRV-Registry/)
//! repositories. Currently it only generates a basic feature set definition consisting of versions, extensions an... | https://raw.githubusercontent.com/2lambda123/ziglang-zig/d7563a7753393d7f0d1af445276a64b8a55cb857/tools/update_spirv_features.zig |
const std = @import("std");
const windows = std.os.windows;
const memory = std.mem;
const ArenaAllocator = std.heap.ArenaAllocator;
const assert = std.debug.assert;
const warn = std.debug.warn;
const testing = std.testing;
const win32 = @import("win32");
const time = std.time;
const debug = std.debug;
pub fn getAllDri... | https://raw.githubusercontent.com/GoNZooo/zig-disk-info/215061808ef0e034f3a055208b0b39617eb987ac/src/disk.zig |
const std = @import("std");
const testing = std.testing;
const Allocator = std.mem.Allocator;
pub const Map = struct {
allocator: Allocator,
orig: std.ArrayList(isize),
pub fn init(allocator: Allocator) Map {
var self = Map{
.allocator = allocator,
.orig = std.ArrayList(is... | https://raw.githubusercontent.com/gonzus/AdventOfCode/7e972b92a23db29461b2869713a3251998af5822/2022/p20/map.zig |
allocator: std.mem.Allocator,
version: Version,
transitionTimes: []i64,
transitionTypes: []u8,
localTimeTypes: []LocalTimeType,
designations: []u8,
leapSeconds: []LeapSecond,
transitionIsStd: []bool,
transitionIsUT: []bool,
string: []u8,
posixTZ: ?Posix,
const TZif = @This();
pub fn deinit(this: *@This()) void {
... | https://raw.githubusercontent.com/leroycep/chrono-zig/bedd9339af9b05c240956b137cb1a5b67a9b74b7/src/tz/TZif.zig |
// SPDX-License-Identifier: MIT
// Copyright (c) 2015-2021 Zig Contributors
// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
// The MIT license requires this copyright notice to be included in all copies
// and substantial portions of the software.
const std = @import("std.zig");
const cstr =... | https://raw.githubusercontent.com/dip-proto/zig/8f79f7e60937481fcf861c2941db02cbf449cdca/lib/std/child_process.zig |
const std = @import("std");
const Handle = windows.HANDLE;
const windows = std.os.windows;
pub const bindings = @import("bindings.zig");
pub const WinDivert = struct {
const Self = @This();
handle: Handle,
pub fn open(filter: []const u8, layer: bindings.Layer, priority: i16, flags: bindings.Flags) bindi... | https://raw.githubusercontent.com/SuperAuguste/windivert-zig/4f0eb63fa8190b4ea097bc940483fcd3d09c2a2e/src/windivert.zig |
const std = @import("std");
pub fn build(b: *std.build.Builder) void {
const test_step = b.step("test", "dummy test step to pass CI checks");
_ = test_step;
}
| https://raw.githubusercontent.com/nektro/zig-git/103f4e419c35b88f802bb8234ece1c0a9aa40c03/build.zig |
const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// Standard target options allows the person running `zig build` to choose
// what target t... | https://raw.githubusercontent.com/JustinBraben/zig-clipse/46c65b990772f16cbe7fc0cc614ddfb71b4aad99/serializer/build.zig |
const std = @import("std");
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);
const file = try std.fs.cwd().openFile(args[1], .{ .read = true }... | https://raw.githubusercontent.com/jeltz/advent/c2a5671a9db86e73aa12313badb5fe4dfd344847/2020/13/13a.zig |
//
// Remember how a function with 'suspend' is async and calling an
// async function without the 'async' keyword makes the CALLING
// function async?
//
// fn fooThatMightSuspend(maybe: bool) void {
// if (maybe) suspend {}
// }
//
// fn bar() void {
// fooThatMightSuspend(true); // Now ba... | https://raw.githubusercontent.com/BasixKOR/ziglings/b55e0127be63b041cda11fe93f6b0a25a08542ce/exercises/090_async7.zig |
const std = @import("std");
const Pkg = std.build.Pkg;
const Builder = std.build.Builder;
const Mode = std.builtin.Mode;
const CrossTarget = std.zig.CrossTarget;
const pkg_bitset = Pkg {
.name = "bitset",
.source = .{.path = "bitset/bitset.zig"},
};
const pkg_libev = Pkg {
.name = "ev",
.source = .{.p... | https://raw.githubusercontent.com/zephyrchien/libev-zig/3c8e410ad010939bc8866b45c60afeecc7e3ce60/build.zig |
//! Generic Stack Structure
const std = @import("std");
const vm = @import("vm.zig");
pub const Error = error{
Overflow,
Underflow,
} || std.mem.Allocator.Error;
const enable_checks: bool = false;
/// Stack structure used for the runtime, like the evaluation stack and the
/// call stack. Static stack size.
... | https://raw.githubusercontent.com/N-Adkins/lang/cc8d9b92977262a37e1d90cdd6ad24079b369eaf/src/runtime/stack.zig |
const std = @import("std");
const utils_mod = @import("../utils.zig");
const print = utils_mod.print;
const value_mod = @import("../value.zig");
const Value = value_mod.Value;
const ValueType = value_mod.ValueType;
const vm_mod = @import("../vm.zig");
const VM = vm_mod.VM;
const index = @import("index.zig").index;
... | https://raw.githubusercontent.com/dstrachan/openk/0a739d96593fe3e1a7ebe54e5b82e2a69f64302a/src/verbs/where.zig |
const std = @import("std");
const string = @import("./vm.zig").string;
const size16 = @import("./vm.zig").size16;
const size32 = @import("./vm.zig").size32;
const naming = @import("./vm.zig").naming;
const strings = @import("./vm.zig").strings;
const vm_stash = @import("./vm.zig").vm_stash;
const byte = @import("./ty... | https://raw.githubusercontent.com/chaoyangnz/zava/a5578f0a65f93d6e11724771220524afc3045817/src/native.zig |
const abi = @import("../abi/abi.zig");
const params = @import("../abi/abi_parameter.zig");
const std = @import("std");
const testing = std.testing;
// Types
const Abitype = abi.Abitype;
const AbiEventParameter = params.AbiEventParameter;
const AbiParameter = params.AbiParameter;
const ParamType = @import("../abi/param... | https://raw.githubusercontent.com/Raiden1411/zabi/beee3c26d0eaa6b426fdc62e66cf24626e3be6fa/src/meta/abi.zig |
//! This module contains the representation of a chessboard and related features.
const squares = @import("squares.zig");
pub const Piece = enum {
pawn,
knight,
bishop,
rook,
queen,
king,
};
const Positions = struct {
pawns: u64 = 0,
knights: u64 = 0,
bishops: u64 = 0,
rooks: ... | https://raw.githubusercontent.com/MattEstHaut/Victoire/ea23fc9af3b996ca528341371a4ea4951db73815/src/chess.zig |
const std = @import("std");
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
// const allocator = gpa.allocator();
// _ = allocator;
defer if (gpa.deinit() != .ok) {
std.log.err("oh no, we've got a leak", .{});
} else {
std.log.debug("memory managed correctly... | https://raw.githubusercontent.com/hajsf/zig-tutorial/19ef824f3430dec8987441f527e2b72f56abc3ed/zig-exe/src/env.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const Writer = std.io.Writer;
const dprint = std.debug.print;
pub fn main() !void {
const stdout_file = std.io.getStdOut().writer();
var bw = std.io.bufferedWriter(stdout_file);
const stdout = bw.writer();
var gpa = std.heap.GeneralPurpo... | https://raw.githubusercontent.com/rendellc/aoc/e9a0ac442477e2a1a04deb0384a941df166abfdb/2023-day11-zig/src/main.zig |
const std = @import("std");
const Digit = enum(usize) {
one = 1,
two,
three,
four,
five,
six,
seven,
eight,
nine,
fn fromSlice(string: []const u8) ?Digit {
return for (std.meta.tags(Digit)) |tag| {
const name = @tagName(tag);
if (name.len > strin... | https://raw.githubusercontent.com/arrufat/advent-of-code/5485808de0bdb1fb2c72df51604de1c2ee511192/2023/src/day01.zig |
const std = @import("std");
pub fn Queue(comptime T: type) type {
return struct {
const Self = @This();
listData: []T = undefined,
length: usize = 0,
capacity: usize = 0,
front: usize = 0,
mem_arena: ?std.heap.ArenaAllocator = undefined,
mem_allocator: st... | https://raw.githubusercontent.com/anthony-aleman/Zig-Data-Structures/9e717e711014a4edf92c420b00ae62b947f32193/queue/src/main.zig |
const std = @import("std");
const objc = @import("objc");
const runtime_support = @import("Runtime-Support");
pub const NSTableViewSelectors = struct {
pub fn dataSource() objc.Sel {
if (_sel_dataSource == null) {
_sel_dataSource = objc.Sel.registerName("dataSource");
}
return _... | https://raw.githubusercontent.com/ritalin/zig-7gui-macos/52ee58a27d60c90f48c9dc1025392bf977d01b8b/src/fw/AppKit/NSTableView/selector.zig |
const std = @import("std");
const find = @import("./find.zig");
const du = @import("./du.zig");
const cat = @import("./cat.zig");
const echo = @import("./echo.zig");
const basename = @import("./basename.zig");
const dirname = @import("./dirname.zig");
const time = @import("./time.zig");
const rm = @import("./rm.zig");
... | https://raw.githubusercontent.com/aburdulescu/rene/b5db0d0ad2cb8b8b288ce4905dc9c733ce63e0ef/src/main.zig |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.