#include <sys/ioctl.h>
#include <sys/time.h>
#include <sys/file.h>
-#include <sgtty.h>
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#else
+# ifdef HAVE_SGTTY_H
+# include <sgtty.h>
+# endif
+#endif
#include "ntp_fp.h"
#include "ntp.h"
#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
#ifdef CHULDISC
# ifdef HAVE_SYS_CHUDEFS_H
int openterm(char *dev);
int process_raw(int s);
int process_ldisc(int s);
-int raw_filter(unsigned int c, struct timeval *tv);
+void raw_filter(unsigned int c, struct timeval *tv);
void chufilter(struct chucode *chuc, l_fp *rtime);
/*
* raw_filter - run the line discipline filter over raw data
*/
-int
+void
raw_filter(
unsigned int c,
struct timeval *tv
* work most of the time.
*/
date_ui = tmp + yearstart;
-#define CLOCK_WAYTOOBIG (4 * 60 * 60) /* WAG Juergen please review */
+#define CLOCK_WAYTOOBIG 1000 /* revived from ancient sources */
if (date_ui < (rtime->l_ui + CLOCK_WAYTOOBIG)
&& date_ui > (rtime->l_ui - CLOCK_WAYTOOBIG))
goto codeokay; /* looks good */
* Trouble. Next check is to see if the year rolled over and, if
* so, try again with the new year's start.
*/
- date_ui = calyearstart(rtime->l_ui);
+ date_ui = calyearstart(rtime->l_ui, NULL);
if (date_ui != yearstart) {
yearstart = date_ui;
date_ui += tmp;
* than CLOCK_WAYTOOBIG seconds into the new year.
*/
if ((rtime->l_ui - yearstart) < CLOCK_WAYTOOBIG) {
- date_ui = tmp + calyearstart(yearstart - CLOCK_WAYTOOBIG);
+ date_ui = tmp;
+ date_ui += calyearstart(yearstart - CLOCK_WAYTOOBIG,
+ NULL);
if ((rtime->l_ui - date_ui) < CLOCK_WAYTOOBIG)
goto codeokay;
}
* following the year the system is in. Try this one before
* giving up.
*/
- date_ui = tmp + calyearstart(yearstart + (400*24*60*60)); /* 400 days */
+ date_ui = tmp;
+ date_ui += calyearstart(yearstart + (400 * SECSPERDAY),
+ NULL);
if ((date_ui - rtime->l_ui) >= CLOCK_WAYTOOBIG) {
printf("Date hopelessly off\n");
return; /* hopeless, let it sync to other peers */
# Checks for header files.
AC_HEADER_STDC
+dnl HP-UX 11.31 on HPPA has a net/if.h that can't be compiled with gcc4
+dnl due to an incomplete type (a union) mpinfou used in an array. gcc3
+dnl compiles it without complaint. The mpinfou union is defined later
+dnl in the resulting preprocessed source than the spu_info array in
+dnl /usr/include/machine/sys/getppdp.h:
+dnl extern union mpinfou spu_info[];
+dnl triggering the error. Our strategy is on HP-UX only, test compile
+dnl net/if.h. If that fails, try adding a duplicate definition of
+dnl mpinfou, and if that helps add it to confdefs.h (used for further
+dnl configure tests) and config.h.
+#
+AC_CHECK_HEADERS([net/if.h], [], [], [
+ #ifdef HAVE_SYS_SOCKET_H
+ # include <sys/socket.h>
+ #endif
+])
+case "$host" in
+ *-hp-hpux*)
+ AC_CACHE_CHECK(
+ [if net/if.h requires mpinfou predeclaration],
+ [ntp_cv_predecl_mpinfou],
+ [
+ np_cv_predecl_mpinfou=no
+ case "$ac_cv_header_net_if_h" in
+ no)
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[
+ typedef union mpinfou {
+ struct pdk_mpinfo *pdkptr;
+ struct mpinfo *pikptr;
+ } mpinfou_t;
+ #ifdef HAVE_SYS_SOCKET_H
+ # include <sys/socket.h>
+ #endif
+ #include <net/if.h>
+ ]],
+ [[
+ ]]
+ )],
+ [
+ ntp_cv_predecl_mpinfou=yes
+ ac_cv_header_net_if_h=yes
+ ]
+ )
+ esac
+ ]
+ )
+ case "$ntp_cv_predecl_mpinfou" in
+ yes)
+ cat >>confdefs.h <<_ACEOF
+#ifndef MPINFOU_PREDECLARED
+# define MPINFOU_PREDECLARED
+typedef union mpinfou {
+ struct pdk_mpinfo *pdkptr;
+ struct mpinfo *pikptr;
+} mpinfou_t;
+#endif
+_ACEOF
+ AH_BOTTOM([
+#ifndef MPINFOU_PREDECLARED
+# define MPINFOU_PREDECLARED
+typedef union mpinfou {
+ struct pdk_mpinfo *pdkptr;
+ struct mpinfo *pikptr;
+} mpinfou_t;
+#endif
+])
+ esac
+esac
+
AC_CHECK_HEADERS([netdb.h netinet/in.h stdlib.h string.h strings.h syslog.h])
AC_CHECK_HEADERS([sys/socket.h sys/time.h])
AC_HEADER_TIME