1/* $NetBSD$ */ 2 3/* 4 * ntp_syscall.h - various ways to perform the ntp_adjtime() and ntp_gettime() 5 * system calls. 6 */ 7 8#ifndef NTP_SYSCALL_H 9#define NTP_SYSCALL_H 10 11#ifdef HAVE_CONFIG_H 12#include <config.h> 13#endif 14 15#ifdef HAVE_SYS_TIMEX_H 16# include <sys/timex.h> 17#endif 18 19#ifndef NTP_SYSCALLS_LIBC 20#ifdef NTP_SYSCALLS_STD 21# define ntp_adjtime(t) syscall(SYS_ntp_adjtime, (t)) 22# define ntp_gettime(t) syscall(SYS_ntp_gettime, (t)) 23#else /* !NTP_SYSCALLS_STD */ 24# ifdef HAVE___ADJTIMEX 25extern int __adjtimex (struct timex *); 26 27# define ntp_adjtime(t) __adjtimex((t)) 28 29#ifndef HAVE_STRUCT_NTPTIMEVAL 30struct ntptimeval 31{ 32 struct timeval time; /* current time (ro) */ 33 long int maxerror; /* maximum error (us) (ro) */ 34 long int esterror; /* estimated error (us) (ro) */ 35}; 36#endif 37 38static inline int 39ntp_gettime( 40 struct ntptimeval *ntv 41 ) 42{ 43 struct timex tntx; 44 int result; 45 46 tntx.modes = 0; 47 result = __adjtimex (&tntx); 48 ntv->time = tntx.time; 49 ntv->maxerror = tntx.maxerror; 50 ntv->esterror = tntx.esterror; 51#ifdef NTP_API 52# if NTP_API > 3 53 ntv->tai = tntx.tai; 54# endif 55#endif 56 return(result); 57} 58# else /* !HAVE__ADJTIMEX */ 59# ifdef HAVE___NTP_GETTIME 60# define ntp_gettime(t) __ntp_gettime((t)) 61# endif 62# endif /* !HAVE_ADJTIMEX */ 63#endif /* !NTP_SYSCALLS_STD */ 64#endif /* !NTP_SYSCALLS_LIBC */ 65 66#endif /* NTP_SYSCALL_H */ 67