003 File Manager
Current Path:
/usr/src/contrib/ntp/include
usr
/
src
/
contrib
/
ntp
/
include
/
📁
..
📄
Makefile.am
(1.2 KB)
📄
Makefile.in
(24.68 KB)
📄
README
(157 B)
📄
adjtime.h
(1.96 KB)
📄
ascii.h
(2.78 KB)
📄
audio.h
(283 B)
📄
binio.h
(3.26 KB)
📄
declcond.h
(803 B)
📄
gps.h
(2.84 KB)
📄
hopf6039.h
(3.51 KB)
📄
icom.h
(2.33 KB)
📄
ieee754io.h
(2.94 KB)
📄
intreswork.h
(808 B)
📄
iosignal.h
(1.46 KB)
📁
isc
📄
l_stdlib.h
(4.8 KB)
📄
lib_strbuf.h
(674 B)
📄
libntp.h
(436 B)
📄
libssl_compat.h
(4.25 KB)
📄
mbg_gps166.h
(36.84 KB)
📄
mx4200.h
(2.15 KB)
📄
ntif.h
(2.86 KB)
📄
ntp.h
(33.52 KB)
📄
ntp_assert.h
(2.73 KB)
📄
ntp_calendar.h
(14.99 KB)
📄
ntp_calgps.h
(4.02 KB)
📄
ntp_cmdargs.h
(38 B)
📄
ntp_config.h
(8.33 KB)
📄
ntp_control.h
(5.66 KB)
📄
ntp_crypto.h
(6.61 KB)
📄
ntp_datum.h
(1.07 KB)
📄
ntp_debug.h
(635 B)
📄
ntp_filegen.h
(1.76 KB)
📄
ntp_fp.h
(13.37 KB)
📄
ntp_if.h
(651 B)
📄
ntp_intres.h
(1.77 KB)
📄
ntp_io.h
(1.82 KB)
📄
ntp_keyacc.h
(658 B)
📄
ntp_libopts.h
(330 B)
📄
ntp_lineedit.h
(251 B)
📄
ntp_lists.h
(12.09 KB)
📄
ntp_machine.h
(7.18 KB)
📄
ntp_malloc.h
(1.18 KB)
📄
ntp_md5.h
(1.32 KB)
📄
ntp_net.h
(6.61 KB)
📄
ntp_prio_q.h
(1.93 KB)
📄
ntp_proto.h
(95 B)
📄
ntp_psl.h
(342 B)
📄
ntp_random.h
(402 B)
📄
ntp_refclock.h
(7.81 KB)
📄
ntp_request.h
(30.83 KB)
📄
ntp_rfc2553.h
(8.46 KB)
📄
ntp_select.h
(1.02 KB)
📄
ntp_stdlib.h
(9.83 KB)
📄
ntp_string.h
(708 B)
📄
ntp_syscall.h
(1.17 KB)
📄
ntp_syslog.h
(2.94 KB)
📄
ntp_tty.h
(2.61 KB)
📄
ntp_types.h
(7.21 KB)
📄
ntp_unixtime.h
(1.6 KB)
📄
ntp_worker.h
(5.54 KB)
📄
ntp_workimpl.h
(749 B)
📄
ntpd.h
(20.67 KB)
📄
ntpsim.h
(3.85 KB)
📄
parse.h
(14.58 KB)
📄
parse_conf.h
(2.76 KB)
📄
rc_cmdlength.h
(83 B)
📄
recvbuff.h
(3.84 KB)
📄
refclock_atom.h
(449 B)
📄
refidsmear.h
(89 B)
📄
safecast.h
(1.04 KB)
📄
ssl_applink.c
(2.1 KB)
📄
timepps-SCO.h
(11.67 KB)
📄
timepps-Solaris.h
(13.24 KB)
📄
timepps-SunOS.h
(11.78 KB)
📄
timespecops.h
(4.82 KB)
📄
timetoa.h
(2.62 KB)
📄
timevalops.h
(8.33 KB)
📄
timexsup.h
(1.37 KB)
📄
trimble.h
(8.01 KB)
📄
vint64ops.h
(1.05 KB)
Editing: timespecops.h
/* * timespecops.h -- calculations on 'struct timespec' values * * Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project. * The contents of 'html/copyright.html' apply. * * Rationale * --------- * * Doing basic arithmetic on a 'struct timespec' is not exceedingly * hard, but it requires tedious and repetitive code to keep the result * normalised. We consider a timespec normalised when the nanosecond * fraction is in the interval [0 .. 10^9[ ; there are multiple value * pairs of seconds and nanoseconds that denote the same time interval, * but the normalised representation is unique. No two different * intervals can have the same normalised representation. * * Another topic is the representation of negative time intervals. * There's more than one way to this, since both the seconds and the * nanoseconds of a timespec are signed values. IMHO, the easiest way is * to use a complement representation where the nanoseconds are still * normalised, no matter what the sign of the seconds value. This makes * normalisation easier, since the sign of the integer part is * irrelevant, and it removes several sign decision cases during the * calculations. * * As long as no signed integer overflow can occur with the nanosecond * part of the operands, all operations work as expected and produce a * normalised result. * * The exception to this are functions fix a '_fast' suffix, which do no * normalisation on input data and therefore expect the input data to be * normalised. * * Input and output operands may overlap; all input is consumed before * the output is written to. */ #ifndef TIMESPECOPS_H #define TIMESPECOPS_H #include <sys/types.h> #include <stdio.h> #include <math.h> #include "ntp.h" #include "timetoa.h" /* nanoseconds per second */ #define NANOSECONDS 1000000000 /* predicate: returns TRUE if the nanoseconds are in nominal range */ #define timespec_isnormal(x) \ ((x)->tv_nsec >= 0 && (x)->tv_nsec < NANOSECONDS) /* predicate: returns TRUE if the nanoseconds are out-of-bounds */ #define timespec_isdenormal(x) (!timespec_isnormal(x)) /* make sure nanoseconds are in nominal range */ extern struct timespec normalize_tspec(struct timespec x); /* x = a + b */ static inline struct timespec add_tspec( struct timespec a, struct timespec b ) { struct timespec x; x = a; x.tv_sec += b.tv_sec; x.tv_nsec += b.tv_nsec; return normalize_tspec(x); } /* x = a + b, b is fraction only */ static inline struct timespec add_tspec_ns( struct timespec a, long b ) { struct timespec x; x = a; x.tv_nsec += b; return normalize_tspec(x); } /* x = a - b */ static inline struct timespec sub_tspec( struct timespec a, struct timespec b ) { struct timespec x; x = a; x.tv_sec -= b.tv_sec; x.tv_nsec -= b.tv_nsec; return normalize_tspec(x); } /* x = a - b, b is fraction only */ static inline struct timespec sub_tspec_ns( struct timespec a, long b ) { struct timespec x; x = a; x.tv_nsec -= b; return normalize_tspec(x); } /* x = -a */ static inline struct timespec neg_tspec( struct timespec a ) { struct timespec x; x.tv_sec = -a.tv_sec; x.tv_nsec = -a.tv_nsec; return normalize_tspec(x); } /* x = abs(a) */ struct timespec abs_tspec(struct timespec a); /* * compare previously-normalised a and b * return 1 / 0 / -1 if a < / == / > b */ extern int cmp_tspec(struct timespec a, struct timespec b); /* * compare possibly-denormal a and b * return 1 / 0 / -1 if a < / == / > b */ static inline int cmp_tspec_denorm( struct timespec a, struct timespec b ) { return cmp_tspec(normalize_tspec(a), normalize_tspec(b)); } /* * test previously-normalised a * return 1 / 0 / -1 if a < / == / > 0 */ extern int test_tspec(struct timespec a); /* * test possibly-denormal a * return 1 / 0 / -1 if a < / == / > 0 */ static inline int test_tspec_denorm( struct timespec a ) { return test_tspec(normalize_tspec(a)); } /* return LIB buffer ptr to string rep */ static inline const char * tspectoa( struct timespec x ) { return format_time_fraction(x.tv_sec, x.tv_nsec, 9); } /* * convert to l_fp type, relative and absolute */ /* convert from timespec duration to l_fp duration */ extern l_fp tspec_intv_to_lfp(struct timespec x); /* x must be UN*X epoch, output will be in NTP epoch */ static inline l_fp tspec_stamp_to_lfp( struct timespec x ) { l_fp y; y = tspec_intv_to_lfp(x); y.l_ui += JAN_1970; return y; } /* convert from l_fp type, relative signed/unsigned and absolute */ extern struct timespec lfp_intv_to_tspec(l_fp x); extern struct timespec lfp_uintv_to_tspec(l_fp x); /* * absolute (timestamp) conversion. Input is time in NTP epoch, output * is in UN*X epoch. The NTP time stamp will be expanded around the * pivot time *p or the current time, if p is NULL. */ extern struct timespec lfp_stamp_to_tspec(l_fp x, const time_t *pivot); #endif /* TIMESPECOPS_H */
Upload File
Create Folder