unsigned long long monotonic_ns(void) FAST_FUNC;
unsigned long long monotonic_us(void) FAST_FUNC;
+unsigned long long monotonic_ms(void) FAST_FUNC;
unsigned monotonic_sec(void) FAST_FUNC;
extern void chomp(char *s) FAST_FUNC;
get_mono(&ts);
return ts.tv_sec * 1000000ULL + ts.tv_nsec/1000;
}
+unsigned long long FAST_FUNC monotonic_ms(void)
+{
+ struct timespec ts;
+ get_mono(&ts);
+ return ts.tv_sec * 1000ULL + ts.tv_nsec/1000000;
+}
unsigned FAST_FUNC monotonic_sec(void)
{
struct timespec ts;
gettimeofday(&tv, NULL);
return tv.tv_sec * 1000000ULL + tv.tv_usec;
}
+unsigned long long FAST_FUNC monotonic_ms(void)
+{
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ return tv.tv_sec * 1000ULL + tv.tv_usec / 1000;
+}
unsigned FAST_FUNC monotonic_sec(void)
{
return time(NULL);
return;
}
}
- resp->elapsed_ms = (monotonic_us() / 1000) - resp->elapsed_ms;
+ resp->elapsed_ms = monotonic_ms() - resp->elapsed_ms;
}
static void printargv(char *const *argv)
void (*interrupt_signal)(int);
void (*quit_signal)(int);
- resp->elapsed_ms = monotonic_us() / 1000;
+ resp->elapsed_ms = monotonic_ms();
pid = vfork(); /* Run CMD as child process. */
if (pid < 0)
bb_perror_msg_and_die("fork");
timeout_ms = 2000;
do {
int r;
- unsigned prevTime = monotonic_us();
+ unsigned prevTime = monotonic_ms();
pfd[0].events = POLLIN;
r = safe_poll(pfd, 1, timeout_ms);
break;
}
}
- timeout_ms -= ((unsigned)monotonic_us() - prevTime) / 1000;
+ timeout_ms -= (unsigned)monotonic_ms() - prevTime;
} while (timeout_ms > 0);
ret:
backslash = 0;
#if ENABLE_ASH_READ_TIMEOUT
if (timeout) /* NB: ensuring end_ms is nonzero */
- end_ms = ((unsigned)(monotonic_us() / 1000) + timeout) | 1;
+ end_ms = ((unsigned)monotonic_ms() + timeout) | 1;
#endif
STARTSTACKSTR(p);
do {
struct pollfd pfd[1];
pfd[0].fd = fd;
pfd[0].events = POLLIN;
- timeout = end_ms - (unsigned)(monotonic_us() / 1000);
+ timeout = end_ms - (unsigned)monotonic_ms();
if ((int)timeout <= 0 /* already late? */
|| safe_poll(pfd, 1, timeout) != 1 /* no? wait... */
) { /* timed out! */