blob: 191554110467e6c33e61401632ca56f0553b462f [file] [log] [blame]
Upstream-Status: Backport
From 08241f1b2c5a4d48020c82b509dc1076f51bf0bd Mon Sep 17 00:00:00 2001
From: Maynard Johnson <maynardj@us.ibm.com>
Date: Wed, 14 Aug 2013 15:40:44 -0500
Subject: [PATCH] Fix compile error on ppc/uClibc platform: 'AT_BASE_PLATFORM'
undeclared'
This issue was reported via bug #245.
The method for obtaining cpu type on the ppc64 platform was recently
modified to detect the case when we're running on a kernel that has
not been updated to recognize the native processor type. The cpu
type returned in the case where the native processor type is newer
than POWER7 will be "CPU_PPC64_ARCH_V1" (architected CPU type).
The method used for detecting when the kernel does not recognize the
native processor type is to inspect the aux vector and compare
AT_PLATFORM and AT_BASE_PLATFORM. The 'AT_BASE_PLATFORM' was defined
in glibc's elf.h around 5 years ago, but was never added to uClibc,
so the code that implements the above-described method fails to compile
on systems using uClibc.
Since the above-described method of using the aux vector is only
required for ppc64 systems, and ppc64-based platforms always use glibc
(which has the AT_BASE_PLATFORM macro defined), we now wrap that code
with '#if PPC64_ARCH' to prevent problems on other architectures.
Signed-off-by: Maynard Johnson <maynardj@us.ibm.com>
---
libop/op_cpu_type.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/libop/op_cpu_type.c b/libop/op_cpu_type.c
index 44d6809..89d5a92 100644
--- a/libop/op_cpu_type.c
+++ b/libop/op_cpu_type.c
@@ -23,9 +23,16 @@
#include <elf.h>
#include <link.h>
+#include "config.h"
#include "op_cpu_type.h"
#include "op_hw_specific.h"
+/* A macro to be used for ppc64 architecture-specific code. The '__powerpc__' macro
+ * is defined for both ppc64 and ppc32 architectures, so we must further qualify by
+ * including the 'HAVE_LIBPFM' macro, since that macro will be defined only for ppc64.
+ */
+#define PPC64_ARCH (HAVE_LIBPFM) && ((defined(__powerpc__) || defined(__powerpc64__)))
+
struct cpu_descr {
char const * pretty;
char const * name;
@@ -176,6 +183,7 @@ static char * _get_cpuinfo_cpu_type(char * buf, int len, const char * prefix)
return _get_cpuinfo_cpu_type_line(buf, len, prefix, 1);
}
+#if PPC64_ARCH
// The aux vector stuff below is currently only used by ppc64 arch
static ElfW(auxv_t) * auxv_buf = NULL;
@@ -312,6 +320,13 @@ static op_cpu _get_ppc64_cpu_type(void)
cpu_type = op_get_cpu_number(cpu_type_str);
return cpu_type;
}
+#else
+static op_cpu _get_ppc64_cpu_type(void)
+{
+ return CPU_NO_GOOD;
+}
+#endif
+
static op_cpu _get_arm_cpu_type(void)
{
--
1.9.0