From: Dave Hart Date: Wed, 1 Dec 2010 07:48:54 +0000 (+0000) Subject: restore HP-UX net/if.h workaround to sntp subproj, needed by ntp.h X-Git-Tag: NTP_4_2_7P89~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3e5c35e20e55a06f931d0ecfee46b15e3136b6c1;p=thirdparty%2Fntp.git restore HP-UX net/if.h workaround to sntp subproj, needed by ntp.h inclusion leading to isc/net.h and then net/if.h. bk: 4cf5fde6PikGmgJIH9SUFMU0Mog2LA --- diff --git a/clockstuff/chutest.c b/clockstuff/chutest.c index b96d5f7ed..632ab2f15 100644 --- a/clockstuff/chutest.c +++ b/clockstuff/chutest.c @@ -23,11 +23,18 @@ #include #include #include -#include +#ifdef HAVE_TERMIOS_H +# include +#else +# ifdef HAVE_SGTTY_H +# include +# 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 */ diff --git a/sntp/configure.ac b/sntp/configure.ac index 353832a48..b5c9e9322 100644 --- a/sntp/configure.ac +++ b/sntp/configure.ac @@ -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 + #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 + #endif + #include + ]], + [[ + ]] + )], + [ + 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