summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lzma/C/CpuArch.c
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/lzma/C/CpuArch.c')
-rw-r--r--3rdparty/lzma/C/CpuArch.c75
1 files changed, 44 insertions, 31 deletions
diff --git a/3rdparty/lzma/C/CpuArch.c b/3rdparty/lzma/C/CpuArch.c
index caf21643cef..36fc5bb4972 100644
--- a/3rdparty/lzma/C/CpuArch.c
+++ b/3rdparty/lzma/C/CpuArch.c
@@ -1,5 +1,7 @@
/* CpuArch.c -- CPU specific code
-2010-10-26: Igor Pavlov : Public domain */
+2015-03-25: Igor Pavlov : Public domain */
+
+#include "Precomp.h"
#include "CpuArch.h"
@@ -9,6 +11,10 @@
#define USE_ASM
#endif
+#if !defined(USE_ASM) && _MSC_VER >= 1500
+#include <intrin.h>
+#endif
+
#if defined(USE_ASM) && !defined(MY_CPU_AMD64)
static UInt32 CheckFlag(UInt32 flag)
{
@@ -48,7 +54,7 @@ static UInt32 CheckFlag(UInt32 flag)
#define CHECK_CPUID_IS_SUPPORTED
#endif
-static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
+void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
{
#ifdef USE_ASM
@@ -72,28 +78,24 @@ static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d)
#else
- #ifdef __PIC__
- __asm__ __volatile__ (
- "mov %%ebx, %%edi;"
- "cpuid;"
- "xchgl %%ebx, %%edi;"
- : "=a" (*a) ,
- "=D" (*b) , /* edi */
- "=c" (*c) ,
- "=d" (*d)
- : "0" (function)) ;
- #else // __PIC__
- __asm__ __volatile__ (
- "cpuid"
- : "=a" (*a) ,
- "=b" (*b) ,
- "=c" (*c) ,
- "=d" (*d)
- : "0" (function)) ;
- #endif // __PIC__
-
- #endif
+ __asm__ __volatile__ (
+ #if defined(MY_CPU_X86) && defined(__PIC__)
+ "mov %%ebx, %%edi;"
+ "cpuid;"
+ "xchgl %%ebx, %%edi;"
+ : "=a" (*a) ,
+ "=D" (*b) ,
+ #else
+ "cpuid"
+ : "=a" (*a) ,
+ "=b" (*b) ,
+ #endif
+ "=c" (*c) ,
+ "=d" (*d)
+ : "0" (function)) ;
+ #endif
+
#else
int CPUInfo[4];
@@ -114,7 +116,7 @@ Bool x86cpuid_CheckAndRead(Cx86cpuid *p)
return True;
}
-static UInt32 kVendors[][3] =
+static const UInt32 kVendors[][3] =
{
{ 0x756E6547, 0x49656E69, 0x6C65746E},
{ 0x68747541, 0x69746E65, 0x444D4163},
@@ -135,27 +137,38 @@ int x86cpuid_GetFirm(const Cx86cpuid *p)
return -1;
}
-Bool CPU_Is_InOrder(void)
+Bool CPU_Is_InOrder()
{
Cx86cpuid p;
int firm;
UInt32 family, model;
if (!x86cpuid_CheckAndRead(&p))
return True;
- family = x86cpuid_GetFamily(&p);
- model = x86cpuid_GetModel(&p);
+
+ family = x86cpuid_GetFamily(p.ver);
+ model = x86cpuid_GetModel(p.ver);
+
firm = x86cpuid_GetFirm(&p);
+
switch (firm)
{
- case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && model == 0x100C));
+ case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && (
+ /* In-Order Atom CPU */
+ model == 0x1C /* 45 nm, N4xx, D4xx, N5xx, D5xx, 230, 330 */
+ || model == 0x26 /* 45 nm, Z6xx */
+ || model == 0x27 /* 32 nm, Z2460 */
+ || model == 0x35 /* 32 nm, Z2760 */
+ || model == 0x36 /* 32 nm, N2xxx, D2xxx */
+ )));
case CPU_FIRM_AMD: return (family < 5 || (family == 5 && (model < 6 || model == 0xA)));
case CPU_FIRM_VIA: return (family < 6 || (family == 6 && model < 0xF));
}
return True;
}
-#if !defined(MY_CPU_AMD64) && defined(_WIN32_7Z)
-static Bool CPU_Sys_Is_SSE_Supported(void)
+#if !defined(MY_CPU_AMD64) && defined(_WIN32)
+#include <windows.h>
+static Bool CPU_Sys_Is_SSE_Supported()
{
OSVERSIONINFO vi;
vi.dwOSVersionInfoSize = sizeof(vi);
@@ -168,7 +181,7 @@ static Bool CPU_Sys_Is_SSE_Supported(void)
#define CHECK_SYS_SSE_SUPPORT
#endif
-Bool CPU_Is_Aes_Supported(void)
+Bool CPU_Is_Aes_Supported()
{
Cx86cpuid p;
CHECK_SYS_SSE_SUPPORT