rpms/libvisual/devel libvisual-0.4.0-better-altivec-detection.patch, NONE, 1.1 libvisual.spec, 1.17, 1.18

Bastien Nocera (hadess) fedora-extras-commits at redhat.com
Tue Mar 11 16:04:48 UTC 2008


Author: hadess

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

Modified Files:
	libvisual.spec 
Added Files:
	libvisual-0.4.0-better-altivec-detection.patch 
Log Message:
* Tue Mar 11 2008 - Bastien Nocera <bnocera at redhat.com> - 0.4.0-6
- Better Altivec detection, code from David Woodhouse


libvisual-0.4.0-better-altivec-detection.patch:

--- NEW FILE libvisual-0.4.0-better-altivec-detection.patch ---
--- libvisual-0.4.0/libvisual/lv_cpu.c.orig	2006-01-22 13:23:37.000000000 +0000
+++ libvisual-0.4.0/libvisual/lv_cpu.c	2008-03-11 16:00:56.000000000 +0000
@@ -50,8 +50,19 @@
 #endif
 
 #if defined(VISUAL_OS_LINUX)
+#if defined(VISUAL_ARCH_POWERPC)
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#include <linux/auxvec.h>
+#include <asm/cputable.h>
+#else /* VISUAL_ARCH_POWERPC */
 #include <signal.h>
 #endif
+#endif
 
 #if defined(VISUAL_OS_WIN32)
 #include <windows.h>
@@ -154,6 +165,46 @@ static void check_os_altivec_support( vo
 	if (err == 0)
 		if (has_vu != 0)
 			__lv_cpu_caps.hasAltiVec = 1;
+#elif defined (VISUAL_OS_LINUX)
+	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;
+
+	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;
+	if (available)
+		__lv_cpu_caps.hasAltiVec = 1;
 #else /* !VISUAL_OS_DARWIN */
 	/* no Darwin, do it the brute-force way */
 	/* this is borrowed from the libmpeg2 library */


Index: libvisual.spec
===================================================================
RCS file: /cvs/pkgs/rpms/libvisual/devel/libvisual.spec,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- libvisual.spec	18 Feb 2008 18:20:25 -0000	1.17
+++ libvisual.spec	11 Mar 2008 16:04:13 -0000	1.18
@@ -12,6 +12,9 @@
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires:  xorg-x11-proto-devel
 
+# https://bugzilla.redhat.com/show_bug.cgi?id=435771
+Patch0:         libvisual-0.4.0-better-altivec-detection.patch
+
 
 %description
 Libvisual is an abstraction library that comes between applications and
@@ -39,6 +42,7 @@
 
 %prep
 %setup -q
+%patch0 -p1 -b .altivec-detection
 
 %build
 %ifarch i386
@@ -80,6 +84,9 @@
 
 
 %changelog
+* Tue Mar 11 2008 - Bastien Nocera <bnocera at redhat.com> - 0.4.0-6
+- Better Altivec detection, code from David Woodhouse
+
 * Mon Feb 18 2008 Fedora Release Engineering <rel-eng at fedoraproject.org> - 0.4.0-5
 - Autorebuild for GCC 4.3
 




More information about the fedora-extras-commits mailing list