Skip to content

Commit

Permalink
Fixed time_in_ms() compile time error (termux and neoterm)
Browse files Browse the repository at this point in the history
clang version 16.0.4
  • Loading branch information
emma-eva authored Jul 25, 2023
1 parent 4e1e83c commit 27d6f1e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions run.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) {
Expand Down

0 comments on commit 27d6f1e

Please sign in to comment.