From 6ce91b1b3b56ff7d43d894c204f965bfbf5d63c9 Mon Sep 17 00:00:00 2001 From: Emma Eva <67018591+emma-eva@users.noreply.github.com> Date: Tue, 25 Jul 2023 12:12:40 +0600 Subject: [PATCH] Fixed time_in_ms() compile time error (termux and neoterm) clang version 16.0.4 --- run.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/run.c b/run.c index e0c7197..3f3c49f 100644 --- a/run.c +++ b/run.c @@ -355,9 +355,14 @@ int argmax(float* v, int n) { // ---------------------------------------------------------------------------- long time_in_ms() { - struct timespec time; - timespec_get(&time, TIME_UTC); - return time.tv_sec * 1000 + time.tv_nsec / 1000000; + struct timespec time; + // Get the current time with nanosecond precision + if (clock_gettime(CLOCK_REALTIME, &time) == 0) { + return time.tv_sec * 1000 + time.tv_nsec / 1000000; + } else { + perror("clock_gettime"); + return -1; // Return -1 to indicate an error + } } int main(int argc, char *argv[]) {