From 4e52fcf87574e53998451a3ead1be5d5a385192f Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Thu, 27 Apr 2023 22:13:13 +0800 Subject: [PATCH 1/3] Misc PPC additions --- src/absl/base/internal/direct_mmap.h | 2 +- src/absl/base/internal/unscaledcycleclock.cc | 10 ++++++---- src/absl/base/internal/unscaledcycleclock.h | 2 +- src/absl/debugging/internal/stack_consumption.cc | 4 ++-- src/absl/debugging/internal/stack_consumption.h | 7 ++++--- src/absl/debugging/internal/stacktrace_config.h | 2 +- 6 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/absl/base/internal/direct_mmap.h b/src/absl/base/internal/direct_mmap.h index e492bb0..2244240 100644 --- a/src/absl/base/internal/direct_mmap.h +++ b/src/absl/base/internal/direct_mmap.h @@ -77,7 +77,7 @@ inline void* DirectMmap(void* start, size_t length, int prot, int flags, int fd, defined(__m68k__) || defined(__sh__) || \ (defined(__hppa__) && !defined(__LP64__)) || \ (defined(__mips__) && _MIPS_SIM == _MIPS_SIM_ABI32) || \ - (defined(__PPC__) && !defined(__PPC64__)) || \ + (defined(__PPC__) && !defined(__PPC64__)) || defined(__ppc__) || \ (defined(__riscv) && __riscv_xlen == 32) || \ (defined(__s390__) && !defined(__s390x__)) || \ (defined(__sparc__) && !defined(__arch64__)) diff --git a/src/absl/base/internal/unscaledcycleclock.cc b/src/absl/base/internal/unscaledcycleclock.cc index b1c396c..db408c9 100644 --- a/src/absl/base/internal/unscaledcycleclock.cc +++ b/src/absl/base/internal/unscaledcycleclock.cc @@ -20,9 +20,11 @@ #include #endif -#if defined(__powerpc__) || defined(__ppc__) +#if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) #ifdef __GLIBC__ -#include +#ifndef __APPLE__ +#include // There is no such a header in macOS. Do we need another? +#endif #elif defined(__FreeBSD__) // clang-format off // This order does actually matter =(. @@ -58,13 +60,13 @@ double UnscaledCycleClock::Frequency() { return base_internal::NominalCPUFrequency(); } -#elif defined(__powerpc__) || defined(__ppc__) +#elif defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) int64_t UnscaledCycleClock::Now() { #ifdef __GLIBC__ return __ppc_get_timebase(); #else -#ifdef __powerpc64__ +#ifdef __powerpc64__ || defined(__ppc64__) int64_t tbr; asm volatile("mfspr %0, 268" : "=r"(tbr)); return tbr; diff --git a/src/absl/base/internal/unscaledcycleclock.h b/src/absl/base/internal/unscaledcycleclock.h index 2cbeae3..59ec151 100644 --- a/src/absl/base/internal/unscaledcycleclock.h +++ b/src/absl/base/internal/unscaledcycleclock.h @@ -46,7 +46,7 @@ // The following platforms have an implementation of a hardware counter. #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \ - defined(__powerpc__) || defined(__ppc__) || defined(__riscv) || \ + defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) || defined(__riscv) || \ defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC)) #define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 1 #else diff --git a/src/absl/debugging/internal/stack_consumption.cc b/src/absl/debugging/internal/stack_consumption.cc index 5134864..f8c3638 100644 --- a/src/absl/debugging/internal/stack_consumption.cc +++ b/src/absl/debugging/internal/stack_consumption.cc @@ -42,8 +42,8 @@ namespace { // one of them is null, the results of pq, p<=q, and p>=q are // unspecified. Therefore, instead we hardcode the direction of the // stack on platforms we know about. -#if defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || \ - defined(__aarch64__) || defined(__riscv) +#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \ + defined(__ppc__) || defined(__ppc64__) || defined(__riscv) constexpr bool kStackGrowsDown = true; #else #error Need to define kStackGrowsDown diff --git a/src/absl/debugging/internal/stack_consumption.h b/src/absl/debugging/internal/stack_consumption.h index f41b64c..0f9d27b 100644 --- a/src/absl/debugging/internal/stack_consumption.h +++ b/src/absl/debugging/internal/stack_consumption.h @@ -24,9 +24,10 @@ // Use this feature test macro to detect its availability. #ifdef ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION #error ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION cannot be set directly -#elif !defined(__APPLE__) && !defined(_WIN32) && \ - (defined(__i386__) || defined(__x86_64__) || defined(__ppc__) || \ - defined(__aarch64__) || defined(__riscv)) +// Presumably macOS PPC should be excluded as well; no RISC V on Apple or Windows. +#elif (!defined(__APPLE__) && !defined(_WIN32) && \ + (defined(__i386__) || defined(__x86_64__) || defined(__aarch64__))) || \ + (defined(__riscv) || defined(__ppc__) || defined(__ppc64__)) #define ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 1 namespace absl { diff --git a/src/absl/debugging/internal/stacktrace_config.h b/src/absl/debugging/internal/stacktrace_config.h index 3929b1b..606d5ff 100644 --- a/src/absl/debugging/internal/stacktrace_config.h +++ b/src/absl/debugging/internal/stacktrace_config.h @@ -60,7 +60,7 @@ #elif defined(__i386__) || defined(__x86_64__) #define ABSL_STACKTRACE_INL_HEADER \ "absl/debugging/internal/stacktrace_x86-inl.inc" -#elif defined(__ppc__) || defined(__PPC__) +#elif defined(__ppc__) || defined(__PPC__) || defined(__ppc64__) #define ABSL_STACKTRACE_INL_HEADER \ "absl/debugging/internal/stacktrace_powerpc-inl.inc" #elif defined(__aarch64__) -- 2.40.0