Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion libcurvecpr/lib/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ long long curvecpr_util_nanoseconds (void)

if (clock_get_time(cclock, &t) != KERN_SUCCESS)
return -1;
#else
#elif defined(CLOCK_MONOTONIC)
struct timespec t;

if (clock_gettime(CLOCK_MONOTONIC, &t) != 0)
return -1;
#elif defined(CLOCK_REALTIME)
struct timespec t;

if (clock_gettime(CLOCK_REALTIME, &t) != 0)
Expand Down
8 changes: 4 additions & 4 deletions libcurvecpr/test/util/test_nanoseconds.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ START_TEST (test_nanoseconds)
long long nanoseconds = curvecpr_util_nanoseconds();

fail_if(nanoseconds < 0);
fail_unless(nanoseconds > 1374047000000000000LL);
fail_unless(nanoseconds > 0);

/* On OS X, we may cache the kernel clock reference. Make sure it still
works. */
nanoseconds = curvecpr_util_nanoseconds();
long long nanoseconds1 = curvecpr_util_nanoseconds();

fail_if(nanoseconds < 0);
fail_unless(nanoseconds > 1374047000000000000LL);
fail_if(nanoseconds1 < 0);
fail_unless(nanoseconds1 > nanoseconds);
}
END_TEST

Expand Down