After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 667790 - Protect call to pthread_condattr_setclock with define
Protect call to pthread_condattr_setclock with define
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: build
unspecified
Other NetBSD
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-01-12 16:02 UTC by Patrick Welche
Modified: 2012-01-16 13:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] Protect call to pthread_condattr_setclock with define (2.73 KB, patch)
2012-01-12 16:02 UTC, Patrick Welche
none Details | Review
Protect call to pthread_condattr_setclock with define. (2.77 KB, patch)
2012-01-16 04:48 UTC, Matthias Clasen
committed Details | Review

Description Patrick Welche 2012-01-12 16:02:34 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.
Comment 1 Allison Karlitskaya (desrt) 2012-01-13 08:17:38 UTC
You set Linux as the OS for this bug.  Can you give more information about your system?
Comment 2 Patrick Welche 2012-01-13 11:17:16 UTC
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.
Comment 3 Matthias Clasen 2012-01-13 18:49:44 UTC
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.
Comment 4 Matthias Clasen 2012-01-16 04:48:07 UTC
The following fix has been pushed:
decac50 Protect call to pthread_condattr_setclock with define.
Comment 5 Matthias Clasen 2012-01-16 04:48:10 UTC
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.
Comment 6 Patrick Welche 2012-01-16 13:14:55 UTC
(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