mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-19 17:21:59 +03:00
98d67499db
* Add utility functions to treat All as a heterogeneous container * Distinguish RefC Int and Bits types * Change RefC Integers to be arbitrary precision * Add RefC Bits maths operations * Make RefC div and mod Euclidean * Add RefC bit-ops tests * Add RefC integer comparison tests * Add RefC IntN support
53 lines
869 B
C
53 lines
869 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 *)makeBits64(time(NULL) * NSEC_PER_SEC);
|
|
}
|
|
|
|
Value *clockTimeProcess()
|
|
{
|
|
uint64_t time_ns = clock() / CLOCKS_PER_NSEC;
|
|
return (Value *)makeBits64(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)
|
|
{
|
|
uint64_t totalNano = ((Value_Bits64 *)clock)->ui64;
|
|
return totalNano / NSEC_PER_SEC;
|
|
}
|
|
|
|
uint64_t clockNanosecond(Value *clock)
|
|
{
|
|
uint64_t totalNano = ((Value_Bits64 *)clock)->ui64;
|
|
return totalNano % NSEC_PER_SEC;
|
|
}
|