rpms/liboil/devel liboil-0.3.13-better-altivec-detect.patch, NONE, 1.1 liboil.spec, 1.29, 1.30 liboil-0.3.13-disable-altivec.patch, 1.1, NONE

Bastien Nocera (hadess) fedora-extras-commits at redhat.com
Tue Mar 11 14:36:06 UTC 2008


Author: hadess

Update of /cvs/pkgs/rpms/liboil/devel
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv4495

Modified Files:
	liboil.spec 
Added Files:
	liboil-0.3.13-better-altivec-detect.patch 
Removed Files:
	liboil-0.3.13-disable-altivec.patch 
Log Message:
* Tue Mar 11 2008 - Bastien Nocera <bnocera at redhat.com> - 0.3.13-5
- Detect Altivec using /proc instead of causing a SIGILL fault


liboil-0.3.13-better-altivec-detect.patch:

--- NEW FILE liboil-0.3.13-better-altivec-detect.patch ---
Index: liboil/liboilcpu-powerpc.c
===================================================================
RCS file: /cvs/liboil/liboil/liboil/liboilcpu-powerpc.c,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 liboilcpu-powerpc.c
--- liboil/liboilcpu-powerpc.c	14 Nov 2007 09:30:20 -0000	1.1
+++ liboil/liboilcpu-powerpc.c	11 Mar 2008 14:29:22 -0000
@@ -44,6 +44,15 @@
 //#include <sys/time.h>
 //#include <time.h>
 
+#if defined(__linux__)
+#include <linux/auxvec.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+#endif
+
 #if defined(__FreeBSD__)
 #include <sys/types.h>
 #include <sys/sysctl.h>
@@ -67,7 +76,7 @@ test_altivec (void * ignored)
 }
 
 #if defined(__FreeBSD__)
-void
+static void
 oil_check_altivec_sysctl (void)
 {
   int ret, av;
@@ -81,6 +90,58 @@ oil_check_altivec_sysctl (void)
 }
 #endif
 
+#if defined(__linux__)
+static void
+oil_check_altivec_proc (void)
+{
+  static int available = -1;
+  int new_avail = 0;
+  char fname[64];
+  unsigned long buf[64];
+  ssize_t count;
+  pid_t pid;
+  int fd, i;
+
+  if (available != -1) {
+    return available;
+  }
+
+  pid = getpid();
+  snprintf(fname, sizeof(fname)-1, "/proc/%d/auxv", pid);
+
+  fd = open(fname, O_RDONLY);
+  if (fd < 0) {
+    goto out;
+  }
+
+more:
+  count = read(fd, buf, sizeof(buf));
+  if (count < 0) {
+    goto out_close;
+  }
+
+  for (i=0; i < (count / sizeof(unsigned long)); i += 2) {
+    if (buf[i] == AT_HWCAP) {
+      new_avail = !!(buf[i+1] & PPC_FEATURE_HAS_ALTIVEC);
+      goto out_close;
+    } else if (buf[i] == AT_NULL) {
+      goto out_close;
+    }
+  }
+
+  if (count == sizeof(buf)) {
+    goto more;
+  }
+
+out_close:
+  close(fd);
+
+out:
+  available = new_avail;
+  return available;
+}
+#endif
+
 void
 oil_check_altivec_fault (void)
 {
@@ -97,6 +158,8 @@ oil_cpu_detect_arch(void)
 {
 #if defined(__FreeBSD__)
   oil_check_altivec_sysctl();
+#elif defined(#ifdef __linux__)
+  oil_check_altivec_proc();
 #else
   oil_check_altivec_fault();
 #endif
@@ -104,5 +167,3 @@ oil_cpu_detect_arch(void)
   _oil_profile_stamp = oil_profile_stamp_tb;
 }
 
-
-


Index: liboil.spec
===================================================================
RCS file: /cvs/pkgs/rpms/liboil/devel/liboil.spec,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- liboil.spec	10 Mar 2008 09:55:22 -0000	1.29
+++ liboil.spec	11 Mar 2008 14:35:30 -0000	1.30
@@ -1,7 +1,7 @@
 Summary: Library of Optimized Inner Loops, CPU optimized functions
 Name: liboil
 Version: 0.3.13
-Release: 4%{?dist}
+Release: 5%{?dist}
 # See COPYING which details everything, various BSD licenses apply
 License: BSD
 Group: System Environment/Libraries
@@ -9,7 +9,7 @@
 Source: http://liboil.freedesktop.org/download/liboil-%{version}.tar.gz
 
 Patch1: liboil-0.3.13-s390.patch
-Patch2: liboil-0.3.13-disable-altivec.patch
+Patch2: liboil-0.3.13-better-altivec-detect.patch
 # from upstream git
 Patch3: clobber-ecx.patch
 
@@ -41,13 +41,13 @@
 %prep
 %setup -q
 %patch1 -p1 -b .s390
-%patch2 -p1 -b .disable-altivec
+%patch2 -p0 -b .better-altivec-detect
 %patch3 -p1 -b .clobber-ecx
 
 # Disable Altivec, so that liboil doesn't SIGILL on non-Altivec PPCs
 # See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=252179#c15
-sed -i 's/CFLAGS="$CFLAGS "-maltivec""/CFLAGS="$CFLAGS "-fno-tree-vectorize -Wa,-maltivec""/' configure
-sed -i 's/LIBOIL_CFLAGS -maltivec/LIBOIL_CFLAGS -fno-tree-vectorize -Wa,-maltivec/' configure
+#sed -i 's/CFLAGS="$CFLAGS "-maltivec""/CFLAGS="$CFLAGS "-fno-tree-vectorize -Wa,-maltivec""/' configure
+#sed -i 's/LIBOIL_CFLAGS -maltivec/LIBOIL_CFLAGS -fno-tree-vectorize -Wa,-maltivec/' configure
 
 %build
 %configure
@@ -90,6 +90,9 @@
 
 
 %changelog
+* Tue Mar 11 2008 - Bastien Nocera <bnocera at redhat.com> - 0.3.13-5
+- Detect Altivec using /proc instead of causing a SIGILL fault
+
 * Mon Mar 10 2008 - Bastien Nocera <bnocera at redhat.com> - 0.3.13-4
 - Try disabling Altivec for now
 


--- liboil-0.3.13-disable-altivec.patch DELETED ---




More information about the fedora-extras-commits mailing list