2 * timexsup.h - 'struct timex' support functions
4 * Written by Juergen Perlinger (perlinger@ntp.org) for the NTP project.
5 * The contents of 'html/copyright.html' apply.
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
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.
19 extern double dbl_from_var_long(long lval, int status);
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.
25 extern double dbl_from_usec_long(long lval);
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
31 * Applies proper bounds checks and saturation on LONG_MAX/LONG_MIN to
32 * avoid undefined behaviour.
34 extern long var_long_from_dbl(double dval, unsigned int *modes);
36 /* convert a 'double' time value (in seconds) into usec with proper
37 * bounds check and range clamp.
39 extern long usec_long_from_dbl(double dval);
42 /* -*- that's all folks -*- */