mirror of
https://github.com/ziglang/zig.git
synced 2024-11-27 23:52:31 +00:00
5aa3f56773
I'm allowing incremental compilation of ZIR modules to be broken. This is not a real use case of ZIR, and the feature requires a lot of code duplication with incremental compilation of Zig AST (which works great).
46 lines
1.1 KiB
Zig
46 lines
1.1 KiB
Zig
pub const std = @import("std");
|
|
|
|
pub const enable = if (std.builtin.is_test) false else @import("build_options").enable_tracy;
|
|
|
|
extern fn ___tracy_emit_zone_begin_callstack(
|
|
srcloc: *const ___tracy_source_location_data,
|
|
depth: c_int,
|
|
active: c_int,
|
|
) ___tracy_c_zone_context;
|
|
|
|
extern fn ___tracy_emit_zone_end(ctx: ___tracy_c_zone_context) void;
|
|
|
|
pub const ___tracy_source_location_data = extern struct {
|
|
name: ?[*:0]const u8,
|
|
function: [*:0]const u8,
|
|
file: [*:0]const u8,
|
|
line: u32,
|
|
color: u32,
|
|
};
|
|
|
|
pub const ___tracy_c_zone_context = extern struct {
|
|
id: u32,
|
|
active: c_int,
|
|
|
|
pub fn end(self: ___tracy_c_zone_context) void {
|
|
___tracy_emit_zone_end(self);
|
|
}
|
|
};
|
|
|
|
pub const Ctx = if (enable) ___tracy_c_zone_context else struct {
|
|
pub fn end(self: Ctx) void {}
|
|
};
|
|
|
|
pub inline fn trace(comptime src: std.builtin.SourceLocation) Ctx {
|
|
if (!enable) return .{};
|
|
|
|
const loc: ___tracy_source_location_data = .{
|
|
.name = null,
|
|
.function = src.fn_name.ptr,
|
|
.file = src.file.ptr,
|
|
.line = src.line,
|
|
.color = 0,
|
|
};
|
|
return ___tracy_emit_zone_begin_callstack(&loc, 1, 1);
|
|
}
|