xref: /freebsd/contrib/ntp/include/ntp_syscall.h (revision daf1cffce2e07931f27c6c6998652e90df6ba87e)
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_CONFIG_H
10 #include <config.h>
11 #endif
12 
13 #ifdef HAVE_SYS_TIMEX_H
14 # include <sys/timex.h>
15 #endif
16 
17 #ifdef NTP_SYSCALLS_STD
18 # define ntp_adjtime(t)		syscall(SYS_ntp_adjtime, (t))
19 # define ntp_gettime(t)		syscall(SYS_ntp_gettime, (t))
20 #else /* !NTP_SYSCALLS_STD */
21 # ifdef HAVE___ADJTIMEX
22 extern	int	__adjtimex	P((struct timex *));
23 
24 #  define ntp_adjtime(t)	__adjtimex((t))
25 
26 static inline int
27 ntp_gettime(
28 	struct ntptimeval *ntv
29 	)
30 {
31 	struct timex tntx;
32 	int result;
33 
34 	tntx.modes = 0;
35 	result = __adjtimex (&tntx);
36 	ntv->time = tntx.time;
37 	ntv->maxerror = tntx.maxerror;
38 	ntv->esterror = tntx.esterror;
39 	return(result);
40 }
41 # else /* !HAVE__ADJTIMEX */
42 #  ifdef HAVE___NTP_GETTIME
43 #   define ntp_gettime(t)	__ntp_gettime((t))
44 #  endif
45 # endif /* !HAVE_ADJTIMEX */
46 #endif /* !NTP_SYSCALLS_STD */
47 
48 #endif /* NTP_SYSCALL_H */
49