From: David CARLIER Date: Fri, 15 Jan 2021 15:41:47 +0000 (+0000) Subject: Profiling: CPU timing implemented for MAC non-x86 (#757) X-Git-Tag: SQUID_4_15~13 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=1aebcbb0db55abb0c92e0e4066df9388839b817a;p=thirdparty%2Fsquid.git Profiling: CPU timing implemented for MAC non-x86 (#757) --- diff --git a/CONTRIBUTORS b/CONTRIBUTORS index c10a221543..4a7edc802b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -105,6 +105,7 @@ Thank you! Dan Searle Dan Searle Dave Dykstra + David Carlier David Hill David Isaacs David J N Begley diff --git a/acinclude/os-deps.m4 b/acinclude/os-deps.m4 index 9ef50cf0e5..0baf42bc3b 100644 --- a/acinclude/os-deps.m4 +++ b/acinclude/os-deps.m4 @@ -792,6 +792,7 @@ AC_DEFUN([SQUID_CHECK_FUNCTIONAL_CPU_PROFILER],[ AC_CACHE_CHECK([for operational CPU clock access], squid_cv_cpu_profiler_works, AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ +#include #if defined(__GNUC__) && ( defined(__i386) || defined(__i386__) ) // okay #elif defined(__GNUC__) && ( defined(__x86_64) || defined(__x86_64__) ) @@ -800,6 +801,8 @@ AC_DEFUN([SQUID_CHECK_FUNCTIONAL_CPU_PROFILER],[ // okay #elif defined(_M_IX86) && defined(_MSC_VER) /* x86 platform on Microsoft C Compiler ONLY */ // okay +#elif defined(HAVE_CLOCK_GETTIME_NSEC_NP) && defined(CLOCK_MONOTONIC_RAW) +// okay #else #error This CPU is unsupported. No profiling available here. #endif diff --git a/configure.ac b/configure.ac index 9a1bf4ca47..6c7a1507c8 100644 --- a/configure.ac +++ b/configure.ac @@ -2816,6 +2816,7 @@ SQUID_YESNO([$enableval], ]) # Default OFF. This is a debug feature. Only check and enable if forced ON. if test "x$enable_cpu_profiling" = "xyes"; then + AC_CHECK_FUNCS(clock_gettime_nsec_np) SQUID_CHECK_FUNCTIONAL_CPU_PROFILER if test "x$squid_cv_cpu_profiler_works" = "xno"; then AC_MSG_ERROR([CPU profiling will not be functional in this build.]) diff --git a/lib/profiler/get_tick.h b/lib/profiler/get_tick.h index 08771723ab..25b193e436 100644 --- a/lib/profiler/get_tick.h +++ b/lib/profiler/get_tick.h @@ -10,6 +10,7 @@ #define _PROFILER_GET_TICK_H_ #if USE_XPROF_STATS +#include /* * Ensure that any changes here are synchronised with SQUID_CHECK_FUNCTIONAL_CPU_PROFILER @@ -67,6 +68,14 @@ get_tick(void) return regs; } +#elif defined(HAVE_CLOCK_GETTIME_NSEC_NP) && defined(CLOCK_MONOTONIC_RAW) + +static inline hrtime_t +get_tick() +{ + return clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW); +} + #else /* This CPU is unsupported. Short-circuit, no profiling here */ // #error for configure tests to prevent library construction