Annotation of embedaddon/ntp/include/ntp_syscall.h, revision 1.1.1.1

1.1       misho       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
                     23: extern int     __adjtimex      (struct timex *);
                     24: 
                     25: #  define ntp_adjtime(t)       __adjtimex((t))
                     26: 
                     27: #ifndef HAVE_STRUCT_NTPTIMEVAL
                     28: struct ntptimeval
                     29: {
                     30:   struct timeval time;  /* current time (ro) */
                     31:   long int maxerror;    /* maximum error (us) (ro) */
                     32:   long int esterror;    /* estimated error (us) (ro) */
                     33: };
                     34: #endif
                     35: 
                     36: static inline int
                     37: ntp_gettime(
                     38:        struct ntptimeval *ntv
                     39:        )
                     40: {
                     41:        struct timex tntx;
                     42:        int result;
                     43: 
                     44:        tntx.modes = 0;
                     45:        result = __adjtimex (&tntx);
                     46:        ntv->time = tntx.time;
                     47:        ntv->maxerror = tntx.maxerror;
                     48:        ntv->esterror = tntx.esterror;
                     49: #ifdef NTP_API
                     50: # if NTP_API > 3
                     51:        ntv->tai = tntx.tai;
                     52: # endif
                     53: #endif
                     54:        return(result);
                     55: }
                     56: # else /* !HAVE__ADJTIMEX */
                     57: #  ifdef HAVE___NTP_GETTIME
                     58: #   define ntp_gettime(t)      __ntp_gettime((t))
                     59: #  endif
                     60: # endif /* !HAVE_ADJTIMEX */
                     61: #endif /* !NTP_SYSCALLS_STD */
                     62: #endif /* !NTP_SYSCALLS_LIBC */
                     63: 
                     64: #endif /* NTP_SYSCALL_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>