diff --git a/src/common/libsys/libsys.c b/src/common/libsys/libsys.c index 6a834c9..008a3c7 100644 --- a/src/common/libsys/libsys.c +++ b/src/common/libsys/libsys.c @@ -46,18 +46,18 @@ void sleep(unsigned ms) usleep(1000*ms); } -void usleep(unsigned us) +void usleep(uint64_t us) { - unsigned stop_us, stop_s, curr_us, curr_s; + uint64_t stop_us, stop_s, curr_us, curr_s; struct timeval t; if (!us) return; gettimeofday(&t, NULL); - stop_s = (unsigned)t.tv_sec; - stop_us = (unsigned)t.tv_usec + us; - if (stop_us >= 1E6) + stop_s = (uint64_t)t.tv_sec; + stop_us = (uint64_t)t.tv_usec + us; + while (stop_us >= 1E6) { stop_us -= 1E6; stop_s++; @@ -66,8 +66,8 @@ void usleep(unsigned us) do { gettimeofday(&t, NULL); - curr_s = (unsigned)t.tv_sec; - curr_us = (unsigned)t.tv_usec; + curr_s = (uint64_t)t.tv_sec; + curr_us = (uint64_t)t.tv_usec; } while ((curr_s < stop_s) || (curr_us < stop_us)); } diff --git a/src/common/libsys/libsys.h b/src/common/libsys/libsys.h index 98195ef..a256fea 100644 --- a/src/common/libsys/libsys.h +++ b/src/common/libsys/libsys.h @@ -24,7 +24,7 @@ void print_byte(char byte); void print_word(int word); void _exit (int exitcode); void sleep(unsigned ms); -void usleep(unsigned us); +void usleep(uint64_t us); void PrintBuffer8(uint8_t *pBuf, int nbpr, int len); void memdump(uint8_t *pBuf, int print_offset_only, int num_bytes_per_row, int len);