*/
static long const pulsewidth = 250000000; /* nanoseconds */
+/*
+ * Minimum gap between pulses.
+ */
+static long const gapwidth = 250000000; /* nanoseconds */
+
/*
* Maximum error to correct by advancing the clock rather than
* stopping it, in seconds. The point where it's faster to stop the
static timer_t main_timer;
+#define TS_SEC(s) ((struct timespec){.tv_sec = s, .tv_nsec = 0})
+#define TS_NSEC(s) ((struct timespec){.tv_sec = 0, .tv_nsec = s})
+
static void
dummy_out(bool state)
{
static void
pulse()
{
- struct timespec const ts = { .tv_sec = 0, .tv_nsec = pulsewidth };
sigset_t saved_mask;
if (sigprocmask(SIG_BLOCK, &signals_to_block, &saved_mask) != 0)
err(1, "sigprocmask(block)");
(*outfn)(true);
record_tick();
- errno = clock_nanosleep(CLOCK_MONOTONIC, 0, &ts, NULL);
+ errno = clock_nanosleep(CLOCK_MONOTONIC, 0,
+ &TS_NSEC(pulsewidth), NULL);
if (errno != 0)
err(1, "clock_nanosleep");
(*outfn)(false);
+ errno = clock_nanosleep(CLOCK_MONOTONIC, 0,
+ &TS_NSEC(gapwidth), NULL);
+ if (errno != 0)
+ err(1, "clock_nanosleep");
record_tick_finished();
if (sigprocmask(SIG_SETMASK, &saved_mask, NULL) != 0)
err(1, "sigprocmask(restore)");