mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-23 19:54:50 +03:00
32 lines
769 B
C
32 lines
769 B
C
#include "clock.h"
|
|
|
|
#define NSEC_PER_SEC 1000000000
|
|
#define CLOCKS_PER_NSEC ((float)CLOCKS_PER_SEC / NSEC_PER_SEC)
|
|
|
|
Value *clockTimeMonotonic() { return clockTimeUtc(); }
|
|
|
|
Value *clockTimeUtc() {
|
|
return (Value *)idris2_mkBits64(time(NULL) * NSEC_PER_SEC);
|
|
}
|
|
|
|
Value *clockTimeProcess() {
|
|
uint64_t time_ns = clock() / CLOCKS_PER_NSEC;
|
|
return (Value *)idris2_mkBits64(time_ns);
|
|
}
|
|
|
|
Value *clockTimeThread() { return clockTimeProcess(); }
|
|
|
|
Value *clockTimeGcCpu() { return NULL; }
|
|
|
|
Value *clockTimeGcReal() { return NULL; }
|
|
|
|
int clockValid(Value *clock) { return clock != NULL; }
|
|
|
|
uint64_t clockSecond(Value *clock) {
|
|
return idris2_vp_to_Bits64(clock) / NSEC_PER_SEC;
|
|
}
|
|
|
|
uint64_t clockNanosecond(Value *clock) {
|
|
return idris2_vp_to_Bits64(clock) % NSEC_PER_SEC;
|
|
}
|