summaryrefslogtreecommitdiff
path: root/targets/clock.c
diff options
context:
space:
mode:
Diffstat (limited to 'targets/clock.c')
-rw-r--r--targets/clock.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/targets/clock.c b/targets/clock.c
new file mode 100644
index 0000000..1a63e8c
--- /dev/null
+++ b/targets/clock.c
@@ -0,0 +1,14 @@
+// The clock read through the vDSO, the kernel's code mapped into the
+// process: no system call, and a loop that retries while the kernel's time
+// data changes under it.
+#include <time.h>
+
+int main(void) {
+ struct timespec ts;
+ long odd = 0;
+ for (int i = 0; i < 3; i++) {
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ odd += ts.tv_nsec & 1;
+ }
+ return odd > 3;
+}