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