Skip to content

Commit

Permalink
Merge pull request #235 from Joe7M/master
Browse files Browse the repository at this point in the history
Fix #232: TICKS stops working after 50 days
  • Loading branch information
chrisws authored Nov 8, 2024
2 parents 657c25f + 4894068 commit 5d8f044
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/common/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,7 @@ void dev_destroy_file_list(char_p_t *list, int count);
* Returns the number of milliseconds that has passed since
* some unknown point in time.
*/
uint32_t dev_get_millisecond_count();
uint64_t dev_get_millisecond_count();

/**
* @ingroup dev_f
Expand Down
9 changes: 4 additions & 5 deletions src/common/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,24 +216,23 @@ const char *dev_getenv_n(int n) {
}
#endif

uint32_t dev_get_millisecond_count(void) {
uint64_t dev_get_millisecond_count(void) {
#if defined(__MACH__)
struct timeval t;
gettimeofday(&t, NULL);
return (uint32_t) (1000L * t.tv_sec + (t.tv_usec / 1000.0));
return (uint64_t) (1000L * t.tv_sec + (t.tv_usec / 1000.0));
#elif defined(_Win32)
return GetTickCount();
#else
struct timespec t;
t.tv_sec = t.tv_nsec = 0;
if (0 == clock_gettime(CLOCK_MONOTONIC, &t)) {
return (uint32_t) (1000L * t.tv_sec + (t.tv_nsec / 1e6));
return (uint64_t) (1000L * t.tv_sec + (t.tv_nsec / 1e6));
} else {
struct timeval now;
gettimeofday(&now, NULL);
return (uint32_t) (1000L * now.tv_sec + (now.tv_usec / 1000.0));
return (uint64_t) (1000L * now.tv_sec + (now.tv_usec / 1000.0));
}
#endif
}


0 comments on commit 5d8f044

Please sign in to comment.