mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
eb280910c9
commit
ab4ff49eda
@ -4,20 +4,26 @@
|
|||||||
|
|
||||||
#define NANOS_PER_SEC 1000000000
|
#define NANOS_PER_SEC 1000000000
|
||||||
|
|
||||||
int64_t time_ns() {
|
#ifndef __circle__
|
||||||
struct timespec tms;
|
int64_t time_ns() {
|
||||||
#ifdef CLOCK_REALTIME
|
struct timespec tms;
|
||||||
clock_gettime(CLOCK_REALTIME, &tms);
|
#ifdef CLOCK_REALTIME
|
||||||
|
clock_gettime(CLOCK_REALTIME, &tms);
|
||||||
|
#else
|
||||||
|
/* The C11 way */
|
||||||
|
timespec_get(&tms, TIME_UTC);
|
||||||
|
#endif
|
||||||
|
/* seconds, multiplied with 1 billion */
|
||||||
|
int64_t nanos = tms.tv_sec * NANOS_PER_SEC;
|
||||||
|
/* Add full nanoseconds */
|
||||||
|
nanos += tms.tv_nsec;
|
||||||
|
return nanos;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
/* The C11 way */
|
int64_t time_ns() {
|
||||||
timespec_get(&tms, TIME_UTC);
|
return 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
/* seconds, multiplied with 1 billion */
|
|
||||||
int64_t nanos = tms.tv_sec * NANOS_PER_SEC;
|
|
||||||
/* Add full nanoseconds */
|
|
||||||
nanos += tms.tv_nsec;
|
|
||||||
return nanos;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool time_time(int argc, py_Ref argv) {
|
static bool time_time(int argc, py_Ref argv) {
|
||||||
PY_CHECK_ARGC(0);
|
PY_CHECK_ARGC(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user