michal-grzedzicki / rpms / rpm

Forked from rpms/rpm 5 months ago
Clone
Blob Blame History Raw
diff -up rpm-4.9.1.3/lib/rpmrc.c.armhfp-logic rpm-4.9.1.3/lib/rpmrc.c
--- rpm-4.9.1.3/lib/rpmrc.c.armhfp-logic	2012-04-19 17:11:32.728750591 +0200
+++ rpm-4.9.1.3/lib/rpmrc.c	2012-04-19 17:11:32.754738455 +0200
@@ -743,6 +743,56 @@ static int is_sun4v()
 }
 #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>
@@ -1220,6 +1270,22 @@ static void defaultMachine(const char **
         }
 #	endif	/* ppc64*-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;