#include "ntp_syslog.h"
#include "ntp_stdlib.h"
#include "ntp_random.h"
+#include "iosignal.h"
#include "timevalops.h"
#include "timespecops.h"
#include "ntp_calendar.h"
#else
# define DONE_SYSTIME_INIT() do {} while (FALSE)
#endif
+
+#ifdef HAVE_SIGNALED_IO
+int using_sigio;
+#endif
+
#ifdef SYS_WINNT
CRITICAL_SECTION get_systime_cs;
#endif
* fuzzed result is strictly later than the prior. Limit the
* necessary fiction to 1 second.
*/
- ts_min = add_tspec_ns(ts_prev, sys_fuzz_nsec);
- if (cmp_tspec(ts, ts_min) < 0) {
- ts_lam = sub_tspec(ts_min, ts);
- if (ts_lam.tv_sec > 0 && !lamport_violated) {
- msyslog(LOG_ERR,
- "get_systime Lamport advance exceeds one second (%.9f)",
- ts_lam.tv_sec + 1e-9 * ts_lam.tv_nsec);
- exit(1);
+ if (!USING_SIGIO()) {
+ ts_min = add_tspec_ns(ts_prev, sys_fuzz_nsec);
+ if (cmp_tspec(ts, ts_min) < 0) {
+ ts_lam = sub_tspec(ts_min, ts);
+ if (ts_lam.tv_sec > 0 && !lamport_violated) {
+ msyslog(LOG_ERR,
+ "get_systime Lamport advance exceeds one second (%.9f)",
+ ts_lam.tv_sec +
+ 1e-9 * ts_lam.tv_nsec);
+ exit(1);
+ }
+ if (!lamport_violated)
+ ts = ts_min;
}
- if (!lamport_violated)
- ts = ts_min;
+ ts_prev_log = ts_prev;
+ ts_prev = ts;
+ } else {
+ /*
+ * Quiet "ts_prev_log.tv_sec may be used uninitialized"
+ * warning from x86 gcc 4.5.2.
+ */
+ ZERO(ts_prev_log);
}
- ts_prev_log = ts_prev;
- ts_prev = ts;
/* convert from timespec to l_fp fixed-point */
result = tspec_stamp_to_lfp(ts);
* sys_residual's effect for now) once sys_fuzz has been
* determined.
*/
- if (!L_ISZERO(&lfp_prev) && !lamport_violated) {
- if (!L_ISGTU(&result, &lfp_prev) && sys_fuzz > 0.) {
- msyslog(LOG_ERR, "ts_min %s ts_prev %s ts %s",
- tspectoa(ts_min), tspectoa(ts_prev_log),
- tspectoa(ts));
- msyslog(LOG_ERR, "sys_fuzz %ld nsec, this fuzz %.9f, prior %.9f",
- sys_fuzz_nsec, dfuzz, dfuzz_prev);
- lfpdelta = lfp_prev;
- L_SUB(&lfpdelta, &result);
- LFPTOD(&lfpdelta, ddelta);
- msyslog(LOG_ERR,
- "get_systime prev result 0x%x.%08x is %.9f later than 0x%x.%08x",
- lfp_prev.l_ui, lfp_prev.l_uf,
- ddelta, result.l_ui, result.l_uf);
+ if (!USING_SIGIO()) {
+ if (!L_ISZERO(&lfp_prev) && !lamport_violated) {
+ if (!L_ISGTU(&result, &lfp_prev) &&
+ sys_fuzz > 0.) {
+ msyslog(LOG_ERR, "ts_prev %s ts_min %s",
+ tspectoa(ts_prev_log),
+ tspectoa(ts_min));
+ msyslog(LOG_ERR, "ts %s", tspectoa(ts));
+ msyslog(LOG_ERR, "sys_fuzz %ld nsec, prior fuzz %.9f",
+ sys_fuzz_nsec, dfuzz_prev);
+ msyslog(LOG_ERR, "this fuzz %.9f",
+ dfuzz);
+ lfpdelta = lfp_prev;
+ L_SUB(&lfpdelta, &result);
+ LFPTOD(&lfpdelta, ddelta);
+ msyslog(LOG_ERR,
+ "prev get_systime 0x%x.%08x is %.9f later than 0x%x.%08x",
+ lfp_prev.l_ui, lfp_prev.l_uf,
+ ddelta, result.l_ui, result.l_uf);
+ }
}
+ lfp_prev = result;
+ dfuzz_prev = dfuzz;
+ if (lamport_violated)
+ lamport_violated = FALSE;
}
- lfp_prev = result;
- dfuzz_prev = dfuzz;
- if (lamport_violated)
- lamport_violated = FALSE;
-
LEAVE_GET_SYSTIME_CRITSEC();
*now = result;
}