timer_time.m4 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # timer_time.m4 serial 3
  2. dnl Copyright (C) 2011-2017 Free Software Foundation, Inc.
  3. dnl This file is free software; the Free Software Foundation
  4. dnl gives unlimited permission to copy and/or distribute it,
  5. dnl with or without modifications, as long as this notice is preserved.
  6. # Check for timer_settime, and set LIB_TIMER_TIME.
  7. AC_DEFUN([gl_TIMER_TIME],
  8. [
  9. dnl Based on clock_time.m4. See details there.
  10. AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
  11. dnl Test whether the gnulib module 'threadlib' is in use.
  12. dnl Some packages like Emacs use --avoid=threadlib.
  13. dnl Write the symbol in such a way that it does not cause 'aclocal' to pick
  14. dnl the threadlib.m4 file that is installed in $PREFIX/share/aclocal/.
  15. m4_ifdef([gl_][THREADLIB], [AC_REQUIRE([gl_][THREADLIB])])
  16. LIB_TIMER_TIME=
  17. AC_SUBST([LIB_TIMER_TIME])
  18. gl_saved_libs=$LIBS
  19. AC_SEARCH_LIBS([timer_settime], [rt posix4],
  20. [test "$ac_cv_search_timer_settime" = "none required" ||
  21. LIB_TIMER_TIME=$ac_cv_search_timer_settime])
  22. m4_ifdef([gl_][THREADLIB],
  23. [dnl GLIBC uses threads to emulate posix timers when kernel support
  24. dnl is not available (like Linux < 2.6 or when used with kFreeBSD)
  25. dnl Now the pthread lib is linked automatically in the normal case,
  26. dnl but when linking statically, it needs to be explicitly specified.
  27. AC_EGREP_CPP([Thread],
  28. [#include <features.h>
  29. #ifdef __GNU_LIBRARY__
  30. #if ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || (__GLIBC__ > 2)) \
  31. && !(__UCLIBC__ && __HAS_NO_THREADS__)
  32. Thread emulation available
  33. #endif
  34. #endif
  35. ],
  36. [LIB_TIMER_TIME="$LIB_TIMER_TIME $LIBMULTITHREAD"])])
  37. AC_CHECK_FUNCS([timer_settime])
  38. LIBS=$gl_saved_libs
  39. ])