Files
c3c/lib/std/time/clock.c3
Christoffer Lerno 1f052da0b9 Clock.c3 fix.
2024-02-16 21:31:49 +01:00

24 lines
397 B
C

module std::time::clock;
import std::time::os;
fn Clock now()
{
$if $defined(os::native_clock):
return os::native_clock();
$else
unreachable("Clock unsupported");
$endif
}
fn NanoDuration Clock.mark(&self)
{
Clock mark = now();
NanoDuration diff = (NanoDuration)(mark - *self);
*self = mark;
return diff;
}
fn NanoDuration Clock.to_now(self)
{
return (NanoDuration)(now() - self);
}