mirror of
https://github.com/ziglang/zig.git
synced 2026-10-14 10:27:43 -04:00
add std.debug.inValgrind
This is like `@inComptime` but for the Valgrind virtual machine. Related #17717
This commit is contained in:
1 parent
12191c8a22
commit
afa0834195
1 file changed
+10
@@ -2858,6 +2858,16 @@ pub const SafetyLock = struct {
|
||||
}
|
||||
};
|
||||
|
||||
/// Detect whether the program is being executed in the Valgrind virtual machine.
|
||||
///
|
||||
/// When Valgrind integrations are disabled, this returns comptime-known false.
|
||||
/// Otherwise, the result is runtime-known.
|
||||
pub inline fn inValgrind() bool {
|
||||
if (@inComptime()) return false;
|
||||
if (!builtin.valgrind_support) return false;
|
||||
return std.valgrind.runningOnValgrind() > 0;
|
||||
}
|
||||
|
||||
test {
|
||||
_ = &dump_hex;
|
||||
}
|
||||
Reference in new issue
Block a user