Added snippet for syscall(__NR_clock_gettime)

Closes: #176
This commit is contained in:
Daniel Kahn Gillmor
2021-02-25 20:44:36 -05:00
parent 26b4b395e9
commit 940502b3de
3 changed files with 10 additions and 0 deletions

View File

@@ -5,3 +5,4 @@
#include <sys/syscall.h>
#include <string.h>
#include <errno.h>
#include <time.h>

View File

@@ -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);

View File

@@ -0,0 +1 @@
FAKETIME 2020-01-01 00:00:00