]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Actually use long long for (u_)int64 by correcting spelling
authorDave Hart <hart@ntp.org>
Fri, 12 Aug 2011 17:17:54 +0000 (17:17 +0000)
committerDave Hart <hart@ntp.org>
Fri, 12 Aug 2011 17:17:54 +0000 (17:17 +0000)
  of SIZEOF_LONG_LONG in ntp_types.h.
Require Visual C++ 2005 or later compilers in Windows port.
Force .exe minimum Windows version to 0x0400 to allow NT4 in
  vs2005/*.vcproj files.

bk: 4e4560424gBv-q1EED0C1EMQCOCk4g

15 files changed:
ChangeLog
include/ntp_machine.h
include/ntp_types.h
include/timetoa.h
lib/isc/win32/include/isc/platform.h
libntp/timespecops.c
ntpd/complete.conf
ports/winnt/include/config.h
ports/winnt/ntpd/nt_clockstuff.c
ports/winnt/vs2005/Instsrv.vcproj
ports/winnt/vs2005/ntpd.vcproj
ports/winnt/vs2005/ntpdate.vcproj
ports/winnt/vs2005/ntpdc.vcproj
ports/winnt/vs2005/ntpkeygen.vcproj
ports/winnt/vs2005/ntpq.vcproj

index 4e6d1308454c282f416086eb4692c7b04ec11608..6703905fee1f40499976ceaf1a50d19d3d254ab4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+* Actually use long long for (u_)int64 by correcting spelling of
+  SIZEOF_LONG_LONG in ntp_types.h.
+* Require Visual C++ 2005 or later compilers in Windows port.
+* Force .exe minimum Windows version to 0x0400 to allow NT4 in
+  vs2005/*.vcproj files.
 * Fix make distcheck with --enable-libevent-regress problem with
   unwritable $srcdir.
 * Correct init_logging()'s def_syslogmask type to u_int32 following
index 057bfb7e40c502362fba1118e97a8118c175d2b2..c5e7248e4115303fd17ebea3d86abb624c4a7098 100644 (file)
@@ -67,11 +67,6 @@ MISC
 
 int ntp_set_tod (struct timeval *tvp, void *tzp);
 
-#if defined (SYS_CYGWIN32)
-#include <windows.h>
-#define __int64 long long
-#endif
-
 /*casey Tue May 27 15:45:25 SAT 1997*/
 #ifdef SYS_VXWORKS
 
index 6d35e18ff94f676acdd226946658216677688db9..504596b61d16099a38e3f41c7def8be8713c43fa 100644 (file)
@@ -99,17 +99,12 @@ typedef unsigned int u_int;
 typedef int64_t int64;
 typedef uint64_t u_int64;
 
-# elif defined(_MSC_VER)
-
-typedef __int64 int64;
-typedef unsigned __int64 u_int64;
-
 # elif SIZEOF_LONG == 8
 
 typedef long int64;
 typedef unsigned long u_int64;
 
-# elif SIZEOF_LONGLONG == 8
+# elif SIZEOF_LONG_LONG == 8
 
 typedef long long int64;
 typedef unsigned long long u_int64;
index 686928ab441e715ecbadcf19df1ef75d71cda067..259944907741c5eb0e975daa7efa37cc15c4a1af 100644 (file)
@@ -61,12 +61,13 @@ typedef unsigned long long u_time;
 #include "GRONK: what size has a time_t here?"
 #endif
 
-/* general fractional time stamp formatting.
+/*
+ * general fractional time stamp formatting.
  *
  * secs - integral seconds of time stamp
  * frac - fractional units
  * prec - log10 of units per second (3=milliseconds, 6=microseconds,..)
- *       or in other words: the number decimal digits required.
+ *       or in other words: the count of decimal digits required.
  *       If prec is < 0, abs(prec) is taken for the precision and secs
  *       is treated as an unsigned value.
  *
index d74fc76b05986181512ec8a0becfebc9751dbf19..3abe8515ab527fc4e1593f4c91ae0ceb9b279043 100644 (file)
@@ -40,7 +40,9 @@
 #define ISC_PLATFORM_NEEDNTOP
 #define ISC_PLATFORM_NEEDPTON
 
+#ifndef ISC_PLATFORM_QUADFORMAT
 #define ISC_PLATFORM_QUADFORMAT "I64"
+#endif
 
 #define ISC_PLATFORM_NEEDSTRSEP
 #define ISC_PLATFORM_NEEDSTRLCPY
index b45fc3bd973833e614169a73093135daadd07efd..8055c17118b745866bb54cf1e5a72df9ef0744c9 100644 (file)
@@ -11,6 +11,7 @@
 #include "timespecops.h"
 
 #include "timetoa.h"
+#include "ntp_types.h"
 #include "ntp_calendar.h"
 
 /* make sure we have the right definition for NANOSECONDS */
 #define NANOSECONDS 1000000000
 
 /* conversion between l_fp fractions and nanoseconds */
-#if SIZEOF_LONG >= 8
+#ifdef HAVE_U_INT64
 # define MYFTOTVN(tsf, tvu)                                            \
        ((tvu) = (int32)                                                \
-               (((u_long)(tsf) * NANOSECONDS + 0x80000000) >> 32))
+               (((u_int64)(tsf) * NANOSECONDS + 0x80000000) >> 32))
 # define MYTVNTOF(tvu, tsf)                                            \
        ((tsf) = (u_int32)                                              \
-               ((((u_long)(tvu) << 32) + NANOSECONDS / 2) /            \
+               ((((u_int64)(tvu) << 32) + NANOSECONDS / 2) /           \
                 NANOSECONDS))
 #else
 # define MYFTOTVN(tsf, tvu)                                            \
index 4dbb6ec76b41448d8456dd3e6e366e119e16991b..a70c3128ec3c741db2d6408afd31aeb8fa0ccd80 100644 (file)
@@ -34,6 +34,7 @@ server -4 2.north-america.pool.ntp.org. minpoll 6 maxpoll 10 iburst
 server -6 ntp.davehart.net. minpoll 6 maxpoll 10 version 5 burst iburst
 peer -6 davehart.broker.freenet6.net. ident "autokey-group" xleave autokey
 peer -4 192.168.192.168 key 1 noselect
+server [fe80::123%1]
 broadcast 192.168.192.255
 manycastclient 224.0.1.1
 manycastclient ff05::101
index c74c4b928c2323afc592003a9fab4ef355f74d40..5733c987111ec183ae6c9e901fe062d3e2c35640 100644 (file)
@@ -2,35 +2,34 @@
  * ports/winnt/include/config.h - static Windows config.h
  *
  * On most systems config.h is generated by the configure script.
- * For the Windows port, it's hand-maintained.
+ * For the Windows port, it's hand-maintained.  Compilers earlier
+ * than Visual C++ 2005 are no longer supported, enabling
+ * portable use of "long long" and "%lld".
  */
 
 #ifndef CONFIG_H
 #define CONFIG_H
 
+#if defined(_MSC_VER) && _MSC_VER < 1400
+#error Minimum supported Microsoft compiler is Visual C++ 2005.
+#endif
+
 /*
- * For newer compilers we want structures and prototypes added after
- * Windows NT 4.0 exposed by Windows header files, so we define
- * _WIN32_WINNT to target Windows XP (version 5.1).  By default,
- * _WIN32_WINNT also controls the minimum required Windows version to
- * launch the .exe.  As we want a single binary to work on all
- * supported Windows versions, we runtime link newer functions, and use
- * the linker /version:0x0400 option to override the .EXE header
- * minimum Windows version.
+ * We want structures and prototypes added after Windows NT 4.0 exposed
+ * by Windows header files, so we define _WIN32_WINNT to target Windows
+ * XP (version 5.1).  By default, _WIN32_WINNT also controls the minimum
+ * required Windows version to launch the .exe.  As we want a single
+ * binary to work on all supported Windows versions, we runtime link
+ * newer functions, and use the linker /version:0x0400 option to
+ * override the .EXE header minimum Windows version.
  *
- * For compilers older than VS 2005, we assume the headers will not
- * have what we need and leave _WIN32_WINNT targetting Windows NT 4.0.
- * This could be modified to change #if _MSC_VER > 1400 to #ifdef _W64
- * and achieve the same result with the default SDK headers and libs
- * included with earlier compilers, while taking advantage of newer
- * functions if an updated SDK is installed.
+ * When using the VC++ 2008 and later compilers, the resulting binaries
+ * will not work on versions earlier than Windows XP, due to runtime
+ * library dependencies.  That is, Visual C++ 2005 is the last version
+ * capable of producing binaries usable with Windows NT 4 and 2000.
  */
 #ifndef _WIN32_WINNT
-#if _MSC_VER > 1400            /* At least VS 2005 */
 #define _WIN32_WINNT 0x0501
-#else                          /* NT 4.0 */
-#define _WIN32_WINNT 0x0400 
-#endif
 #endif
 
 
 #define __RPCASYNC_H__
 #endif
 
-/*
- * VS.NET's version of wspiapi.h has a bug in it
- * where it assigns a value to a variable inside
- * an if statement. It should be comparing them.
- * We prevent inclusion since we are not using this
- * code so we don't have to see the warning messages
- */
-#ifndef _WSPIAPI_H_
-/* #define _WSPIAPI_H_ */ /* need these wrappers for ntpd.exe to load on w2k */
-#endif
-
 /*
  * On Unix struct sock_timeval is equivalent to struct timeval.
  * On Windows built with 64-bit time_t, sock_timeval.tv_sec is a long
@@ -262,8 +250,6 @@ typedef int socklen_t;
  * to other names
  */
 #define inline         __inline
-/* #define vsnprintf   _vsnprintf */
-/* #define snprintf    _snprintf */
 #define stricmp                _stricmp
 #define strcasecmp     _stricmp
 #define isascii                __isascii
@@ -302,8 +288,6 @@ typedef int socklen_t;
 
 typedef int pid_t;             /* PID is an int */
 typedef int ssize_t;           /* ssize is an int */
-typedef __int32 int32_t;       /* define a typedef for int32_t */
-#define HAVE_INT32_T   1
 
 /*
  * Map the stream to the file number
@@ -324,39 +308,43 @@ typedef __int32 int32_t;  /* define a typedef for int32_t */
  */
 #define NTP_REDEFINE_STRERROR
 
-# define MCAST                         /* Enable Multicast Support */
-# define MULTICAST_NONEWSOCKET         /* Don't create a new socket for mcast address */
+#define MCAST                          /* Enable Multicast Support */
+#define MULTICAST_NONEWSOCKET          /* Don't create a new socket for mcast address */
 
 # define REFCLOCK                      /* from ntpd.mak */
 
-/* # define CLOCK_PARSE  */
-# define CLOCK_ACTS
-# define CLOCK_ARBITER
-# define CLOCK_ARCRON_MSF
-# define OWN_PPS_NTP_TIMESTAMP_FROM_COUNTER    /* timepps.h */
-# define HAVE_TIMEPPS_H
-# define HAVE_PPSAPI
-# define CLOCK_ATOM
-# define CLOCK_CHU
-# define CLOCK_CHRONOLOG
-# define CLOCK_DUMBCLOCK
-# define CLOCK_HOPF_SERIAL     /* device 38, hopf DCF77/GPS serial line receiver  */
-# define CLOCK_HOPF_PCI                /* device 39, hopf DCF77/GPS PCI-Bus receiver  */
-# define CLOCK_JUPITER
-# define CLOCK_LOCAL
-# define CLOCK_NMEA
-# define CLOCK_ONCORE
-# define CLOCK_PALISADE                /* from ntpd.mak */
+/* #define CLOCK_PARSE  */
+#define CLOCK_ACTS
+#define CLOCK_ARBITER
+#define CLOCK_ARCRON_MSF
+#define OWN_PPS_NTP_TIMESTAMP_FROM_COUNTER     /* timepps.h */
+#define HAVE_TIMEPPS_H
+#define HAVE_PPSAPI
+#define CLOCK_ATOM
+#define CLOCK_CHU
+#define CLOCK_CHRONOLOG
+#define CLOCK_DUMBCLOCK
+#define CLOCK_HOPF_SERIAL      /* device 38, hopf DCF77/GPS serial line receiver  */
+#define CLOCK_HOPF_PCI         /* device 39, hopf DCF77/GPS PCI-Bus receiver  */
+#define CLOCK_JUPITER
+#define CLOCK_LOCAL
+#define CLOCK_NMEA
+#define CLOCK_ONCORE
+#define CLOCK_PALISADE         /* from ntpd.mak */
 /* # define CLOCK_SHM */
-# define CLOCK_SPECTRACOM      /* refclock_wwvb.c */
-# define CLOCK_TRIMBLEDC
-# define CLOCK_TRIMTSIP 1
-# define CLOCK_TRUETIME
+#define CLOCK_SPECTRACOM       /* refclock_wwvb.c */
+#define CLOCK_TRIMBLEDC
+#define CLOCK_TRIMTSIP 1
+#define CLOCK_TRUETIME
 
-# define NTP_LITTLE_ENDIAN             /* from libntp.mak */
-# define NTP_POSIX_SOURCE
+#define NTP_LITTLE_ENDIAN              /* from libntp.mak */
+#define NTP_POSIX_SOURCE
 
-# define SYSLOG_FILE                   /* from libntp.mak */
+#define SYSLOG_FILE                    /* from libntp.mak */
+
+#define HAVE_LONG_LONG_INT             1
+#define HAVE_UNSIGNED_LONG_LONG_INT    1
+#define HAVE_PTRDIFF_T                 1
 
 # define SIZEOF_SIGNED_CHAR    1
 # define SIZEOF_SHORT          2
@@ -364,6 +352,9 @@ typedef __int32 int32_t;    /* define a typedef for int32_t */
 # define SIZEOF_LONG           4
 # define SIZEOF_LONG_LONG      8
 
+/* libntp/snprintf.c doesn't know %I64d */
+#define ISC_PLATFORM_QUADFORMAT "ll"
+
 # define HAVE_ERRNO_H                  1
 # define HAVE_FCNTL_H                  1
 # define HAVE_LIMITS_H                 1
index 3eb6a0bbe853a0f2256c6eefc9c3554ff861d099..a58e4bee19829c65f624770c8448f4a01899a72e 100644 (file)
@@ -2,9 +2,16 @@
  *
  * Created by Sven Dietrich  sven@inter-yacht.com
  *
- * New interpolation scheme by Dave Hart <davehart@davehart.com> February 2009
- * overcomes 500us-1ms inherent jitter with the older scheme, first identified
- * by Peter Rosin (nee Ekberg) <peda@lysator.liu.se> in 2003 [Bug 216].
+ * New interpolation scheme by Dave Hart <davehart@davehart.com> in
+ * February 2009 overcomes 500us-1ms inherent jitter with the older
+ * scheme, first identified by Peter Rosin (nee Ekberg)
+ * <peda@lysator.liu.se> in 2003 [Bug 216].
+ *
+ * Note:  The Windows port of ntpd uses the C99-snprintf replacement for
+ * (v)snprintf(), also used by msyslog(), which does not understand the
+ * printf format specifier %I64d, only the more common %lld.  With the
+ * minimum supported compiler raised to Visual C++ 2005 in ntp-dev in
+ * August 2011, all MS C runtime routines also understand %lld and %llu.
  */
 
 
@@ -216,26 +223,14 @@ do {      \
        (t) -= HECTONANOSECONDS / 2;    \
 } while (0)
 
-/*
- * workaround for VC6 inability to convert unsigned __int64 to double
- */
-#define        LL_HNS  ((LONGLONG)HECTONANOSECONDS)
-
 /*
  * NT native time format is 100's of nanoseconds since 1601-01-01.
  * Helpers for converting between "hectonanoseconds" and the 
  * performance counter scale from which interpolated time is
  * derived.
- *
- * Once support for VC6 is dropped, the cast of PerfCtrFreq to
- * LONGLONG can come out of PERF2HNS().  It avoids the VC6 error
- * message:
- * 
- * conversion from unsigned __int64 to double not implemented, use
- * signed __int64
  */
-#define HNS2PERF(hns)  ((hns) * PerfCtrFreq / LL_HNS)
-#define PERF2HNS(ctr)  ((ctr) * LL_HNS / (LONGLONG)PerfCtrFreq)
+#define HNS2PERF(hns)  ((hns) * PerfCtrFreq / HECTONANOSECONDS)
+#define PERF2HNS(ctr)  ((ctr) * HECTONANOSECONDS / PerfCtrFreq)
 
 
 #if defined(_MSC_VER) && _MSC_VER >= 1400      /* VS 2005 */
@@ -346,14 +341,14 @@ choose_interp_counter(void)
        use_pcc = 1;
        if (ntpd_pcc_freq_text != NULL)
                sscanf(ntpd_pcc_freq_text, 
-                      "%I64u", 
+                      "%llu", 
                       &NomPerfCtrFreq);
 
        NLOG(NLOG_CLOCKINFO)
                msyslog(LOG_INFO, 
                        "using processor cycle counter "
                        "%.3f MHz", 
-                       (LONGLONG)NomPerfCtrFreq / 1e6);
+                       NomPerfCtrFreq / 1e6);
        return;
 }
 
@@ -421,8 +416,11 @@ adj_systime(
 {
        double dtemp;
        u_char isneg = 0;
-       int rc;
+       BOOL rc;
        long TimeAdjustment;
+       SYSTEMTIME st;
+       ULONGLONG this_perf_count;
+       FT_ULL curr_ft;
 
        /*
         * Add the residual from the previous adjustment to the new
@@ -430,8 +428,7 @@ adj_systime(
         */
        dtemp = sys_residual + now;
        sys_residual = 0;
-       if (dtemp < 0)
-       {
+       if (dtemp < 0) {
                isneg = 1;
                dtemp = -dtemp;
        }
@@ -452,34 +449,31 @@ adj_systime(
         * frequency as per suggestion from Harry Pyle,
         * and leave the remainder in dtemp
         */
-       TimeAdjustment = (long) (dtemp / ppm_per_adjust_unit + (isneg ? -0.5 : 0.5));
-       dtemp -= (double) TimeAdjustment * ppm_per_adjust_unit; 
+       TimeAdjustment = (long)(dtemp / ppm_per_adjust_unit +
+                               (isneg)
+                                   ? -0.5
+                                   : 0.5);
+       dtemp -= (double)TimeAdjustment * ppm_per_adjust_unit;  
 
 
        /*
         * If a leap second is pending then determine the UTC time stamp 
         * of when the insertion must take place 
         */
-       if (leapsec > 0)
-       {
-               if ( ls_ft.ull == 0 )  /* time stamp has not yet been computed */
-               {
-                       SYSTEMTIME st;
-
+       if (leapsec > 0) {
+               if (0 == ls_ft.ull) {  /* time stamp has not yet been computed */
                        GetSystemTime(&st);
 
                        /*
                         * Accept leap announcement only 1 month in advance,
                         * for end of March, June, September, or December.
                         */
-                       if ( ( st.wMonth % 3 ) == 0 )
-                       {
+                       if (0 == (st.wMonth % 3)) {
                                /*
                                 * The comparison time stamp is computed according 
                                 * to 0:00h UTC of the following day 
                                 */
-                               if ( ++st.wMonth > 12 )
-                               {
+                               if (++st.wMonth > 12) {
                                        st.wMonth -= 12;
                                        st.wYear++;
                                }
@@ -498,17 +492,13 @@ adj_systime(
                                        st.wHour, st.wMinute, st.wSecond);
                        }
                }
-       }
-       else
-       {
-               if ( ls_ft.ull )  /* Leap second has been armed before */
-               {
+       } else {
+               if (ls_ft.ull != 0) {  /* Leap second has been armed before */
                        /*
                         * Disarm leap second only if the leap second
                         * is not already in progress.
                         */
-                       if ( !ls_time_adjustment )
-                       {
+                       if (0 == ls_time_adjustment) {
                                ls_ft.ull = 0;
                                msyslog( LOG_NOTICE, "Leap second announcement disarmed" );
                        }
@@ -520,15 +510,10 @@ adj_systime(
         * If the time stamp for the next leap second has been set
         * then check if the leap second must be handled
         */
-       if ( ls_ft.ull )
-       {
-               ULONGLONG this_perf_count;
-
+       if (ls_ft.ull != 0) {
                this_perf_count = perf_ctr();
 
-               if ( ls_time_adjustment == 0 ) /* has not yet been scheduled */
-               {
-                       FT_ULL curr_ft;
+               if (0 == ls_time_adjustment) { /* has not yet been scheduled */
 
                        GetSystemTimeAsFileTime(&curr_ft.ft);   
                        if ( curr_ft.ull >= ls_ft.ull )
@@ -538,17 +523,13 @@ adj_systime(
                                ls_elapsed = 0;
                                msyslog(LOG_NOTICE, "Inserting positive leap second.");
                        }
-               }
-               else  /* leap sec adjustment has been scheduled previously */
-               {
+               } else {  /* leap sec adjustment has been scheduled previously */
                        ls_elapsed = ( this_perf_count - ls_ref_perf_cnt ) 
                                       * HECTONANOSECONDS / PerfCtrFreq;
                }
 
-               if ( ls_time_adjustment )  /* leap second adjustment is currently active */
-               {
-                       if ( ls_elapsed > ( LS_CORR_INTV - LS_CORR_LIMIT ) )
-                       {
+               if (ls_time_adjustment != 0) {  /* leap second adjustment is currently active */
+                       if (ls_elapsed > (LS_CORR_INTV - LS_CORR_LIMIT)) {
                                ls_time_adjustment = 0;  /* leap second adjustment done */
                                ls_ft.ull = 0;
                        }
@@ -569,10 +550,10 @@ adj_systime(
                last_Adj = TimeAdjustment;
                DPRINTF(1, ("SetSystemTimeAdjustment(%+ld)\n", TimeAdjustment));
                rc = !SetSystemTimeAdjustment(clockperiod + TimeAdjustment, FALSE);
+       } else {
+               rc = FALSE;
        }
-       else rc = 0;
-       if (rc)
-       {
+       if (rc) {
                msyslog(LOG_ERR, "Can't adjust time: %m");
                return 0;
        }
@@ -614,14 +595,12 @@ init_winnt_time(void)
        ntservice_init();
 
        /* Set up the Console Handler */
-       if (!SetConsoleCtrlHandler(OnConsoleEvent, TRUE))
-       {
+       if (!SetConsoleCtrlHandler(OnConsoleEvent, TRUE)) {
                msyslog(LOG_ERR, "Can't set console control handler: %m");
        }
 
        /* Set the Event-ID message-file name. */
-       if (!GetModuleFileName(NULL, szMsgPath, sizeof(szMsgPath))) 
-       {
+       if (!GetModuleFileName(NULL, szMsgPath, sizeof(szMsgPath))) {
                msyslog(LOG_ERR, "GetModuleFileName(PGM_EXE_FILE) failed: %m\n");
                exit(1);
        }
@@ -637,7 +616,6 @@ init_winnt_time(void)
        if (SIZEOF_TIME_T != sizeof(time_t)
            || SIZEOF_INT != sizeof(int)
            || SIZEOF_SIGNED_CHAR != sizeof(char)) {
-       
                msyslog(LOG_ERR, "config.h SIZEOF_* macros wrong, fatal");
                exit(1);
        }
@@ -650,9 +628,10 @@ init_winnt_time(void)
         */
 
        /* get the current process token handle */
-       if (!OpenProcessToken(GetCurrentProcess(),
-            TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) 
-       {
+       if (!OpenProcessToken(
+               GetCurrentProcess(),
+               TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
+               &hToken)) {
                msyslog(LOG_ERR, "OpenProcessToken failed: %m");
                exit(-1);
        }
@@ -667,8 +646,7 @@ init_winnt_time(void)
 
        /* cannot use return value of AdjustTokenPrivileges. */
        /* (success does not indicate all privileges were set) */
-       if (GetLastError() != ERROR_SUCCESS) 
-       {
+       if (GetLastError() != ERROR_SUCCESS) {
                msyslog(LOG_ERR, "AdjustTokenPrivileges failed: %m");
                /* later set time call will probably fail */
        }
@@ -700,40 +678,31 @@ init_winnt_time(void)
         * timer manipulation requested via -M option.
         */
        if (modify_mm_timer) {
-
                if (timeGetDevCaps(&tc, sizeof(tc)) == TIMERR_NOERROR) {
-
                        wTimerRes = min(max(tc.wPeriodMin, MM_TIMER_INTV), tc.wPeriodMax);
                        timeBeginPeriod(wTimerRes);
                        atexit(atexit_revert_mm_timer);
                        
                        msyslog(LOG_INFO, "MM timer resolution: %u..%u msec, set to %u msec",
                                tc.wPeriodMin, tc.wPeriodMax, wTimerRes );
-               } else
+               } else {
                        msyslog(LOG_ERR, "Multimedia timer unavailable");
+               }
        }
        
        /* get the performance counter ticks per second */
-       if (!QueryPerformanceFrequency(&Freq) || !Freq.QuadPart)
-       {
+       if (!QueryPerformanceFrequency(&Freq) || !Freq.QuadPart) {
                msyslog(LOG_ERR, "QueryPerformanceFrequency failed: %m\n");
                exit(-1);
        }
 
        NomPerfCtrFreq = PerfCtrFreq = Freq.QuadPart;
-       /*
-        * the cast to LONGLONG is for VC6 compatibility:
-        * nt_clockstuff.c(586) : error C2520: conversion from
-        * unsigned __int64 to double not implemented, use signed 
-        * __int64
-        */
        msyslog(LOG_INFO, 
-               "Performance counter frequency %.3f MHz", 
-               (LONGLONG)PerfCtrFreq / 1e6);
+               "Performance counter frequency %.3f MHz",
+               PerfCtrFreq / 1e6);
 
        /* Determine the existing system time slewing */
-       if (!GetSystemTimeAdjustment(&adjclockperiod, &clockperiod, &noslew))
-       {
+       if (!GetSystemTimeAdjustment(&adjclockperiod, &clockperiod, &noslew)) {
                msyslog(LOG_ERR, "GetSystemTimeAdjustment failed: %m\n");
                exit(-1);
        }
@@ -777,8 +746,7 @@ init_winnt_time(void)
 
        msyslog(LOG_INFO,
                "Windows clock precision %.3f msec, min. slew %.3f ppm/s",
-               (LONGLONG)os_clock_precision / 1e4, 
-               ppm_per_adjust_unit);
+               os_clock_precision / 1e4, ppm_per_adjust_unit);
 
        pch = getenv("NTPD_TICKADJ_PPM");
        if (pch != NULL && 1 == sscanf(pch, "%lf", &adjppm)) {
@@ -833,7 +801,7 @@ reset_winnt_time(void)
         * Verify this will not call SetSystemTimeAdjustment if
         * ntpd is running in ntpdate mode.
         */
-       if (sys_leap == LEAP_NOTINSYNC || ls_time_adjustment)
+       if (sys_leap == LEAP_NOTINSYNC || ls_time_adjustment != 0)
                SetSystemTimeAdjustment(0, TRUE);        
 
        /*
@@ -873,9 +841,9 @@ GetInterpTimeAsFileTime(
        now_count.ull = perf_ctr();
        now_time.ull = interp_time(now_count.ull, TRUE);
 
-       if (last_interp_time <= now_time.ull)
+       if (last_interp_time <= now_time.ull) {
                last_interp_time = now_time.ull;
-       else {
+       else {
                clock_backward = last_interp_time - now_time.ull;
                if (clock_backward > clock_backward_max) {
                        clock_backward_max = clock_backward;
@@ -924,7 +892,6 @@ TimerApcFunction(
         */
        if (INVALID_HANDLE_VALUE == ctr_freq_timer &&
            LEAP_NOTINSYNC != sys_leap)
-
                start_ctr_freq_timer(now_time);
 }
 
@@ -954,7 +921,7 @@ ClockThread(
                timer_period_msec = 43;
        } else if (HZ > 98 && HZ < 102) {
                timer_period_msec = 27;
-               if (!ntpd_int_int_text)
+               if (NULL == ntpd_int_int_text)
                        msyslog(LOG_WARNING, 
                                "%.3f Hz system clock may benefit from "
                                "custom NTPD_INT_INT env var timer interval "
@@ -962,7 +929,7 @@ ClockThread(
                                HZ);
        } else {
                timer_period_msec = (DWORD)(0.5 + (2.752 * clockperiod / 10000));
-               if (!ntpd_int_int_text)
+               if (NULL == ntpd_int_int_text)
                        msyslog(LOG_WARNING, 
                                "unfamiliar %.3f Hz system clock may benefit "
                                "from custom NTPD_INT_INT env var timer "
@@ -971,7 +938,7 @@ ClockThread(
                                HZ);
        }
 
-       if (ntpd_int_int_text) {
+       if (ntpd_int_int_text != NULL) {
                timer_period_msec = atoi(ntpd_int_int_text);
                timer_period_msec = max(9, timer_period_msec);
                msyslog(LOG_NOTICE, 
@@ -1109,7 +1076,7 @@ lock_thread_to_processor(HANDLE thread)
                exit(-1);
        }
 
-       if ( ! winnt_use_interpolation)
+       if (!winnt_use_interpolation)
                return;
        
        if (-1 == lock_interp_threads) {
@@ -1123,7 +1090,7 @@ lock_thread_to_processor(HANDLE thread)
         * Calculate the ThreadAffinityMask we'll use once on the
         * first invocation.
         */
-       if ( ! ProcessAffinityMask) {
+       if (!ProcessAffinityMask) {
 
                /*
                 * Choose which processor to nail the main and clock threads to.
@@ -1181,7 +1148,6 @@ lock_thread_to_processor(HANDLE thread)
 
        if (ThreadAffinityMask && 
            !SetThreadAffinityMask(thread, ThreadAffinityMask))
-
                msyslog(LOG_ERR, 
                        "Unable to wire thread to mask %x: %m\n", 
                        ThreadAffinityMask);
@@ -1231,15 +1197,15 @@ ntp_timestamp_from_counter(
                Now.ll -= InterpTimestamp;
                if (debug &&
                    Now.ll > 60 * HECTONANOSECONDS || 
-                   Now.ll < -60 * (LONGLONG) HECTONANOSECONDS) {
+                   Now.ll < -60 * HECTONANOSECONDS) {
                        DPRINTF(1, ("ntp_timestamp_from_counter interpolated time %.6fs from current\n",
-                                       Now.ll / (double)LL_HNS));
+                                       Now.ll / (double)HECTONANOSECONDS));
                        DPRINTF(1, ("interpol time %llx from  %llx\n",
                                        InterpTimestamp,
                                        Counterstamp));
                        msyslog(LOG_ERR,
                                "ntp_timestamp_from_counter interpolated time %.6fs from current\n",
-                               Now.ll / (double)LL_HNS);
+                               Now.ll / (double)HECTONANOSECONDS);
                        exit(-1);
                }
 #endif
@@ -1251,12 +1217,12 @@ ntp_timestamp_from_counter(
                GetSystemTimeAsFileTime(&Now.ft);
                Now.ll -= InterpTimestamp;
                if (Now.ll > 60 * HECTONANOSECONDS || 
-                   Now.ll < -60 * (LONGLONG) HECTONANOSECONDS) {
+                   Now.ll < -60 * HECTONANOSECONDS) {
                        DPRINTF(1, ("ntp_timestamp_from_counter serial driver system time %.6fs from current\n",
-                                   Now.ll / (double)LL_HNS));
+                                   Now.ll / (double)HECTONANOSECONDS));
                        msyslog(LOG_ERR,
                                "ntp_timestamp_from_counter serial driver system time %.6fs from current\n",
-                               Now.ll / (double)LL_HNS);
+                               Now.ll / (double)HECTONANOSECONDS);
                        exit(-1);
                }
 #endif
@@ -1388,12 +1354,10 @@ ctr_freq_timer_fired(
        now_time.ft.dwHighDateTime = dwTimeHigh;
 
        if (now_time.ull >= next_period_time) {
-
                now_count.ull = perf_ctr();
                tune_ctr_freq(
                        now_count.ull - begin_count.ull,
                        now_time.ull - begin_time.ull);
-
                next_period_time += (ULONGLONG)tune_ctr_period * HECTONANOSECONDS;
                begin_count.ull = now_count.ull;
                begin_time.ull = now_time.ull;
@@ -1402,26 +1366,21 @@ ctr_freq_timer_fired(
        /* 
         * Log clock backward events no more often than 5 minutes.
         */
-       if (!report_systemtime) 
-
+       if (!report_systemtime) {
                report_systemtime = now_time.ull + five_minutes;
-
-       else if (report_systemtime <= now_time.ull) {
-
+       } else if (report_systemtime <= now_time.ull) {
                report_systemtime +=  five_minutes;
-
                if (clock_backward_count) {
                        msyslog(LOG_WARNING, 
                                "clock would have gone backward %d times, "
                                "max %.1f usec",
                                clock_backward_count, 
-                               (LONGLONG)clock_backward_max / 10.);
+                               clock_backward_max / 10.);
 
                        clock_backward_max = CLOCK_BACK_THRESHOLD;
                        clock_backward_count = 0;
                }
        }
-
        reset_ctr_freq_timer(next_period_time, now_time.ull);
 }
 
@@ -1434,7 +1393,6 @@ reset_ctr_freq_timer_abs(
        FT_ULL  fire_time;
 
        fire_time.ull = when; 
-
        SetWaitableTimer(
                ctr_freq_timer,
                &fire_time.li,          /* first fire */
@@ -1453,7 +1411,6 @@ reset_ctr_freq_timer(
 {
        if (when - now > 
            (tune_ctr_freq_max_interval * HECTONANOSECONDS + HECTONANOSECONDS))
-
                when = now + tune_ctr_freq_max_interval * HECTONANOSECONDS;
 
        reset_ctr_freq_timer_abs(when);
@@ -1468,7 +1425,6 @@ start_ctr_freq_timer(
        ULONGLONG when;
 
        ctr_freq_timer = CreateWaitableTimer(NULL, FALSE, NULL);
-
        when = now_time;
        ROUND_TO_NEXT_SEC_BOTTOM(when);
 
@@ -1494,19 +1450,18 @@ tune_ctr_freq(
        static double nom_freq = 0;
        static LONGLONG diffs[TUNE_CTR_DEPTH] = {0};
        static LONGLONG sum = 0;
-
        char ctr_freq_eq[64];
        LONGLONG delta;
        LONGLONG deltadiff;
        ULONGLONG ObsPerfCtrFreq;
        double freq;
        double this_freq;
-       int isneg;
+       BOOL isneg;
 
        /* one-time initialization */
        if (!report_at_count) {
                report_at_count = 24 * 60 * 60 / tune_ctr_period;
-               nom_freq = (LONGLONG)NomPerfCtrFreq / 1e6;
+               nom_freq = NomPerfCtrFreq / 1e6;
        }
 
        /* delta is the per-second observed frequency this time */
@@ -1516,10 +1471,11 @@ tune_ctr_freq(
        /* disbelieve any delta more than +/- 976 PPM from nominal */
        deltadiff = delta - NomPerfCtrFreq;
        if (0 > deltadiff) {
-               isneg = 1;
+               isneg = TRUE;
                deltadiff = -deltadiff;
-       } else
-               isneg = 0;
+       } else {
+               isneg = FALSE;
+       }
 
        if ((ULONGLONG)deltadiff > (NomPerfCtrFreq / 1024)) {
                disbelieved++;
@@ -1555,7 +1511,7 @@ tune_ctr_freq(
        /* get rid of ObsPerfCtrFreq when removing the #ifdef */
        PerfCtrFreq = ObsPerfCtrFreq;
 #endif
-       freq = (LONGLONG)PerfCtrFreq / 1e6;
+       freq = PerfCtrFreq / 1e6;
 
        /*
         * make the performance counter's frequency error from its
index 1a1726ed4471d54f616cc5d85099afe51cb0e45f..74ccb8171dca52ee6ee5c8631134d965e73a5798 100644 (file)
@@ -77,6 +77,7 @@
                                ProgramDatabaseFile=".\instsrv\Debug/Instsrv.pdb"
                                SubSystem="1"
                                TargetMachine="1"
+                               Version="0x0400"
                        />
                        <Tool
                                Name="VCALinkTool"
                                ProgramDatabaseFile=".\instsrv\Release/Instsrv.pdb"
                                SubSystem="1"
                                TargetMachine="1"
+                               Version="0x0400"
                        />
                        <Tool
                                Name="VCALinkTool"
index 625a31751c217611d533c739d1b9ff207e25a7be..8e3d6666e481a07e874ae3450fbbc68c5791b783 100644 (file)
@@ -77,6 +77,7 @@
                                ProgramDatabaseFile="bin/Release/ntpd.pdb"
                                SubSystem="1"
                                TargetMachine="1"
+                               Version="0x0400"
                        />
                        <Tool
                                Name="VCALinkTool"
                                ProgramDatabaseFile="bin/Debug/ntpd.pdb"
                                SubSystem="1"
                                TargetMachine="1"
+                               Version="0x0400"
                        />
                        <Tool
                                Name="VCALinkTool"
index ee5b9dcd93d09250c516fff6c1c7fa605a53d4b4..2e40cad478370f722bf86364f63774cc54f7c822 100644 (file)
@@ -78,6 +78,7 @@
                                ProgramDatabaseFile="bin/Debug/ntpdate.pdb"
                                SubSystem="1"
                                TargetMachine="1"
+                               Version="0x0400"
                        />
                        <Tool
                                Name="VCALinkTool"
                                ProgramDatabaseFile="bin/Release/ntpdate.pdb"
                                SubSystem="1"
                                TargetMachine="1"
+                               Version="0x0400"
                        />
                        <Tool
                                Name="VCALinkTool"
index b13814bacbdc59a5ed04def65fba886a211df4c0..8339c58ab7d921ca8010222390aed99b91be1e4d 100644 (file)
@@ -78,6 +78,7 @@
                                ProgramDatabaseFile="bin/Debug/ntpdc.pdb"
                                SubSystem="1"
                                TargetMachine="1"
+                               Version="0x0400"
                        />
                        <Tool
                                Name="VCALinkTool"
                                ProgramDatabaseFile="bin/Release/ntpdc.pdb"
                                SubSystem="1"
                                TargetMachine="1"
+                               Version="0x0400"
                        />
                        <Tool
                                Name="VCALinkTool"
index 18fb7180f0137683850ee00e802b19430d0b6117..b6c0ab8edb0d8b1bb7c5d6d869814ca534f0bc94 100644 (file)
@@ -78,6 +78,7 @@
                                ProgramDatabaseFile="bin/Debug/ntp-keygen.pdb"
                                SubSystem="1"
                                TargetMachine="1"
+                               Version="0x0400"
                        />
                        <Tool
                                Name="VCALinkTool"
                                ProgramDatabaseFile="bin/Release/ntp-keygen.pdb"
                                SubSystem="1"
                                TargetMachine="1"
+                               Version="0x0400"
                        />
                        <Tool
                                Name="VCALinkTool"
index 112d27c084ed65718dd3eee7cb645660afe8e460..ec7c1a5ae30c7a7b4c4fd97703b19e574a4aa913 100644 (file)
@@ -76,6 +76,7 @@
                                ProgramDatabaseFile="bin/Release/ntpq.pdb"
                                SubSystem="1"
                                TargetMachine="1"
+                               Version="0x0400"
                        />
                        <Tool
                                Name="VCALinkTool"
                                ProgramDatabaseFile="bin/Debug/ntpq.pdb"
                                SubSystem="1"
                                TargetMachine="1"
+                               Version="0x0400"
                        />
                        <Tool
                                Name="VCALinkTool"