teknoraver / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone
Blob Blame History Raw
diff -uNr rpm-4.9.0-orig//lib/rpmrc.c rpm-4.9.0/lib/rpmrc.c
--- rpm-4.9.0-orig//lib/rpmrc.c	2011-08-05 12:23:04.000000000 -0500
+++ rpm-4.9.0/lib/rpmrc.c	2011-08-05 12:25:13.000000000 -0500
@@ -732,6 +732,56 @@
 }
 #endif
 
+#if defined(__linux__) && defined(__arm__)
+static int has_neon()
+{
+        char buffer[4096], *p;
+        int fd = open("/proc/cpuinfo", O_RDONLY);
+        if (read(fd, &buffer, sizeof(buffer) - 1) == -1) {
+                rpmlog(RPMLOG_WARNING, _("read(/proc/cpuinfo) failed\n"));
+                close(fd);
+                return 0;
+        }
+        close(fd);
+
+        p = strstr(buffer, "Features");
+        p = strtok(p, "\n");
+        p = strstr(p, "neon");
+        p = strtok(p, " ");
+        if (p == NULL) {
+                rpmlog(RPMLOG_WARNING, _("/proc/cpuinfo has no 'Features' line\n"));
+                return 0;
+        } else if (strcmp(p, "neon") == 0) {
+                return 1;
+        }
+        return 0;
+}
+
+static int has_hfp()
+{
+        char buffer[4096], *p;
+        int fd = open("/proc/cpuinfo", O_RDONLY);
+        if (read(fd, &buffer, sizeof(buffer) - 1) == -1) {
+                rpmlog(RPMLOG_WARNING, _("read(/proc/cpuinfo) failed\n"));
+                close(fd);
+                return 0;
+        }
+        close(fd);
+
+        p = strstr(buffer, "Features");
+        p = strtok(p, "\n");
+        p = strstr(p, "vfpv3");
+        p = strtok(p, " ");
+        if (p == NULL) {
+                rpmlog(RPMLOG_WARNING, _("/proc/cpuinfo has no 'Features' line\n"));
+                return 0;
+        } else if (strcmp(p, "vfpv3") == 0) {
+                return 1;
+        }
+        return 0;
+}
+#endif
+
 
 #	if defined(__linux__) && defined(__i386__)
 #include <setjmp.h>
@@ -1157,6 +1207,22 @@
 	}
 #	endif	/* sparc*-linux */
 
+#	if defined(__linux__) && defined(__arm__)
+	{
+	    if (strcmp(un.machine, "armv7l") == 0 ) {
+	        if (has_neon() && has_hfp())
+                    strcpy(un.machine, "armv7hnl");
+                else if (has_hfp())
+                    strcpy(un.machine, "armv7hl");
+	    } else if (strcmp(un.machine, "armv6l") == 0 ) {
+	        if (has_neon() && has_hfp())
+                    strcpy(un.machine, "armv6hnl");
+                else if (has_hfp())
+                    strcpy(un.machine, "armv6hl");
+	    }
+	}
+#	endif	/* arm*-linux */
+
 #	if defined(__GNUC__) && defined(__alpha__)
 	{
 	    unsigned long amask, implver;