michal-grzedzicki / rpms / rpm

Forked from rpms/rpm 5 months ago
Clone
78383f
diff -up rpm-4.11.1/lib/rpmrc.c.armhfp-logic rpm-4.11.1/lib/rpmrc.c
78383f
--- rpm-4.11.1/lib/rpmrc.c.armhfp-logic	2013-10-01 14:59:12.841041726 +0300
78383f
+++ rpm-4.11.1/lib/rpmrc.c	2013-10-01 14:59:12.856041684 +0300
78383f
@@ -733,6 +733,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>
78383f
@@ -1136,6 +1186,22 @@ static void defaultMachine(const char **
78383f
 #	endif	/* __ORDER_BIG_ENDIAN__ */
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;