Commit 8398c1df by Ian Lance Taylor Committed by Ian Lance Taylor

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
parent 0adaaf00
2017-10-02 Ian Lance Taylor <iant@golang.org>
* 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.
2017-10-02 Thomas Schwinge <thomas@codesourcery.com> 2017-10-02 Thomas Schwinge <thomas@codesourcery.com>
PR other/67165 PR other/67165
......
...@@ -108,7 +108,7 @@ ztest_LDADD = libbacktrace.la ...@@ -108,7 +108,7 @@ ztest_LDADD = libbacktrace.la
if HAVE_ZLIB if HAVE_ZLIB
ztest_LDADD += -lz ztest_LDADD += -lz
endif endif
ztest_LDADD += $(clock_gettime_link) ztest_LDADD += $(CLOCK_GETTIME_LINK)
check_PROGRAMS += ztest check_PROGRAMS += ztest
......
...@@ -215,6 +215,7 @@ BACKTRACE_SUPPORTS_THREADS = @BACKTRACE_SUPPORTS_THREADS@ ...@@ -215,6 +215,7 @@ BACKTRACE_SUPPORTS_THREADS = @BACKTRACE_SUPPORTS_THREADS@
BACKTRACE_USES_MALLOC = @BACKTRACE_USES_MALLOC@ BACKTRACE_USES_MALLOC = @BACKTRACE_USES_MALLOC@
CC = @CC@ CC = @CC@
CFLAGS = @CFLAGS@ CFLAGS = @CFLAGS@
CLOCK_GETTIME_LINK = @CLOCK_GETTIME_LINK@
CPP = @CPP@ CPP = @CPP@
CPPFLAGS = @CPPFLAGS@ CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@ CYGPATH_W = @CYGPATH_W@
...@@ -287,7 +288,6 @@ build_cpu = @build_cpu@ ...@@ -287,7 +288,6 @@ build_cpu = @build_cpu@
build_os = @build_os@ build_os = @build_os@
build_vendor = @build_vendor@ build_vendor = @build_vendor@
builddir = @builddir@ builddir = @builddir@
clock_gettime_link = @clock_gettime_link@
datadir = @datadir@ datadir = @datadir@
datarootdir = @datarootdir@ datarootdir = @datarootdir@
docdir = @docdir@ docdir = @docdir@
...@@ -385,7 +385,7 @@ TESTS = $(check_PROGRAMS) $(am__append_4) ...@@ -385,7 +385,7 @@ TESTS = $(check_PROGRAMS) $(am__append_4)
@NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c @NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c
@NATIVE_TRUE@ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\" @NATIVE_TRUE@ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"
@NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_2) \ @NATIVE_TRUE@ztest_LDADD = libbacktrace.la $(am__append_2) \
@NATIVE_TRUE@ $(clock_gettime_link) @NATIVE_TRUE@ $(CLOCK_GETTIME_LINK)
@NATIVE_TRUE@edtest_SOURCES = edtest.c edtest2_build.c testlib.c @NATIVE_TRUE@edtest_SOURCES = edtest.c edtest2_build.c testlib.c
@NATIVE_TRUE@edtest_LDADD = libbacktrace.la @NATIVE_TRUE@edtest_LDADD = libbacktrace.la
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_SOURCES = ttest.c testlib.c @HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_SOURCES = ttest.c testlib.c
......
...@@ -614,7 +614,7 @@ HAVE_ZLIB_TRUE ...@@ -614,7 +614,7 @@ HAVE_ZLIB_TRUE
HAVE_PTHREAD_FALSE HAVE_PTHREAD_FALSE
HAVE_PTHREAD_TRUE HAVE_PTHREAD_TRUE
PTHREAD_CFLAGS PTHREAD_CFLAGS
clock_gettime_link CLOCK_GETTIME_LINK
BACKTRACE_USES_MALLOC BACKTRACE_USES_MALLOC
ALLOC_FILE ALLOC_FILE
VIEW_FILE VIEW_FILE
...@@ -12803,7 +12803,7 @@ fi ...@@ -12803,7 +12803,7 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5
$as_echo "$ac_cv_lib_rt_clock_gettime" >&6; } $as_echo "$ac_cv_lib_rt_clock_gettime" >&6; }
if test "x$ac_cv_lib_rt_clock_gettime" = x""yes; then : if test "x$ac_cv_lib_rt_clock_gettime" = x""yes; then :
clock_gettime_link=-lrt CLOCK_GETTIME_LINK=-lrt
$as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h $as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
......
...@@ -397,11 +397,11 @@ clock_gettime_link= ...@@ -397,11 +397,11 @@ clock_gettime_link=
# we're using this for test timing only. # we're using this for test timing only.
if test "$ac_cv_func_clock_gettime" = no; then if test "$ac_cv_func_clock_gettime" = no; then
AC_CHECK_LIB(rt, clock_gettime, AC_CHECK_LIB(rt, clock_gettime,
[clock_gettime_link=-lrt [CLOCK_GETTIME_LINK=-lrt
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
[Define to 1 if you have the `clock_gettime' function.])]) [Define to 1 if you have the `clock_gettime' function.])])
fi fi
AC_SUBST(clock_gettime_link) AC_SUBST(CLOCK_GETTIME_LINK)
dnl Test whether the compiler supports the -pthread option. dnl Test whether the compiler supports the -pthread option.
AC_CACHE_CHECK([whether -pthread is supported], AC_CACHE_CHECK([whether -pthread is supported],
......
...@@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. */ ...@@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE. */
#include "config.h" #include "config.h"
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -43,16 +44,37 @@ POSSIBILITY OF SUCH DAMAGE. */ ...@@ -43,16 +44,37 @@ POSSIBILITY OF SUCH DAMAGE. */
#include <zlib.h> #include <zlib.h>
#endif #endif
#ifdef HAVE_CLOCK_GETTIME
# define TEST_TIMING
#endif
#include "backtrace.h" #include "backtrace.h"
#include "backtrace-supported.h" #include "backtrace-supported.h"
#include "internal.h" #include "internal.h"
#include "testlib.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. */ /* Some tests for the local zlib inflation code. */
struct zlib_test struct zlib_test
...@@ -161,7 +183,7 @@ test_samples (struct backtrace_state *state) ...@@ -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 /* Given a set of TRIALS timings, discard the lowest and highest
values and return the mean average of the rest. */ values and return the mean average of the rest. */
...@@ -220,7 +242,6 @@ test_large (struct backtrace_state *state) ...@@ -220,7 +242,6 @@ test_large (struct backtrace_state *state)
unsigned char *uncompressed_buf; unsigned char *uncompressed_buf;
size_t uncompressed_bufsize; size_t uncompressed_bufsize;
int r; int r;
# ifdef TEST_TIMING
clockid_t cid; clockid_t cid;
struct timespec ts1; struct timespec ts1;
struct timespec ts2; struct timespec ts2;
...@@ -229,7 +250,6 @@ test_large (struct backtrace_state *state) ...@@ -229,7 +250,6 @@ test_large (struct backtrace_state *state)
const size_t trials = 16; const size_t trials = 16;
size_t ctimes[16]; size_t ctimes[16];
size_t ztimes[16]; size_t ztimes[16];
# endif /* TEST_TIMING */
static const char * const names[] = { static const char * const names[] = {
"Mark.Twain-Tom.Sawyer.txt", "Mark.Twain-Tom.Sawyer.txt",
"../libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt" "../libgo/go/compress/testdata/Mark.Twain-Tom.Sawyer.txt"
...@@ -347,16 +367,13 @@ test_large (struct backtrace_state *state) ...@@ -347,16 +367,13 @@ test_large (struct backtrace_state *state)
printf ("PASS: inflate large\n"); printf ("PASS: inflate large\n");
# ifdef TEST_TIMING
for (i = 0; i < trials; ++i) for (i = 0; i < trials; ++i)
{ {
cid = CLOCK_REALTIME; cid = ZLIB_CLOCK_GETTIME_ARG;
#ifdef CLOCK_PROCESS_CPUTIME_ID
cid = CLOCK_PROCESS_CPUTIME_ID;
#endif
if (clock_gettime (cid, &ts1) < 0) if (clock_gettime (cid, &ts1) < 0)
{ {
if (errno == EINVAL)
return;
perror ("clock_gettime"); perror ("clock_gettime");
return; return;
} }
...@@ -419,8 +436,6 @@ test_large (struct backtrace_state *state) ...@@ -419,8 +436,6 @@ test_large (struct backtrace_state *state)
printf ("zlib time: : %zu ns\n", ztime); printf ("zlib time: : %zu ns\n", ztime);
printf ("percentage : %g\n", (double) ztime / (double) ctime); printf ("percentage : %g\n", (double) ztime / (double) ctime);
# endif /* TEST_TIMING */
return; return;
fail: fail:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment