mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-24 14:22:40 -06:00
Core: CpuHypervisor
git-svn-id: svn://ultimatepp.org/upp/trunk@11387 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
b2ff8b33cd
commit
3eaadf060e
2 changed files with 19 additions and 11 deletions
|
|
@ -1,10 +1,14 @@
|
|||
#include "Core.h"
|
||||
#include "cpuid.h"
|
||||
|
||||
namespace Upp {
|
||||
|
||||
#ifdef CPU_X86
|
||||
|
||||
#ifdef COMPILER_MSC
|
||||
#include <intrin.h>
|
||||
#else
|
||||
#include <cpuid.h>
|
||||
#endif
|
||||
|
||||
static bool sHasMMX;
|
||||
static bool sHasSSE;
|
||||
static bool sHasSSE2;
|
||||
|
|
@ -16,17 +20,15 @@ static void sCheckCPU()
|
|||
static bool done;
|
||||
if(done) return;
|
||||
done = true;
|
||||
unsigned int eax, ebx, ecx, edx;
|
||||
ONCELOCK {
|
||||
unsigned int eax, ebx, ecx, edx;
|
||||
#ifdef COMPILER_MSC
|
||||
dword info1;
|
||||
dword info2;
|
||||
__asm {
|
||||
mov eax, 1
|
||||
cpuid
|
||||
mov info1, edx
|
||||
mov info2, ecx
|
||||
}
|
||||
int cpuInfo[4];
|
||||
__cpuid(cpuInfo, 1);
|
||||
eax = cpuInfo[0];
|
||||
ebx = cpuInfo[1];
|
||||
ecx = cpuInfo[2];
|
||||
edx = cpuInfo[3];
|
||||
#else
|
||||
__get_cpuid(1, &eax, &ebx, &ecx, &edx);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -225,6 +225,12 @@ last argument [%-*@3 def].&]
|
|||
[s2;%% Returns true if CPU has SSE3 support.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:CpuHypervisor`(`): [@(0.0.255) bool]_[* CpuHypervisor]()&]
|
||||
[s2;%% Checks whether CPU has hypervisor flag set. If it has, the
|
||||
program is running in virtual machine. Unfortunately, opposite
|
||||
is not true `- some VMs run without this flag set.&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:CPU`_Cores`(`): [@(0.0.255) int]_[* CPU`_Cores]()&]
|
||||
[s2;%% Returns the number of cores the CPU has.&]
|
||||
[s3; &]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue