]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
restore HP-UX net/if.h workaround to sntp subproj, needed by ntp.h
authorDave Hart <hart@ntp.org>
Wed, 1 Dec 2010 07:48:54 +0000 (07:48 +0000)
committerDave Hart <hart@ntp.org>
Wed, 1 Dec 2010 07:48:54 +0000 (07:48 +0000)
 inclusion leading to isc/net.h and then net/if.h.

bk: 4cf5fde6PikGmgJIH9SUFMU0Mog2LA

clockstuff/chutest.c
sntp/configure.ac

index b96d5f7ed7d482eecde03d906dfde13fd6d52e98..632ab2f157185a3f876c35d51a6edc595e93a656 100644 (file)
 #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
@@ -74,7 +81,7 @@ void  init_chu(void);
 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);
 
 
@@ -272,7 +279,7 @@ process_raw(
 /*
  * raw_filter - run the line discipline filter over raw data
  */
-int
+void
 raw_filter(
        unsigned int c,
        struct timeval *tv
@@ -638,7 +645,7 @@ chufilter(
         * 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 */
@@ -647,7 +654,7 @@ chufilter(
         * 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;
@@ -673,7 +680,9 @@ chufilter(
         * 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;
        }
@@ -683,7 +692,9 @@ chufilter(
         * 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 */
index 353832a4867f5d9136ad27a3c49c32dccbd57ee9..b5c9e9322a48c2f54ff9696518583bfbdf6dcae2 100644 (file)
@@ -223,6 +223,77 @@ esac
 # 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