mirror of
https://github.com/wolfcw/libfaketime.git
synced 2026-05-17 00:26:16 +03:00
Add clock_gettime_heap snippet
This invokes clock_gettime, but uses a timespec from the heap instead of the stack.
This commit is contained in:
8
test/snippets/clock_gettime_heap.c
Normal file
8
test/snippets/clock_gettime_heap.c
Normal file
@@ -0,0 +1,8 @@
|
||||
struct timespec *ts = malloc(sizeof(struct timespec));
|
||||
clockid_t ckid = CLOCK_REALTIME;
|
||||
int ret = clock_gettime(ckid, ts);
|
||||
if (ret == 0) {
|
||||
printf("[%s] clock_gettime_heap(CLOCK_REALTIME[%d], ts) -> {%lld, %ld}\n", where, ckid, (long long)ts->tv_sec, ts->tv_nsec);
|
||||
} else {
|
||||
printf("[%s] clock_gettime_heap(CLOCK_REALTIME[%d], ts) returned non-zero (%d), errno = %d (%s)\n", where, ckid, ret, errno, strerror(errno));
|
||||
}
|
||||
1
test/snippets/clock_gettime_heap.variable
Normal file
1
test/snippets/clock_gettime_heap.variable
Normal file
@@ -0,0 +1 @@
|
||||
FAKETIME 2020-02-02 02:02:02+00:00
|
||||
@@ -6,3 +6,4 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
Reference in New Issue
Block a user