bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] m4: fix gl_TIMER_TIME() detection of threads on uClibc


From: Thomas Petazzoni
Subject: [PATCH] m4: fix gl_TIMER_TIME() detection of threads on uClibc
Date: Sat, 22 Feb 2014 00:41:38 +0100

The timer_time.m4 gl_TIMER_TIME function determines which libraries
need to be linked to get access to the timer function, generally -lrt
for Linux systems. On platforms where threads are used, librt
typically uses thread functions from libpthread.

However, the test to determine whether the platform has thread or not
is incorrect: it assumes that if the C library is uClibc, then threads
are not available. This is actually not true: uClibc has configurable
thread support, and when thread support is available, librt calls
libpthread functions.

This is important when static linking is used, because otherwise only
-lrt is used at link time, which fails because librt calls undefined
thread functions. Both -lrt and -lpthread must be passed.

This problem is fixed by making the uClibc thread detection a bit
smarter, thanks to the usage of the __HAS_NO_THREADS__ macro defined
in <bits/uClibc_config.h>, which itself is included by <features.h>.

Signed-off-by: Thomas Petazzoni <address@hidden>
---
 m4/timer_time.m4 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/m4/timer_time.m4 b/m4/timer_time.m4
index 6eceadd..8e2c921 100644
--- a/m4/timer_time.m4
+++ b/m4/timer_time.m4
@@ -28,7 +28,7 @@ AC_DEFUN([gl_TIMER_TIME],
 #include <features.h>
 #ifdef __GNU_LIBRARY__
  #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || (__GLIBC__ > 2)) \
-     && !defined __UCLIBC__
+     && !(__UCLIBC__ && __HAS_NO_THREADS__)
   Thread emulation available
  #endif
 #endif
-- 
1.8.3.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]