From c2407e6d4cca53c9987c2c197e9a7d932588c36f Mon Sep 17 00:00:00 2001 From: barracuda156 Date: Thu, 9 Nov 2023 02:55:54 +0800 Subject: [PATCH 03/12] cpu.cc: support powerpc-darwin --- src/base/cpu.cc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/base/cpu.cc b/src/base/cpu.cc index f1c48fa1356..06afd61c2dc 100644 --- a/v8/src/base/cpu.cc +++ b/v8/src/base/cpu.cc @@ -28,6 +28,15 @@ #define POWER_9 0x20000 #endif #endif +#if V8_OS_MACOSX +#include // sysctlbyname +#if V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64 +#include +#include +#include +#include +#endif +#endif #if V8_OS_POSIX #include // sysconf() #endif @@ -679,7 +688,24 @@ CPU::CPU() part_ = PPC_POWER5; break; } -#endif // V8_OS_AIX + +#elif V8_OS_MACOSX + +struct host_basic_info host_basic_info; + switch(host_basic_info.cpu_subtype) { + case CPU_SUBTYPE_POWERPC_970: + default: + part_ = PPC_G5; + break; + case CPU_SUBTYPE_POWERPC_7450: + part_ = PPC_G4; + break; + case CPU_SUBTYPE_POWERPC_7400: + part_ = PPC_G4; + break; + } + +#endif // V8_OS_MACOSX #endif // !USE_SIMULATOR #endif // V8_HOST_ARCH_PPC || V8_HOST_ARCH_PPC64 }