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: 4.15-20210522-snapshot~38 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9b8a8fe3a8f1544a880689acc84223b8883a312a;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 e88ae7b9b7..a0c4e8cc83 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 2396cd74ba..f24a62998f 100644 --- a/configure.ac +++ b/configure.ac @@ -2638,6 +2638,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 8e8189f27d..f748d2feeb 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