aboutsummaryrefslogtreecommitdiff
path: root/libbacktrace
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2017-10-02 13:56:25 +0200
committerThomas Schwinge <tschwinge@gcc.gnu.org>2017-10-02 13:56:25 +0200
commitdbc31f20d30615404c2994f2d0bb9876cd75585a (patch)
tree6180153dd27e37972f90f06729c67e136418f62c /libbacktrace
parent6146ee73730cd2a4406918a0d5f98f0f71331f01 (diff)
downloadgcc-dbc31f20d30615404c2994f2d0bb9876cd75585a.zip
gcc-dbc31f20d30615404c2994f2d0bb9876cd75585a.tar.gz
gcc-dbc31f20d30615404c2994f2d0bb9876cd75585a.tar.bz2
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
Diffstat (limited to 'libbacktrace')
-rw-r--r--libbacktrace/ChangeLog9
-rw-r--r--libbacktrace/config.h.in3
-rwxr-xr-xlibbacktrace/configure13
-rw-r--r--libbacktrace/configure.ac3
-rw-r--r--libbacktrace/ztest.c12
5 files changed, 39 insertions, 1 deletions
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog
index 9597a68..0e4cfd2 100644
--- a/libbacktrace/ChangeLog
+++ b/libbacktrace/ChangeLog
@@ -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.
diff --git a/libbacktrace/config.h.in b/libbacktrace/config.h.in
index a9f70da..c19b6e4 100644
--- a/libbacktrace/config.h.in
+++ b/libbacktrace/config.h.in
@@ -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
diff --git a/libbacktrace/configure b/libbacktrace/configure
index ece4151..062dc77 100755
--- a/libbacktrace/configure
+++ b/libbacktrace/configure
@@ -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 :
diff --git a/libbacktrace/configure.ac b/libbacktrace/configure.ac
index f389c72..75ec9f5 100644
--- a/libbacktrace/configure.ac
+++ b/libbacktrace/configure.ac
@@ -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],
diff --git a/libbacktrace/ztest.c b/libbacktrace/ztest.c
index 103ad65..0b1cbc3 100644
--- a/libbacktrace/ztest.c
+++ b/libbacktrace/ztest.c
@@ -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: