File rpmrctests.diff of Package rpm
Patch machine detection code: always use "ppc", restore SIGILL
handler, detect transmeta. [#52713]
--- ./lib/rpmrc.c.orig	2005-01-17 18:46:23.000000000 +0000
+++ ./lib/rpmrc.c	2005-12-16 18:30:29.000000000 +0000
@@ -2,9 +2,6 @@
 #include "system.h"
 
 #include <stdarg.h>
-#if defined(__linux__) && defined(__powerpc__)
-#include <setjmp.h>
-#endif
 
 #include <ctype.h>	/* XXX for /etc/rpm/platform contents */
 
@@ -953,20 +950,38 @@ static inline int RPMClass(void)
 {
 	int cpu;
 	unsigned int tfms, junk, cap, capamd;
+	struct sigaction oldsa;
 	
+	sigaction(SIGILL, NULL, &oldsa);
 	signal(SIGILL, model3);
 	
-	if (sigsetjmp(jenv, 1))
+	if (sigsetjmp(jenv, 1)) {
+		sigaction(SIGILL, &oldsa, NULL);
 		return 3;
+	}
 		
-	if (cpuid_eax(0x000000000)==0)
+	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;
 	
+        /* Check if we have a Transmeta i686-compatible CPU
+           that reports as being i586 */
+	if(cpu == 5
+	    && cpuid_ecx(0)=='68xM'
+	    && cpuid_edx(0)=='Teni'
+	    && (cpuid_edx(1) & ((1<<8)|(1<<15))) == ((1<<8)|(1<<15))) {
+		sigaction(SIGILL, &oldsa, NULL);
+		return 6;       /* has CX8 and CMOV */
+	}
+
+	sigaction(SIGILL, &oldsa, NULL);
+
 	if (cpu < 6)
 		return cpu;
 		
@@ -1076,15 +1091,6 @@ static int is_pentium4()
 
 #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(/*@out@*/ const char ** arch,
@@ -1219,6 +1225,11 @@ static void defaultMachine(/*@out@*/ con
 	   /* big endian */
 		strcpy(un.machine, "mips");
 #	endif
+	/* in linux, lets rename parisc to hppa */
+#if defined(__linux__)
+	if (!strcmp(un.machine,"parisc"))
+	    strcpy(un.machine,"hppa");
+#endif
 
 #	if defined(__hpux) && defined(_SC_CPU_VERSION)
 	{
@@ -1326,27 +1337,6 @@ static void defaultMachine(/*@out@*/ con
 	}
 #	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;
-		if ( pvr >= 0x40)
-		    strcpy(un.machine, "ppcpseries");
-		else if ( (pvr == 0x36) || (pvr == 0x37) )
-		    strcpy(un.machine, "ppciseries");
-		else
-		    strcpy(un.machine, "ppc");
-	    }
-	}
-#	endif
-
 	/* the uname() result goes through the arch_canon table */
 	canon = lookupInCanonTable(un.machine,
 				   tables[RPM_MACHTABLE_INSTARCH].canons,