rpm/rpm-4.9.1.2-ppc64p7.patch

147 lines
3.8 KiB
Diff
Raw Normal View History

diff --git a/lib/rpmrc.c b/lib/rpmrc.c
index 1b47dc3..0050091 100644
--- a/lib/rpmrc.c
+++ b/lib/rpmrc.c
@@ -5,6 +5,12 @@
#include <setjmp.h>
#endif
+#if defined(__linux__)
+#include <elf.h>
+#include <link.h>
+#endif
+
+
#if HAVE_SYS_UTSNAME_H
#include <sys/utsname.h>
#endif
@@ -78,6 +84,11 @@ int required;
struct rpmOptionValue * value;
};
+static struct rpmat_s {
+ const char *platform;
+ uint64_t hwcap;
+} rpmat;
+
typedef struct defaultEntry_s {
char * name;
char * defName;
@@ -933,6 +944,45 @@ static void mfspr_ill(int notused)
}
#endif
+#if defined(__linux__)
+/**
+ * Populate rpmat structure with parsed info from /proc/self/auxv
+ */
+static void parse_auxv(void)
+{
+ static int oneshot = 1;
+
+ if (oneshot) {
+ rpmat.platform = "";
+ int fd = open("/proc/self/auxv", O_RDONLY);
+
+ if (fd == -1) {
+ rpmlog(RPMLOG_WARNING,
+ _("Failed to read auxiliary vector, /proc not mounted?\n"));
+ return;
+ } else {
+ ElfW(auxv_t) auxv;
+ while (read(fd, &auxv, sizeof(auxv)) == sizeof(auxv)) {
+ switch (auxv.a_type)
+ {
+ case AT_NULL:
+ break;
+ case AT_PLATFORM:
+ rpmat.platform = strdup((char *) auxv.a_un.a_val);
+ break;
+ case AT_HWCAP:
+ rpmat.hwcap = auxv.a_un.a_val;
+ break;
+ }
+ }
+ close(fd);
+ }
+ oneshot = 0; /* only try once even if it fails */
+ }
+ return;
+}
+#endif
+
/**
*/
static void defaultMachine(const char ** arch,
@@ -944,6 +994,11 @@ static void defaultMachine(const char ** arch,
canonEntry canon;
int rc;
+#if defined(__linux__)
+ /* Populate rpmat struct with hw info */
+ parse_auxv();
+#endif
+
while (!gotDefaults) {
if (!rpmPlatform(platform)) {
char * s;
@@ -1125,6 +1180,14 @@ static void defaultMachine(const char ** arch,
}
# endif /* sparc*-linux */
+# if defined(__linux__) && defined(__powerpc__)
+ {
+ int powerlvl;
+ if (sscanf(rpmat.platform, "power%d", &powerlvl) == 1 && powerlvl > 6)
+ strcpy(un.machine, "ppc64p7");
+ }
+# endif /* ppc64*-linux */
+
# if defined(__GNUC__) && defined(__alpha__)
{
unsigned long amask, implver;
diff --git a/rpmrc.in b/rpmrc.in
index 0033bbd..9b00b71 100644
--- a/rpmrc.in
+++ b/rpmrc.in
@@ -48,6 +48,7 @@ optflags: ppc32dy4 -O2 -g -fsigned-char
optflags: ppciseries -O2 -g -fsigned-char
optflags: ppcpseries -O2 -g -fsigned-char
optflags: ppc64 -O2 -g -fsigned-char
+optflags: ppc64p7 -O3 -mtune=power7 -mcpu=power7 -g -fsigned-char
optflags: parisc -O2 -g -mpa-risc-1-0
optflags: hppa1.0 -O2 -g -mpa-risc-1-0
@@ -157,6 +158,7 @@ arch_canon: s390x: s390x 15
arch_canon: ppc64: ppc64 16
arch_canon: ppc64pseries: ppc64pseries 16
arch_canon: ppc64iseries: ppc64iseries 16
+arch_canon: ppc64p7: ppc64p7 16
arch_canon: sh: sh 17
arch_canon: sh3: sh3 17
@@ -239,6 +241,7 @@ buildarchtranslate: ppciseries: ppc
buildarchtranslate: ppcpseries: ppc
buildarchtranslate: ppc64iseries: ppc64
buildarchtranslate: ppc64pseries: ppc64
+buildarchtranslate: ppc64p7: ppc64
buildarchtranslate: armv3l: armv3l
buildarchtranslate: armv4b: armv4b
@@ -307,6 +310,7 @@ arch_compat: ppc: rs6000
arch_compat: rs6000: noarch fat
arch_compat: ppc64pseries: ppc64
arch_compat: ppc64iseries: ppc64
+arch_compat: ppc64p7: ppc64
arch_compat: sun4c: sparc
arch_compat: sun4d: sparc
@@ -428,6 +432,7 @@ buildarch_compat: ppc: noarch fat
buildarch_compat: ppc64: noarch fat
buildarch_compat: ppc64pseries: ppc64
buildarch_compat: ppc64iseries: ppc64
+buildarch_compat: ppc64p7: ppc64
buildarch_compat: mips: noarch
buildarch_compat: mipsel: noarch