[PATCH] Add support for AltiVec detection for OpenBSD/PowerPC.

Brad Smith brad at comstyle.com
Mon Aug 2 10:37:49 PDT 2010


Bug 29331.
---
 pixman/pixman-cpu.c |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/pixman/pixman-cpu.c b/pixman/pixman-cpu.c
index e96b140..e4fb1e4 100644
--- a/pixman/pixman-cpu.c
+++ b/pixman/pixman-cpu.c
@@ -61,6 +61,29 @@ pixman_have_vmx (void)
     return have_vmx;
 }
=20
+#elif defined (__OpenBSD__)
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <machine/cpu.h>
+
+static pixman_bool_t
+pixman_have_vmx (void)
+{
+    if (!initialized)
+    {
+	int mib[2] =3D { CTL_MACHDEP, CPU_ALTIVEC };
+	size_t length =3D sizeof(have_vmx);
+	int error =3D
+	    sysctl (mib, 2, &have_vmx, &length, NULL, 0);
+
+	if (error !=3D 0)
+	    have_vmx =3D FALSE;
+
+	initialized =3D TRUE;
+    }
+    return have_vmx;
+}
+
 #elif defined (__linux__)
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -123,7 +146,7 @@ pixman_have_vmx (void)
     return have_vmx;
 }
=20
-#else /* !__APPLE__ && !__linux__ */
+#else /* !__APPLE__ && !__OpenBSD__ && !__linux__ */
 #include <signal.h>
 #include <setjmp.h>
=20
--=20
1.7.1.1


More information about the Pixman mailing list