From 0624936711f351c1a7dab127817fe816639eb53c Mon Sep 17 00:00:00 2001 From: Nicholas Rodrigues Lordello Date: Mon, 18 Aug 2025 09:13:23 +0200 Subject: [PATCH] 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). --- src/core/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/util.c b/src/core/util.c index cbd608ab..5914b99e 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -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; }