]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Many files:
authorHarlan Stenn <stenn@ntp.org>
Thu, 19 Aug 1999 03:08:18 +0000 (03:08 -0000)
committerHarlan Stenn <stenn@ntp.org>
Thu, 19 Aug 1999 03:08:18 +0000 (03:08 -0000)
  Convert NT files to Unix EOLs; a CVS checkout on an NT box will DTRT.
  * libntp/systime.c:
  * ntpd/ntp_loopfilter.c:
  * ntpd/ntpd.c:
  * ports/winnt/libntp/nt_clockstuff.c:
  From: Sven Dietrich <Sven_Dietrich@trimble.com>

bk: 37bb7522c3tVaTpFpJHoo-44nFYucw

ChangeLog
NEWS
libntp/systime.c
ntpd/ntp_loopfilter.c
ntpd/ntpd.c
ports/winnt/libntp/nt_clockstuff.c

index bcdacbf0043f31a9e14a6f5e75d6f7408405f63e..bcf05c37e48b1fd2a4bd119e2d4e6376294c31bd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 1999-08-18  Harlan Stenn  <stenn@whimsy.udel.edu>
 
+       * libntp/systime.c:
+       * ntpd/ntp_loopfilter.c:
+       * ntpd/ntpd.c:
+       * ports/winnt/libntp/nt_clockstuff.c:
+       From: Sven Dietrich <Sven_Dietrich@trimble.com>
+       
        * README.cvs: Updated.
 
        * configure.in: 
diff --git a/NEWS b/NEWS
index 99d7406e1c1dcd535cebd3073f5a1fae67f11603..99aec7b15c79060e28a66bd0ecb719219bc80509 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+* NT patches
+* AIX,SunOS,IRIX portability
 * NeXT portability
 * ntptimeset utility added
 * cygwin portability patches
index 258e3b01069accf4d2284ab0c0e4c7f508fbfa32..5e9d39fed956eaee24dc6de1005c5fc468e90ec3 100644 (file)
@@ -45,6 +45,7 @@ double sys_maxfreq = MAXFREQ; /* max frequency correction */
 
 #if defined SYS_WINNT || defined SYS_CYGWIN32
 static long last_Adj = 0;
+extern DWORD units_per_tick;
 /*long adj_precision = (long)(HZ * 0.1); */ /* adj precision in usec (tickadj) */
 #endif /* SYS_WINNT */
 
@@ -183,7 +184,7 @@ adj_systime(
         * and leave the remainder in dtemp */
        dwTimeAdjustment = dtemp / 10;
        dtemp +=  (double) -dwTimeAdjustment * 10.0;    
-       dwTimeAdjustment += PRESET_TICK;
+       dwTimeAdjustment += units_per_tick;
 
        /* only adjust the clock if adjustment changes */
        if (last_Adj != dwTimeAdjustment) {     
index c2632a9b5fb7cf18e163802698301c75fab75495..a501931e6f4d2fa9ae413d0b1d824465b8757f5b 100644 (file)
@@ -194,13 +194,14 @@ local_clock(
        /*
         * If the clock is way off, don't tempt fate by correcting it.
         */
+#ifndef SYS_WINNT
        if (fabs(fp_offset) >= clock_panic && !correct_any) {
-               msyslog(LOG_ERR,
+                       msyslog(LOG_ERR,
                    "time error %.0f over %d seconds; set clock manually)",
                    fp_offset, (int)clock_panic);
                return (-1);
        }
-
+#endif
        /*
         * If the clock has never been set, set it and initialize the
         * discipline parameters. We then switch to frequency mode to
index 7cfa01d9a1b71409502616637795847003443b65..dc7db8214b9ce4d1009e4e8e618dc73ef1081bf2 100644 (file)
@@ -1061,11 +1061,6 @@ service_exit(
        int status
        )
 {
-       /* restore the clock frequency back to its original value */
-       if (!SetSystemTimeAdjustment((DWORD)0, TRUE)) {
-               msyslog(LOG_ERR, "Failed to reset clock frequency, SetSystemTimeAdjustment(): %m");
-       }
-
        if (!debug) { /* did not become a service, simply exit */
                /* service mode, need to have the service_main routine
                 * register with the service control manager that the 
index 557b19295b9faf87ffe27407264005b7008de48a..5d05673839fe44202df6b21bb4da76e8f2382a6e 100644 (file)
@@ -1,5 +1,3 @@
-
-
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -13,6 +11,8 @@
 
 char * set_tod_using = "SetSystemTime";
 extern double drift_comp;
+DWORD units_per_tick;
+static DWORD initial_units_per_tick;
 
 /* Windows NT versions of gettimeofday and settimeofday
  *
@@ -77,7 +77,7 @@ gettimeofday(
        }
        else {
          TicksElapsed = NowCount + 1 + ~Count; /* tick counter has wrapped around - I don't think this will ever happen*/
-               msyslog(LOG_INFO, "Wraparound %m");
+               msyslog(LOG_INFO, "Wraparound %d -> %d%m", Count, NowCount);
 
        }
 
@@ -120,12 +120,11 @@ TimerApcFunction(
 
 DWORD WINAPI ClockThread(void *arg)
 {
+
        LARGE_INTEGER DueTime;
        HANDLE WaitableTimerHandle = CreateWaitableTimer(NULL, FALSE, NULL);
 
        (void) arg; /* not used */
-       /* Reset the Clock to a reasonable increment */
-       SetSystemTimeAdjustment(PRESET_TICK, FALSE);
 
        if (WaitableTimerHandle != NULL) {
                DueTime.QuadPart = 0i64;
@@ -147,12 +146,27 @@ static void StartClockThread(void)
        DWORD tid;
        FILETIME StartTime;
        LARGE_INTEGER Freq = { 0, 0 };
+       DWORD every;
+       BOOL noslew;
+       /* Reset the Clock to a reasonable increment */
+       if (!GetSystemTimeAdjustment(&initial_units_per_tick, &every, &noslew)) {
+               msyslog(LOG_ERR, "GetSystemTimeAdjustment failed: %m\n");
+               exit (-1);
+       }
+
+    units_per_tick = initial_units_per_tick;
+
+       msyslog(LOG_INFO, "Initial Clock increment %d\n",
+                       units_per_tick);
        
        /* get the performance counter freq*/
-    if (QueryPerformanceFrequency(&Freq)) { 
-               PerfFrequency = Freq.QuadPart;
+    if (!QueryPerformanceFrequency(&Freq)) { 
+               msyslog(LOG_ERR, "QueryPerformanceFrequency failed: %m\n");
+               exit (-1);
        }
 
+       PerfFrequency = Freq.QuadPart;
+
        /* init variables with the time now */
        GetSystemTimeAsFileTime(&StartTime);
        LastTimerTime = (((ULONGLONG) StartTime.dwHighDateTime) << 32) + (ULONGLONG) StartTime.dwLowDateTime;
@@ -181,6 +195,11 @@ static void StopClockThread(void)
 
                DeleteCriticalSection(&TimerCritialSection);
        } 
+       
+       /* restore the clock frequency back to its original value */
+       if (!SetSystemTimeAdjustment(initial_units_per_tick, TRUE)) {
+               msyslog(LOG_ERR, "Failed to reset clock frequency, SetSystemTimeAdjustment(): %m");
+       }
 }
 
 typedef void (__cdecl *CRuntimeFunction)(void);