Deleted Added
full compact
sht.c (302408) sht.c (338530)
1/*
2 * sht.c - Testprogram for shared memory refclock
3 * read/write shared memory segment; see usage
4 */
5#include "config.h"
6
7#ifndef SYS_WINNT
8#include <sys/types.h>

--- 182 unchanged lines hidden (view full) ---

191
192 case 'w': {
193 /* To show some life action, we read the system
194 * clock and use a bit of fuzz from 'random()' to get a
195 * bit of wobbling into the values (so we can observe a
196 * certain jitter!)
197 */
198 time_t clk_sec, rcv_sec;
1/*
2 * sht.c - Testprogram for shared memory refclock
3 * read/write shared memory segment; see usage
4 */
5#include "config.h"
6
7#ifndef SYS_WINNT
8#include <sys/types.h>

--- 182 unchanged lines hidden (view full) ---

191
192 case 'w': {
193 /* To show some life action, we read the system
194 * clock and use a bit of fuzz from 'random()' to get a
195 * bit of wobbling into the values (so we can observe a
196 * certain jitter!)
197 */
198 time_t clk_sec, rcv_sec;
199 uint clk_frc, rcv_frc;
199 u_int clk_frc, rcv_frc;
200
201#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
202
203 /* Here we have a high-resolution system clock, and
204 * we're not afraid to use it!
205 */
206 struct timespec tmptime;
207 if (0 == clock_gettime(CLOCK_REALTIME, &tmptime)) {
208 rcv_sec = tmptime.tv_sec;
200
201#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
202
203 /* Here we have a high-resolution system clock, and
204 * we're not afraid to use it!
205 */
206 struct timespec tmptime;
207 if (0 == clock_gettime(CLOCK_REALTIME, &tmptime)) {
208 rcv_sec = tmptime.tv_sec;
209 rcv_frc = (uint)tmptime.tv_nsec;
209 rcv_frc = (u_int)tmptime.tv_nsec;
210 }
211 else
212#endif
213 {
214 time(&rcv_sec);
210 }
211 else
212#endif
213 {
214 time(&rcv_sec);
215 rcv_frc = (uint)random() % 1000000000u;
215 rcv_frc = (u_int)random() % 1000000000u;
216 }
217 /* add a wobble of ~3.5msec to the clock time */
218 clk_sec = rcv_sec;
216 }
217 /* add a wobble of ~3.5msec to the clock time */
218 clk_sec = rcv_sec;
219 clk_frc = rcv_frc + (uint)(random()%7094713 - 3547356);
219 clk_frc = rcv_frc + (u_int)(random()%7094713 - 3547356);
220 /* normalise result -- the SHM driver is picky! */
221 while ((int)clk_frc < 0) {
222 clk_frc += 1000000000;
223 clk_sec -= 1;
224 }
225 while ((int)clk_frc >= 1000000000) {
226 clk_frc -= 1000000000;
227 clk_sec += 1;

--- 33 unchanged lines hidden ---
220 /* normalise result -- the SHM driver is picky! */
221 while ((int)clk_frc < 0) {
222 clk_frc += 1000000000;
223 clk_sec -= 1;
224 }
225 while ((int)clk_frc >= 1000000000) {
226 clk_frc -= 1000000000;
227 clk_sec += 1;

--- 33 unchanged lines hidden ---