const struct timeval *second);
void testDelay(float amt);
+void testDelaySpin(float amt);
// Pseudo Random Utilities
int testRandBool(void);
} while (true);
}
+// Delay spins for the number of seconds specified by amt or a greater
+// amount. The amt variable is of type float and thus non-integer amounts
+// of time can be specified. Differs from testDelay() in that
+// testDelaySpin() performs a spin loop, instead of using nanosleep().
+void testDelaySpin(float amt)
+{
+ struct timespec start, current, delta;
+
+ // Get the time at which we started
+ clock_gettime(CLOCK_MONOTONIC, &start);
+
+ do {
+ // Get current time
+ clock_gettime(CLOCK_MONOTONIC, ¤t);
+
+ // How much time is left
+ delta = tsDelta(&start, ¤t);
+ if (ts2double(&delta) > amt) { break; }
+ } while (true);
+}
+
/*
* Hex Dump
*