[svn] Check that _POSIX_CLOCK_MONOTONIC >= 0 before using it.

This commit is contained in:
hniksic 2005-04-07 16:38:08 -07:00
parent fbea09290b
commit c159a45df1
2 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,8 @@
2005-04-08 Hrvoje Niksic <hniksic@xemacs.org> 2005-04-08 Hrvoje Niksic <hniksic@xemacs.org>
* ptimer.c (ptimer_init): In fact, _POSIX_MONOTONIC_CLOCK needs to
be >= 0.
* ptimer.c (ptimer_init): Check whether _POSIX_MONOTONIC_CLOCK is * ptimer.c (ptimer_init): Check whether _POSIX_MONOTONIC_CLOCK is
defined instead of whether it's greater than 0. glibc defines it defined instead of whether it's greater than 0. glibc defines it
to 0, but still makes it available via sysconf. to 0, but still makes it available via sysconf.

View File

@ -183,7 +183,7 @@ ptimer_init (void)
{ {
struct timespec res; struct timespec res;
#ifdef _POSIX_MONOTONIC_CLOCK #if _POSIX_MONOTONIC_CLOCK >= 0 /* -1 means not supported */
if (sysconf (_SC_MONOTONIC_CLOCK) > 0) if (sysconf (_SC_MONOTONIC_CLOCK) > 0)
posix_clock_id = CLOCK_MONOTONIC; posix_clock_id = CLOCK_MONOTONIC;
else else