michal-grzedzicki / rpms / rpm

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