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
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;
tp->tv_usec = ts.tv_nsec / 1000;
return 0;
#else
-
if (!posix_clock_set) {
logger(LOG_WARNING, NO_MONOTONIC);
posix_clock_set = 1;