From 7dfc27d55ee516d6471044901a19bb3e46f53fb8 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer <eike@sf-mail.de> Date: Wed, 9 Jan 2013 19:45:31 +0100 Subject: [PATCH] SystemInformation: check CPU vendor and SSE support on OpenBSD Change-Id: I9ec994e96c895196491dccba7d867cdfe6321a61 --- CMakeLists.txt | 7 +++++++ SystemInformation.cxx | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bfcab0..5df5a74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -603,6 +603,13 @@ IF(KWSYS_USE_SystemInformation) COMPILE_DEFINITIONS KWSYS_SYS_HAS_MPCTL_H=1) ENDIF() ENDIF() + IF(CMAKE_SYSTEM MATCHES "BSD") + CHECK_INCLUDE_FILES("machine/cpu.h" KWSYS_SYS_HAS_MACHINE_CPU_H) + IF(KWSYS_SYS_HAS_MACHINE_CPU_H) + SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY + COMPILE_DEFINITIONS KWSYS_SYS_HAS_MACHINE_CPU_H=1) + ENDIF() + ENDIF() IF(KWSYS_LFS_AVAILABLE AND NOT KWSYS_LFS_DISABLE) SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_HAS_LFS=1) ENDIF() diff --git a/SystemInformation.cxx b/SystemInformation.cxx index 93c7f28..9cb67d2 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -91,6 +91,10 @@ typedef int siginfo_t; # include <sys/sysctl.h> #endif +#if defined(KWSYS_SYS_HAS_MACHINE_CPU_H) +# include <machine/cpu.h> +#endif + #if defined(__DragonFly__) # include <sys/sysctl.h> #endif @@ -4423,6 +4427,45 @@ bool SystemInformationImplementation::QueryBSDProcessor() this->CPUSpeedInMHz = (float) k; #endif +#if defined(CPU_SSE) + ctrl[0] = CTL_MACHDEP; + ctrl[1] = CPU_SSE; + + if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) + { + return false; + } + + this->Features.HasSSE = (k > 0); +#endif + +#if defined(CPU_SSE2) + ctrl[0] = CTL_MACHDEP; + ctrl[1] = CPU_SSE2; + + if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) + { + return false; + } + + this->Features.HasSSE2 = (k > 0); +#endif + +#if defined(CPU_CPUVENDOR) + ctrl[0] = CTL_MACHDEP; + ctrl[1] = CPU_CPUVENDOR; + char vbuf[25]; + ::memset(vbuf, 0, sizeof(vbuf)); + sz = sizeof(vbuf) - 1; + if (sysctl(ctrl, 2, vbuf, &sz, NULL, 0) != 0) + { + return false; + } + + this->ChipID.Vendor = vbuf; + this->FindManufacturer(); +#endif + return true; #else return false; -- GitLab