]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
local: replace is_step_change parameter of change handler with enum
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 30 May 2014 11:02:45 +0000 (13:02 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 2 Jun 2014 14:46:53 +0000 (16:46 +0200)
Prepare for a new change type that will be added later.

local.c
local.h
manual.c
ntp_sources.c
refclock.c
reference.c
rtc_linux.c
sched.c
sources.c
sys_generic.c

diff --git a/local.c b/local.c
index f43de38e18e41be227803286b47c404b6b97430e..3619b589204ccf7b58ed3826095ae50e1521f9b9 100644 (file)
--- a/local.c
+++ b/local.c
@@ -251,12 +251,12 @@ void LCL_RemoveParameterChangeHandler(LCL_ParameterChangeHandler handler, void *
 static void
 invoke_parameter_change_handlers(struct timeval *raw, struct timeval *cooked,
                                  double dfreq, double doffset,
-                                 int is_step_change)
+                                 LCL_ChangeType change_type)
 {
   ChangeListEntry *ptr;
 
   for (ptr = change_list.next; ptr != &change_list; ptr = ptr->next) {
-    (ptr->handler)(raw, cooked, dfreq, doffset, is_step_change, ptr->anything);
+    (ptr->handler)(raw, cooked, dfreq, doffset, change_type, ptr->anything);
   }
 }
 
@@ -401,7 +401,7 @@ LCL_SetAbsoluteFrequency(double afreq_ppm)
   LCL_CookTime(&raw, &cooked, NULL);
 
   /* Dispatch to all handlers */
-  invoke_parameter_change_handlers(&raw, &cooked, dfreq, 0.0, 0);
+  invoke_parameter_change_handlers(&raw, &cooked, dfreq, 0.0, LCL_ChangeAdjust);
 
   current_freq_ppm = afreq_ppm;
 
@@ -431,7 +431,7 @@ LCL_AccumulateDeltaFrequency(double dfreq)
   LCL_CookTime(&raw, &cooked, NULL);
 
   /* Dispatch to all handlers */
-  invoke_parameter_change_handlers(&raw, &cooked, dfreq, 0.0, 0);
+  invoke_parameter_change_handlers(&raw, &cooked, dfreq, 0.0, LCL_ChangeAdjust);
 }
 
 /* ================================================== */
@@ -450,7 +450,7 @@ LCL_AccumulateOffset(double offset, double corr_rate)
   (*drv_accrue_offset)(offset, corr_rate);
 
   /* Dispatch to all handlers */
-  invoke_parameter_change_handlers(&raw, &cooked, 0.0, offset, 0);
+  invoke_parameter_change_handlers(&raw, &cooked, 0.0, offset, LCL_ChangeAdjust);
 }
 
 /* ================================================== */
@@ -469,7 +469,7 @@ LCL_ApplyStepOffset(double offset)
   (*drv_apply_step_offset)(offset);
 
   /* Dispatch to all handlers */
-  invoke_parameter_change_handlers(&raw, &cooked, 0.0, offset, 1);
+  invoke_parameter_change_handlers(&raw, &cooked, 0.0, offset, LCL_ChangeStep);
 }
 
 /* ================================================== */
@@ -479,7 +479,7 @@ LCL_NotifyExternalTimeStep(struct timeval *raw, struct timeval *cooked,
     double offset, double dispersion)
 {
   /* Dispatch to all handlers */
-  invoke_parameter_change_handlers(raw, cooked, 0.0, offset, 1);
+  invoke_parameter_change_handlers(raw, cooked, 0.0, offset, LCL_ChangeStep);
 
   lcl_InvokeDispersionNotifyHandlers(dispersion);
 }
diff --git a/local.h b/local.h
index eea70722f7ba94c1ca00cd612dce5e425dd7d3c8..bdf38bd62245c98a606283c431a30ebec2ed2d2f 100644 (file)
--- a/local.h
+++ b/local.h
@@ -67,16 +67,21 @@ extern void LCL_GetOffsetCorrection(struct timeval *raw, double *correction, dou
    doffset : delta offset applied (positive => make local system fast
    by that amount, negative => make it slow by that amount)
 
-   is_step_change : true if change is being applied as a jump (using
-   settimeofday rather than adjtime)
+   change_type : what type of change is being applied
    
    anything : Passthrough argument from call to registration routine */
 
 
+typedef enum {
+  LCL_ChangeAdjust,
+  LCL_ChangeStep
+} LCL_ChangeType;
+
 typedef void (*LCL_ParameterChangeHandler)
      (struct timeval *raw, struct timeval *cooked,
       double dfreq,
-      double doffset, int is_step_change,
+      double doffset,
+      LCL_ChangeType change_type,
       void *anything
       );
 
index 9886ce59348eb15164e0edf887d934e7baf72eb8..011d07a1f05db7ec8a5744611320cb4437ca3b84 100644 (file)
--- a/manual.c
+++ b/manual.c
@@ -66,7 +66,7 @@ slew_samples(struct timeval *raw,
              struct timeval *cooked, 
              double dfreq,
              double doffset,
-             int is_step_change,
+             LCL_ChangeType change_type,
              void *not_used);
 
 /* ================================================== */
@@ -216,7 +216,7 @@ slew_samples(struct timeval *raw,
              struct timeval *cooked, 
              double dfreq,
              double doffset,
-             int is_step_change,
+             LCL_ChangeType change_type,
              void *not_used)
 {
   double delta_time;
index ddba8a38a318057a3ea764f7c8128c97a95fad55..3fa5b2910302c55f0d192049d6eaf14dd4a08f53 100644 (file)
@@ -94,7 +94,7 @@ slew_sources(struct timeval *raw,
              struct timeval *cooked,
              double dfreq,
              double doffset,
-             int is_step_change,
+             LCL_ChangeType change_type,
              void *anything);
 
 /* ================================================== */
@@ -479,7 +479,7 @@ slew_sources(struct timeval *raw,
              struct timeval *cooked,
              double dfreq,
              double doffset,
-             int is_step_change,
+             LCL_ChangeType change_type,
              void *anything)
 {
   int i;
index 67f0588987e36b2abca66b390cb58094529ee3c8..83b94885d1bb7da1f18b4c82e3d25ab2b0ee242a 100644 (file)
@@ -97,7 +97,7 @@ static int valid_sample_time(RCL_Instance instance, struct timeval *tv);
 static int pps_stratum(RCL_Instance instance, struct timeval *tv);
 static void poll_timeout(void *arg);
 static void slew_samples(struct timeval *raw, struct timeval *cooked, double dfreq,
-             double doffset, int is_step_change, void *anything);
+             double doffset, LCL_ChangeType change_type, void *anything);
 static void add_dispersion(double dispersion, void *anything);
 static void log_sample(RCL_Instance instance, struct timeval *sample_time, int filtered, int pulse, double raw_offset, double cooked_offset, double dispersion);
 
@@ -577,7 +577,7 @@ poll_timeout(void *arg)
 
 static void
 slew_samples(struct timeval *raw, struct timeval *cooked, double dfreq,
-             double doffset, int is_step_change, void *anything)
+             double doffset, LCL_ChangeType change_type, void *anything)
 {
   int i;
 
index b1a638657351ff8435afa467a7ba28fed1c15c3e..6038ce3d9a44b27f6217bc518a44995ba5a1c28a 100644 (file)
@@ -144,10 +144,10 @@ handle_slew(struct timeval *raw,
             struct timeval *cooked,
             double dfreq,
             double doffset,
-            int is_step_change,
+            LCL_ChangeType change_type,
             void *anything)
 {
-  if (is_step_change) {
+  if (change_type == LCL_ChangeStep) {
     UTI_AddDoubleToTimeval(&last_ref_update, -doffset, &last_ref_update);
   }
 }
index 198e3b7c10533abfc87305a7139beb5f059dc629..602345c5f66a07c2454f2867c3688f38e1124481 100644 (file)
@@ -265,7 +265,8 @@ static void
 slew_samples
 (struct timeval *raw, struct timeval *cooked,
  double dfreq,
- double doffset, int is_step_change,
+ double doffset,
+ LCL_ChangeType change_type,
  void *anything)
 {
   int i;
diff --git a/sched.c b/sched.c
index 8c547a100bb190ec961efb8f0d551dbb9b50e936..2204f96dece25a8711405c24f9a7d151717bb4b7 100644 (file)
--- a/sched.c
+++ b/sched.c
@@ -123,7 +123,7 @@ handle_slew(struct timeval *raw,
             struct timeval *cooked,
             double dfreq,
             double doffset,
-            int is_step_change,
+            LCL_ChangeType change_type,
             void *anything);
 
 /* ================================================== */
@@ -503,14 +503,14 @@ handle_slew(struct timeval *raw,
             struct timeval *cooked,
             double dfreq,
             double doffset,
-            int is_step_change,
+            LCL_ChangeType change_type,
             void *anything)
 {
   TimerQueueEntry *ptr;
   double delta;
   int i;
 
-  if (is_step_change) {
+  if (change_type != LCL_ChangeAdjust) {
     /* If a step change occurs, just shift all raw time stamps by the offset */
     
     for (ptr = timer_queue.next; ptr != &timer_queue; ptr = ptr->next) {
index 8eae88b8d7b726b2a0eefc0b17886dc7954a785a..d0600ccfde129a5fa1bb6107641882ca20ce1bbd 100644 (file)
--- a/sources.c
+++ b/sources.c
@@ -154,7 +154,7 @@ static double combine_limit;
 
 static void
 slew_sources(struct timeval *raw, struct timeval *cooked, double dfreq,
-             double doffset, int is_step_change, void *anything);
+             double doffset, LCL_ChangeType change_type, void *anything);
 static void
 add_dispersion(double dispersion, void *anything);
 static char *
@@ -1087,7 +1087,7 @@ slew_sources(struct timeval *raw,
              struct timeval *cooked,
              double dfreq,
              double doffset,
-             int is_step_change,
+             LCL_ChangeType change_type,
              void *anything)
 {
   int i;
index 33b792f01820e952236d1ae30cb02ddfd5aea285..51c682464c2678dea6ec33288cf833026e010831 100644 (file)
@@ -93,9 +93,9 @@ static void handle_end_of_slew(void *anything);
 
 static void
 handle_step(struct timeval *raw, struct timeval *cooked, double dfreq,
-            double doffset, int is_step_change, void *anything)
+            double doffset, LCL_ChangeType change_type, void *anything)
 {
-  if (is_step_change)
+  if (change_type == LCL_ChangeStep)
     UTI_AddDoubleToTimeval(&slew_start, -doffset, &slew_start);
 }