1c0b746e5SOllivier Robert /* 2*2b15cb3dSCy Schubert * ntp_unixtime.h - much of what was here is now in timevalops.h 3c0b746e5SOllivier Robert */ 4c0b746e5SOllivier Robert 5*2b15cb3dSCy Schubert #ifndef NTP_UNIXTIME_H 6*2b15cb3dSCy Schubert #define NTP_UNIXTIME_H 7c0b746e5SOllivier Robert 8*2b15cb3dSCy Schubert #include "ntp_types.h" /* picks up time.h via ntp_machine.h */ 9*2b15cb3dSCy Schubert #include "ntp_calendar.h" 109c2daa00SOllivier Robert 119c2daa00SOllivier Robert #ifdef SIM 129c2daa00SOllivier Robert # define GETTIMEOFDAY(a, b) (node_gettime(&ntp_node, a)) 139c2daa00SOllivier Robert # define SETTIMEOFDAY(a, b) (node_settime(&ntp_node, a)) 149c2daa00SOllivier Robert # define ADJTIMEOFDAY(a, b) (node_adjtime(&ntp_node, a, b)) 159c2daa00SOllivier Robert #else 169c2daa00SOllivier Robert # define ADJTIMEOFDAY(a, b) (adjtime(a, b)) 17c0b746e5SOllivier Robert /* gettimeofday() takes two args in BSD and only one in SYSV */ 18c0b746e5SOllivier Robert # if defined(HAVE_SYS_TIMERS_H) && defined(HAVE_GETCLOCK) 19c0b746e5SOllivier Robert # include <sys/timers.h> 20c0b746e5SOllivier Robert int getclock (int clock_type, struct timespec *tp); 21*2b15cb3dSCy Schubert # define GETTIMEOFDAY(a, b) (gettimeofday(a, b)) 22c0b746e5SOllivier Robert # define SETTIMEOFDAY(a, b) (settimeofday(a, b)) 23c0b746e5SOllivier Robert # else /* not (HAVE_SYS_TIMERS_H && HAVE_GETCLOCK) */ 24c0b746e5SOllivier Robert # ifdef SYSV_TIMEOFDAY 25c0b746e5SOllivier Robert # define GETTIMEOFDAY(a, b) (gettimeofday(a)) 26c0b746e5SOllivier Robert # define SETTIMEOFDAY(a, b) (settimeofday(a)) 27c0b746e5SOllivier Robert # else /* ! SYSV_TIMEOFDAY */ 28c0b746e5SOllivier Robert #if defined SYS_CYGWIN32 29c0b746e5SOllivier Robert # define GETTIMEOFDAY(a, b) (gettimeofday(a, b)) 30c0b746e5SOllivier Robert # define SETTIMEOFDAY(a, b) (settimeofday_NT(a)) 31c0b746e5SOllivier Robert #else 32c0b746e5SOllivier Robert # define GETTIMEOFDAY(a, b) (gettimeofday(a, b)) 33c0b746e5SOllivier Robert # define SETTIMEOFDAY(a, b) (settimeofday(a, b)) 34c0b746e5SOllivier Robert #endif 35c0b746e5SOllivier Robert # endif /* SYSV_TIMEOFDAY */ 36c0b746e5SOllivier Robert # endif /* not (HAVE_SYS_TIMERS_H && HAVE_GETCLOCK) */ 379c2daa00SOllivier Robert #endif /* SIM */ 38c0b746e5SOllivier Robert 39c0b746e5SOllivier Robert /* 40c0b746e5SOllivier Robert * Time of day conversion constant. Ntp's time scale starts in 1900, 41*2b15cb3dSCy Schubert * Unix in 1970. The value is 1970 - 1900 in seconds, 0x83aa7e80 or 42*2b15cb3dSCy Schubert * 2208988800. This is larger than 32-bit INT_MAX, so unsigned 43*2b15cb3dSCy Schubert * type is forced. 44c0b746e5SOllivier Robert */ 45*2b15cb3dSCy Schubert #define JAN_1970 ((u_int)NTP_TO_UNIX_DAYS * (u_int)SECSPERDAY) 46c0b746e5SOllivier Robert 47*2b15cb3dSCy Schubert #endif /* !defined(NTP_UNIXTIME_H) */ 48