aboutsummaryrefslogtreecommitdiff
path: root/devel/abseil/files/patch-absl_base_internal_unscaledcycleclock.cc
diff options
context:
space:
mode:
authorPiotr Kubaj <pkubaj@FreeBSD.org>2019-08-28 17:15:45 +0000
committerPiotr Kubaj <pkubaj@FreeBSD.org>2019-08-28 17:15:45 +0000
commit282a3799a4c07fd63c5402308ab03d546cc6fbb6 (patch)
treea839fafd6c38c6465fc0a49566af927dc571da66 /devel/abseil/files/patch-absl_base_internal_unscaledcycleclock.cc
parent06c0cc0bac7dd9ca227da2fbd59ebf2969074ee4 (diff)
downloadports-282a3799a4c07fd63c5402308ab03d546cc6fbb6.tar.gz
ports-282a3799a4c07fd63c5402308ab03d546cc6fbb6.zip
devel/abseil: fix build on powerpc*
Implement logic for querying TBR and TBR frequency to fix build. PR: 239423 Approved by: danfe (maintainer), tcberner (mentor) Differential Revision: https://reviews.freebsd.org/D21430
Notes
Notes: svn path=/head/; revision=510083
Diffstat (limited to 'devel/abseil/files/patch-absl_base_internal_unscaledcycleclock.cc')
-rw-r--r--devel/abseil/files/patch-absl_base_internal_unscaledcycleclock.cc54
1 files changed, 54 insertions, 0 deletions
diff --git a/devel/abseil/files/patch-absl_base_internal_unscaledcycleclock.cc b/devel/abseil/files/patch-absl_base_internal_unscaledcycleclock.cc
new file mode 100644
index 000000000000..392739e0ed1c
--- /dev/null
+++ b/devel/abseil/files/patch-absl_base_internal_unscaledcycleclock.cc
@@ -0,0 +1,54 @@
+--- absl/base/internal/unscaledcycleclock.cc.orig 2019-07-24 12:47:23 UTC
++++ absl/base/internal/unscaledcycleclock.cc
+@@ -20,10 +20,15 @@
+ #include <intrin.h>
+ #endif
+
+-#if defined(__powerpc__) || defined(__ppc__)
++#if (defined(__powerpc__) || defined(__ppc__)) && !defined(__FreeBSD__)
+ #include <sys/platform/ppc.h>
+ #endif
+
++#ifdef __FreeBSD__
++#include <sys/types.h>
++#include <sys/sysctl.h>
++#endif
++
+ #include "absl/base/internal/sysinfo.h"
+
+ namespace absl {
+@@ -56,11 +61,34 @@ double UnscaledCycleClock::Frequency() {
+ #elif defined(__powerpc__) || defined(__ppc__)
+
+ int64_t UnscaledCycleClock::Now() {
++#ifndef __FreeBSD__
+ return __ppc_get_timebase();
++#else
++ union { long long complete; unsigned int part[2]; } ticks;
++ unsigned int tmp;
++ asm volatile(
++ "0:\n"
++ "mftbu %[hi32]\n"
++ "mftb %[lo32]\n"
++ "mftbu %[tmp]\n"
++ "cmpw %[tmp],%[hi32]\n"
++ "bne 0b\n"
++ : [hi32] "=r"(ticks.part[0]), [lo32] "=r"(ticks.part[1]),
++ [tmp] "=r"(tmp)
++ );
++ return ticks.complete;
++#endif
+ }
+
+ double UnscaledCycleClock::Frequency() {
++#ifndef __FreeBSD__
+ return __ppc_get_timebase_freq();
++#else
++ long timebaseFrequency = 0;
++ size_t length = sizeof(timebaseFrequency);
++ sysctlbyname("kern.timecounter.tc.timebase.frequency", &timebaseFrequency, &length, NULL, 0);
++ return timebaseFrequency;
++#endif
+ }
+
+ #elif defined(__aarch64__)