diff options
Diffstat (limited to 'gprofng/libcollector')
-rw-r--r-- | gprofng/libcollector/Makefile.am | 2 | ||||
-rw-r--r-- | gprofng/libcollector/Makefile.in | 6 | ||||
-rwxr-xr-x | gprofng/libcollector/configure | 57 | ||||
-rw-r--r-- | gprofng/libcollector/configure.ac | 13 | ||||
-rw-r--r-- | gprofng/libcollector/gethrtime.c | 17 |
5 files changed, 84 insertions, 11 deletions
diff --git a/gprofng/libcollector/Makefile.am b/gprofng/libcollector/Makefile.am index bd86e97753d..a41b92030e0 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 920c7a7ad11..f9ed2d95db5 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 ed23350d7b6..887d2719910 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 8acd66f6977..bc8c3f1e144 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 f369cdc8ee1..002de7c77ba 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; |