changeset 20052:33c40d61bf33

Detect sse/2 on intel mac, Valtteri Vuorikoski(vuori@sci.fi)
author nplourde
date Thu, 05 Oct 2006 00:12:04 +0000
parents 4b066db32976
children 63979c96cca5
files cpudetect.c
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cpudetect.c	Wed Oct 04 22:18:40 2006 +0000
+++ b/cpudetect.c	Thu Oct 05 00:12:04 2006 +0000
@@ -182,7 +182,7 @@
 #endif
 
 		/* FIXME: Does SSE2 need more OS support, too? */
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__CYGWIN__) || defined(__OpenBSD__) || defined(__DragonFly__)
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__CYGWIN__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__APPLE__)
 		if (caps->hasSSE)
 			check_os_katmai_support();
 		if (!caps->hasSSE)
@@ -345,16 +345,23 @@
  * and RedHat patched 2.2 kernels that have broken exception handling
  * support for user space apps that do SSE.
  */
+ 
+#if defined(__FreeBSD__) || defined(__DragonFly__)
+#define SSE_SYSCTL_NAME "hw.instruction_sse"
+#elif defined(__APPLE__)
+#define SSE_SYSCTL_NAME "hw.optional.sse"
+#endif
+
 static void check_os_katmai_support( void )
 {
 #ifdef ARCH_X86_64
    gCpuCaps.hasSSE=1;
    gCpuCaps.hasSSE2=1;
-#elif defined(__FreeBSD__) || defined(__DragonFly__)
+#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__APPLE__)
    int has_sse=0, ret;
    size_t len=sizeof(has_sse);
 
-   ret = sysctlbyname("hw.instruction_sse", &has_sse, &len, NULL, 0);
+   ret = sysctlbyname(SSE_SYSCTL_NAME, &has_sse, &len, NULL, 0);
    if (ret || !has_sse)
       gCpuCaps.hasSSE=0;