Add support for AltiVec detection using the sysctl node on OpenBSD and

remove the dependency on gcc4.

ok jasper@ ajacoutot@
This commit is contained in:
brad 2008-08-22 11:53:32 +00:00
parent 0b7d92ed0b
commit 7dbaaa1ccf
2 changed files with 82 additions and 7 deletions

View File

@ -1,8 +1,9 @@
# $OpenBSD: Makefile,v 1.12 2008/06/10 05:11:21 pvalchev Exp $
# $OpenBSD: Makefile,v 1.13 2008/08/22 11:53:32 brad Exp $
COMMENT= library of optimized inner loops
DISTNAME= liboil-0.3.14
PKGNAME= ${DISTNAME}p0
SHARED_LIBS += oil-0.3 3.0 # .2.0
CATEGORIES= devel
@ -18,13 +19,7 @@ PERMIT_PACKAGE_FTP= Yes
WANTLIB= c m
MODULES= gcc4
MODGCC4_ARCHES= powerpc
MODGCC4_LANGS= c
USE_LIBTOOL= Yes
CONFIGURE_STYLE= gnu
CONFIGURE_ARGS= --disable-glib

View File

@ -0,0 +1,80 @@
$OpenBSD: patch-liboil_liboilcpu-powerpc_c,v 1.1 2008/08/22 11:53:32 brad Exp $
--- liboil/liboilcpu-powerpc.c.orig Thu Mar 13 03:22:52 2008
+++ liboil/liboilcpu-powerpc.c Tue Aug 12 21:04:23 2008
@@ -54,6 +54,11 @@
#include <sys/sysctl.h>
#endif
+#if defined(__OpenBSD__)
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <machine/cpu.h>
+#endif
/***** powerpc *****/
@@ -65,11 +70,13 @@ oil_profile_stamp_tb(void)
return ts;
}
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(__linux__)
static void
test_altivec (void * ignored)
{
asm volatile ("vor v0, v0, v0\n");
}
+#endif
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
static void
@@ -86,6 +93,24 @@ oil_check_altivec_sysctl_freebsd (void)
}
#endif
+#if defined(__OpenBSD__)
+static void
+oil_check_altivec_sysctl_openbsd (void)
+{
+ int mib[2], av, ret;
+ size_t len;
+
+ mib[0] = CTL_MACHDEP;
+ mib[1] = CPU_ALTIVEC;
+
+ len = sizeof(av);
+ ret = sysctl(mib, 2, &av, &len, NULL, 0);
+ if (!ret && av) {
+ oil_cpu_flags |= OIL_IMPL_FLAG_ALTIVEC;
+ }
+}
+#endif
+
#if defined(__APPLE__)
static void
oil_check_altivec_sysctl_darwin (void)
@@ -151,7 +176,8 @@ out:
}
#endif
-void
+#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(__linux__)
+static void
oil_check_altivec_fault (void)
{
oil_fault_check_enable ();
@@ -161,12 +187,15 @@ oil_check_altivec_fault (void)
}
oil_fault_check_disable ();
}
+#endif
void
oil_cpu_detect_arch(void)
{
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
oil_check_altivec_sysctl_freebsd();
+#elif defined(__OpenBSD__)
+ oil_check_altivec_sysctl_openbsd();
#elif defined(__APPLE__)
oil_check_altivec_sysctl_darwin();
#elif defined(__linux__)