GNOME Bugzilla – Bug 667790
Protect call to pthread_condattr_setclock with define
Last modified: 2012-01-16 13:14:55 UTC
Created attachment 205114 [details] [review] [PATCH] Protect call to pthread_condattr_setclock with define gthread-posix.c calls pthread_condattr_setclock, and protects this call with #if CLOCK_MONOTONIC. CLOCK_MONOTONIC, at least on my system, is defined in <sys/time.h>, but my system doesn't have a pthread_condattr_setclock function. This patch provides a configure test, and protects the call with HAVE_PTHREAD_CONDATTR_SETCLOCK as well. While here update pthread_attr_setstacksize test to use AC_LINK_IFELSE and avoid an unused variable in glib/tests/thread.c.
You set Linux as the OS for this bug. Can you give more information about your system?
I don't think the OS is relevant? glib/gthread-posix.c g_cond_impl_new() contains: #ifdef CLOCK_MONOTONIC pthread_condattr_setclock (&attr, CLOCK_MONOTONIC); #endif pthread_condattr_setclock is in the "ADVANCED REALTIME" section of posix threads, so a system implementing posix threads has to have e.g., pthread_attr_setsacksize() (which this patch updates the test for), but doesn't need to implement pthread_condattr_setclock() which this patch tests for. CLOCK_MONOTONIC simply appears in time.h (http://pubs.opengroup.org/onlinepubs/009695399/basedefs/time.h.html) or in practice sys/time.h which is included by time.h, so to me testing for CLOCK_MONOTONIC really isn't the obvious choice of test. If you insist on knowing the OS (I was hoping the code would speak for itself), it is NetBSD-5.99.59/amd64, and after my patch, I see checking thread related libraries... -pthread checking for localtime_r... yes checking for gmtime_r... (cached) yes checking for posix getpwuid_r... yes checking for posix getgrgid_r... yes checking for pthread_attr_setstacksize... yes checking for pthread_condattr_setclock... no checking for clock_gettime... yes and can then compile glib.
I think these checks should really be just AC_CHECK_FUNC, btw. I don't want to know what craziness the comment in configure.ac refers to.
The following fix has been pushed: decac50 Protect call to pthread_condattr_setclock with define.
Created attachment 205332 [details] [review] Protect call to pthread_condattr_setclock with define. While here update pthread_attr_setstacksize test to use AC_LINK_IFELSE and avoid an unused variable in glib/tests/thread.c.
(In reply to comment #3) > I think these checks should really be just AC_CHECK_FUNC, btw. > I don't want to know what craziness the comment in configure.ac refers to. I had exactly the same reaction: would you like an AC_CHECK_FUNC patch, and we take the risk that the craziness has gone away? It appeared in http://git.gnome.org/browse/glib/commit/?id=4c63008b6cd4e3a9a81ff96ab195d23fc84a4515