Mercurial > gnulib
changeset 36326:3b7906f3434e
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
author | Pádraig Brady <P@draigBrady.com> |
---|---|
date | Tue, 06 Mar 2012 15:02:40 +0000 |
parents | fe942e07962c |
children | bea7f85ab111 |
files | ChangeLog m4/timer_time.m4 modules/timer-time |
diffstat | 3 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sat Mar 10 10:56:05 2012 +0100 +++ b/ChangeLog Tue Mar 06 15:02:40 2012 +0000 @@ -1,3 +1,13 @@ +2012-03-10 Pádraig Brady <P@draigBrady.com> + + 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 <bruno@clisp.org> log* tests: More tests.
--- a/m4/timer_time.m4 Sat Mar 10 10:56:05 2012 +0100 +++ b/m4/timer_time.m4 Tue Mar 06 15:02:40 2012 +0000 @@ -11,6 +11,7 @@ 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_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 <features.h> +#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 ])