text stringlengths 32 314k | url stringlengths 93 243 |
|---|---|
const std = @import("std");
const builtin = @import("builtin");
pub usingnamespace @cImport({
@cInclude("mpack.h");
@cInclude("raylib.h");
@cInclude("blip_buf.h");
if (builtin.os.tag == .emscripten) {
@cInclude("emscripten/html5.h");
}
});
pub const Event = enum(u32) {
core_loaded = 1,... | https://raw.githubusercontent.com/iury/retrobob/396a46988d76e8c1e61ffc3f8d1972519d377b64/packages/engine/src/c.zig |
//! # Linux IO Interface
//!
//! The linux IO interface for kvcache uses IO Uring,
//! which is a relatively standardized method of
//! Async IO (designed to replace linux AIO).
//!
//! ## Features
//!
//! This implementation takes advantage of a few
//! extensions to IO Uring, which is why the minimum
//! kernel veris... | https://raw.githubusercontent.com/cleanbaja/kvcache/4ee7d3e33f1367ad5a128b1a583a81f2095cf1e7/src/io/linux.zig |
const std = @import("std");
const math = std.math;
const print = std.debug.print;
const panic = std.debug.panic;
const rl = @import("raylib");
const grid_width: i32 = 10;
const grid_height: i32 = 20;
const grid_cell_size: i32 = 32;
const margin: i32 = 20;
const piece_preview_width = grid_cell_size * 5;
const screen_wi... | https://raw.githubusercontent.com/jlafayette/zig-tetris/9858d8d098d854d2d61190c3dd9a2b3842076d60/src/main.zig |
const std = @import("std");
const input_file = @embedFile("input.txt");
//I really should calculate these based on the amount of fall off room required but just hard coding them based on the input data
const GRID_WIDTH = 500;
const GRID_HEIGHT = 160;
const GRID_WIDTH_OFFSET = 300; //All coords are up around ~500 so w... | https://raw.githubusercontent.com/RevDownie/AdventOfCodeSolutions/6bc8950f93d7b60088587809ba752a5640b74a01/2022/Day14/day14.zig |
pub const title = "English (Bork)";
pub const code = "en_BORK";
pub const variant = "BORK";
pub const language = "en";
pub const endonym = "English (Bork)";
pub const dir = "ltr";
pub const script = "Latn";
| https://raw.githubusercontent.com/cksac/faker-zig/5a51eb6e6aa4ce50a25a354affca36e8fa059675/src/locales/en_BORK/metadata.zig |
const std = @import("std");
const sdl = @cImport(@cInclude("SDL2/SDL.h"));
const mysdl = @import("./sdl.zig");
const CPU = @import("./cpu.zig").CPU;
const CPUCallback = @import("./cpu.zig").CPUCallback;
// ref: https://gist.github.com/wkjagt/9043907
const game_code = [_]u8{
0x20, 0x06, 0x06, 0x20, 0x38, 0x06, 0x20... | https://raw.githubusercontent.com/LeafChage/fc.zig/df876f264bec0fcd49ef0c446a8747c81c9c407c/src/main.zig |
// There is a generic CRC implementation "Crc()" which can be paramterized via
// the Algorithm struct for a plethora of uses.
//
// The primary interface for all of the standard CRC algorithms is the
// generated file "crc.zig", which uses the implementation code here to define
// many standard CRCs.
const std = @imp... | https://raw.githubusercontent.com/ziglang/zig-bootstrap/ec2dca85a340f134d2fcfdc9007e91f9abed6996/zig/lib/std/hash/crc/impl.zig |
// There is a generic CRC implementation "Crc()" which can be paramterized via
// the Algorithm struct for a plethora of uses.
//
// The primary interface for all of the standard CRC algorithms is the
// generated file "crc.zig", which uses the implementation code here to define
// many standard CRCs.
const std = @imp... | https://raw.githubusercontent.com/cyberegoorg/cetech1-zig/7438a7b157a4047261d161c06248b54fe9d822eb/lib/std/hash/crc/impl.zig |
// There is a generic CRC implementation "Crc()" which can be paramterized via
// the Algorithm struct for a plethora of uses.
//
// The primary interface for all of the standard CRC algorithms is the
// generated file "crc.zig", which uses the implementation code here to define
// many standard CRCs.
const std = @imp... | https://raw.githubusercontent.com/kassane/zig-mos-bootstrap/19aac4779b9e93b0e833402c26c93cfc13bb94e2/zig/lib/std/hash/crc/impl.zig |
const expect = @import("std").testing.expect;
test "if statement" {
const a = true;
var x: u16 = 0;
if (a) {
x += 1;
} else {
x += 2;
}
try expect(x == 1);
}
| https://raw.githubusercontent.com/Sobeston/zig.guide/a49e8a20cd5b3699fc1510f3c9c2c5a698869358/website/versioned_docs/version-0.11/01-language-basics/03.expect.zig |
const expect = @import("std").testing.expect;
test "if statement" {
const a = true;
var x: u16 = 0;
if (a) {
x += 1;
} else {
x += 2;
}
try expect(x == 1);
}
| https://raw.githubusercontent.com/wolffshots/ziglearn/5743d7a6748bf38207e5395ea0cc7b5dbdeaf230/if.zig |
const expect = @import("std").testing.expect;
test "if statement" {
const a = true;
var x: u16 = 0;
if (a) {
x += 1;
} else {
x += 2;
}
try expect(x == 1);
}
| https://raw.githubusercontent.com/Nathan3-14/zig/0a8078ca3940dacec6fb9630ce38cd838fca54a8/files/if_statments.zig |
const expect = @import("std").testing.expect;
test "if statement" {
const a = true;
var x: u16 = 0;
if (a) {
x += 1;
} else {
x += 2;
}
try expect(x == 1);
}
| https://raw.githubusercontent.com/axsaucedo/zigplayground/21bf2ed32945ed42d01c0b99d5678b99ef9eaf84/test_if_simple.zig |
const std = @import("std.zig");
const assert = std.debug.assert;
const testing = std.testing;
const mem = std.mem;
const math = std.math;
pub fn binarySearch(
comptime T: type,
key: T,
items: []const T,
context: anytype,
comptime compareFn: fn (context: @TypeOf(context), lhs: T, rhs: T) math.Order,... | https://raw.githubusercontent.com/kraxli/dev_tools_mswindows/1d1a8f61299e4b7ba356fae3a37af0ddc8daf356/zig-windows-x86_64-0.9.1/lib/std/sort.zig |
const std = @import("std.zig");
const assert = std.debug.assert;
const testing = std.testing;
const mem = std.mem;
const math = std.math;
pub fn binarySearch(
comptime T: type,
key: T,
items: []const T,
context: anytype,
comptime compareFn: fn (context: @TypeOf(context), lhs: T, rhs: T) math.Order,... | https://raw.githubusercontent.com/jamesmintram/jimzos/8eb52e7efffb1a97eca4899ff72549f96ed3460b/tools/ext2fs/data/test3/sort.zig |
// BITCOUNT key [start end]
pub const BITCOUNT = struct {
//! ```
//! const cmd = BITCOUNT.init("test", BITCOUNT.Bounds{ .Slice = .{ .start = -2, .end = -1 } });
//! ```
key: []const u8,
bounds: Bounds = .FullString,
const Self = @This();
pub fn init(key: []const u8, bounds: Bounds) BITC... | https://raw.githubusercontent.com/MarcoPolo/zig-libp2p/478d9b60c99069e5bc557b8f60c36ae72dedc83a/interop/okredis/src/commands/strings/bitcount.zig |
//! Futex is a mechanism used to block (`wait`) and unblock (`wake`) threads using a 32bit memory address as hints.
//! Blocking a thread is acknowledged only if the 32bit memory address is equal to a given value.
//! This check helps avoid block/unblock deadlocks which occur if a `wake()` happens before a `wait()`.
//... | https://raw.githubusercontent.com/mundusnine/FoundryTools_linux_x64/98e738bf92a416b255c9d11b78e8033071b52672/lib/std/Thread/Futex.zig |
//! Futex is a mechanism used to block (`wait`) and unblock (`wake`) threads using a 32bit memory address as hints.
//! Blocking a thread is acknowledged only if the 32bit memory address is equal to a given value.
//! This check helps avoid block/unblock deadlocks which occur if a `wake()` happens before a `wait()`.
//... | https://raw.githubusercontent.com/matpx/daydream/018ad0c7caaf796d8a04b882fcbed39ccb7c9cd8/toolchain/zig/lib/std/Thread/Futex.zig |
//
// Now that we've seen how methods work, let's see if we can help
// our elephants out a bit more with some Elephant methods.
//
const std = @import("std");
const Elephant = struct {
letter: u8,
tail: ?*Elephant = null,
visited: bool = false,
// New Elephant methods!
pub fn getTail(self: *Eleph... | https://raw.githubusercontent.com/tomial/ziglings/c49f10c08770775b596309d3e4f54d774c327b95/exercises/048_methods2.zig |
//
// Now that we've seen how methods work, let's see if we can help
// our elephants out a bit more with some Elephant methods.
//
const std = @import("std");
const Elephant = struct {
letter: u8,
tail: ?*Elephant = null,
visited: bool = false,
// New Elephant methods!
pub fn getTail(self: *Eleph... | https://raw.githubusercontent.com/Hiten-Tandon/my-ziglings-attempt/798ec87da4f2a3f6ff8f04703b706d4f0f8def17/exercises/048_methods2.zig |
//
// Being able to group values together lets us turn this:
//
// point1_x = 3;
// point1_y = 16;
// point1_z = 27;
// point2_x = 7;
// point2_y = 13;
// point2_z = 34;
//
// into this:
//
// point1 = Point{ .x=3, .y=16, .z=27 };
// point2 = Point{ .x=7, .y=13, .z=34 };
//
// The Point ... | https://raw.githubusercontent.com/mhanberg/ziglings/b57ff44f37d088f253e44f38ae16ab0c00e42aee/exercises/037_structs.zig |
//
// Being able to group values together lets us turn this:
//
// point1_x = 3;
// point1_y = 16;
// point1_z = 27;
// point2_x = 7;
// point2_y = 13;
// point2_z = 34;
//
// into this:
//
// point1 = Point{ .x=3, .y=16, .z=27 };
// point2 = Point{ .x=7, .y=13, .z=34 };
//
// The Point ... | https://raw.githubusercontent.com/Steven0351/ziglings/345445f187efcfca0898d1622931d8ab45fa8935/exercises/037_structs.zig |
//
// Being able to group values together lets us turn this:
//
// point1_x = 3;
// point1_y = 16;
// point1_z = 27;
// point2_x = 7;
// point2_y = 13;
// point2_z = 34;
//
// into this:
//
// point1 = Point{ .x=3, .y=16, .z=27 };
// point2 = Point{ .x=7, .y=13, .z=34 };
//
// The Point ... | https://raw.githubusercontent.com/matthewsimo/ziglings/76b194775858a18b011a0f38206ae16024d2a221/exercises/037_structs.zig |
//
// Being able to group values together lets us turn this:
//
// point1_x = 3;
// point1_y = 16;
// point1_z = 27;
// point2_x = 7;
// point2_y = 13;
// point2_z = 34;
//
// into this:
//
// point1 = Point{ .x=3, .y=16, .z=27 };
// point2 = Point{ .x=7, .y=13, .z=34 };
//
// The Point ... | https://raw.githubusercontent.com/saggit/ziglings/d2ccc075df5fb1f0efe5e615c5b35d129267bfde/exercises/037_structs.zig |
const common = @import("../common.zig");
const jsFree = common.jsFree;
const jsCreateClass = common.jsCreateClass;
const Classes = common.Classes;
const toJSBool = common.toJSBool;
const Undefined = common.Undefined;
const True = common.True;
const object = @import("../object.zig");
const Object = object.Object;
const ... | https://raw.githubusercontent.com/CraigglesO/workers-zig-auth/44c7c7c83e4360457037450dc74a57d5c9e06819/auth/workers-zig/lib/bindings/streams/readable.zig |
const std = @import("std");
pub const Options = struct {
enable_cross_platform_determinism: bool = true,
};
pub const Package = struct {
target: std.Build.ResolvedTarget,
options: Options,
zmath: *std.Build.Module,
zmath_options: *std.Build.Module,
pub fn link(pkg: Package, exe: *std.Build.St... | https://raw.githubusercontent.com/sarr-io/realityarch/996e9cf6b72a2c9ae969ccb29f145a9563d9e503/libs/zmath/build.zig |
const std = @import("std");
pub const Options = struct {
enable_cross_platform_determinism: bool = true,
};
pub const Package = struct {
target: std.Build.ResolvedTarget,
options: Options,
zmath: *std.Build.Module,
zmath_options: *std.Build.Module,
pub fn link(pkg: Package, exe: *std.Build.St... | https://raw.githubusercontent.com/freakmangd/zentig_ecs/709736c26d00d5ad919b454609a2d566e8b92e36/deps/zmath/build.zig |
const std = @import("std");
const utils = @import("utils.zig");
const res = @import("res.zig");
const SourceBytes = @import("literals.zig").SourceBytes;
// https://learn.microsoft.com/en-us/windows/win32/menurc/about-resource-files
pub const Resource = enum {
accelerators,
bitmap,
cursor,
dialog,
... | https://raw.githubusercontent.com/beingofexistence13/multiversal-lang/dd769e3fc6182c23ef43ed4479614f43f29738c9/zig/src/resinator/rc.zig |
const std = @import("std");
const utils = @import("utils.zig");
const res = @import("res.zig");
const SourceBytes = @import("literals.zig").SourceBytes;
// https://learn.microsoft.com/en-us/windows/win32/menurc/about-resource-files
pub const Resource = enum {
accelerators,
bitmap,
cursor,
dialog,
... | https://raw.githubusercontent.com/2lambda123/ziglang-zig-bootstrap/f56dc0fd298f41c8cc2a4f76a9648111e6c75503/zig/src/resinator/rc.zig |
// Ported from musl, which is licensed under the MIT license:
// https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
//
// https://git.musl-libc.org/cgit/musl/tree/src/math/sinhf.c
// https://git.musl-libc.org/cgit/musl/tree/src/math/sinh.c
const std = @import("../std.zig");
const math = std.math;
const expect = std.te... | https://raw.githubusercontent.com/beingofexistence13/multiversal-lang/dd769e3fc6182c23ef43ed4479614f43f29738c9/zig/lib/std/math/sinh.zig |
// Ported from musl, which is licensed under the MIT license:
// https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
//
// https://git.musl-libc.org/cgit/musl/tree/src/math/sinhf.c
// https://git.musl-libc.org/cgit/musl/tree/src/math/sinh.c
const std = @import("../std.zig");
const math = std.math;
const expect = std.te... | https://raw.githubusercontent.com/mundusnine/FoundryTools_windows_x64/b64cdb7e56db28eb710a05a089aed0daff8bc8be/lib/std/math/sinh.zig |
// Ported from musl, which is licensed under the MIT license:
// https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
//
// https://git.musl-libc.org/cgit/musl/tree/src/math/sinhf.c
// https://git.musl-libc.org/cgit/musl/tree/src/math/sinh.c
const std = @import("../std.zig");
const math = std.math;
const expect = std.te... | https://raw.githubusercontent.com/mundusnine/FoundryTools_linux_x64/98e738bf92a416b255c9d11b78e8033071b52672/lib/std/math/sinh.zig |
// Ported from musl, which is licensed under the MIT license:
// https://git.musl-libc.org/cgit/musl/tree/COPYRIGHT
//
// https://git.musl-libc.org/cgit/musl/tree/src/math/sinhf.c
// https://git.musl-libc.org/cgit/musl/tree/src/math/sinh.c
const std = @import("../std.zig");
const math = std.math;
const expect = std.te... | https://raw.githubusercontent.com/matpx/daydream/018ad0c7caaf796d8a04b882fcbed39ccb7c9cd8/toolchain/zig/lib/std/math/sinh.zig |
const std = @import("std");
pub fn twoFer(buffer: []u8, name: ?[]const u8) anyerror![]u8 {
return std.fmt.bufPrint(buffer, "One for {s}, one for me.", .{name orelse "you"});
}
| https://raw.githubusercontent.com/emanuel-bs/exercism-12in23/d5521f9712907b22aaa4b42623c3e7c34edd7a38/zig/two-fer/two_fer.zig |
const std = @import("std");
pub fn twoFer(buffer: []u8, name: ?[]const u8) anyerror![]u8 {
return std.fmt.bufPrint(buffer, "One for {s}, one for me.", .{name orelse "you"});
}
| https://raw.githubusercontent.com/alexwheezy/Exercism/d1bef009856cb121de80fec80322f60cdbc8034a/zig/two-fer/two_fer.zig |
const std = @import("std");
pub fn twoFer(buffer: []u8, name: ?[]const u8) anyerror![]u8 {
return std.fmt.bufPrint(buffer, "One for {s}, one for me.", .{name orelse "you"});
}
| https://raw.githubusercontent.com/binhtran432k/exercism-learning/7f52068bf630aa54226acc132464c9035669b4c4/zig/two-fer/two_fer.zig |
const std = @import("std");
pub fn twoFer(buffer: []u8, name: ?[]const u8) anyerror![]u8 {
return std.fmt.bufPrint(buffer, "One for {s}, one for me.", .{name orelse "you"});
}
| https://raw.githubusercontent.com/stackcats/exercism/2d8f8e5494f04a4ce53eefd9fcb36bee5128ba43/zig/two_fer.zig |
pub const AllocateType = @import("tables/boot_services.zig").AllocateType;
pub const BootServices = @import("tables/boot_services.zig").BootServices;
pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable;
pub const global_variable align(8) = @import("tables/runtime_services.zig").g... | https://raw.githubusercontent.com/natanalt/zig-x86_16/1b38fc3ef5e539047c76604ffe71b81e246f1a1e/lib/std/os/uefi/tables.zig |
pub const AllocateType = @import("tables/boot_services.zig").AllocateType;
pub const BootServices = @import("tables/boot_services.zig").BootServices;
pub const ConfigurationTable = @import("tables/configuration_table.zig").ConfigurationTable;
pub const global_variable align(8) = @import("tables/runtime_services.zig").g... | https://raw.githubusercontent.com/kraxli/dev_tools_mswindows/1d1a8f61299e4b7ba356fae3a37af0ddc8daf356/zig-windows-x86_64-0.9.1/lib/std/os/uefi/tables.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");
const builtin = ... | https://raw.githubusercontent.com/creationix/zig-toolset/9ad208cd93d1f05eb772deff4af24f58eb42386f/zig-linux-x86_64-0.8.0-dev.1860+1fada3746/lib/std/c.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... | https://raw.githubusercontent.com/JoeyMckenzie/advent-of-code/05fffbcbaa2a5112c6fa740b55466ecacb70f956/2022/zig/day-1/build.zig |
//
// Now let's create a function that takes a parameter. Here's an
// example that takes two parameters. As you can see, parameters
// are declared just like any other types ("name": "type"):
//
// fn myFunction(number: u8, is_lucky: bool) {
// ...
// }
//
const std = @import("std");
pub fn main() voi... | https://raw.githubusercontent.com/thomastanck/ziglings/2de5b69c3fb491cd4327a31d60258bef41e33bf7/exercises/019_functions2.zig |
const std = @import("std");
const isNan = std.math.isNan;
const isInf = std.math.isInf;
const copysign = std.math.copysign;
pub fn Complex(comptime T: type) type {
return extern struct {
real: T,
imag: T,
};
}
/// Implementation based on Annex G of C17 Standard (N2176)
pub inline fn mulc3(comp... | https://raw.githubusercontent.com/beingofexistence13/multiversal-lang/dd769e3fc6182c23ef43ed4479614f43f29738c9/zig/lib/compiler_rt/mulc3.zig |
const std = @import("std");
const isNan = std.math.isNan;
const isInf = std.math.isInf;
const copysign = std.math.copysign;
pub fn Complex(comptime T: type) type {
return extern struct {
real: T,
imag: T,
};
}
/// Implementation based on Annex G of C17 Standard (N2176)
pub inline fn mulc3(comp... | https://raw.githubusercontent.com/mundusnine/FoundryTools_windows_x64/b64cdb7e56db28eb710a05a089aed0daff8bc8be/lib/compiler_rt/mulc3.zig |
const std = @import("std");
const isNan = std.math.isNan;
const isInf = std.math.isInf;
const copysign = std.math.copysign;
pub fn Complex(comptime T: type) type {
return extern struct {
real: T,
imag: T,
};
}
/// Implementation based on Annex G of C17 Standard (N2176)
pub inline fn mulc3(comp... | https://raw.githubusercontent.com/mundusnine/FoundryTools_linux_x64/98e738bf92a416b255c9d11b78e8033071b52672/lib/compiler_rt/mulc3.zig |
const std = @import("std");
const isNan = std.math.isNan;
const isInf = std.math.isInf;
const copysign = std.math.copysign;
pub fn Complex(comptime T: type) type {
return extern struct {
real: T,
imag: T,
};
}
/// Implementation based on Annex G of C17 Standard (N2176)
pub inline fn mulc3(comp... | https://raw.githubusercontent.com/matpx/daydream/018ad0c7caaf796d8a04b882fcbed39ccb7c9cd8/toolchain/zig/lib/compiler_rt/mulc3.zig |
//! This file is auto-generated by tools/update_cpu_features.zig.
const std = @import("../std.zig");
const CpuFeature = std.Target.Cpu.Feature;
const CpuModel = std.Target.Cpu.Model;
pub const Feature = enum {
a510,
a65,
a710,
a76,
a78,
a78c,
aes,
aggressive_fma,
alternate_sextload... | https://raw.githubusercontent.com/beingofexistence13/multiversal-lang/dd769e3fc6182c23ef43ed4479614f43f29738c9/zig/lib/std/target/aarch64.zig |
//! This file is auto-generated by tools/update_cpu_features.zig.
const std = @import("../std.zig");
const CpuFeature = std.Target.Cpu.Feature;
const CpuModel = std.Target.Cpu.Model;
pub const Feature = enum {
a510,
a65,
a710,
a76,
a78,
a78c,
aes,
aggressive_fma,
alternate_sextload... | https://raw.githubusercontent.com/2lambda123/ziglang-zig-bootstrap/f56dc0fd298f41c8cc2a4f76a9648111e6c75503/zig/lib/std/Target/aarch64.zig |
//
// One of the more common uses of 'comptime' function parameters is
// passing a type to a function:
//
// fn foo(comptime MyType: type) void { ... }
//
// In fact, types are ONLY available at compile time, so the
// 'comptime' keyword is required here.
//
// Please take a moment to put on the wizard hat which h... | https://raw.githubusercontent.com/arpangreat/my_ziglings/781f88d8c8eb12b15349462e176b7fb7b384925f/exercises/069_comptime4.zig |
//
// One of the more common uses of 'comptime' function parameters is
// passing a type to a function:
//
// fn foo(comptime MyType: type) void { ... }
//
// In fact, types are ONLY available at compile time, so the
// 'comptime' keyword is required here.
//
// Please take a moment to put on the wizard hat which h... | https://raw.githubusercontent.com/stdrc/ziglings/68a151a8d7c0d69e8dd6590026758dba8c82150a/exercises/069_comptime4.zig |
//
// One of the more common uses of 'comptime' function parameters is
// passing a type to a function:
//
// fn foo(comptime MyType: type) void { ... }
//
// In fact, types are ONLY available at compile time, so the
// 'comptime' keyword is required here.
//
// Please take a moment to put on the wizard hat which h... | https://raw.githubusercontent.com/blotta/ziglings/b5ad06ab1f28683bc6931ab1fa6f3238113df73d/exercises/069_comptime4.zig |
//
// One of the more common uses of 'comptime' function parameters is
// passing a type to a function:
//
// fn foo(comptime MyType: type) void { ... }
//
// In fact, types are ONLY available at compile time, so the
// 'comptime' keyword is required here.
//
// Please take a moment to put on the wizard hat which h... | https://raw.githubusercontent.com/marlalain/ziglings/c282e48c41d77dab8f96c0d72082e9679d59a31d/exercises/069_comptime4.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 uefi = @import("std").os.uefi;
const G... | https://raw.githubusercontent.com/creationix/zig-toolset/9ad208cd93d1f05eb772deff4af24f58eb42386f/zig-linux-x86_64-0.8.0-dev.1860+1fada3746/lib/std/os/uefi/protocols/ip6_protocol.zig |
const std = @import("std");
pub fn main() void {
var value: i32 = -1; // runtime-known
_ = &value;
const unsigned: u32 = @intCast(value);
std.debug.print("value: {}\n", .{unsigned});
}
// exe=fail
| https://raw.githubusercontent.com/ziglang/zig-bootstrap/ec2dca85a340f134d2fcfdc9007e91f9abed6996/zig/doc/langref/runtime_invalid_cast.zig |
const std = @import("std");
pub fn main() void {
var value: i32 = -1; // runtime-known
_ = &value;
const unsigned: u32 = @intCast(value);
std.debug.print("value: {}\n", .{unsigned});
}
// exe=fail
| https://raw.githubusercontent.com/kassane/zig-mos-bootstrap/19aac4779b9e93b0e833402c26c93cfc13bb94e2/zig/doc/langref/runtime_invalid_cast.zig |
const std = @import("std");
const bun = @import("root").bun;
const string = bun.string;
const Output = bun.Output;
const Global = bun.Global;
const Environment = bun.Environment;
const strings = bun.strings;
const MutableString = bun.MutableString;
const stringZ = bun.stringZ;
const default_allocator = bun.default_allo... | https://raw.githubusercontent.com/oven-sh/bun/fab96a74ea13da04459ea7f62663c4d2fd421778/misctools/http_bench.zig |
const std = @import("std.zig");
const debug = std.debug;
const assert = debug.assert;
const testing = std.testing;
const mem = std.mem;
const math = std.math;
const Allocator = mem.Allocator;
/// A contiguous, growable list of items in memory.
/// This is a wrapper around an array of T values. Initialize with `init`.
... | https://raw.githubusercontent.com/ziglang/zig/d9bd34fd0533295044ffb4160da41f7873aff905/lib/std/array_list.zig |
const std = @import("std");
const raylib = @import("src/build.zig");
// This has been tested to work with zig 0.12.0
pub fn build(b: *std.Build) !void {
try raylib.build(b);
}
// expose helper functions to user's build.zig
pub const addRaylib = raylib.addRaylib;
pub const addRaygui = raylib.addRaygui;
| https://raw.githubusercontent.com/raysan5/raylib/33c598123c4b6ef78ff2ac3dcc1094da4dd6efef/build.zig |
const mach = @import("../main.zig");
const math = mach.math;
pub const name = .mach_gfx_text_style;
pub const Mod = mach.Mod(@This());
pub const components = .{
// // TODO: ship a default font
// .font_name = .{ .type = []const u8, .description =
// \\ Desired font to render text with.
// \\ TODO(text... | https://raw.githubusercontent.com/hexops/mach/b72f0e11b6d292c2b60789359a61f7ee6d7dc371/src/gfx/TextStyle.zig |
const builtin = @import("builtin");
const native_arch = builtin.cpu.arch;
const std = @import("std");
pub extern "ole32" fn CoInitializeEx(pvReserved: ?LPVOID, dwCoInit: DWORD) callconv(WINAPI) HRESULT;
pub extern "ole32" fn CoUninitialize() callconv(WINAPI) void;
pub extern "ole32" fn CoTaskMemAlloc(size: SIZE_T) cal... | https://raw.githubusercontent.com/zig-gamedev/zig-gamedev/dcef066b6ecc9f9b9de0e23fc9360f6bea1db2aa/libs/zwin32/src/w32.zig |
std.log.debug("{}", .{{{_cursor_}}});
| https://raw.githubusercontent.com/mattn/vim-sonictemplate/9959750bc0c6ac9f00a613c1870d589651a6b317/template/zig/snip-log-debug.zig |
//! This example is ported from : https://github.com/microsoft/Windows-classic-samples/blob/master/Samples/Win7Samples/begin/LearnWin32/Direct2DCircle/cpp/main.cpp
pub const UNICODE = true;
const WINAPI = @import("std").os.windows.WINAPI;
const win32 = struct {
usingnamespace @import("win32").zig;
usingnamespa... | https://raw.githubusercontent.com/marlersoft/zigwin32gen/a7ea975694193ef077c34aa3bca5ec3fbdba4712/examples/d2dcircle.zig |
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distribu... | https://raw.githubusercontent.com/spiraldb/ziggy-pydust/59703a878b8c3dbbbb6198fff4e67dc8d7bf50f0/pydust/src/attributes.zig |
// Forked from https://github.com/gernest/base32
const std = @import("std");
const testing = std.testing;
const log = std.log.scoped(.base32);
const encode_std = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
const encode_hex = "0123456789ABCDEFGHIJKLMNOPQRSTUV";
const crockford_alphabet = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
pu... | https://raw.githubusercontent.com/MarcoPolo/zig-libp2p/478d9b60c99069e5bc557b8f60c36ae72dedc83a/src/multibase/base32.zig |
///
/// タイマドライバシミュレータのシステムコンフィギュレーション記述
///
usingnamespace @import("../../kernel/kernel_cfg.zig");
usingnamespace zig;
///
/// タイマドライバ
///
const sim_timer = @import("sim_timer.zig");
usingnamespace sim_timer.ExternDefs;
///
/// システムコンフィギュレーション記述
///
pub fn configuration(comptime cfg: *CfgData) void {
// 高分解能タイ... | https://raw.githubusercontent.com/toppers/asp3_in_zig/7413474dc07ab906ac31eb367636ecf9c1cf2580/arch/simtimer/sim_timer_cfg.zig |
pub fn from(addr: usize) []Partition {
return @intToPtr([*]Partition, addr)[0..4];
}
pub fn first_bootable(parts: []Partition) ?*Partition {
for (parts) |*part| {
if (part.is_bootable()) {
return part;
}
}
return null;
}
pub const Partition = packed struct {
attributes:... | https://raw.githubusercontent.com/sajjadium/ctf-archives/b7012a5fc5454f8c74ce534ecf4da521c5b9595e/ctfs/AmateursCTF/2023/pwn/simpleOS/src/common/partitions.zig |
const std = @import("std");
const gl = @import("opengl");
export fn dummy() void {
{
@setEvalBranchQuota(100_000); // Yes, this is necessary. OpenGL gets quite large!
std.testing.refAllDecls(gl);
}
gl.load({}, fakeLoader) catch {};
}
comptime {
@export(gl.getIntegerv, .{ .name = "glGe... | https://raw.githubusercontent.com/ikskuh/zig-opengl/77a0a4e9221f81b7b61f5f53b8844b94cd6ab383/scripts/tester.zig |
const std = @import("std");
const bc = @import("bytecode.zig");
const lexer = @import("lexer.zig");
const parser = @import("parser.zig");
const sema = @import("sema.zig");
/// Compile takes a program and compiles it into bytecode.
pub const Compiler = struct {
gpa: std.mem.Allocator,
chunk: bc.Chunk,
progr... | https://raw.githubusercontent.com/mattyhall/polari/8ea72bbded88d771d3f5450158f35581576ae2da/src/compiler.zig |
//! run 'zig build jsons' to generate bindings for raylib
//! run 'zig build raylib_parser' to build the raylib_parser.exe
/// this needs to be here so the zig compiler won't complain that there is no entry point
/// but actually we are using main() of 'raylib/src/parser/raylib_parser.c'
pub extern fn main() c_int;
| https://raw.githubusercontent.com/ryupold/raylib.zig/bd561b3689bc4e703f46bf1908633abb09680b4b/raylib_parser.zig |
const std = @import("std");
const microzig = @import("microzig");
const include_path = [_][]const u8{
"csrc/connectivity/paho.mqtt.embedded-c/MQTTPacket/src/",
};
const paho_src_path = "csrc/connectivity/paho.mqtt.embedded-c/MQTTPacket/src/";
const source_path = [_][]const u8{
paho_src_path ++ "MQTTFormat.c"... | https://raw.githubusercontent.com/FranciscoLlobet/efm32-freertos-zig/879cb83fe3aa68205e3726b50fc47973ebf0ccd0/build_mqtt.zig |
/// Calculates Md5 hash of each chunk in parallel and then hashes all Md5 hashes to produce
/// the final digest.
/// While this is NOT a correct MD5 hash of the contents, this methodology is used by LLVM/LLD
/// and we will use it too as it seems accepted by Apple OSes.
/// TODO LLD also hashes the output filename to ... | https://raw.githubusercontent.com/kubkon/zld/01da87911bd7f53b860d8ba0aebb99eee63e5b76/src/MachO/uuid.zig |
const std = @import("std");
const Ast = std.zig.Ast;
const log = std.log.scoped(.zls_hover);
const ast = @import("../ast.zig");
const types = @import("../lsp.zig");
const offsets = @import("../offsets.zig");
const URI = @import("../uri.zig");
const tracy = @import("tracy");
const Analyser = @import("../analysis.zig")... | https://raw.githubusercontent.com/zigtools/zls/c5ceadf362df07aa40b657db166bf6229a5ea1c5/src/features/hover.zig |
// Copyright (C) 2023-2024 Lightpanda (Selecy SAS)
//
// Francis Bouvier <francis@lightpanda.io>
// Pierre Tachoire <pierre@lightpanda.io>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Found... | https://raw.githubusercontent.com/lightpanda-io/browser/152a4e5e7fdab3cc5c4509599407740aaae56f25/src/mimalloc.zig |
//! https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader
//! https://learn.microsoft.com/en-us/previous-versions//dd183376(v=vs.85)
//! https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfo
//! https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingd... | https://raw.githubusercontent.com/squeek502/resinator/e9023319993177ac3d49a8a833522eecedc903f7/src/bmp.zig |
// pub fn checkTransaction(tx: *Transaction, state: *TxValidationState) !bool {
// if (tx.vin.empty()) {
// return false;
// }
// if (tx.vout.empty()) {
// return false;
// }
// return true;
// }
| https://raw.githubusercontent.com/iskyd/zbtc/ce96eca9ef58530ce2fda696adf193e1a1c62454/src/consensus/txcheck.zig |
const std = @import("std");
pub const Fixbuf = @compileError("Please use std.BoundedArray instead");
pub fn errSetContains(comptime ErrorSet: type, err: anyerror) bool {
inline for (comptime std.meta.fields(ErrorSet)) |e| {
if (err == @field(ErrorSet, e.name)) {
return true;
}
}
... | https://raw.githubusercontent.com/fengb/zCord/a6334ebf39773abe7e7272205170d7bed1d93dcd/src/util.zig |
const std = @import("../../../std.zig");
const kern = @import("kern.zig");
const PtRegs = @compileError("TODO missing os bits: PtRegs");
const TcpHdr = @compileError("TODO missing os bits: TcpHdr");
const SkFullSock = @compileError("TODO missing os bits: SkFullSock");
// in BPF, all the helper calls
// TODO: when htt... | https://raw.githubusercontent.com/ziglang/zig/d9bd34fd0533295044ffb4160da41f7873aff905/lib/std/os/linux/bpf/helpers.zig |
const std = @import("std");
const mem = std.mem;
const net = std.net;
const os = std.os;
const IO = @import("tigerbeetle-io").IO;
const http = @import("http");
fn IoOpContext(comptime ResultType: type) type {
return struct {
frame: anyframe = undefined,
result: ResultType = undefined,
};
}
con... | https://raw.githubusercontent.com/hnakamur/tigerbeetle-io/d0369de079ea822935391cf247f1e42ae1778140/examples/async_tcp_echo_client.zig |
const std = @import("std");
const testing = std.testing;
pub fn Trie(comptime T: type) type {
const TrieNode = struct {
children: [26]?*TN = [1]?*TN{null} ** 26,
value: T,
is_word: bool = false,
const TN = @This();
pub fn init(alloc: std.mem.Allocator, value: T) !*TN {
... | https://raw.githubusercontent.com/tsunaminoai/zigtrie/8d419015af7a73ec34331c282e2c531f5f936620/src/root.zig |
const std = @import("std");
const ascii = std.ascii;
const mem = std.mem;
const expectEqual = std.testing.expectEqual;
test "reads number correctly" {
const testData = "12";
const expected: u32 = 12;
const actual = part1Solver(testData);
try expectEqual(expected, actual);
}
test "single digit" {
... | https://raw.githubusercontent.com/arntj/advent-of-code/d6a234e5bf9dd22ed10e7e215b3c262edfee61ff/2023/01/part1.zig |
const tensor = @import("../tensor.zig");
fn buildMatMulShape(comptime t1_shape: []const u8, comptime t2_shape: []const u8) [2]u8 {
comptime {
if (t1_shape[1] != t2_shape[0]) {
@panic("Cannot matrix multiply tensors with the current shape");
}
}
const shape = [2]u8{ t2_shape[1], ... | https://raw.githubusercontent.com/SilasMarvin/dfdz/873f486a6a243bbe9263354f2617fda947486198/src/tensor_operations/matrixMultiply.zig |
const std = @import("std");
const console = @import("console");
const Token = @import("Token.zig");
const Error = @import("Error.zig");
const Source = @import("Source.zig");
const Ast = @import("Ast.zig");
const Compiler = @import("Compiler");
const Parser = @This();
gpa: std.mem.Allocator,
temp_arena: std.mem.Alloca... | https://raw.githubusercontent.com/bcrist/footlang/c540286e4bcf006690136728093466a947fc13b1/src/Parser.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const StringHashMap = std.StringHashMap;
const TestAllocator = std.testing.allocator;
const types = @import("types.zig");
const ESVarType = types.ESVarType;
const ESNumber = types.ESNumber;
const ESString = types.ESString... | https://raw.githubusercontent.com/jlandrum/jz/74a66f98d888272b451e2f644baa7aa822d00e7d/lib/runtime.zig |
const std = @import("std");
const Allocator = std.mem.Allocator;
const Self = @This();
const Error = error{
InvalidHeader,
};
allocator: Allocator,
data: []const u8,
header: std.elf.Elf64_Ehdr,
debug_info_sect: ?std.elf.Elf64_Shdr = null,
debug_string_sect: ?std.elf.Elf64_Shdr = null,
debug_abbrev_sect: ?std.elf... | https://raw.githubusercontent.com/aapen/aapen/c02010f570ec1f69905afe607d2ed4080c2e8edb/tools/build-symtab/src/dwarf/Elf.zig |
const std = @import("std");
const fs = std.fs;
const print = std.debug.print;
// sauce: https://ziglang.cc/zig-cookbook/01-01-read-file-line-by-line.html
pub fn fileReader(fileName: []const u8) !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();
const allocator = gpa.allocat... | https://raw.githubusercontent.com/reillyjodonnell/zig-tokenizer/6b502ebbb1a5fdb31ab16ab0fb77f153ef7d30d2/src/file-reader.zig |
const std = @import("std");
const x = @import("./x.zig");
const common = @import("common.zig");
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
const allocator = arena.allocator();
const window_width = 400;
const window_height = 400;
pub fn main() !u8 {
try x.wsaStartup();
const conn = try... | https://raw.githubusercontent.com/marler8997/zigx/f09fd6fa5d593c759c0d9d35db4dfb5a150d366a/graphics.zig |
const std = @import("std");
const Token = @import("Token.zig");
const Error = @import("Error.zig");
const Parser = @import("Parser.zig");
const Source = @This();
handle: Handle,
name: []const u8,
text: []const u8,
token_data: Token.List,
pub const Handle = u32;
pub fn deinit(self: Source, gpa: std.mem.Allocator, ma... | https://raw.githubusercontent.com/bcrist/footlang/c540286e4bcf006690136728093466a947fc13b1/src/Source.zig |
const std = @import("std");
const allocator = std.heap.page_allocator;
extern fn yomo_observe_datatag(tag: u32) void;
extern fn yomo_context_tag() u32;
extern fn yomo_context_data(pointer: *const u8, size: u32) u32;
extern fn yomo_context_data_size() u32;
extern fn yomo_write(tag: u32, pointer: *const u8, length: usiz... | https://raw.githubusercontent.com/yomorun/yomo/ab56d6d9e007be0af15be0d0d2de67bb6207cd7c/example/7-wasm/sfn/zig/src/main.zig |
const hw = if (@import("BuildOptions").DISCOVERY) @import("discovery.zig") else @import("nucleo.zig");
const blinky = if (@import("BuildOptions").DISCOVERY) @import("examples/discovery_blinky.zig") else @import("examples/nucleo_blinky.zig");
pub fn zig_entry() void {
hw.systemInit();
blinky.blinky();
}
| https://raw.githubusercontent.com/amitfr123/ZigStmBlinky/3f73f48e46a7f5f6d95d37e1ee72c79baccacd35/src/main.zig |
//
// We've absorbed a lot of information about the variations of types
// we can use in Zig. Roughly, in order we have:
//
// u8 single item
// *u8 single-item pointer
// []u8 slice (size known at runtime)
// [5]u8 array ... | https://raw.githubusercontent.com/mvolkmann/ziglings-solutions/9375498a857a6aa9278f2d308dd11222efe8f4a1/exercises/058_quiz7.zig |
//! Cairo surface PDF backend.
//! The PDF surface is used to render cairo graphics to Adobe PDF files and is a
//! multi-page vector surface backend.
//! https://www.cairographics.org/manual/cairo-PDF-Surfaces.html
const c = @import("../c.zig");
const Error = @import("../utilities/error_handling.zig").Error;
const enu... | https://raw.githubusercontent.com/jackdbd/zig-cairo/c2736f512b5a48a5ad38a15973b2879166da1d8a/src/surfaces/pdf.zig |
const std = @import("std");
const builtin = @import("builtin");
const Pkg = std.build.Pkg;
const pkgs = struct {
const s2s = Pkg{
.name = "s2s",
.source = .{ .path = "./deps/s2s/s2s.zig" },
.dependencies = &[_]Pkg{},
};
};
const LMDB_PATH = "./deps/lmdb/libraries/liblmdb/";
pub fn build... | https://raw.githubusercontent.com/Ultra-Code/recblock/20d8a3aea30ea312df21509ae1d69a6e3bbbe116/build.zig |
const mtr = @import("package.zig");
const std = @import("std");
pub const Idx = u64;
pub const ConstructInfo = struct {
offset : u64, length : u64,
usage : mtr.buffer.Usage,
queueSharing : mtr.queue.SharingUsage,
label : [:0] const u8,
};
// describes in what contexts the buffer may be accessed for both read... | https://raw.githubusercontent.com/AODQ/ztoadz/5af950d72deb78b383b0c1c748bf9a3d675b381b/src/mtr/buffer.zig |
const std = @import("std");
const expect = std.testing.expect;
const ArrayList = std.ArrayList;
const Allocator = std.mem.Allocator;
const test_allocator = std.testing.allocator;
const Solver = struct {
allocator: Allocator,
values: []ArrayList(u8) = undefined,
instructions: [][3]u8 = undefined,
fn pa... | https://raw.githubusercontent.com/graynk/aoc2022/b7da1f3b71ec6684aa902659da2bacec621ff125/day5/src/main.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/quantumshiro/zion/154c60fb3e33e9bd749f8c5bca8116bdaf74c9aa/build.zig |
const std = @import("std");
const mem = std.mem;
const Allocator = std.mem.Allocator;
// Similar to KeyValue with two important differences
// 1 - We don't need to normalize (i.e. lowercase) the names, because they're
// statically defined in code, and presumably, if the param is called "id"
// then the devel... | https://raw.githubusercontent.com/EdamAme-x/Precisock/e8613429c23b78acd00cdea5bb72daaeea253d41/src/params.zig |
//
// Helper functions to convert microsecond to system clock ticks,
// and keep track of executed ticks.
//
const assert = @import("std").debug.assert;
const Clock = @This();
freq_hz: i64,
ticks_to_run: i64 = 0,
overrun_ticks: i64 = 0,
// return the number of ticks to run for micro_seconds, taking overrun
// ticks... | https://raw.githubusercontent.com/floooh/kc85.zig/3af78174516d5c0aa8ce0fdba7e0cfd145261e4b/src/emu/Clock.zig |
pub const TracerProvider = @import("sdk/provider.zig").TracerProvider;
pub const RecordingSpan = @import("sdk/span.zig").RecordingSpan;
pub const Tracer = @import("sdk/tracer.zig").Tracer;
pub const Resource = @import("sdk/resource.zig").Resource;
pub const SimpleSpanProcessor = @import("sdk/simple_span_processor.zig"... | https://raw.githubusercontent.com/Drumato/opentelemetry-zig/2534edfc257a8c2f00277d53f1937511db6aa2bc/src/otel/sdk.zig |
const common = @import("./common.zig");
const addf3 = @import("./addf3.zig").addf3;
pub const panic = common.panic;
comptime {
@export(__addhf3, .{ .name = "__addhf3", .linkage = common.linkage, .visibility = common.visibility });
}
fn __addhf3(a: f16, b: f16) callconv(.C) f16 {
return addf3(f16, a, b);
}
| https://raw.githubusercontent.com/ziglang/zig-bootstrap/ec2dca85a340f134d2fcfdc9007e91f9abed6996/zig/lib/compiler_rt/addhf3.zig |
const micro = @import("microzig");
const mmio = micro.mmio;
pub const devices = struct {
pub const ATtiny214 = struct {
pub const properties = struct {
pub const family = "AVR TINY";
pub const arch = "AVR8X";
};
pub const VectorTable = extern struct {
co... | https://raw.githubusercontent.com/burgrp/microzig-avr/f6f7a766fac9f85d2643789b46bc882ff4ade0ed/src/chips/ATtiny214.zig |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.