From 940502b3debaba2b03b23dcf6615cc88729a3d61 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Thu, 25 Feb 2021 20:44:36 -0500 Subject: [PATCH] Added snippet for syscall(__NR_clock_gettime) Closes: #176 --- test/snippets/include_headers.h | 1 + test/snippets/syscall_clock_gettime.c | 8 ++++++++ test/snippets/syscall_clock_gettime.variable | 1 + 3 files changed, 10 insertions(+) create mode 100644 test/snippets/syscall_clock_gettime.c create mode 100644 test/snippets/syscall_clock_gettime.variable diff --git a/test/snippets/include_headers.h b/test/snippets/include_headers.h index 0c1bd85..55cd48f 100644 --- a/test/snippets/include_headers.h +++ b/test/snippets/include_headers.h @@ -5,3 +5,4 @@ #include #include #include +#include diff --git a/test/snippets/syscall_clock_gettime.c b/test/snippets/syscall_clock_gettime.c new file mode 100644 index 0000000..21b99ba --- /dev/null +++ b/test/snippets/syscall_clock_gettime.c @@ -0,0 +1,8 @@ +struct timespec ts; +clockid_t ckid = CLOCK_REALTIME; +long ret = syscall(__NR_clock_gettime, ckid, &ts); +if (ret == 0) + printf("[%s] syscall(__NR_gettime, CLOCK_REALTIME[%d], &ts) -> {%lld, %ld}\n", where, ckid, (long long)ts.tv_sec, ts.tv_nsec); +else + printf("[%s] syscall(__NR_gettime, CLOCK_REALTIME[%d], &ts) returned non-zero (%ld)\n", where, ckid, ret); + diff --git a/test/snippets/syscall_clock_gettime.variable b/test/snippets/syscall_clock_gettime.variable new file mode 100644 index 0000000..e89e166 --- /dev/null +++ b/test/snippets/syscall_clock_gettime.variable @@ -0,0 +1 @@ +FAKETIME 2020-01-01 00:00:00