always apply arm hfp macros, conditionally apply the logic to detect hfp

This commit is contained in:
Dennis Gilmore 2012-01-15 17:26:03 -06:00
parent c3ac54c9d5
commit 72d4c0c695
3 changed files with 92 additions and 86 deletions

View File

@ -0,0 +1,84 @@
diff -uNr rpm-4.9.0-orig//lib/rpmrc.c rpm-4.9.0/lib/rpmrc.c
--- rpm-4.9.0-orig//lib/rpmrc.c 2011-08-05 12:23:04.000000000 -0500
+++ rpm-4.9.0/lib/rpmrc.c 2011-08-05 12:25:13.000000000 -0500
@@ -732,6 +732,56 @@
}
#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>
@@ -1157,6 +1207,22 @@
}
# endif /* sparc*-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;

View File

@ -10,89 +10,6 @@ diff -uNr rpm-4.9.0-orig//installplatform rpm-4.9.0/installplatform
sh4*) SUBSTS='s_sh4_sh4_ s_sh4_sh4a_' ;;
sparc*) SUBSTS='s_sparc\(64\|64v\|v9v\|v9\)_sparc_ s_sparc64_sparcv9_;s_sparc\([^v]\|$\)_sparcv9\1_ s_sparcv9_sparc64_;s_sparc\([^6]\|$\)_sparc64\1_' ;;
powerpc*|ppc*) SUBSTS='s_ppc64_ppc_ s_ppc\([^6ip]\|$\)_ppc64\1_ s_ppc\([^6ip]\|$\)_ppciseries_ s_ppc\([^6ip]\|$\)_ppcpseries_ s_ppc\([^6ip]\|$\)_ppc64iseries_ s_ppc\([^6ip]\|$\)_ppc64pseries_' ;;
diff -uNr rpm-4.9.0-orig//lib/rpmrc.c rpm-4.9.0/lib/rpmrc.c
--- rpm-4.9.0-orig//lib/rpmrc.c 2011-08-05 12:23:04.000000000 -0500
+++ rpm-4.9.0/lib/rpmrc.c 2011-08-05 12:25:13.000000000 -0500
@@ -732,6 +732,56 @@
}
#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>
@@ -1157,6 +1207,22 @@
}
# endif /* sparc*-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;
diff -uNr rpm-4.9.0-orig//macros.in rpm-4.9.0/macros.in
--- rpm-4.9.0-orig//macros.in 2011-08-05 12:23:04.000000000 -0500
+++ rpm-4.9.0/macros.in 2011-08-05 12:25:13.000000000 -0500

View File

@ -21,7 +21,7 @@
Summary: The RPM package management system
Name: rpm
Version: %{rpmver}
Release: %{?snapver:0.%{snapver}.}10%{?dist}
Release: %{?snapver:0.%{snapver}.}11%{?dist}
Group: System Environment/Base
Url: http://www.rpm.org/
Source0: http://rpm.org/releases/rpm-4.9.x/%{name}-%{srcver}.tar.bz2
@ -38,8 +38,9 @@ Patch2: rpm-4.8.90-fedora-specspo.patch
Patch3: rpm-4.8.0-no-man-dirs.patch
# gnupg2 comes installed by default, avoid need to drag in gnupg too
Patch4: rpm-4.8.1-use-gpg2.patch
#conditionally applied patch for arm hardware floating point
Patch5: rpm-4.9.0-armhfp.patch
#conditionally applied patch for arm hardware floating point
Patch6: rpm-4.9.0-armhfp-logic.patch
# Patches already in upstream
Patch100: rpm-4.9.x-fontattr.patch
@ -236,9 +237,10 @@ packages on a system.
%patch400 -p1 -b .rpmlib-filesystem-check
%patch401 -p1 -b .perl-script
%patch5 -p1 -b .armhfp
# this patch cant be applied on softfp builds
%ifnarch armv3l armv4b armv4l armv4tl armv5tel armv5tejl armv6l armv7l
%patch5 -p1 -b .armhfp
%patch6 -p1 -b .armhfp-logic
%endif
%if %{with int_bdb}
@ -453,6 +455,9 @@ exit 0
%doc COPYING doc/librpm/html/*
%changelog
* Sun Jan 15 2012 Dennis Gilmore <dennis@ausil.us> - 4.9.1.2-11
- always apply arm hfp macros, conditionally apply the logic to detect hfp
* Tue Jan 10 2012 Panu Matilainen <pmatilai@redhat.com> - 4.9.1.2-10
- adjust perl and python detection rules for libmagic change (#772699)