diff options
author | Ian Lance Taylor <iant@golang.org> | 2017-10-03 02:27:33 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2017-10-03 02:27:33 +0000 |
commit | 8398c1dfe24391ee18b6147d22415f30f7b82f2a (patch) | |
tree | bbc2c4e35dd9dd451be9a9530db6d5c480ffb5c2 /libbacktrace/ztest.c | |
parent | 0adaaf009b580258831b4392fd653b26c9258c52 (diff) | |
download | gcc-8398c1dfe24391ee18b6147d22415f30f7b82f2a.zip gcc-8398c1dfe24391ee18b6147d22415f30f7b82f2a.tar.gz gcc-8398c1dfe24391ee18b6147d22415f30f7b82f2a.tar.bz2 |
ztest.c: #include <errno.h>.
* ztest.c: #include <errno.h>.
(TEST_TIMING): Don't define, don't test.
(xclock_gettime, xclockid_t): Define if !HAVE_CLOCK_GETTIME.
(clockid_t, clock_gettime, CLOCK_REALTIME): Likewise.
(ZLIB_CLOCK_GETTIME_ARG): Define.
* configure.ac: Change clock_gettime_link to CLOCK_GETTIME_LINK.
* Makefile.am: Likewise.
* configure, Makefile.in: Rebuild.
From-SVN: r253377
Diffstat (limited to 'libbacktrace/ztest.c')
-rw-r--r-- | libbacktrace/ztest.c | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/libbacktrace/ztest.c b/libbacktrace/ztest.c index 0b1cbc3..e2ab524 100644 --- a/libbacktrace/ztest.c +++ b/libbacktrace/ztest.c @@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. */ #include "config.h" +#include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -43,16 +44,37 @@ POSSIBILITY OF SUCH DAMAGE. */ #include <zlib.h> #endif -#ifdef HAVE_CLOCK_GETTIME -# define TEST_TIMING -#endif - #include "backtrace.h" #include "backtrace-supported.h" #include "internal.h" #include "testlib.h" +#ifndef HAVE_CLOCK_GETTIME + +typedef int xclockid_t; + +static int +xclock_gettime (xclockid_t id ATTRIBUTE_UNUSED, + struct timespec *ts ATTRIBUTE_UNUSED) +{ + errno = EINVAL; + return -1; +} + +#define clockid_t xclockid_t +#define clock_gettime xclock_gettime +#undef CLOCK_REALTIME +#define CLOCK_REALTIME 0 + +#endif /* !defined(HAVE_CLOCK_GETTIME) */ + +#ifdef CLOCK_PROCESS_CPUTIME_ID +#define ZLIB_CLOCK_GETTIME_ARG CLOCK_PROCESS_CPUTIME_ID +#else +#define ZLIB_CLOCK_GETTIME_ARG CLOCK_REALTIME +#endif + /* Some tests for the local zlib inflation code. */ struct zlib_test @@ -161,7 +183,7 @@ test_samples (struct backtrace_state *state) } } -#if defined HAVE_ZLIB && defined TEST_TIMING +#ifdef HAVE_ZLIB /* Given a set of TRIALS timings, discard the lowest and highest values and return the mean average of the rest. */ @@ -220,7 +242,6 @@ test_large (struct backtrace_state *state) unsigned char *uncompressed_buf; size_t uncompressed_bufsize; int r; -# ifdef TEST_TIMING clockid_t cid; struct timespec ts1; struct timespec ts2; @@ -229,7 +250,6 @@ test_large (struct backtrace_state *state) const size_t trials = 16; size_t ctimes[16]; size_t ztimes[16]; -# endif /* TEST_TIMING */ static const char * const names[] = { "Mark.Twain-Tom.Sawyer.txt", "../libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt" @@ -347,16 +367,13 @@ test_large (struct backtrace_state *state) printf ("PASS: inflate large\n"); -# ifdef TEST_TIMING - for (i = 0; i < trials; ++i) { - cid = CLOCK_REALTIME; -#ifdef CLOCK_PROCESS_CPUTIME_ID - cid = CLOCK_PROCESS_CPUTIME_ID; -#endif + cid = ZLIB_CLOCK_GETTIME_ARG; if (clock_gettime (cid, &ts1) < 0) { + if (errno == EINVAL) + return; perror ("clock_gettime"); return; } @@ -419,8 +436,6 @@ test_large (struct backtrace_state *state) printf ("zlib time: : %zu ns\n", ztime); printf ("percentage : %g\n", (double) ztime / (double) ctime); -# endif /* TEST_TIMING */ - return; fail: |