mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-24 01:38:45 +00:00
Changed: #842 Removed obsolete files (all methods are already implemented in CSystemInfo)
This commit is contained in:
parent
b65d4fc2cf
commit
8bb1ed6a70
2 changed files with 0 additions and 196 deletions
|
@ -1,58 +0,0 @@
|
|||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#ifndef NL_CPU_INFO_H
|
||||
#define NL_CPU_INFO_H
|
||||
|
||||
#include "types_nl.h"
|
||||
|
||||
|
||||
namespace NLMISC {
|
||||
|
||||
|
||||
/**
|
||||
* This helps to know whether cpu has some features such as mmx, sse ...
|
||||
* \author Nicolas Vizerie
|
||||
* \author Nevrax France
|
||||
* \date 2001
|
||||
*/
|
||||
struct CCpuInfo___
|
||||
{
|
||||
/** test whether the cpuid instruction is supported
|
||||
* (always false on non intel architectures)
|
||||
*/
|
||||
static bool hasCPUID(void);
|
||||
|
||||
/** helps to know whether the processor features mmx instruction set
|
||||
* This is initialized at startup, so it's fast
|
||||
* (always false on not 0x86 architecture ...)
|
||||
*/
|
||||
static bool hasMMX(void);
|
||||
|
||||
/** helps to know whether the processor has streaming SIMD instructions (the OS must support it)
|
||||
* This is initialized at startup, so it's fast
|
||||
* (always false on not 0x86 architecture ...)
|
||||
*/
|
||||
static bool hasSSE(void);
|
||||
};
|
||||
|
||||
|
||||
} // NLMISC
|
||||
|
||||
|
||||
#endif // NL_CPU_INFO_H
|
||||
|
||||
/* End of cpu_info.h */
|
|
@ -1,138 +0,0 @@
|
|||
// NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
|
||||
// Copyright (C) 2010 Winch Gate Property Limited
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "stdmisc.h"
|
||||
|
||||
#include "nel/misc/cpu_info.h"
|
||||
|
||||
|
||||
namespace NLMISC
|
||||
{
|
||||
|
||||
static bool DetectMMX(void)
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
if (!CCpuInfo___::hasCPUID()) return false; // cpuid not supported ...
|
||||
|
||||
uint32 result = 0;
|
||||
__asm
|
||||
{
|
||||
mov eax,1
|
||||
cpuid
|
||||
test edx,0x800000 // bit 23 = MMX instruction set
|
||||
je noMMX
|
||||
mov result, 1
|
||||
noMMX:
|
||||
}
|
||||
|
||||
return result == 1;
|
||||
|
||||
// printf("mmx detected\n");
|
||||
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
static bool DetectSSE()
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
if (!CCpuInfo___::hasCPUID()) return false; // cpuid not supported ...
|
||||
|
||||
uint32 result = 0;
|
||||
__asm
|
||||
{
|
||||
mov eax, 1 // request for feature flags
|
||||
cpuid
|
||||
test EDX, 002000000h // bit 25 in feature flags equal to 1
|
||||
je noSSE
|
||||
mov result, 1 // sse detected
|
||||
noSSE:
|
||||
}
|
||||
|
||||
|
||||
if (result)
|
||||
{
|
||||
// check OS support for SSE
|
||||
try
|
||||
{
|
||||
__asm
|
||||
{
|
||||
xorps xmm0, xmm0 // Streaming SIMD Extension
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// printf("sse detected\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool HasMMX = DetectMMX();
|
||||
bool HasSSE = DetectSSE();
|
||||
|
||||
bool CCpuInfo___::hasCPUID()
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
uint32 result;
|
||||
__asm
|
||||
{
|
||||
pushad
|
||||
pushfd
|
||||
// If ID bit of EFLAGS can change, then cpuid is available
|
||||
pushfd
|
||||
pop eax // Get EFLAG
|
||||
mov ecx,eax
|
||||
xor eax,0x200000 // Flip ID bit
|
||||
push eax
|
||||
popfd // Write EFLAGS
|
||||
pushfd
|
||||
pop eax // read back EFLAG
|
||||
xor eax,ecx
|
||||
je noCpuid // no flip -> no CPUID instr.
|
||||
|
||||
popfd // restore state
|
||||
popad
|
||||
mov result, 1
|
||||
jmp CPUIDPresent
|
||||
|
||||
noCpuid:
|
||||
popfd // restore state
|
||||
popad
|
||||
mov result, 0
|
||||
CPUIDPresent:
|
||||
}
|
||||
return result == 1;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
bool CCpuInfo___::hasMMX() { return HasMMX; }
|
||||
bool CCpuInfo___::hasSSE() { return HasSSE; }
|
||||
|
||||
} // NLMISC
|
Loading…
Reference in a new issue