Fix build when using uClinux.

Unfortunately uClinux is rather inconsistent with respect to
clock_nanosleep().  Older versions of uclibc lack that function, while
newer versions may include the declaration but still lack the
definition, depending on whether pthreads are selected in the
configuration.

This patch works around uClinux shortcomings by using the library call
when available at compile time, otherwise falling back to syscall().

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
master
Richard Cochran 2017-05-30 08:42:27 +02:00
parent 95b5a13cb2
commit 97c351cafd
1 changed files with 9 additions and 1 deletions

View File

@ -69,7 +69,10 @@ static inline int clock_adjtime(clockid_t id, struct timex *tx)
} }
#endif #endif
#ifndef __uClinux__ #ifdef __UCLIBC__
#if (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L) && \
defined __UCLIBC_HAS_THREADS_NATIVE__
#include <sys/timerfd.h> #include <sys/timerfd.h>
@ -93,6 +96,11 @@ static inline int timerfd_settime(int fd, int flags,
{ {
return syscall(__NR_timerfd_settime, fd, flags, new_value, old_value); return syscall(__NR_timerfd_settime, fd, flags, new_value, old_value);
} }
#endif
#else /*__UCLIBC__*/
#include <sys/timerfd.h>
#endif #endif