[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Correct way to check for clock_gettime()
From: |
Thomas Petazzoni |
Subject: |
Re: Correct way to check for clock_gettime() |
Date: |
Thu, 12 Aug 2010 17:15:13 +0200 |
Hello,
On Mon, 09 Aug 2010 11:50:19 -0600
Eric Blake <address@hidden> wrote:
> At any rate, I'd argue that glib's configure.ac (the one that does not
> check for -lrt) would be the best candidate for proposing an upstream
> patch. glib in isolation will not use clock_gettime even if it is
> available through an alternate library; this is correct but not optimal
> behavior. Therefore, it seems like it would be easier to get them to
> adopt the same approach as CTorrent of allowing -lrt to be able to use
> clock_gettime on more platforms.
Ok, in the end I came up with the following modification to glib's
configure.in :
========================================================================
Index: glib-2.24.1/configure.in
===================================================================
--- glib-2.24.1.orig/configure.in 2010-08-11 19:29:20.530916023 +0200
+++ glib-2.24.1/configure.in 2010-08-11 19:46:41.308866269 +0200
@@ -2392,13 +2392,14 @@
LIBS="$glib_save_LIBS"
fi
-AC_CHECK_FUNCS(clock_gettime, [], [
- AC_CHECK_LIB(rt, clock_gettime, [
- AC_DEFINE(HAVE_CLOCK_GETTIME, 1)
+AC_SEARCH_LIBS([clock_gettime], [rt], [
+ AC_DEFINE(HAVE_CLOCK_GETTIME, 1,[Have clock_gettime])
+])
+
+if test "$ac_cv_search_clock_gettime" = "-lrt"; then
G_THREAD_LIBS="$G_THREAD_LIBS -lrt"
G_THREAD_LIBS_FOR_GTHREAD="$G_THREAD_LIBS_FOR_GTHREAD -lrt"
- ])
-])
+fi
AC_CACHE_CHECK(for monotonic clocks,
glib_cv_monotonic_clock,AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
========================================================================
I'm not sure it's the perfect fix but it seems to work.
> Sure; although I can't guarantee that we can always provide a solution
> (let alone in a timely manner), it can't hurt to document your findings
> on the list for more eyes to look at.
Ok, thanks, will do.
Regards,
Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
signature.asc
Description: PGP signature