| ... | ... | @@ -451,10 +451,17 @@ fn isProblematicTimestamp(fs_clock: i128) bool { |
| 451 | 451 | // to detect precision of seconds, because looking at the zero bits in base |
| 452 | 452 | // 2 would not detect precision of the seconds value. |
| 453 | 453 | const fs_sec = @intCast(i64, @divFloor(fs_clock, std.time.ns_per_s)); |
| 454 | | const fs_nsec = @intCast(i64, @mod(fs_clock, std.time.ns_per_s)); |
| 454 | var fs_nsec = @intCast(i64, @mod(fs_clock, std.time.ns_per_s)); |
| 455 | 455 | var wall_sec = @intCast(i64, @divFloor(wall_clock, std.time.ns_per_s)); |
| 456 | 456 | var wall_nsec = @intCast(i64, @mod(wall_clock, std.time.ns_per_s)); |
| 457 | 457 | |
| 458 | if (std.Target.current.os.tag == .linux) { |
| 459 | // TODO As a temporary measure while we figure out how to solve |
| 460 | // https://github.com/ziglang/zig/issues/6082, we cut the granularity of nanoseconds |
| 461 | // by a large amount. |
| 462 | fs_nsec &= @as(i64, -1) << 23; |
| 463 | } |
| 464 | |
| 458 | 465 | // First make all the least significant zero bits in the fs_clock, also zero bits in the wall clock. |
| 459 | 466 | if (fs_nsec == 0) { |
| 460 | 467 | wall_nsec = 0; |
| ... | ... | @@ -466,16 +473,7 @@ fn isProblematicTimestamp(fs_clock: i128) bool { |
| 466 | 473 | } else { |
| 467 | 474 | wall_nsec &= @as(i64, -1) << @intCast(u6, @ctz(i64, fs_nsec)); |
| 468 | 475 | } |
| 469 | | if (wall_nsec == fs_nsec and wall_sec == fs_sec) |
| 470 | | return true; |
| 471 | | |
| 472 | | // I have also observed precision problems at a millisecond granularity. |
| 473 | | const fs_msec = @intCast(i64, @divFloor(fs_clock, std.time.ns_per_ms * 2)); |
| 474 | | const wall_msec = @intCast(i64, @divFloor(wall_clock, std.time.ns_per_ms * 2)); |
| 475 | | if (fs_msec == wall_msec) |
| 476 | | return true; |
| 477 | | |
| 478 | | return false; |
| 476 | return wall_nsec == fs_nsec and wall_sec == fs_sec; |
| 479 | 477 | } |
| 480 | 478 | |
| 481 | 479 | test "cache file and then recall it" { |