1
0
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:
Nicholas Rodrigues Lordello 2025-08-18 09:13:23 +02:00
parent f764788b36
commit 0624936711
No known key found for this signature in database
GPG Key ID: 117BA330BEA207A2

View File

@ -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;
}