mirror of
https://github.com/xmrig/xmrig.git
synced 2024-12-23 20:19:23 +00:00
Update libcpuid to recent git version.
This commit is contained in:
parent
cf76d9254a
commit
1f609c7ebd
8 changed files with 991 additions and 929 deletions
21
src/3rdparty/libcpuid/asm-bits.c
vendored
21
src/3rdparty/libcpuid/asm-bits.c
vendored
|
@ -32,7 +32,7 @@ int cpuid_exists_by_eflags(void)
|
||||||
#if defined(PLATFORM_X64)
|
#if defined(PLATFORM_X64)
|
||||||
return 1; /* CPUID is always present on the x86_64 */
|
return 1; /* CPUID is always present on the x86_64 */
|
||||||
#elif defined(PLATFORM_X86)
|
#elif defined(PLATFORM_X86)
|
||||||
# if defined(COMPILER_GCC)
|
# if defined(COMPILER_GCC) || defined(COMPILER_CLANG)
|
||||||
int result;
|
int result;
|
||||||
__asm __volatile(
|
__asm __volatile(
|
||||||
" pushfl\n"
|
" pushfl\n"
|
||||||
|
@ -70,6 +70,8 @@ int cpuid_exists_by_eflags(void)
|
||||||
# else
|
# else
|
||||||
return 0;
|
return 0;
|
||||||
# endif /* COMPILER_MICROSOFT */
|
# endif /* COMPILER_MICROSOFT */
|
||||||
|
#elif defined(PLATFORM_ARM)
|
||||||
|
return 0;
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif /* PLATFORM_X86 */
|
#endif /* PLATFORM_X86 */
|
||||||
|
@ -82,7 +84,7 @@ int cpuid_exists_by_eflags(void)
|
||||||
*/
|
*/
|
||||||
void exec_cpuid(uint32_t *regs)
|
void exec_cpuid(uint32_t *regs)
|
||||||
{
|
{
|
||||||
#ifdef COMPILER_GCC
|
# if defined(COMPILER_GCC) || defined(COMPILER_CLANG)
|
||||||
# ifdef PLATFORM_X64
|
# ifdef PLATFORM_X64
|
||||||
__asm __volatile(
|
__asm __volatile(
|
||||||
" mov %0, %%rdi\n"
|
" mov %0, %%rdi\n"
|
||||||
|
@ -109,7 +111,7 @@ void exec_cpuid(uint32_t *regs)
|
||||||
:"m"(regs)
|
:"m"(regs)
|
||||||
:"memory", "eax", "rdi"
|
:"memory", "eax", "rdi"
|
||||||
);
|
);
|
||||||
# else
|
# elif defined(PLATFORM_X86)
|
||||||
__asm __volatile(
|
__asm __volatile(
|
||||||
" mov %0, %%edi\n"
|
" mov %0, %%edi\n"
|
||||||
|
|
||||||
|
@ -135,6 +137,7 @@ void exec_cpuid(uint32_t *regs)
|
||||||
:"m"(regs)
|
:"m"(regs)
|
||||||
:"memory", "eax", "edi"
|
:"memory", "eax", "edi"
|
||||||
);
|
);
|
||||||
|
# elif defined(PLATFORM_ARM)
|
||||||
# endif /* COMPILER_GCC */
|
# endif /* COMPILER_GCC */
|
||||||
#else
|
#else
|
||||||
# ifdef COMPILER_MICROSOFT
|
# ifdef COMPILER_MICROSOFT
|
||||||
|
@ -173,13 +176,18 @@ void exec_cpuid(uint32_t *regs)
|
||||||
void cpu_rdtsc(uint64_t* result)
|
void cpu_rdtsc(uint64_t* result)
|
||||||
{
|
{
|
||||||
uint32_t low_part, hi_part;
|
uint32_t low_part, hi_part;
|
||||||
#ifdef COMPILER_GCC
|
#if defined(COMPILER_GCC) || defined(COMPILER_CLANG)
|
||||||
|
#ifdef PLATFORM_ARM
|
||||||
|
low_part = 0;
|
||||||
|
hi_part = 0;
|
||||||
|
#else
|
||||||
__asm __volatile (
|
__asm __volatile (
|
||||||
" rdtsc\n"
|
" rdtsc\n"
|
||||||
" mov %%eax, %0\n"
|
" mov %%eax, %0\n"
|
||||||
" mov %%edx, %1\n"
|
" mov %%edx, %1\n"
|
||||||
:"=m"(low_part), "=m"(hi_part)::"memory", "eax", "edx"
|
:"=m"(low_part), "=m"(hi_part)::"memory", "eax", "edx"
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
# ifdef COMPILER_MICROSOFT
|
# ifdef COMPILER_MICROSOFT
|
||||||
__asm {
|
__asm {
|
||||||
|
@ -198,12 +206,14 @@ void cpu_rdtsc(uint64_t* result)
|
||||||
#ifdef INLINE_ASM_SUPPORTED
|
#ifdef INLINE_ASM_SUPPORTED
|
||||||
void busy_sse_loop(int cycles)
|
void busy_sse_loop(int cycles)
|
||||||
{
|
{
|
||||||
#ifdef COMPILER_GCC
|
# if defined(COMPILER_GCC) || defined(COMPILER_CLANG)
|
||||||
#ifndef __APPLE__
|
#ifndef __APPLE__
|
||||||
# define XALIGN ".balign 16\n"
|
# define XALIGN ".balign 16\n"
|
||||||
#else
|
#else
|
||||||
# define XALIGN ".align 4\n"
|
# define XALIGN ".align 4\n"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef PLATFORM_ARM
|
||||||
|
#else
|
||||||
__asm __volatile (
|
__asm __volatile (
|
||||||
" xorps %%xmm0, %%xmm0\n"
|
" xorps %%xmm0, %%xmm0\n"
|
||||||
" xorps %%xmm1, %%xmm1\n"
|
" xorps %%xmm1, %%xmm1\n"
|
||||||
|
@ -510,6 +520,7 @@ void busy_sse_loop(int cycles)
|
||||||
" jnz 1b\n"
|
" jnz 1b\n"
|
||||||
::"a"(cycles)
|
::"a"(cycles)
|
||||||
);
|
);
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
# ifdef COMPILER_MICROSOFT
|
# ifdef COMPILER_MICROSOFT
|
||||||
__asm {
|
__asm {
|
||||||
|
|
20
src/3rdparty/libcpuid/asm-bits.h
vendored
20
src/3rdparty/libcpuid/asm-bits.h
vendored
|
@ -29,20 +29,38 @@
|
||||||
|
|
||||||
/* Determine Compiler: */
|
/* Determine Compiler: */
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
|
#if !defined(COMPILER_MICROSOFT)
|
||||||
# define COMPILER_MICROSOFT
|
# define COMPILER_MICROSOFT
|
||||||
|
#endif
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
|
#if !defined(COMPILER_GCC)
|
||||||
# define COMPILER_GCC
|
# define COMPILER_GCC
|
||||||
#endif
|
#endif
|
||||||
|
#elif defined(__clang__)
|
||||||
|
#if !defined(COMPILER_CLANG)
|
||||||
|
# define COMPILER_CLANG
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Determine Platform */
|
/* Determine Platform */
|
||||||
#if defined(__x86_64__) || defined(_M_AMD64)
|
#if defined(__x86_64__) || defined(_M_AMD64)
|
||||||
|
#if !defined(PLATFORM_X64)
|
||||||
# define PLATFORM_X64
|
# define PLATFORM_X64
|
||||||
|
#endif
|
||||||
#elif defined(__i386__) || defined(_M_IX86)
|
#elif defined(__i386__) || defined(_M_IX86)
|
||||||
|
#if !defined(PLATFORM_X86)
|
||||||
# define PLATFORM_X86
|
# define PLATFORM_X86
|
||||||
#endif
|
#endif
|
||||||
|
#elif defined(__ARMEL__)
|
||||||
|
#if !defined(PLATFORM_ARM)
|
||||||
|
# define PLATFORM_ARM
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Under Windows/AMD64 with MSVC, inline assembly isn't supported */
|
/* Under Windows/AMD64 with MSVC, inline assembly isn't supported */
|
||||||
#if (defined(COMPILER_GCC) && defined(PLATFORM_X64)) || defined(PLATFORM_X86)
|
#if (((defined(COMPILER_GCC) || defined(COMPILER_CLANG))) && \
|
||||||
|
(defined(PLATFORM_X64) || defined(PLATFORM_X86) || defined(PLATFORM_ARM))) || \
|
||||||
|
(defined(COMPILER_MICROSOFT) && defined(PLATFORM_X86))
|
||||||
# define INLINE_ASM_SUPPORTED
|
# define INLINE_ASM_SUPPORTED
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
56
src/3rdparty/libcpuid/cpuid_main.c
vendored
56
src/3rdparty/libcpuid/cpuid_main.c
vendored
|
@ -221,42 +221,42 @@ static void load_features_common(struct cpu_raw_data_t* raw, struct cpu_id_t* da
|
||||||
|
|
||||||
static cpu_vendor_t cpuid_vendor_identify(const uint32_t *raw_vendor, char *vendor_str)
|
static cpu_vendor_t cpuid_vendor_identify(const uint32_t *raw_vendor, char *vendor_str)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
cpu_vendor_t vendor = VENDOR_UNKNOWN;
|
cpu_vendor_t vendor = VENDOR_UNKNOWN;
|
||||||
const struct { cpu_vendor_t vendor; char match[16]; }
|
const struct { cpu_vendor_t vendor; char match[16]; }
|
||||||
matchtable[NUM_CPU_VENDORS] = {
|
matchtable[NUM_CPU_VENDORS] = {
|
||||||
/* source: http://www.sandpile.org/ia32/cpuid.htm */
|
/* source: http://www.sandpile.org/ia32/cpuid.htm */
|
||||||
{ VENDOR_INTEL , "GenuineIntel" },
|
{ VENDOR_INTEL , "GenuineIntel" },
|
||||||
{ VENDOR_AMD , "AuthenticAMD" },
|
{ VENDOR_AMD , "AuthenticAMD" },
|
||||||
{ VENDOR_CYRIX , "CyrixInstead" },
|
{ VENDOR_CYRIX , "CyrixInstead" },
|
||||||
{ VENDOR_NEXGEN , "NexGenDriven" },
|
{ VENDOR_NEXGEN , "NexGenDriven" },
|
||||||
{ VENDOR_TRANSMETA , "GenuineTMx86" },
|
{ VENDOR_TRANSMETA , "GenuineTMx86" },
|
||||||
{ VENDOR_UMC , "UMC UMC UMC " },
|
{ VENDOR_UMC , "UMC UMC UMC " },
|
||||||
{ VENDOR_CENTAUR , "CentaurHauls" },
|
{ VENDOR_CENTAUR , "CentaurHauls" },
|
||||||
{ VENDOR_RISE , "RiseRiseRise" },
|
{ VENDOR_RISE , "RiseRiseRise" },
|
||||||
{ VENDOR_SIS , "SiS SiS SiS " },
|
{ VENDOR_SIS , "SiS SiS SiS " },
|
||||||
{ VENDOR_NSC , "Geode by NSC" },
|
{ VENDOR_NSC , "Geode by NSC" },
|
||||||
};
|
};
|
||||||
|
|
||||||
memcpy(vendor_str + 0, &raw_vendor[1], 4);
|
memcpy(vendor_str + 0, &raw_vendor[1], 4);
|
||||||
memcpy(vendor_str + 4, &raw_vendor[3], 4);
|
memcpy(vendor_str + 4, &raw_vendor[3], 4);
|
||||||
memcpy(vendor_str + 8, &raw_vendor[2], 4);
|
memcpy(vendor_str + 8, &raw_vendor[2], 4);
|
||||||
vendor_str[12] = 0;
|
vendor_str[12] = 0;
|
||||||
|
|
||||||
/* Determine vendor: */
|
/* Determine vendor: */
|
||||||
for (i = 0; i < NUM_CPU_VENDORS; i++)
|
for (i = 0; i < NUM_CPU_VENDORS; i++)
|
||||||
if (!strcmp(vendor_str, matchtable[i].match)) {
|
if (!strcmp(vendor_str, matchtable[i].match)) {
|
||||||
vendor = matchtable[i].vendor;
|
vendor = matchtable[i].vendor;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return vendor;
|
return vendor;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cpuid_basic_identify(struct cpu_raw_data_t* raw, struct cpu_id_t* data)
|
static int cpuid_basic_identify(struct cpu_raw_data_t* raw, struct cpu_id_t* data)
|
||||||
{
|
{
|
||||||
int i, j, basic, xmodel, xfamily, ext;
|
int i, j, basic, xmodel, xfamily, ext;
|
||||||
char brandstr[64] = {0};
|
char brandstr[64] = {0};
|
||||||
data->vendor = cpuid_vendor_identify(raw->basic_cpuid[0], data->vendor_str);
|
data->vendor = cpuid_vendor_identify(raw->basic_cpuid[0], data->vendor_str);
|
||||||
|
|
||||||
if (data->vendor == VENDOR_UNKNOWN)
|
if (data->vendor == VENDOR_UNKNOWN)
|
||||||
return set_error(ERR_CPU_UNKN);
|
return set_error(ERR_CPU_UNKN);
|
||||||
|
|
37
src/3rdparty/libcpuid/libcpuid.h
vendored
37
src/3rdparty/libcpuid/libcpuid.h
vendored
|
@ -82,6 +82,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @defgroup libcpuid LibCPUID
|
/** @defgroup libcpuid LibCPUID
|
||||||
|
* @brief LibCPUID provides CPU identification
|
||||||
@{ */
|
@{ */
|
||||||
|
|
||||||
/* Include some integer type specifications: */
|
/* Include some integer type specifications: */
|
||||||
|
@ -535,23 +536,23 @@ typedef enum {
|
||||||
* @brief Describes common library error codes
|
* @brief Describes common library error codes
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ERR_OK = 0, /*!< "No error" */
|
ERR_OK = 0, /*!< No error */
|
||||||
ERR_NO_CPUID = -1, /*!< "CPUID instruction is not supported" */
|
ERR_NO_CPUID = -1, /*!< CPUID instruction is not supported */
|
||||||
ERR_NO_RDTSC = -2, /*!< "RDTSC instruction is not supported" */
|
ERR_NO_RDTSC = -2, /*!< RDTSC instruction is not supported */
|
||||||
ERR_NO_MEM = -3, /*!< "Memory allocation failed" */
|
ERR_NO_MEM = -3, /*!< Memory allocation failed */
|
||||||
ERR_OPEN = -4, /*!< "File open operation failed" */
|
ERR_OPEN = -4, /*!< File open operation failed */
|
||||||
ERR_BADFMT = -5, /*!< "Bad file format" */
|
ERR_BADFMT = -5, /*!< Bad file format */
|
||||||
ERR_NOT_IMP = -6, /*!< "Not implemented" */
|
ERR_NOT_IMP = -6, /*!< Not implemented */
|
||||||
ERR_CPU_UNKN = -7, /*!< "Unsupported processor" */
|
ERR_CPU_UNKN = -7, /*!< Unsupported processor */
|
||||||
ERR_NO_RDMSR = -8, /*!< "RDMSR instruction is not supported" */
|
ERR_NO_RDMSR = -8, /*!< RDMSR instruction is not supported */
|
||||||
ERR_NO_DRIVER= -9, /*!< "RDMSR driver error (generic)" */
|
ERR_NO_DRIVER= -9, /*!< RDMSR driver error (generic) */
|
||||||
ERR_NO_PERMS = -10, /*!< "No permissions to install RDMSR driver" */
|
ERR_NO_PERMS = -10, /*!< No permissions to install RDMSR driver */
|
||||||
ERR_EXTRACT = -11, /*!< "Cannot extract RDMSR driver (read only media?)" */
|
ERR_EXTRACT = -11, /*!< Cannot extract RDMSR driver (read only media?) */
|
||||||
ERR_HANDLE = -12, /*!< "Bad handle" */
|
ERR_HANDLE = -12, /*!< Bad handle */
|
||||||
ERR_INVMSR = -13, /*!< "Invalid MSR" */
|
ERR_INVMSR = -13, /*!< Invalid MSR */
|
||||||
ERR_INVCNB = -14, /*!< "Invalid core number" */
|
ERR_INVCNB = -14, /*!< Invalid core number */
|
||||||
ERR_HANDLE_R = -15, /*!< "Error on handle read" */
|
ERR_HANDLE_R = -15, /*!< Error on handle read */
|
||||||
ERR_INVRANGE = -16, /*!< "Invalid given range" */
|
ERR_INVRANGE = -16, /*!< Invalid given range */
|
||||||
} cpu_error_t;
|
} cpu_error_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -668,7 +669,7 @@ struct cpu_epc_t cpuid_get_epc(int index, const struct cpu_raw_data_t* raw);
|
||||||
const char* cpuid_lib_version(void);
|
const char* cpuid_lib_version(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}; /* extern "C" */
|
} /* extern "C" */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
5
src/3rdparty/libcpuid/libcpuid_internal.h
vendored
5
src/3rdparty/libcpuid/libcpuid_internal.h
vendored
|
@ -75,8 +75,9 @@ enum _intel_bits_t {
|
||||||
_3 = LBIT( 14 ),
|
_3 = LBIT( 14 ),
|
||||||
_5 = LBIT( 15 ),
|
_5 = LBIT( 15 ),
|
||||||
_7 = LBIT( 16 ),
|
_7 = LBIT( 16 ),
|
||||||
XEON_ = LBIT( 17 ),
|
_9 = LBIT( 17 ),
|
||||||
ATOM_ = LBIT( 18 ),
|
XEON_ = LBIT( 18 ),
|
||||||
|
ATOM_ = LBIT( 19 ),
|
||||||
};
|
};
|
||||||
typedef enum _intel_bits_t intel_bits_t;
|
typedef enum _intel_bits_t intel_bits_t;
|
||||||
|
|
||||||
|
|
28
src/3rdparty/libcpuid/libcpuid_types.h
vendored
28
src/3rdparty/libcpuid/libcpuid_types.h
vendored
|
@ -32,6 +32,32 @@
|
||||||
#ifndef __LIBCPUID_TYPES_H__
|
#ifndef __LIBCPUID_TYPES_H__
|
||||||
#define __LIBCPUID_TYPES_H__
|
#define __LIBCPUID_TYPES_H__
|
||||||
|
|
||||||
#include <stdint.h>
|
#if !defined(_MSC_VER) || _MSC_VER >= 1600
|
||||||
|
# include <stdint.h>
|
||||||
|
#else
|
||||||
|
/* we have to provide our own: */
|
||||||
|
# if !defined(__int32_t_defined)
|
||||||
|
typedef int int32_t;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# if !defined(__uint32_t_defined)
|
||||||
|
typedef unsigned uint32_t;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
typedef signed char int8_t;
|
||||||
|
typedef unsigned char uint8_t;
|
||||||
|
typedef signed short int16_t;
|
||||||
|
typedef unsigned short uint16_t;
|
||||||
|
#if (defined _MSC_VER) && (_MSC_VER <= 1300)
|
||||||
|
/* MSVC 6.0: no long longs ... */
|
||||||
|
typedef signed __int64 int64_t;
|
||||||
|
typedef unsigned __int64 uint64_t;
|
||||||
|
#else
|
||||||
|
/* all other sane compilers: */
|
||||||
|
typedef signed long long int64_t;
|
||||||
|
typedef unsigned long long uint64_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* __LIBCPUID_TYPES_H__ */
|
#endif /* __LIBCPUID_TYPES_H__ */
|
||||||
|
|
4
src/3rdparty/libcpuid/recog_amd.c
vendored
4
src/3rdparty/libcpuid/recog_amd.c
vendored
|
@ -49,6 +49,10 @@ enum _amd_model_codes_t {
|
||||||
_1400,
|
_1400,
|
||||||
_1500,
|
_1500,
|
||||||
_1600,
|
_1600,
|
||||||
|
_1900,
|
||||||
|
_2400,
|
||||||
|
_2500,
|
||||||
|
_2700,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void load_amd_features(struct cpu_raw_data_t* raw, struct cpu_id_t* data)
|
static void load_amd_features(struct cpu_raw_data_t* raw, struct cpu_id_t* data)
|
||||||
|
|
3
src/3rdparty/libcpuid/recog_intel.c
vendored
3
src/3rdparty/libcpuid/recog_intel.c
vendored
|
@ -376,7 +376,7 @@ static intel_code_and_bits_t get_brand_code_and_bits(struct cpu_id_t* data)
|
||||||
bits |= bit_matchtable[i].bit;
|
bits |= bit_matchtable[i].bit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((i = match_pattern(bs, "Core(TM) [im][357]")) != 0) {
|
if ((i = match_pattern(bs, "Core(TM) [im][3579]")) != 0) {
|
||||||
bits |= CORE_;
|
bits |= CORE_;
|
||||||
i--;
|
i--;
|
||||||
switch (bs[i + 9]) {
|
switch (bs[i + 9]) {
|
||||||
|
@ -387,6 +387,7 @@ static intel_code_and_bits_t get_brand_code_and_bits(struct cpu_id_t* data)
|
||||||
case '3': bits |= _3; break;
|
case '3': bits |= _3; break;
|
||||||
case '5': bits |= _5; break;
|
case '5': bits |= _5; break;
|
||||||
case '7': bits |= _7; break;
|
case '7': bits |= _7; break;
|
||||||
|
case '9': bits |= _9; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i = 0; i < COUNT_OF(matchtable); i++)
|
for (i = 0; i < COUNT_OF(matchtable); i++)
|
||||||
|
|
Loading…
Reference in a new issue