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 353694 - glib-2.12.3 fails to compile if CLOCK_MONOTONIC is undefined
glib-2.12.3 fails to compile if CLOCK_MONOTONIC is undefined
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.12.x
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 354938 356020 359683 367894 376487 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-08-31 14:56 UTC by Chris Vine
Modified: 2006-12-04 14:28 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
Patch as described in bug report (439 bytes, patch)
2006-08-31 15:01 UTC, Chris Vine
none Details | Review
Further patch which tests for CLOCK_MONOTONIC (470 bytes, patch)
2006-09-03 21:48 UTC, Chris Vine
none Details | Review
build fix (313 bytes, patch)
2006-10-02 16:02 UTC, Jens Granseuer
none Details | Review

Description Chris Vine 2006-08-31 14:56:18 UTC
Please describe the problem:
glib-2.12.3 fails to compile if glibc does not define CLOCK_MONOTONIC (in my case, glibc 2.3.2).  It fails in glib/gtimer.c at line 96.

Steps to reproduce:
1. Attempt to compile glib-2.12.3 with a version of glibc which does not define CLOCK_MONOTONIC
2. 
3. 


Actual results:
Compilation fails in glib/gtimer.c

Expected results:
Compilation to complete successfully

Does this happen every time?
Yes

Other information:
Line 94 of glib/gtimer.c is extremely suspicious and is as follows:
#if !defined(_POSIX_MONOTONIC_CLOCK) || _POSIX_MONOTONIC_CLOCK >= 0
If it is changed to this:
#if defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0
then compilation proceeds correctly and glib appears to work.
Comment 1 Chris Vine 2006-08-31 15:01:51 UTC
Created attachment 71966 [details] [review]
Patch as described in bug report
Comment 2 Matthias Clasen 2006-08-31 18:37:57 UTC
I'm following the sysconf man page here:

       For options, typically, there is a  constant  _POSIX_FOO  that  may  be
       defined in <unistd.h>.  If it is undefined, one should ask at run-time.
       If it is defined to -1, then the option is not  supported.   If  it  is
       defined to 0, then relevant functions and headers exist, but one has to
       ask at runtime what degree of support is available.  If it  is  defined
       to  a  value  other than -1 or 0, then the option is supported.

We probably need to wrap this additionally in

#ifdef CLOCK_MONOTONIC
#endif

Comment 3 Chris Vine 2006-08-31 19:12:27 UTC
If _POSIX_MONOTIC_CLOCK is undefined, I doubt that CLOCK_MONOTONIC will ever be defined: it would be a bizarre set of headers which did this, even if the SUS were to allow it (looking at the SUS I am not clear whether this is allowed or not).  As not much depends on it anyway in this case, I would be inclined to ignore it.

In any event, if you are going to do something more on this you may want to remove the call to sysconf() where _POSIX_MONOTIC_CLOCK is defined to a value greater than 0, as it is redundant in that case.
Comment 4 Chris Vine 2006-09-03 21:48:43 UTC
Created attachment 72158 [details] [review]
Further patch which tests for CLOCK_MONOTONIC

This tests for CLOCK_MONOTONIC if you would like to go down that route.  It does not deal with the redundant call to sysconf where _POSIX_MONOTONIC_CLOCK is greater than 0, but you may not be too fussed about that.
Comment 5 Behdad Esfahbod 2006-09-15 17:21:25 UTC
*** Bug 356020 has been marked as a duplicate of this bug. ***
Comment 6 Guilherme de Siqueira Pastore 2006-09-17 15:47:36 UTC
*** Bug 354938 has been marked as a duplicate of this bug. ***
Comment 7 Matthias Clasen 2006-10-01 05:30:27 UTC
I think the current code handles CLOCK_MONOTONIC not being defined.
Comment 8 Jens Granseuer 2006-10-02 16:02:49 UTC
Created attachment 73855 [details] [review]
build fix

Not quite. This patch is needed for 2.12.4 to build correctly.
Comment 9 Jens Granseuer 2006-10-06 12:29:49 UTC
*** Bug 359683 has been marked as a duplicate of this bug. ***
Comment 10 Matthias Clasen 2006-10-08 20:01:42 UTC
Fixed in cvs.
Comment 11 Jens Granseuer 2006-12-04 14:26:42 UTC
*** Bug 376487 has been marked as a duplicate of this bug. ***
Comment 12 Jens Granseuer 2006-12-04 14:28:19 UTC
*** Bug 367894 has been marked as a duplicate of this bug. ***