libbacktrace: Conditionalize test timing on clock_gettime availability

libbacktrace/
	PR other/67165
	* configure.ac: Check for clock_gettime.
	* config.h.in: Regenerate.
	* configure: Likewise.
	* ztest.c (average_time, test_large): Conditionalize test timing
	on clock_gettime availability.

From-SVN: r253344
This commit is contained in:
Thomas Schwinge 2017-10-02 13:56:25 +02:00 committed by Thomas Schwinge
parent 6146ee7373
commit dbc31f20d3
5 changed files with 39 additions and 1 deletions

View File

@ -1,3 +1,12 @@
2017-10-02 Thomas Schwinge <thomas@codesourcery.com>
PR other/67165
* configure.ac: Check for clock_gettime.
* config.h.in: Regenerate.
* configure: Likewise.
* ztest.c (average_time, test_large): Conditionalize test timing
on clock_gettime availability.
2017-09-29 Tony Reix <tony.reix@atos.net>
* xcoff.c: Initial support for DWARF debug sections in XCOFF.

View File

@ -9,6 +9,9 @@
/* Define to 1 if you have the __atomic functions */
#undef HAVE_ATOMIC_FUNCTIONS
/* Define to 1 if you have the `clock_gettime' function. */
#undef HAVE_CLOCK_GETTIME
/* Define to 1 if you have the declaration of `strnlen', and to 0 if you
don't. */
#undef HAVE_DECL_STRNLEN

View File

@ -12747,6 +12747,19 @@ $as_echo "#define HAVE_GETEXECNAME 1" >>confdefs.h
fi
# Check for the clock_gettime function.
for ac_func in clock_gettime
do :
ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"
if test "x$ac_cv_func_clock_gettime" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_CLOCK_GETTIME 1
_ACEOF
fi
done
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is supported" >&5
$as_echo_n "checking whether -pthread is supported... " >&6; }
if test "${libgo_cv_lib_pthread+set}" = set; then :

View File

@ -388,6 +388,9 @@ if test "$have_getexecname" = "yes"; then
AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
fi
# Check for the clock_gettime function.
AC_CHECK_FUNCS(clock_gettime)
dnl Test whether the compiler supports the -pthread option.
AC_CACHE_CHECK([whether -pthread is supported],
[libgo_cv_lib_pthread],

View File

@ -43,6 +43,10 @@ POSSIBILITY OF SUCH DAMAGE. */
#include <zlib.h>
#endif
#ifdef HAVE_CLOCK_GETTIME
# define TEST_TIMING
#endif
#include "backtrace.h"
#include "backtrace-supported.h"
@ -157,7 +161,7 @@ test_samples (struct backtrace_state *state)
}
}
#ifdef HAVE_ZLIB
#if defined HAVE_ZLIB && defined TEST_TIMING
/* Given a set of TRIALS timings, discard the lowest and highest
values and return the mean average of the rest. */
@ -216,6 +220,7 @@ 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;
@ -224,6 +229,7 @@ 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"
@ -341,6 +347,8 @@ test_large (struct backtrace_state *state)
printf ("PASS: inflate large\n");
# ifdef TEST_TIMING
for (i = 0; i < trials; ++i)
{
cid = CLOCK_REALTIME;
@ -411,6 +419,8 @@ 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: