From: Richard Cochran <rcoch...@linutronix.de>

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 <richardcoch...@gmail.com>
---
 missing.h | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/missing.h b/missing.h
index f7efd92..7bc1776 100644
--- a/missing.h
+++ b/missing.h
@@ -69,7 +69,10 @@ static inline int clock_adjtime(clockid_t id, struct timex 
*tx)
 }
 #endif
 
-#ifndef __uClinux__
+#ifdef __UCLIBC__
+
+#if (_XOPEN_SOURCE >= 600 || _POSIX_C_SOURCE >= 200112L) && \
+       defined __UCLIBC_HAS_THREADS_NATIVE__
 
 #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);
 }
+#endif
+
+#else /*__UCLIBC__*/
+
+#include <sys/timerfd.h>
 
 #endif
 
-- 
2.1.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to