]> Savannah Git Hosting - gnulib.git/commitdiff
m4: fix gl_TIMER_TIME() detection of threads on uClibc
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Fri, 21 Feb 2014 23:41:38 +0000 (00:41 +0100)
committerEric Blake <eblake@redhat.com>
Sat, 22 Feb 2014 00:09:58 +0000 (17:09 -0700)
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 <thomas.petazzoni@free-electrons.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
m4/timer_time.m4

index 6a115e266aeff10738576ee81be4790e7b8dcd60..4cf45008d571f799d42ebaf6be52f2bde7a4f99b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-21  Thomas Petazzoni  <thomas.petazzoni@free-electrons.com>  (tiny change)
+       timer: fix uClibc detection of threading
+       * m4/time_time.m4 (gl_TIMER_TIME): Detect whether threads are
+       enabled in uClibc.
+
 2014-02-21  Eric Blake  <eblake@redhat.com>
 
        maintainer-makefiles: provide AC_PROG_SED for older autoconf
index 6eceadd59a389f82da64772338869ca550473890..8e2c921cbef74aceab5626d3f33bd166e25485c1 100644 (file)
@@ -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