diff options
| author | Can Celik <ogulcancelik@gmail.com> | 2026-09-10 21:51:57 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-10 21:51:57 +0300 |
| commit | 425c86179791cd32e2d4ce0ae7f269940b4b0663 (patch) | |
| tree | e52c4383a6d69216cbe2a32638bf90841d7e2189 /vendor/libghostty-vt/pkg/wuffs/src/main.zig | |
| parent | 90e947a6e26e02f10ec7f1694c4eb5b78a86406b (diff) | |
chore: upgrade libghostty and preserve terminal behavior (#3906)
Diffstat (limited to 'vendor/libghostty-vt/pkg/wuffs/src/main.zig')
| -rw-r--r-- | vendor/libghostty-vt/pkg/wuffs/src/main.zig | 48 |
1 files changed, 47 insertions, 1 deletions
diff --git a/vendor/libghostty-vt/pkg/wuffs/src/main.zig b/vendor/libghostty-vt/pkg/wuffs/src/main.zig index 207d83f9..41b74cab 100644 --- a/vendor/libghostty-vt/pkg/wuffs/src/main.zig +++ b/vendor/libghostty-vt/pkg/wuffs/src/main.zig @@ -1,3 +1,4 @@ +const builtin = @import("builtin"); const std = @import("std"); pub const png = @import("png.zig"); @@ -15,6 +16,51 @@ pub const ImageData = struct { data: []u8, }; +// Wuffs' generated `wuffs_foo__bar__alloc()` convenience functions are the +// only code that references libc's calloc/free. We never call them +// and linker garbage collection strips them, but that isn't guaranteed. +// Freestanding consumers may have no allocator to resolve these symbols. +// Never export stubs for hosted targets: hidden weak symbols in a static +// archive can override the embedding executable's dynamically linked libc. +comptime { + if (!builtin.link_libc and builtin.os.tag == .freestanding) { + @export(&callocStub, .{ + .name = "calloc", + .linkage = .weak, + .visibility = .hidden, + }); + @export(&freeStub, .{ + .name = "free", + .linkage = .weak, + .visibility = .hidden, + }); + } +} + +fn callocStub(count: usize, size: usize) callconv(.c) ?*anyopaque { + _ = count; + _ = size; + return null; +} + +fn freeStub(ptr: ?*anyopaque) callconv(.c) void { + _ = ptr; +} + test { - std.testing.refAllDeclsRecursive(@This()); + refAllDeclsRecursive(@This()); +} + +/// Copied from 0.15.2 stdlib (MIT license). +fn refAllDeclsRecursive(comptime T: type) void { + if (!builtin.is_test) return; + inline for (comptime std.meta.declarations(T)) |decl| { + if (@TypeOf(@field(T, decl.name)) == type) { + switch (@typeInfo(@field(T, decl.name))) { + .@"struct", .@"enum", .@"union", .@"opaque" => refAllDeclsRecursive(@field(T, decl.name)), + else => {}, + } + } + _ = &@field(T, decl.name); + } } |
