-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into documentation-beautify-swedish-translation
- Loading branch information
Showing
16 changed files
with
103 additions
and
679 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,33 @@ | ||
#if !MAC | ||
#include "CpuArchitecture.h" | ||
#include <string.h> | ||
|
||
unsigned int CpuArchitecture = 0; | ||
|
||
extern "C" void __cpuid(int* CPUInfo, int InfoType); | ||
#pragma intrinsic(__cpuid) | ||
|
||
unsigned int determine_support() | ||
void initCpuArchitecture() | ||
{ | ||
unsigned int arch = 0; | ||
#if WINDOWS | ||
int CPUInfo[4] = {-1}; | ||
__cpuid(CPUInfo, 0); | ||
char vendor[12]; | ||
memcpy(vendor, &CPUInfo[1], 4 * sizeof(char)); | ||
memcpy(&vendor[8], &CPUInfo[2], 4 * sizeof(char)); | ||
memcpy(&vendor[4], &CPUInfo[3], 4 * sizeof(char)); | ||
if (!CPUInfo[0]) | ||
return 0; // no additional instructions supported | ||
return; // no additional instructions supported | ||
|
||
__cpuid(CPUInfo, 1); | ||
if ((1 << 15) & CPUInfo[3]) | ||
arch |= ca_CMOV; | ||
if ((1 << 25) & CPUInfo[3]) | ||
arch |= ca_SSE; | ||
CpuArchitecture |= CaCMOV; | ||
if ((1 << 26) & CPUInfo[3]) | ||
arch |= ca_SSE2; | ||
if (CPUInfo[2] & 0x1) | ||
arch |= ca_SSE3; | ||
|
||
// get number of extended pages | ||
__cpuid(CPUInfo, 0x80000000); | ||
unsigned int extendedpages = CPUInfo[0]; | ||
|
||
// determine 3DNow! support | ||
if (!strncmp("AuthenticAMD", vendor, 12) && (extendedpages >= 0x80000001)) | ||
{ | ||
__cpuid(CPUInfo, 0x80000001); | ||
if (((1 << 30) & CPUInfo[3]) && ((1 << 31) & CPUInfo[3])) | ||
arch |= ca_3DNOW; | ||
} | ||
|
||
return arch; | ||
CpuArchitecture |= CaSSE2; | ||
#else | ||
__builtin_cpu_init(); | ||
if (__builtin_cpu_supports("sse2")) | ||
CpuArchitecture |= CaSSE2; | ||
if (__builtin_cpu_supports("cmov")) | ||
CpuArchitecture |= CaCMOV; | ||
#endif | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
#ifndef CPUARCHITECTURE_H | ||
#define CPUARCHITECTURE_H | ||
|
||
enum CpuArchitecture | ||
{ | ||
ca_SSE = 0x1, | ||
ca_SSE2 = 0x2, | ||
ca_SSE3 = 0x4, | ||
ca_3DNOW = 0x8, | ||
ca_X64 = 0x10, | ||
ca_PPC = 0x20, | ||
ca_CMOV = 0x40, | ||
CaSSE2 = 0x2, | ||
CaCMOV = 0x40, | ||
}; | ||
|
||
unsigned int determine_support(); | ||
extern unsigned int CpuArchitecture; | ||
|
||
void initCpuArchitecture(); | ||
|
||
#endif // CPUARCHITECTURE_H |
Oops, something went wrong.