Lines Matching refs:tsp
75 int timeutil_sync_state_update(struct timeutil_sync_state *tsp, in timeutil_sync_state_update() argument
80 if (((tsp->base.ref == 0) && (inst->ref > 0)) in timeutil_sync_state_update()
81 || ((inst->ref > tsp->base.ref) in timeutil_sync_state_update()
82 && (inst->local > tsp->base.local))) { in timeutil_sync_state_update()
83 if (tsp->base.ref == 0) { in timeutil_sync_state_update()
84 tsp->base = *inst; in timeutil_sync_state_update()
85 tsp->latest = (struct timeutil_sync_instant){}; in timeutil_sync_state_update()
86 tsp->skew = 1.0f; in timeutil_sync_state_update()
89 tsp->latest = *inst; in timeutil_sync_state_update()
97 int timeutil_sync_state_set_skew(struct timeutil_sync_state *tsp, float skew, in timeutil_sync_state_set_skew() argument
103 tsp->skew = skew; in timeutil_sync_state_set_skew()
105 tsp->base = *base; in timeutil_sync_state_set_skew()
106 tsp->latest = (struct timeutil_sync_instant){}; in timeutil_sync_state_set_skew()
114 float timeutil_sync_estimate_skew(const struct timeutil_sync_state *tsp) in timeutil_sync_estimate_skew() argument
118 if ((tsp->base.ref != 0) && (tsp->latest.ref != 0) in timeutil_sync_estimate_skew()
119 && (tsp->latest.local > tsp->base.local)) { in timeutil_sync_estimate_skew()
120 const struct timeutil_sync_config *cfg = tsp->cfg; in timeutil_sync_estimate_skew()
121 double ref_delta = tsp->latest.ref - tsp->base.ref; in timeutil_sync_estimate_skew()
122 double local_delta = tsp->latest.local - tsp->base.local; in timeutil_sync_estimate_skew()
130 int timeutil_sync_ref_from_local(const struct timeutil_sync_state *tsp, in timeutil_sync_ref_from_local() argument
135 if ((tsp->skew > 0) && (tsp->base.ref > 0) && (refp != NULL)) { in timeutil_sync_ref_from_local()
136 const struct timeutil_sync_config *cfg = tsp->cfg; in timeutil_sync_ref_from_local()
137 int64_t local_delta = local - tsp->base.local; in timeutil_sync_ref_from_local()
141 if (tsp->skew != 1.0f) { in timeutil_sync_ref_from_local()
142 local_delta *= (double)tsp->skew; in timeutil_sync_ref_from_local()
145 int64_t ref_abs = (int64_t)tsp->base.ref + ref_delta; in timeutil_sync_ref_from_local()
151 rv = (tsp->skew != 1.0f) ? 1 : 0; in timeutil_sync_ref_from_local()
158 int timeutil_sync_local_from_ref(const struct timeutil_sync_state *tsp, in timeutil_sync_local_from_ref() argument
163 if ((tsp->skew > 0) && (tsp->base.ref > 0) && (localp != NULL)) { in timeutil_sync_local_from_ref()
164 const struct timeutil_sync_config *cfg = tsp->cfg; in timeutil_sync_local_from_ref()
165 int64_t ref_delta = (int64_t)(ref - tsp->base.ref); in timeutil_sync_local_from_ref()
171 if (tsp->skew != 1.0f) { in timeutil_sync_local_from_ref()
172 local_delta /= (double)tsp->skew; in timeutil_sync_local_from_ref()
174 int64_t local_abs = (int64_t)tsp->base.local in timeutil_sync_local_from_ref()
178 rv = (tsp->skew != 1.0f) ? 1 : 0; in timeutil_sync_local_from_ref()