mirror of https://github.com/ericonr/sndio.git
sndiod: use CLOCK_UPTIME when available
This commit is contained in:
parent
220e7731bc
commit
27da5245d0
|
@ -37,4 +37,8 @@ int clock_gettime(int, struct timespec *);
|
|||
#define SOCK_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
#if !defined(CLOCK_UPTIME) && defined(CLOCK_MONOTONIC)
|
||||
#define CLOCK_UPTIME CLOCK_MONOTONIC
|
||||
#endif
|
||||
|
||||
#endif /* !defined(BSD_COMPAT_H) */
|
||||
|
|
|
@ -281,7 +281,7 @@ file_process(struct file *f, struct pollfd *pfd)
|
|||
|
||||
#ifdef DEBUG
|
||||
if (log_level >= 3)
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts0);
|
||||
clock_gettime(CLOCK_UPTIME, &ts0);
|
||||
#endif
|
||||
revents = (f->state != FILE_ZOMB) ?
|
||||
f->ops->revents(f->arg, pfd) : 0;
|
||||
|
@ -293,7 +293,7 @@ file_process(struct file *f, struct pollfd *pfd)
|
|||
f->ops->out(f->arg);
|
||||
#ifdef DEBUG
|
||||
if (log_level >= 3) {
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts1);
|
||||
clock_gettime(CLOCK_UPTIME, &ts1);
|
||||
us = 1000000L * (ts1.tv_sec - ts0.tv_sec);
|
||||
us += (ts1.tv_nsec - ts0.tv_nsec) / 1000;
|
||||
if (log_level >= 4 || us >= 5000) {
|
||||
|
@ -383,7 +383,7 @@ file_poll(void)
|
|||
* timeout (i.e -1).
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
clock_gettime(CLOCK_MONOTONIC, &sleepts);
|
||||
clock_gettime(CLOCK_UPTIME, &sleepts);
|
||||
file_utime += 1000000000LL * (sleepts.tv_sec - file_ts.tv_sec);
|
||||
file_utime += sleepts.tv_nsec - file_ts.tv_nsec;
|
||||
#endif
|
||||
|
@ -406,7 +406,7 @@ file_poll(void)
|
|||
/*
|
||||
* run timeouts
|
||||
*/
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
clock_gettime(CLOCK_UPTIME, &ts);
|
||||
#ifdef DEBUG
|
||||
file_wtime += 1000000000LL * (ts.tv_sec - sleepts.tv_sec);
|
||||
file_wtime += ts.tv_nsec - sleepts.tv_nsec;
|
||||
|
@ -441,8 +441,8 @@ filelist_init(void)
|
|||
{
|
||||
sigset_t set;
|
||||
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &file_ts) < 0) {
|
||||
log_puts("filelist_init: CLOCK_MONOTONIC unsupported\n");
|
||||
if (clock_gettime(CLOCK_UPTIME, &file_ts) < 0) {
|
||||
log_puts("filelist_init: CLOCK_UPTIME unsupported\n");
|
||||
panic();
|
||||
}
|
||||
sigemptyset(&set);
|
||||
|
|
Loading…
Reference in New Issue