diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2014-10-20 10:17:03 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2015-02-08 10:29:16 +0100 |
commit | 4b68c98d420fffd06d205179734c84b67959deae (patch) | |
tree | 923719302472faa853600ac46b311a1eb87cdce1 /src | |
parent | 5c315f7e720daa45796b5f82493b0c4624fbb7e0 (diff) | |
download | cmocka-4b68c98d420fffd06d205179734c84b67959deae.tar.gz cmocka-4b68c98d420fffd06d205179734c84b67959deae.tar.bz2 cmocka-4b68c98d420fffd06d205179734c84b67959deae.zip |
cmocka: Add correct checks for clock_gettime().
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/cmocka.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/cmocka.c b/src/cmocka.c index f275a37..7f92d5f 100644 --- a/src/cmocka.c +++ b/src/cmocka.c @@ -91,6 +91,12 @@ WINBASEAPI BOOL WINAPI IsDebuggerPresent(VOID); # define CMOCKA_THREAD #endif +#ifdef HAVE_CLOCK_GETTIME_REALTIME +#define CMOCKA_CLOCK_GETTIME(clock_id, ts) clock_gettime((clock_id), (ts)) +#else +#define CMOCKA_CLOCK_GETTIME(clock_id, ts) +#endif + /* * Declare and initialize the pointer member of ValuePointer variable name * with ptr. @@ -1963,7 +1969,14 @@ static int cmocka_run_group_fixture(const char *function_name, static int cmocka_run_one_tests(struct CMUnitTestState *test_state) { - struct timespec start, finish; + struct timespec start = { + .tv_sec = 0, + .tv_nsec = 0, + }; + struct timespec finish = { + .tv_sec = 0, + .tv_nsec = 0, + }; int rc = 0; /* Run setup */ @@ -1983,7 +1996,7 @@ static int cmocka_run_one_tests(struct CMUnitTestState *test_state) } /* Run test */ - clock_gettime(CLOCK_REALTIME, &start); + CMOCKA_CLOCK_GETTIME(CLOCK_REALTIME, &start); if (rc == 0) { rc = cmocka_run_one_test_or_fixture(test_state->test->name, @@ -2000,7 +2013,7 @@ static int cmocka_run_one_tests(struct CMUnitTestState *test_state) rc = 0; } - clock_gettime(CLOCK_REALTIME, &finish); + CMOCKA_CLOCK_GETTIME(CLOCK_REALTIME, &finish); test_state->runtime = cm_secdiff(finish, start); /* Run teardown */ |