1 // commit 5f95f965e933c5b155db75520ac27c92ddbcf400 2014-03-18
2 // syscall should not sign extend pointers on x32
8 #include <sys/syscall.h>
11 #define T(f) ((f) && (t_error(#f " failed: %s\n", strerror(errno)), 0))
13 static unsigned long long tsdiff(struct timespec ts2, struct timespec ts)
15 if (ts2.tv_nsec < ts.tv_nsec) {
16 ts2.tv_nsec += 1000000000;
19 if (ts2.tv_sec < ts.tv_sec)
21 return (ts2.tv_sec - ts.tv_sec)*1000000000ULL + (ts2.tv_nsec - ts.tv_nsec);
26 struct timespec ts, ts2;
27 unsigned long long diff;
29 // test syscall with pointer
30 T(syscall(SYS_clock_gettime, CLOCK_REALTIME, &ts));
32 // check if timespec is filled correctly
33 T(clock_gettime(CLOCK_REALTIME, &ts2));
34 diff = tsdiff(ts2, ts);
35 if (diff > 10 * 1000000000ULL)
36 t_error("large diff between clock_gettime calls: %llu ns\n", diff);