mirror of
https://github.com/janet-lang/janet
synced 2025-08-26 07:32:25 +00:00
Use CLOCKS_PER_SEC
The POSIX standard defines that `clock(3)` returns a `clock_t` as a number of clock ticks in `CLOCKS_PER_SEC` and not `CLOCKS_PER_SECOND`, [source](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html).
This commit is contained in:
parent
f764788b36
commit
0624936711
@ -950,8 +950,8 @@ int janet_gettime(struct timespec *spec, enum JanetTimeSource source) {
|
||||
}
|
||||
if (source == JANET_TIME_CPUTIME) {
|
||||
clock_t tmp = clock();
|
||||
spec->tv_sec = tmp / CLOCKS_PER_SECOND;
|
||||
spec->tv_nsec = ((tmp - (spec->tv_sec * CLOCKS_PER_SECOND)) * 1000000000) / CLOCKS_PER_SECOND;
|
||||
spec->tv_sec = tmp / CLOCKS_PER_SEC;
|
||||
spec->tv_nsec = ((tmp - (spec->tv_sec * CLOCKS_PER_SEC)) * 1000000000) / CLOCKS_PER_SEC;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user