RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  [EMAIL PROTECTED]
  Module: rpm                              Date:   06-Jul-2007 21:14:47
  Branch: HEAD                             Handle: 2007070620144601

  Modified files:
    rpm                     CHANGES
    rpm/lib                 rpmrc.c

  Log:
    - eliminate the voo-doo asm arch identification.

  Summary:
    Revision    Changes     Path
    1.1441      +1  -0      rpm/CHANGES
    2.203       +0  -473    rpm/lib/rpmrc.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1440 -r1.1441 CHANGES
  --- rpm/CHANGES       6 Jul 2007 19:05:57 -0000       1.1440
  +++ rpm/CHANGES       6 Jul 2007 19:14:46 -0000       1.1441
  @@ -1,4 +1,5 @@
   4.5 -> 5.0:
  +    - jbj: eliminate the voo-doo asm arch identification.
       - jbj: eliminate recursive parser helpers.
       - jbj: expunge every occurence of Rcfiles.
       - jbj: eliminate rcfile reading everywhere.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/rpmrc.c
  ============================================================================
  $ cvs diff -u -r2.202 -r2.203 rpmrc.c
  --- rpm/lib/rpmrc.c   6 Jul 2007 19:05:57 -0000       2.202
  +++ rpm/lib/rpmrc.c   6 Jul 2007 19:14:47 -0000       2.203
  @@ -2,9 +2,6 @@
   #include "system.h"
   
   #include <stdarg.h>
  -#if defined(__linux__) && defined(__powerpc__)
  -#include <setjmp.h>
  -#endif
   
   #if HAVE_SYS_SYSTEMCFG_H
   #include <sys/systemcfg.h>
  @@ -550,220 +547,6 @@
       return 0;
   }
   
  -#    if defined(__linux__) && defined(__i386__)
  -#include <setjmp.h>
  -#include <signal.h>
  -
  -/*
  - * Generic CPUID function
  - */
  -static inline void cpuid(unsigned int op, unsigned int *eax, unsigned int 
*ebx, unsigned int *ecx, unsigned int *edx)
  -     /[EMAIL PROTECTED] *eax, *ebx, *ecx, *edx @*/
  -{
  -#ifdef       __LCLINT__
  -    *eax = *ebx = *ecx = *edx = 0;
  -#endif
  -    asm volatile (
  -     "pushl  %%ebx           \n"
  -     "cpuid                  \n"
  -     "movl   %%ebx,  %%esi   \n"
  -     "popl   %%ebx           \n"
  -    : "=a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
  -    : "a" (op));
  -}
  -
  -/*
  - * CPUID functions returning a single datum
  - */
  -static inline unsigned int cpuid_eax(unsigned int op)
  -     /[EMAIL PROTECTED]/
  -{
  -     unsigned int tmp, val;
  -     cpuid(op, &val, &tmp, &tmp, &tmp);
  -     return val;
  -}
  -
  -static inline unsigned int cpuid_ebx(unsigned int op)
  -     /[EMAIL PROTECTED]/
  -{
  -     unsigned int tmp, val;
  -     cpuid(op, &tmp, &val, &tmp, &tmp);
  -     return val;
  -}
  -
  -static inline unsigned int cpuid_ecx(unsigned int op)
  -     /[EMAIL PROTECTED]/
  -{
  -     unsigned int tmp, val;
  -     cpuid(op, &tmp, &tmp, &val, &tmp);
  -     return val;
  -}
  -
  -static inline unsigned int cpuid_edx(unsigned int op)
  -     /[EMAIL PROTECTED]/
  -{
  -     unsigned int tmp, val;
  -     cpuid(op, &tmp, &tmp, &tmp, &val);
  -     return val;
  -}
  -
  -/[EMAIL PROTECTED]@*/
  -static sigjmp_buf jenv;
  -
  -static inline void model3(int _unused)
  -     /[EMAIL PROTECTED] internalState @*/
  -     /[EMAIL PROTECTED] internalState @*/
  -{
  -     siglongjmp(jenv, 1);
  -}
  -
  -static inline int RPMClass(void)
  -     /[EMAIL PROTECTED] internalState @*/
  -     /[EMAIL PROTECTED] internalState @*/
  -{
  -     int cpu;
  -     unsigned int tfms, junk, cap, capamd;
  -     struct sigaction oldsa;
  -     
  -     sigaction(SIGILL, NULL, &oldsa);
  -     signal(SIGILL, model3);
  -     
  -     if (sigsetjmp(jenv, 1)) {
  -             sigaction(SIGILL, &oldsa, NULL);
  -             return 3;
  -     }
  -             
  -     if (cpuid_eax(0x000000000)==0) {
  -             sigaction(SIGILL, &oldsa, NULL);
  -             return 4;
  -     }
  -
  -     cpuid(0x00000001, &tfms, &junk, &junk, &cap);
  -     cpuid(0x80000001, &junk, &junk, &junk, &capamd);
  -     
  -     cpu = (tfms>>8)&15;
  -
  -     sigaction(SIGILL, &oldsa, NULL);
  -     
  -     if (cpu < 6)
  -             return cpu;
  -             
  -     if (cap & (1<<15)) {
  -             /* CMOV supported? */
  -             if (capamd & (1<<30))
  -                     return 7;       /* 3DNOWEXT supported */
  -             return 6;
  -     }
  -             
  -     return 5;
  -}
  -
  -/* should only be called for model 6 CPU's */
  -static int is_athlon(void)
  -     /[EMAIL PROTECTED]/
  -{
  -     unsigned int eax, ebx, ecx, edx;
  -     char vendor[16];
  -     int i;
  -     
  -     cpuid (0, &eax, &ebx, &ecx, &edx);
  -
  -     /* If you care about space, you can just check ebx, ecx and edx directly
  -        instead of forming a string first and then doing a strcmp */
  -     memset(vendor, 0, sizeof(vendor));
  -     
  -     for (i=0; i<4; i++)
  -             vendor[i] = (unsigned char) (ebx >>(8*i));
  -     for (i=0; i<4; i++)
  -             vendor[4+i] = (unsigned char) (edx >>(8*i));
  -     for (i=0; i<4; i++)
  -             vendor[8+i] = (unsigned char) (ecx >>(8*i));
  -             
  -     if (strncmp(vendor, "AuthenticAMD", 12) != 0)  
  -             return 0;
  -
  -     return 1;
  -}
  -
  -static int is_pentium3(void)
  -{
  -    unsigned int eax, ebx, ecx, edx, family, model;
  -    char vendor[16];
  -    cpuid(0, &eax, &ebx, &ecx, &edx);
  -    memset(vendor, 0, sizeof(vendor));
  -    *((unsigned int *)&vendor[0]) = ebx;
  -    *((unsigned int *)&vendor[4]) = edx;
  -    *((unsigned int *)&vendor[8]) = ecx;
  -    if (strncmp(vendor, "GenuineIntel", 12) != 0)
  -     return 0;
  -    cpuid(1, &eax, &ebx, &ecx, &edx);
  -    family = (eax >> 8) & 0x0f;
  -    model = (eax >> 4) & 0x0f;
  -    if (family == 6)
  -     switch (model)
  -     {
  -         case 7:     // Pentium III, Pentium III Xeon (model 7)
  -         case 8:     // Pentium III, Pentium III Xeon, Celeron (model 8)
  -         case 9:     // Pentium M
  -                     /*
  -                         Intel recently announced its new technology for 
mobile platforms,
  -                         named Centrino, and presents it as a big advance in 
mobile PCs.
  -                         One of the main part of Centrino consists in a 
brand new CPU,
  -                         the Pentium M, codenamed Banias, that we'll study 
in this review.
  -                         A particularity of this CPU is that it was designed 
for mobile platform
  -                         exclusively, unlike previous mobile CPU (Pentium 
III-M, Pentium 4-M)
  -                         that share the same micro-architecture as their 
desktop counterparts.
  -                         The Pentium M introduces a new micro-architecture, 
adapted for mobility
  -                         constraints, and that is halfway between the 
Pentium III and the Pentium 4.
  -                                                 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  -                     */
  -         case 10:    // Pentium III Xeon (model A)
  -         case 11:    // Pentium III (model B)
  -             return 1;
  -     }
  -    return 0;
  -}
  -
  -static int is_pentium4(void)
  -{
  -    unsigned int eax, ebx, ecx, edx, family, model;
  -    char vendor[16];
  -    cpuid(0, &eax, &ebx, &ecx, &edx);
  -    memset(vendor, 0, sizeof(vendor));
  -    *((unsigned int *)&vendor[0]) = ebx;
  -    *((unsigned int *)&vendor[4]) = edx;
  -    *((unsigned int *)&vendor[8]) = ecx;
  -    if (strncmp(vendor, "GenuineIntel", 12) != 0)
  -     return 0;
  -    cpuid(1, &eax, &ebx, &ecx, &edx);
  -    family = (eax >> 8) & 0x0f;
  -    model = (eax >> 4) & 0x0f;
  -    if (family == 15)
  -     switch (model)
  -     {
  -         case 0:     // Pentium 4, Pentium 4 Xeon                 (0.18um)
  -         case 1:     // Pentium 4, Pentium 4 Xeon MP, Celeron     (0.18um)
  -         case 2:     // Pentium 4, Mobile Pentium 4-M,
  -                     // Pentium 4 Xeon, Pentium 4 Xeon MP,
  -                     // Celeron, Mobile Celron                    (0.13um)
  -         case 3:     // Pentium 4, Celeron                        (0.09um)
  -         case 4:     // Pentium 4 540J
  -             return 1;
  -     }
  -    return 0;
  -}
  -
  -#endif
  -
  -#if defined(__linux__) && defined(__powerpc__)
  -static jmp_buf mfspr_jmpbuf;
  -
  -static void mfspr_ill(int notused)
  -{
  -    longjmp(mfspr_jmpbuf, -1);
  -}
  -#endif
  -
   /**
    */
   static void defaultMachine(/[EMAIL PROTECTED]@*/ const char ** arch,
  @@ -773,8 +556,6 @@
   {
       static struct utsname un;
       static int gotDefaults = 0;
  -    char * chptr;
  -    canonEntry canon;
       int rc;
   
       while (!gotDefaults) {
  @@ -814,260 +595,6 @@
        }
        if (gotDefaults)
            break;
  -
  -#if !defined(__linux__)
  -#ifdef SNI
  -     /* USUALLY un.sysname on sinix does start with the word "SINIX"
  -      * let's be absolutely sure
  -      */
  -     strncpy(un.sysname, "SINIX", sizeof(un.sysname));
  -#endif
  -     /[EMAIL PROTECTED]@*/
  -     if (!strcmp(un.sysname, "AIX")) {
  -         strcpy(un.machine, __power_pc() ? "ppc" : "rs6000");
  -         sprintf(un.sysname,"aix%s.%s", un.version, un.release);
  -     }
  -     else if(!strcmp(un.sysname, "Darwin")) { 
  -#ifdef __ppc__
  -         strcpy(un.machine, "ppc");
  -#else /* ifdef __i386__ */
  -         strcpy(un.machine, "i386");
  -#endif 
  -     }
  -     else if (!strcmp(un.sysname, "SunOS")) {
  -         if (!strncmp(un.release,"4", 1)) /* SunOS 4.x */ {
  -             int fd;
  -             for (fd = 0;
  -                 (un.release[fd] != 0 && (fd < sizeof(un.release)));
  -                 fd++) {
  -                   if (!xisdigit(un.release[fd]) && (un.release[fd] != '.')) 
{
  -                     un.release[fd] = 0;
  -                     /[EMAIL PROTECTED]@*/ break;
  -                   }
  -                 }
  -                 sprintf(un.sysname,"sunos%s",un.release);
  -         }
  -
  -         else /* Solaris 2.x: n.x.x becomes n-3.x.x */
  -             sprintf(un.sysname, "solaris%1d%s", atoi(un.release)-3,
  -                     un.release+1+(atoi(un.release)/10));
  -
  -         /* Solaris on Intel hardware reports i86pc instead of i386
  -          * (at least on 2.6 and 2.8)
  -          */
  -         if (!strcmp(un.machine, "i86pc"))
  -             sprintf(un.machine, "i386");
  -     }
  -     else if (!strcmp(un.sysname, "HP-UX"))
  -         /*make un.sysname look like hpux9.05 for example*/
  -         sprintf(un.sysname, "hpux%s", strpbrk(un.release, "123456789"));
  -     else if (!strcmp(un.sysname, "OSF1"))
  -         /*make un.sysname look like osf3.2 for example*/
  -         sprintf(un.sysname, "osf%s", strpbrk(un.release, "123456789"));
  -     else if (!strncmp(un.sysname, "IP", 2))
  -         un.sysname[2] = '\0';
  -     else if (!strncmp(un.sysname, "SINIX", 5)) {
  -         sprintf(un.sysname, "sinix%s",un.release);
  -         if (!strncmp(un.machine, "RM", 2))
  -             sprintf(un.machine, "mips");
  -     }
  -     else if ((!strncmp(un.machine, "34", 2) ||
  -             !strncmp(un.machine, "33", 2)) && \
  -             !strncmp(un.release, "4.0", 3))
  -     {
  -         /* we are on ncr-sysv4 */
  -         char * prelid = NULL;
  -         FD_t fd = Fopen("/etc/.relid", "r.fdio");
  -         int gotit = 0;
  -         /[EMAIL PROTECTED]@*/
  -         if (fd != NULL && !Ferror(fd)) {
  -             chptr = xcalloc(1, 256);
  -             {   int irelid = Fread(chptr, sizeof(*chptr), 256, fd);
  -                 (void) Fclose(fd);
  -                 /* example: "112393 RELEASE 020200 Version 01 OS" */
  -                 if (irelid > 0) {
  -                     if ((prelid = strstr(chptr, "RELEASE "))){
  -                         prelid += strlen("RELEASE ")+1;
  -                         sprintf(un.sysname,"ncr-sysv4.%.*s",1,prelid);
  -                         gotit = 1;
  -                     }
  -                 }
  -             }
  -             chptr = _free (chptr);
  -         }
  -         /[EMAIL PROTECTED]@*/
  -         if (!gotit) /* parsing /etc/.relid file failed? */
  -             strcpy(un.sysname,"ncr-sysv4");
  -         /* wrong, just for now, find out how to look for i586 later*/
  -         strcpy(un.machine,"i486");
  -     }
  -     /[EMAIL PROTECTED]@*/
  -#endif       /* __linux__ */
  -
  -     /* get rid of the hyphens in the sysname */
  -     for (chptr = un.machine; *chptr != '\0'; chptr++)
  -         if (*chptr == '/') *chptr = '-';
  -
  -#    if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL)
  -         /* little endian */
  -         strcpy(un.machine, "mipsel");
  -#    elif defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB)
  -        /* big endian */
  -             strcpy(un.machine, "mips");
  -#    endif
  -
  -#    if defined(__hpux) && defined(_SC_CPU_VERSION)
  -     {
  -#        if !defined(CPU_PA_RISC1_2)
  -#                define CPU_PA_RISC1_2  0x211 /* HP PA-RISC1.2 */
  -#           endif
  -#           if !defined(CPU_PA_RISC2_0)
  -#               define CPU_PA_RISC2_0  0x214 /* HP PA-RISC2.0 */
  -#           endif
  -         int cpu_version = sysconf(_SC_CPU_VERSION);
  -
  -#        if defined(CPU_HP_MC68020)
  -             if (cpu_version == CPU_HP_MC68020)
  -                 strcpy(un.machine, "m68k");
  -#        endif
  -#        if defined(CPU_HP_MC68030)
  -             if (cpu_version == CPU_HP_MC68030)
  -                 strcpy(un.machine, "m68k");
  -#        endif
  -#        if defined(CPU_HP_MC68040)
  -             if (cpu_version == CPU_HP_MC68040)
  -                 strcpy(un.machine, "m68k");
  -#        endif
  -
  -#        if defined(CPU_PA_RISC1_0)
  -             if (cpu_version == CPU_PA_RISC1_0)
  -                 strcpy(un.machine, "hppa1.0");
  -#        endif
  -#        if defined(CPU_PA_RISC1_1)
  -             if (cpu_version == CPU_PA_RISC1_1)
  -                 strcpy(un.machine, "hppa1.1");
  -#        endif
  -#        if defined(CPU_PA_RISC1_2)
  -             if (cpu_version == CPU_PA_RISC1_2)
  -                 strcpy(un.machine, "hppa1.2");
  -#        endif
  -#        if defined(CPU_PA_RISC2_0)
  -             if (cpu_version == CPU_PA_RISC2_0)
  -                 strcpy(un.machine, "hppa2.0");
  -#        endif
  -     }
  -#    endif   /* hpux */
  -
  -#    if defined(__linux__) && defined(__sparc__)
  -     if (!strcmp(un.machine, "sparc")) {
  -         #define PERS_LINUX          0x00000000
  -         #define PERS_LINUX_32BIT    0x00800000
  -         #define PERS_LINUX32        0x00000008
  -
  -         extern int personality(unsigned long);
  -         int oldpers;
  -         
  -         oldpers = personality(PERS_LINUX_32BIT);
  -         if (oldpers != -1) {
  -             if (personality(PERS_LINUX) != -1) {
  -                 uname(&un);
  -                 if (! strcmp(un.machine, "sparc64")) {
  -                     strcpy(un.machine, "sparcv9");
  -                     oldpers = PERS_LINUX32;
  -                 }
  -             }
  -             personality(oldpers);
  -         }
  -     }
  -#    endif   /* sparc*-linux */
  -
  -#    if defined(__GNUC__) && defined(__alpha__)
  -     {
  -         unsigned long amask, implver;
  -         register long v0 __asm__("$0") = -1;
  -         __asm__ (".long 0x47e00c20" : "=r"(v0) : "0"(v0));
  -         amask = ~v0;
  -         __asm__ (".long 0x47e03d80" : "=r"(v0));
  -         implver = v0;
  -         switch (implver) {
  -         case 1:
  -             switch (amask) {
  -             case 0: strcpy(un.machine, "alphaev5"); break;
  -             case 1: strcpy(un.machine, "alphaev56"); break;
  -             case 0x101: strcpy(un.machine, "alphapca56"); break;
  -             }
  -             break;
  -         case 2:
  -             switch (amask) {
  -             case 0x303: strcpy(un.machine, "alphaev6"); break;
  -             case 0x307: strcpy(un.machine, "alphaev67"); break;
  -             }
  -             break;
  -         }
  -     }
  -#    endif
  -
  -#    if defined(__linux__) && defined(__i386__)
  -     {
  -         char class = (char) (RPMClass() | '0');
  -
  -         if ((class == '6' && is_athlon()) || class == '7')
  -             strcpy(un.machine, "athlon");
  -         else if (is_pentium4())
  -             strcpy(un.machine, "pentium4");
  -         else if (is_pentium3())
  -             strcpy(un.machine, "pentium3");
  -         else if (strchr("3456", un.machine[1]) && un.machine[1] != class)
  -             un.machine[1] = class;
  -     }
  -#    endif
  -
  -#    if defined(__linux__) && defined(__powerpc__)
  -     {
  -         unsigned pvr = 0;
  -         __sighandler_t oldh = signal(SIGILL, mfspr_ill);
  -         if (setjmp(mfspr_jmpbuf) == 0) {
  -             __asm__ __volatile__ ("mfspr %0, 287" : "=r" (pvr));
  -         }
  -         signal(SIGILL, oldh);
  -
  -         if ( pvr ) {
  -             pvr >>= 16;
  -             switch (pvr) {
  -             /* IBM750FX, 7410, 7450,  7451, 7441, 7455, 7445 */ 
  -             case 0x7000:
  -             case 0x8000:
  -             case 0x8001:
  -             case 0x800c:
  -                 strcpy(un.machine, "ppc"); 
  -                 break;
  -             case 0x36:
  -             case 0x37:
  -                 strcpy(un.machine, "ppciseries");
  -                 break;
  -             default:
  -                 if ( pvr >= 0x40)
  -                     strcpy(un.machine, "ppcpseries");
  -                 else
  -                     strcpy(un.machine, "ppc");
  -                 break;
  -             }
  -         }
  -     }
  -#    endif
  -
  -     /* the uname() result goes through the arch_canon table */
  -     canon = lookupInCanonTable(un.machine,
  -                                tables[RPM_MACHTABLE_INSTARCH].canons,
  -                                tables[RPM_MACHTABLE_INSTARCH].canonsLength);
  -     if (canon)
  -         strcpy(un.machine, canon->short_name);
  -
  -     canon = lookupInCanonTable(un.sysname,
  -                                tables[RPM_MACHTABLE_INSTOS].canons,
  -                                tables[RPM_MACHTABLE_INSTOS].canonsLength);
  -     if (canon)
  -         strcpy(un.sysname, canon->short_name);
        gotDefaults = 1;
        break;
       }
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to