/* ISC license. */ /* MT-unsafe */ #include #ifdef SKALIBS_HASCLOCKRT #include #include int sysclock_set (tain_t const *a) { struct timespec now ; tain_t aa ; tain_add(&aa, a, &tain_nano500) ; if (!timespec_from_tain(&now, &aa)) return 0 ; if (clock_settime(CLOCK_REALTIME, &now) < 0) return 0 ; return 1 ; } #else #ifdef SKALIBS_HASSETTIMEOFDAY #include #include #include int sysclock_set (tain_t const *a) { struct timeval now ; tain_t aa ; tain_add(&aa, a, &tain_nano500) ; if (!timeval_from_tain(&now, &aa)) return 0 ; if (settimeofday(&now, 0) < 0) return 0 ; return 1 ; } #else #error "neither clockrt nor settimeofday sysdeps are present. How do your set your system clock?" #endif #endif