1999-12-09 13:01:21 +00:00
|
|
|
/*
|
|
|
|
* ntp_syscall.h - various ways to perform the ntp_adjtime() and ntp_gettime()
|
|
|
|
* system calls.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef NTP_SYSCALL_H
|
|
|
|
#define NTP_SYSCALL_H
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TIMEX_H
|
|
|
|
# include <sys/timex.h>
|
|
|
|
#endif
|
|
|
|
|
2002-11-04 19:36:11 +00:00
|
|
|
#ifndef NTP_SYSCALLS_LIBC
|
2014-12-20 22:52:39 +00:00
|
|
|
# ifdef NTP_SYSCALLS_STD
|
|
|
|
# define ntp_adjtime(t) syscall(SYS_ntp_adjtime, (t))
|
|
|
|
# define ntp_gettime(t) syscall(SYS_ntp_gettime, (t))
|
|
|
|
# else /* !NTP_SYSCALLS_STD */
|
|
|
|
# ifdef HAVE_NTP_ADJTIME
|
|
|
|
extern int ntp_adjtime (struct timex *);
|
|
|
|
|
|
|
|
# ifndef HAVE_STRUCT_NTPTIMEVAL
|
2013-12-04 21:33:17 +00:00
|
|
|
struct ntptimeval
|
|
|
|
{
|
2014-12-20 22:52:39 +00:00
|
|
|
struct timeval time; /* current time (ro) */
|
|
|
|
long int maxerror; /* maximum error (us) (ro) */
|
|
|
|
long int esterror; /* estimated error (us) (ro) */
|
2013-12-04 21:33:17 +00:00
|
|
|
};
|
2014-12-20 22:52:39 +00:00
|
|
|
# endif
|
2013-12-04 21:33:17 +00:00
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
# ifndef HAVE_NTP_GETTIME
|
1999-12-09 13:01:21 +00:00
|
|
|
static inline int
|
|
|
|
ntp_gettime(
|
|
|
|
struct ntptimeval *ntv
|
|
|
|
)
|
|
|
|
{
|
|
|
|
struct timex tntx;
|
|
|
|
int result;
|
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
ZERO(tntx);
|
|
|
|
result = ntp_adjtime(&tntx);
|
1999-12-09 13:01:21 +00:00
|
|
|
ntv->time = tntx.time;
|
|
|
|
ntv->maxerror = tntx.maxerror;
|
|
|
|
ntv->esterror = tntx.esterror;
|
2014-12-20 22:52:39 +00:00
|
|
|
# ifdef NTP_API
|
|
|
|
# if NTP_API > 3
|
2001-08-29 14:35:15 +00:00
|
|
|
ntv->tai = tntx.tai;
|
2014-12-20 22:52:39 +00:00
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
return result;
|
1999-12-09 13:01:21 +00:00
|
|
|
}
|
2014-12-20 22:52:39 +00:00
|
|
|
# endif /* !HAVE_NTP_GETTIME */
|
|
|
|
# endif /* !HAVE_NTP_ADJTIME */
|
|
|
|
# endif /* !NTP_SYSCALLS_STD */
|
|
|
|
#endif /* !NTP_SYSCALLS_LIBC */
|
1999-12-09 13:01:21 +00:00
|
|
|
|
2014-12-20 22:52:39 +00:00
|
|
|
#endif /* NTP_SYSCALL_H */
|