xref: /freebsd/contrib/ntp/include/ntp_syscall.h (revision 224ba2bd37e182b64f7d78defef8a6cacaad3415)
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 #ifdef NTP_API
40 # if NTP_API > 3
41 	ntv->tai = tntx.tai;
42 # endif
43 #endif
44 	return(result);
45 }
46 # else /* !HAVE__ADJTIMEX */
47 #  ifdef HAVE___NTP_GETTIME
48 #   define ntp_gettime(t)	__ntp_gettime((t))
49 #  endif
50 # endif /* !HAVE_ADJTIMEX */
51 #endif /* !NTP_SYSCALLS_STD */
52 
53 #endif /* NTP_SYSCALL_H */
54