From: Pádraig Brady
Date: Tue, 6 Mar 2012 15:02:40 +0000 (+0000)
Subject: timer-time: link explicitly with pthreads on glibc
X-Git-Tag: v0.1~891
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=d0738c7634890553f4405677888f4d4d2726e93b;p=gnulib.git
timer-time: link explicitly with pthreads on glibc
To support static linking we need to explicitly
specify the pthreads library which is referenced
(but not used on modern Linux kernels at least).
* m4/timer_time.m4 (LIB_TIMER_TIME): Add -lpthread
when newer GLIBC is detected as that contains
the pthread emulation.
* modules/timer-time: Depend on threadlib to
pull in the appropriate library to link
---
diff --git a/ChangeLog b/ChangeLog
index e873f361aa..d470b304c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2012-03-10 Pádraig Brady
+
+ timer-time: link explicitly with pthreads on glibc
+ * m4/timer_time.m4 (LIB_TIMER_TIME): Add -lpthread
+ to support static linking, when newer glibc is
+ detected, as that contains pthread emulation of
+ POSIX timer functions where required.
+ * modules/timer-time: Depend on threadlib to
+ pull in the appropriate library to link.
+
2012-03-10 Bruno Haible
log* tests: More tests.
diff --git a/m4/timer_time.m4 b/m4/timer_time.m4
index 6276759339..d6e0efeb61 100644
--- a/m4/timer_time.m4
+++ b/m4/timer_time.m4
@@ -11,6 +11,7 @@ AC_DEFUN([gl_TIMER_TIME],
dnl Based on clock_time.m4. See details there.
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+ AC_REQUIRE([gl_THREADLIB])
LIB_TIMER_TIME=
AC_SUBST([LIB_TIMER_TIME])
@@ -18,6 +19,21 @@ AC_DEFUN([gl_TIMER_TIME],
AC_SEARCH_LIBS([timer_settime], [rt posix4],
[test "$ac_cv_search_timer_settime" = "none required" ||
LIB_TIMER_TIME=$ac_cv_search_timer_settime])
+ dnl GLIBC uses threads to emulate posix timers when kernel support
+ dnl is not available (like Linux < 2.6 or when used with kFreeBSD)
+ dnl Now the pthread lib is linked automatically in the normal case,
+ dnl but when linking statically, it needs to be explicitly specified.
+ AC_EGREP_CPP([Thread],
+ [
+#include
+#ifdef __GNU_LIBRARY__
+ #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || (__GLIBC__ > 2)) \
+ && !defined __UCLIBC__
+ Thread emulation available
+ #endif
+#endif
+ ],
+ [LIB_TIMER_TIME="$LIBMULTITHREAD $LIB_TIMER_TIME"])
AC_CHECK_FUNCS([timer_settime])
LIBS=$gl_saved_libs
])
diff --git a/modules/timer-time b/modules/timer-time
index 07b439bbf8..7bf8079dcd 100644
--- a/modules/timer-time
+++ b/modules/timer-time
@@ -7,6 +7,7 @@ m4/timer_time.m4
Depends-on:
extensions
+threadlib
configure.ac:
gl_TIMER_TIME