aboutsummaryrefslogtreecommitdiff
path: root/gprofng
diff options
context:
space:
mode:
Diffstat (limited to 'gprofng')
-rw-r--r--gprofng/common/config.h.in3
-rwxr-xr-xgprofng/configure9
-rw-r--r--gprofng/configure.ac2
-rw-r--r--gprofng/libcollector/Makefile.am2
-rw-r--r--gprofng/libcollector/Makefile.in6
-rwxr-xr-xgprofng/libcollector/configure57
-rw-r--r--gprofng/libcollector/configure.ac13
-rw-r--r--gprofng/libcollector/gethrtime.c17
8 files changed, 93 insertions, 16 deletions
diff --git a/gprofng/common/config.h.in b/gprofng/common/config.h.in
index e46e64f..8409ce7 100644
--- a/gprofng/common/config.h.in
+++ b/gprofng/common/config.h.in
@@ -6,6 +6,9 @@
/* Enable java profiling */
#undef GPROFNG_JAVA_PROFILING
+/* Define to 1 if you have the `clock_gettime' function. */
+#undef HAVE_CLOCK_GETTIME
+
/* Define to 1 if you have the declaration of `basename', and to 0 if you
don't. */
#undef HAVE_DECL_BASENAME
diff --git a/gprofng/configure b/gprofng/configure
index 3cf4dc7..9a4a334 100755
--- a/gprofng/configure
+++ b/gprofng/configure
@@ -16523,12 +16523,13 @@ cat >>confdefs.h <<_ACEOF
#define HAVE_DECL_BASENAME $ac_have_decl
_ACEOF
-for ac_func in strsignal
+for ac_func in clock_gettime strsignal
do :
- ac_fn_c_check_func "$LINENO" "strsignal" "ac_cv_func_strsignal"
-if test "x$ac_cv_func_strsignal" = xyes; then :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
cat >>confdefs.h <<_ACEOF
-#define HAVE_STRSIGNAL 1
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF
fi
diff --git a/gprofng/configure.ac b/gprofng/configure.ac
index 8977e8b..fa924dc 100644
--- a/gprofng/configure.ac
+++ b/gprofng/configure.ac
@@ -178,7 +178,7 @@ AC_SUBST(GPROFNG_CPPFLAGS, [${gprofng_cppflags}])
AC_SUBST(GPROFNG_LIBDIR, [${libdir}])
AC_CHECK_DECLS([basename])
-AC_CHECK_FUNCS([strsignal])
+AC_CHECK_FUNCS(clock_gettime strsignal)
AC_SUBST(BUILD_SUBDIRS)
diff --git a/gprofng/libcollector/Makefile.am b/gprofng/libcollector/Makefile.am
index bd86e97..a41b920 100644
--- a/gprofng/libcollector/Makefile.am
+++ b/gprofng/libcollector/Makefile.am
@@ -63,7 +63,7 @@ libgp_collector_la_CPPFLAGS = $(AM_CPPFLAGS) $(jdk_inc) \
# Prevent libtool from reordering -Wl,--no-as-needed after -lrt by
# disguising -lrt as a linker flag.
libgp_collector_la_LDFLAGS = $(AM_LDFLAGS)
-libgp_collector_la_LIBADD =
+libgp_collector_la_LIBADD = $(CLOCK_GETTIME_LINK)
libgp_heap_la_SOURCES = heaptrace.c
libgp_heap_la_LDFLAGS = $(AM_LDFLAGS)
diff --git a/gprofng/libcollector/Makefile.in b/gprofng/libcollector/Makefile.in
index 920c7a7..f9ed2d9 100644
--- a/gprofng/libcollector/Makefile.in
+++ b/gprofng/libcollector/Makefile.in
@@ -156,7 +156,8 @@ am__uninstall_files_from_dir = { \
}
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(myincludedir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
-libgp_collector_la_DEPENDENCIES =
+am__DEPENDENCIES_1 =
+libgp_collector_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am__objects_1 = libgp_collector_la-gethrtime.lo \
libgp_collector_la-dispatcher.lo libgp_collector_la-iolib.lo \
libgp_collector_la-mmaptrace.lo libgp_collector_la-memmgr.lo \
@@ -305,6 +306,7 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
+CLOCK_GETTIME_LINK = @CLOCK_GETTIME_LINK@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
@@ -459,7 +461,7 @@ libgp_collector_la_CPPFLAGS = $(AM_CPPFLAGS) $(jdk_inc) \
# Prevent libtool from reordering -Wl,--no-as-needed after -lrt by
# disguising -lrt as a linker flag.
libgp_collector_la_LDFLAGS = $(AM_LDFLAGS)
-libgp_collector_la_LIBADD =
+libgp_collector_la_LIBADD = $(CLOCK_GETTIME_LINK)
libgp_heap_la_SOURCES = heaptrace.c
libgp_heap_la_LDFLAGS = $(AM_LDFLAGS)
libgp_sync_la_SOURCES = synctrace.c
diff --git a/gprofng/libcollector/configure b/gprofng/libcollector/configure
index ed23350..887d271 100755
--- a/gprofng/libcollector/configure
+++ b/gprofng/libcollector/configure
@@ -633,6 +633,7 @@ ac_subst_vars='am__EXEEXT_FALSE
am__EXEEXT_TRUE
LTLIBOBJS
LIBOBJS
+CLOCK_GETTIME_LINK
GPROFNG_VARIANT
CXXCPP
OTOOL64
@@ -12013,7 +12014,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12016 "configure"
+#line 12017 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -12119,7 +12120,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12122 "configure"
+#line 12123 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -15437,6 +15438,58 @@ case "${target}" in
esac
+clock_gettime_link=
+# At least for glibc, clock_gettime is in librt. But don't
+# pull that in if it still doesn't give us the function we want. This
+# test is copied from libgomp, and modified to not link in -lrt as
+# we're using this for test timing only.
+if test "$ac_cv_func_clock_gettime" = no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
+$as_echo_n "checking for clock_gettime in -lrt... " >&6; }
+if ${ac_cv_lib_rt_clock_gettime+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lrt $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char clock_gettime ();
+int
+main ()
+{
+return clock_gettime ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_rt_clock_gettime=yes
+else
+ ac_cv_lib_rt_clock_gettime=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $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" = xyes; then :
+ CLOCK_GETTIME_LINK=-lrt
+
+$as_echo "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
+
+fi
+
+fi
+
+
ac_config_files="$ac_config_files Makefile"
ac_config_headers="$ac_config_headers lib-config.h:../common/config.h.in"
diff --git a/gprofng/libcollector/configure.ac b/gprofng/libcollector/configure.ac
index 8acd66f..bc8c3f1 100644
--- a/gprofng/libcollector/configure.ac
+++ b/gprofng/libcollector/configure.ac
@@ -54,6 +54,19 @@ case "${target}" in
esac
AC_SUBST(GPROFNG_VARIANT)
+clock_gettime_link=
+# At least for glibc, clock_gettime is in librt. But don't
+# pull that in if it still doesn't give us the function we want. This
+# test is copied from libgomp, and modified to not link in -lrt as
+# 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
+ AC_DEFINE(HAVE_CLOCK_GETTIME, 1,
+ [Define to 1 if you have the `clock_gettime' function.])])
+fi
+AC_SUBST(CLOCK_GETTIME_LINK)
+
AC_CONFIG_FILES([Makefile])
AC_CONFIG_HEADERS([lib-config.h:../common/config.h.in])
AC_OUTPUT
diff --git a/gprofng/libcollector/gethrtime.c b/gprofng/libcollector/gethrtime.c
index f369cdc..002de7c 100644
--- a/gprofng/libcollector/gethrtime.c
+++ b/gprofng/libcollector/gethrtime.c
@@ -22,17 +22,22 @@
#include <time.h>
#include "gp-time.h"
-/*
- * CLOCK_MONOTONIC
- * Clock that cannot be set and represents monotonic time since some
- * unspecified starting point.
- */
+/* CLOCK_MONOTONIC
+ Clock that cannot be set and represents monotonic time since some
+ unspecified starting point. */
+
static hrtime_t
-linux_gethrtime ()
+linux_gethrtime (void)
{
struct timespec tp;
hrtime_t rc = 0;
+
+#ifdef CLOCK_MONOTONIC_RAW
int r = clock_gettime (CLOCK_MONOTONIC_RAW, &tp);
+#else
+ int r = clock_gettime (CLOCK_MONOTONIC, &tp);
+#endif
+
if (r == 0)
rc = ((hrtime_t) tp.tv_sec)*1000000000 + (hrtime_t) tp.tv_nsec;
return rc;