Index: src/base/cpu.cc |
diff --git a/src/base/cpu.cc b/src/base/cpu.cc |
index 56e1c4633c6e28edbfc9b1e17bf3f0c67ffcd5df..0cf3fb85304a912dae428e67bf37ddb5c6001789 100644 |
--- a/src/base/cpu.cc |
+++ b/src/base/cpu.cc |
@@ -16,6 +16,9 @@ |
#if V8_OS_QNX |
#include <sys/syspage.h> // cpuinfo |
#endif |
+#if V8_OS_LINUX && V8_HOST_ARCH_PPC |
+#include <elf.h> |
+#endif |
#if V8_OS_POSIX |
#include <unistd.h> // sysconf() |
#endif |
@@ -580,7 +583,54 @@ CPU::CPU() |
delete[] part; |
} |
+#elif V8_HOST_ARCH_PPC |
+ |
+#ifndef USE_SIMULATOR |
+#if V8_OS_LINUX |
+ // Read processor info from /proc/self/auxv. |
+ char* auxv_cpu_type = NULL; |
+ FILE* fp = fopen("/proc/self/auxv", "r"); |
+ if (fp != NULL) { |
+#if V8_TARGET_ARCH_PPC64 |
+ Elf64_auxv_t entry; |
+#else |
+ Elf32_auxv_t entry; |
#endif |
+ for (;;) { |
+ size_t n = fread(&entry, sizeof(entry), 1, fp); |
+ if (n == 0 || entry.a_type == AT_NULL) { |
+ break; |
+ } |
+ if (entry.a_type == AT_PLATFORM) { |
+ auxv_cpu_type = reinterpret_cast<char*>(entry.a_un.a_val); |
+ break; |
+ } |
+ } |
+ fclose(fp); |
+ } |
+ |
+ part_ = -1; |
+ if (auxv_cpu_type) { |
+ if (strcmp(auxv_cpu_type, "power8") == 0) { |
+ part_ = PPC_POWER8; |
+ } else if (strcmp(auxv_cpu_type, "power7") == 0) { |
+ part_ = PPC_POWER7; |
+ } else if (strcmp(auxv_cpu_type, "power6") == 0) { |
+ part_ = PPC_POWER6; |
+ } else if (strcmp(auxv_cpu_type, "power5") == 0) { |
+ part_ = PPC_POWER5; |
+ } else if (strcmp(auxv_cpu_type, "ppc970") == 0) { |
+ part_ = PPC_G5; |
+ } else if (strcmp(auxv_cpu_type, "ppc7450") == 0) { |
+ part_ = PPC_G4; |
+ } else if (strcmp(auxv_cpu_type, "pa6t") == 0) { |
+ part_ = PPC_PA6T; |
+ } |
+ } |
+ |
+#endif // V8_OS_LINUX |
+#endif // !USE_SIMULATOR |
+#endif // V8_HOST_ARCH_PPC |
} |
} } // namespace v8::base |