richardphibel / rpms / rpm

Forked from rpms/rpm 2 years ago
Clone
648606
diff -up rpm-4.11.1/lib/rpmrc.c.armhfp-logic rpm-4.11.1/lib/rpmrc.c
648606
--- rpm-4.11.1/lib/rpmrc.c.armhfp-logic	2013-10-01 14:59:12.841041726 +0300
648606
+++ rpm-4.11.1/lib/rpmrc.c	2013-10-01 14:59:12.856041684 +0300
648606
@@ -733,6 +733,56 @@ static int is_sun4v()
648606
 }
648606
 #endif
648606
 
648606
+#if defined(__linux__) && defined(__arm__)
648606
+static int has_neon()
648606
+{
648606
+        char buffer[4096], *p;
648606
+        int fd = open("/proc/cpuinfo", O_RDONLY);
648606
+        if (read(fd, &buffer, sizeof(buffer) - 1) == -1) {
648606
+                rpmlog(RPMLOG_WARNING, _("read(/proc/cpuinfo) failed\n"));
648606
+                close(fd);
648606
+                return 0;
648606
+        }
648606
+        close(fd);
648606
+
648606
+        p = strstr(buffer, "Features");
648606
+        p = strtok(p, "\n");
648606
+        p = strstr(p, "neon");
648606
+        p = strtok(p, " ");
648606
+        if (p == NULL) {
648606
+                rpmlog(RPMLOG_WARNING, _("/proc/cpuinfo has no 'Features' line\n"));
648606
+                return 0;
648606
+        } else if (strcmp(p, "neon") == 0) {
648606
+                return 1;
648606
+        }
648606
+        return 0;
648606
+}
648606
+
648606
+static int has_hfp()
648606
+{
648606
+        char buffer[4096], *p;
648606
+        int fd = open("/proc/cpuinfo", O_RDONLY);
648606
+        if (read(fd, &buffer, sizeof(buffer) - 1) == -1) {
648606
+                rpmlog(RPMLOG_WARNING, _("read(/proc/cpuinfo) failed\n"));
648606
+                close(fd);
648606
+                return 0;
648606
+        }
648606
+        close(fd);
648606
+
648606
+        p = strstr(buffer, "Features");
648606
+        p = strtok(p, "\n");
648606
+        p = strstr(p, "vfpv3");
648606
+        p = strtok(p, " ");
648606
+        if (p == NULL) {
648606
+                rpmlog(RPMLOG_WARNING, _("/proc/cpuinfo has no 'Features' line\n"));
648606
+                return 0;
648606
+        } else if (strcmp(p, "vfpv3") == 0) {
648606
+                return 1;
648606
+        }
648606
+        return 0;
648606
+}
648606
+#endif
648606
+
648606
 
648606
 #	if defined(__linux__) && defined(__i386__)
648606
 #include <setjmp.h>
648606
@@ -1136,6 +1186,22 @@ static void defaultMachine(const char **
648606
 #	endif	/* __ORDER_BIG_ENDIAN__ */
648606
 #	endif	/* ppc64*-linux */
648606
 
648606
+#	if defined(__linux__) && defined(__arm__)
648606
+	{
648606
+	    if (strcmp(un.machine, "armv7l") == 0 ) {
648606
+	        if (has_neon() && has_hfp())
648606
+                    strcpy(un.machine, "armv7hnl");
648606
+                else if (has_hfp())
648606
+                    strcpy(un.machine, "armv7hl");
648606
+	    } else if (strcmp(un.machine, "armv6l") == 0 ) {
648606
+	        if (has_neon() && has_hfp())
648606
+                    strcpy(un.machine, "armv6hnl");
648606
+                else if (has_hfp())
648606
+                    strcpy(un.machine, "armv6hl");
648606
+	    }
648606
+	}
648606
+#	endif	/* arm*-linux */
648606
+
648606
 #	if defined(__GNUC__) && defined(__alpha__)
648606
 	{
648606
 	    unsigned long amask, implver;