Commit d71076c982

Alex Rønne Petersen <alex@alexrp.com>
2024-08-03 18:46:04
std.os.linux: Replace `@hasDecl()` with `!= void` check for VDSO.
If there is a VDSO, it will have clock_gettime(). The main thing we're concerned about is architectures that don't have a VDSO at all, of which there are a few.
1 parent 624fa85
Changed files (1)
lib
std
lib/std/os/linux.zig
@@ -1399,7 +1399,7 @@ const VdsoClockGettime = *align(1) const fn (clockid_t, *timespec) callconv(.C)
 var vdso_clock_gettime: ?VdsoClockGettime = &init_vdso_clock_gettime;
 
 pub fn clock_gettime(clk_id: clockid_t, tp: *timespec) usize {
-    if (@hasDecl(VDSO, "CGT_SYM")) {
+    if (VDSO != void) {
         const ptr = @atomicLoad(?VdsoClockGettime, &vdso_clock_gettime, .unordered);
         if (ptr) |f| {
             const rc = f(clk_id, tp);