PageRenderTime 23ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/ntp/include/ntp_syscall.h

https://bitbucket.org/freebsd/freebsd-head/
C++ Header | 55 lines | 43 code | 8 blank | 4 comment | 2 complexity | cf5a15fb5666934569b01c94ba2f0d18 MD5 | raw file
 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#ifndef NTP_SYSCALLS_LIBC
18#ifdef NTP_SYSCALLS_STD
19# define ntp_adjtime(t)		syscall(SYS_ntp_adjtime, (t))
20# define ntp_gettime(t)		syscall(SYS_ntp_gettime, (t))
21#else /* !NTP_SYSCALLS_STD */
22# ifdef HAVE___ADJTIMEX
23extern	int	__adjtimex	P((struct timex *));
24
25#  define ntp_adjtime(t)	__adjtimex((t))
26
27static inline int
28ntp_gettime(
29	struct ntptimeval *ntv
30	)
31{
32	struct timex tntx;
33	int result;
34
35	tntx.modes = 0;
36	result = __adjtimex (&tntx);
37	ntv->time = tntx.time;
38	ntv->maxerror = tntx.maxerror;
39	ntv->esterror = tntx.esterror;
40#ifdef NTP_API
41# if NTP_API > 3
42	ntv->tai = tntx.tai;
43# endif
44#endif
45	return(result);
46}
47# else /* !HAVE__ADJTIMEX */
48#  ifdef HAVE___NTP_GETTIME
49#   define ntp_gettime(t)	__ntp_gettime((t))
50#  endif
51# endif /* !HAVE_ADJTIMEX */
52#endif /* !NTP_SYSCALLS_STD */
53#endif /* !NTP_SYSCALLS_LIBC */
54
55#endif /* NTP_SYSCALL_H */