]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Brute force detection of monotonic clock as sysconf is unreliable. Instead rely on...
authorRoy Marples <roy@marples.name>
Fri, 1 Aug 2008 13:15:11 +0000 (13:15 +0000)
committerRoy Marples <roy@marples.name>
Fri, 1 Aug 2008 13:15:11 +0000 (13:15 +0000)
README
common.c

diff --git a/README b/README
index ef7e78420add22adfacd80f06ae9bf2aee2714d5..b3550c13fd2cb404ae65a2aefba631fb047dbdd0 100644 (file)
--- a/README
+++ b/README
@@ -18,15 +18,6 @@ OS=BSD | Linux
 If you're building for an MMU-less system where fork() does not work, you
 should add -DTHERE_IS_NO_FORK to your CPPFLAGS.
 
-dhcpcd will try and use a monotonic clock when possible.
-Some libc implementations do not correctly report that they have a monotonic
-clock, but they have the headers to make it work. dhcpcd will warn about this.
-Without a monotonic clock, we fall victim of the year 2038 time_t bug on
-32-bit platforms AND the timers will be sufer from clock skew if the system
-clock changes.
-To force the use of a monotonic clock you can add -DFORCE_MONOTONIC
-to your CPPFLAGS.
-
 You can change the default dir with these knobs.
 For example, to satisfy FHS compliance you would do this:-
 LIBEXECDIR=/lib/dhcpcd
index 9bedc6de28aeb4107e95743046192da875dc0864..55e4e5ff1da49cfbea22e90e510e49c90675dbf6 100644 (file)
--- a/common.c
+++ b/common.c
@@ -193,25 +193,16 @@ get_monotonic(struct timeval *tp)
        struct timespec ts;
        static clockid_t posix_clock;
 
-#ifdef FORCE_MONOTONIC
        if (!posix_clock_set) {
-               posix_clock = CLOCK_MONOTONIC;
-               posix_clock_set = 1;
-               clock_monotonic = 1;
-       }
-#else
-       if (!posix_clock_set) {
-               if (sysconf(_SC_MONOTONIC_CLOCK) >= 0) {
+               if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
                        posix_clock = CLOCK_MONOTONIC;
                        clock_monotonic = 1;
                } else {
                        posix_clock = CLOCK_REALTIME;
                        logger(LOG_WARNING, NO_MONOTONIC);
                }
-
                posix_clock_set = 1;
        }
-#endif
 
        if (clock_gettime(posix_clock, &ts) == -1)
                return -1;
@@ -220,7 +211,6 @@ get_monotonic(struct timeval *tp)
        tp->tv_usec = ts.tv_nsec / 1000;
        return 0;
 #else
-
        if (!posix_clock_set) {
                logger(LOG_WARNING, NO_MONOTONIC);
                posix_clock_set = 1;