chantra / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
5860f5
diff -up rpm-4.9.1.3/lib/rpmrc.c.armhfp-logic rpm-4.9.1.3/lib/rpmrc.c
5860f5
--- rpm-4.9.1.3/lib/rpmrc.c.armhfp-logic	2012-04-19 17:11:32.728750591 +0200
5860f5
+++ rpm-4.9.1.3/lib/rpmrc.c	2012-04-19 17:11:32.754738455 +0200
5860f5
@@ -743,6 +743,56 @@ static int is_sun4v()
5860f5
 }
5860f5
 #endif
5860f5
 
5860f5
+#if defined(__linux__) && defined(__arm__)
5860f5
+static int has_neon()
5860f5
+{
5860f5
+        char buffer[4096], *p;
5860f5
+        int fd = open("/proc/cpuinfo", O_RDONLY);
5860f5
+        if (read(fd, &buffer, sizeof(buffer) - 1) == -1) {
5860f5
+                rpmlog(RPMLOG_WARNING, _("read(/proc/cpuinfo) failed\n"));
5860f5
+                close(fd);
5860f5
+                return 0;
5860f5
+        }
5860f5
+        close(fd);
5860f5
+
5860f5
+        p = strstr(buffer, "Features");
5860f5
+        p = strtok(p, "\n");
5860f5
+        p = strstr(p, "neon");
5860f5
+        p = strtok(p, " ");
5860f5
+        if (p == NULL) {
5860f5
+                rpmlog(RPMLOG_WARNING, _("/proc/cpuinfo has no 'Features' line\n"));
5860f5
+                return 0;
5860f5
+        } else if (strcmp(p, "neon") == 0) {
5860f5
+                return 1;
5860f5
+        }
5860f5
+        return 0;
5860f5
+}
5860f5
+
5860f5
+static int has_hfp()
5860f5
+{
5860f5
+        char buffer[4096], *p;
5860f5
+        int fd = open("/proc/cpuinfo", O_RDONLY);
5860f5
+        if (read(fd, &buffer, sizeof(buffer) - 1) == -1) {
5860f5
+                rpmlog(RPMLOG_WARNING, _("read(/proc/cpuinfo) failed\n"));
5860f5
+                close(fd);
5860f5
+                return 0;
5860f5
+        }
5860f5
+        close(fd);
5860f5
+
5860f5
+        p = strstr(buffer, "Features");
5860f5
+        p = strtok(p, "\n");
5860f5
+        p = strstr(p, "vfpv3");
5860f5
+        p = strtok(p, " ");
5860f5
+        if (p == NULL) {
5860f5
+                rpmlog(RPMLOG_WARNING, _("/proc/cpuinfo has no 'Features' line\n"));
5860f5
+                return 0;
5860f5
+        } else if (strcmp(p, "vfpv3") == 0) {
5860f5
+                return 1;
5860f5
+        }
5860f5
+        return 0;
5860f5
+}
5860f5
+#endif
5860f5
+
5860f5
 
5860f5
 #	if defined(__linux__) && defined(__i386__)
5860f5
 #include <setjmp.h>
5860f5
@@ -1220,6 +1270,22 @@ static void defaultMachine(const char **
5860f5
         }
5860f5
 #	endif	/* ppc64*-linux */
5860f5
 
5860f5
+#	if defined(__linux__) && defined(__arm__)
5860f5
+	{
5860f5
+	    if (strcmp(un.machine, "armv7l") == 0 ) {
5860f5
+	        if (has_neon() && has_hfp())
5860f5
+                    strcpy(un.machine, "armv7hnl");
5860f5
+                else if (has_hfp())
5860f5
+                    strcpy(un.machine, "armv7hl");
5860f5
+	    } else if (strcmp(un.machine, "armv6l") == 0 ) {
5860f5
+	        if (has_neon() && has_hfp())
5860f5
+                    strcpy(un.machine, "armv6hnl");
5860f5
+                else if (has_hfp())
5860f5
+                    strcpy(un.machine, "armv6hl");
5860f5
+	    }
5860f5
+	}
5860f5
+#	endif	/* arm*-linux */
5860f5
+
5860f5
 #	if defined(__GNUC__) && defined(__alpha__)
5860f5
 	{
5860f5
 	    unsigned long amask, implver;