[rpm/f17] - Add support for ppc64p7 architecture using new auxv parsing info

Phil Knirsch pknirsch at fedoraproject.org
Wed Apr 18 12:03:33 UTC 2012


commit 3c2064a504268a1b24f81be9776c98241566c0dc
Author: Phil Knirsch <pknirsch at redhat.com>
Date:   Wed Apr 18 13:09:06 2012 +0200

        - Add support for ppc64p7 architecture using new auxv parsing info
    
        Signed-off-by: Panu Matilainen <pmatilai at redhat.com>
        (cherry picked from commit f9eedd7f694a3dd3db637089f978dab4bd6858ee)
    
        - Add general /proc/self/auxv parsing to rpmrc for better machine detection
    
        Signed-off-by: Panu Matilainen <pmatilai at redhat.com>
        (cherry picked from commit 280494cce023f3938023b9b2b1173405601e4ddf)
    
        Conflicts:
    
            lib/rpmrc.c

 rpm-4.9.1.2-ppc64p7.patch |  146 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 146 insertions(+), 0 deletions(-)
---
diff --git a/rpm-4.9.1.2-ppc64p7.patch b/rpm-4.9.1.2-ppc64p7.patch
new file mode 100644
index 0000000..a21d8a4
--- /dev/null
+++ b/rpm-4.9.1.2-ppc64p7.patch
@@ -0,0 +1,146 @@
+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


More information about the scm-commits mailing list