Commit 65aa3a08 authored by David Schleef's avatar David Schleef

Add support for OpenBSD in CPU detection

From Brad <brad@comstyle.com>.
parent f19794a4
......@@ -50,6 +50,11 @@
#include <sys/sysctl.h>
#endif
#if defined(__OpenBSD__)
#include <sys/param.h>
#include <sys/sysctl.h>
#include <machine/cpu.h>
#endif
/***** powerpc *****/
......@@ -63,7 +68,7 @@ orc_profile_stamp_tb(void)
}
#endif
#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(__APPLE__) && !defined(__linux__)
#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(__linux__)
static void
test_altivec (void * ignored)
{
......@@ -95,6 +100,27 @@ orc_check_altivec_sysctl_bsd (void)
}
#endif
#if defined(__OpenBSD__)
static unsigned long
orc_check_altivec_sysctl_openbsd (void)
{
unsigned long cpu_flags = 0;
int mib[2], ret, vu;
size_t len;
mib[0] = CTL_MACHDEP;
mib[1] = CPU_ALTIVEC;
len = sizeof(vu);
ret = sysctl(mib, 2, &vu, &len, NULL, 0);
if (!ret && vu) {
cpu_flags |= ORC_TARGET_ALTIVEC_ALTIVEC;
}
return cpu_flags;
}
#endif
#if defined(__linux__)
static unsigned long
orc_check_altivec_proc_auxv (void)
......@@ -148,7 +174,7 @@ out:
}
#endif
#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(__APPLE__) && !defined(__linux__)
#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(__OpenBSD__) && !defined(__APPLE__) && !defined(__linux__)
static void
orc_check_altivec_fault (void)
{
......@@ -166,6 +192,8 @@ orc_cpu_detect_arch(void)
{
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__)
orc_check_altivec_sysctl_bsd();
#elif defined(__OpenBSD__)
orc_check_altivec_sysctl_openbsd();
#elif defined(__linux__)
orc_check_altivec_proc_auxv();
#else
......
......@@ -453,10 +453,8 @@ orc_cpu_detect_kernel_support (void)
* unmasked SSE FPU exception bug. Other than that, if /proc/cpuinfo
* reported SSE, then it's safe.
*/
#elif defined(__sun)
/* Solaris is OK */
#elif defined(__NetBSD__)
/* NetBSD is OK */
#elif defined(__sun) || defined(__NetBSD__) || defined(__OpenBSD__)
/* Solaris/NetBSD/OpenBSD are OK */
#else
ORC_WARNING("Operating system is not known to support SSE. "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment