* 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
+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>
PR other/67165
if HAVE_ZLIB
ztest_LDADD += -lz
endif
-ztest_LDADD += $(clock_gettime_link)
+ztest_LDADD += $(CLOCK_GETTIME_LINK)
check_PROGRAMS += ztest
BACKTRACE_USES_MALLOC = @BACKTRACE_USES_MALLOC@
CC = @CC@
CFLAGS = @CFLAGS@
+CLOCK_GETTIME_LINK = @CLOCK_GETTIME_LINK@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
-clock_gettime_link = @clock_gettime_link@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
@NATIVE_TRUE@ztest_SOURCES = ztest.c testlib.c
@NATIVE_TRUE@ztest_CFLAGS = -DSRCDIR=\"$(srcdir)\"
@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_LDADD = libbacktrace.la
@HAVE_PTHREAD_TRUE@@NATIVE_TRUE@ttest_SOURCES = ttest.c testlib.c
HAVE_PTHREAD_FALSE
HAVE_PTHREAD_TRUE
PTHREAD_CFLAGS
-clock_gettime_link
+CLOCK_GETTIME_LINK
BACKTRACE_USES_MALLOC
ALLOC_FILE
VIEW_FILE
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5
$as_echo "$ac_cv_lib_rt_clock_gettime" >&6; }
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
# we're using this for test timing only.
if test "$ac_cv_func_clock_gettime" = no; then
AC_CHECK_LIB(rt, clock_gettime,
- [clock_gettime_link=-lrt
+ [CLOCK_GETTIME_LINK=-lrt
AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
[Define to 1 if you have the `clock_gettime' function.])])
fi
-AC_SUBST(clock_gettime_link)
+AC_SUBST(CLOCK_GETTIME_LINK)
dnl Test whether the compiler supports the -pthread option.
AC_CACHE_CHECK([whether -pthread is supported],
#include "config.h"
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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
}
}
-#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. */
unsigned char *uncompressed_buf;
size_t uncompressed_bufsize;
int r;
-# ifdef TEST_TIMING
clockid_t cid;
struct timespec ts1;
struct timespec ts2;
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"
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;
}
printf ("zlib time: : %zu ns\n", ztime);
printf ("percentage : %g\n", (double) ztime / (double) ctime);
-# endif /* TEST_TIMING */
-
return;
fail: