]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ntp/include/timexsup.h
Fix multiple denial of service in ntpd.
[FreeBSD/FreeBSD.git] / contrib / ntp / include / timexsup.h
1 /*
2  * timexsup.h - 'struct timex' support functions
3  *
4  * Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
5  * The contents of 'html/copyright.html' apply.
6  */
7 #ifndef TIMEXSUP_H
8 #define TIMEXSUP_H
9
10
11 /* convert a 'long' time value (in usec or nsec) into seconds, expressed
12  * as a 'double'. If 'STA_NANO' is not defined, this will always convert
13  * from usec. ('STA_NANO' is Linux specific at the time of this
14  * writing.)
15  *
16  * If 'STA_NANO' is defined, it will be checked in 'status' to decide
17  * which time base (usec or nsec) applies for this conversion.
18  */
19 extern double dbl_from_var_long(long lval, int status);
20
21 /* convert a 'long' time value in usec into seconds, expressed as
22  * 'double'.  This function is there for pure symmetry right now -- it
23  * just casts and scales without any additional bells and whistles.
24  */ 
25 extern double dbl_from_usec_long(long lval);
26
27 /* If MOD_NANO is defined, set the MOD_NANO bit in '*modes' and
28  * calculate the time stamp in nsec; otherwise, calculate the result in
29  * usec.
30  *
31  * Applies proper bounds checks and saturation on LONG_MAX/LONG_MIN to
32  * avoid undefined behaviour.
33  */
34 extern long var_long_from_dbl(double dval, unsigned int *modes);
35
36 /* convert a 'double' time value (in seconds) into usec with proper
37  * bounds check and range clamp.
38  */
39 extern long usec_long_from_dbl(double dval);
40
41 #endif
42 /* -*- that's all folks -*- */