aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-05-07 14:07:00 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-05-07 14:07:00 +0000
commit815d242f1e298b0ae52efa896acd27780a80c738 (patch)
tree768ef68aad7333a0b6731f7f9d8fcbfaf3a615f2
parente98dd2a640ebabadd72a652184743df06bbd0b57 (diff)
parent7dc5036d091589cbb9942bb9d55daa1ff3531fdd (diff)
downloadperfetto-815d242f1e298b0ae52efa896acd27780a80c738.tar.gz
Merge "Use inline asm for clang/gcc in base::Rdtsc()" into main
-rw-r--r--include/perfetto/base/time.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/perfetto/base/time.h b/include/perfetto/base/time.h
index 13e575cbe..6436503d2 100644
--- a/include/perfetto/base/time.h
+++ b/include/perfetto/base/time.h
@@ -40,8 +40,6 @@
#if PERFETTO_BUILDFLAG(PERFETTO_ARCH_CPU_X86_64)
#if PERFETTO_BUILDFLAG(PERFETTO_COMPILER_MSVC)
#include <intrin.h>
-#else
-#include <x86intrin.h>
#endif
#endif
@@ -282,7 +280,15 @@ inline int64_t MkTime(int year, int month, int day, int h, int m, int s) {
#if PERFETTO_BUILDFLAG(PERFETTO_ARCH_CPU_X86_64)
inline uint64_t Rdtsc() {
+#if PERFETTO_BUILDFLAG(PERFETTO_COMPILER_MSVC)
return static_cast<uint64_t>(__rdtsc());
+#else
+ // Use inline asm for clang and gcc: rust ffi bindgen crashes in using
+ // intrinsics on ChromeOS.
+ uint64_t low, high;
+ __asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
+ return (high << 32) | low;
+#endif
}
#endif