Added SDL_GetCPUCount() to see how many cores are available.
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404328
This commit is contained in:
parent
3f0f9188ed
commit
29601c280b
9 changed files with 175 additions and 183 deletions
|
@ -207,7 +207,7 @@ if test x$enable_libc = xyes; then
|
||||||
AC_DEFINE(HAVE_MPROTECT)
|
AC_DEFINE(HAVE_MPROTECT)
|
||||||
]),
|
]),
|
||||||
)
|
)
|
||||||
AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf sigaction setjmp nanosleep)
|
AC_CHECK_FUNCS(malloc calloc realloc free getenv putenv unsetenv qsort abs bcopy memset memcpy memmove strlen strlcpy strlcat strdup _strrev _strupr _strlwr strchr strrchr strstr itoa _ltoa _uitoa _ultoa strtol strtoul _i64toa _ui64toa strtoll strtoull atoi atof strcmp strncmp _stricmp strcasecmp _strnicmp strncasecmp sscanf snprintf vsnprintf sigaction setjmp nanosleep sysctlbyname)
|
||||||
|
|
||||||
AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
|
AC_CHECK_LIB(m, pow, [LIBS="$LIBS -lm"; EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lm"])
|
||||||
AC_CHECK_FUNCS(ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt)
|
AC_CHECK_FUNCS(ceil copysign cos cosf fabs floor log pow scalbn sin sinf sqrt)
|
||||||
|
|
|
@ -150,6 +150,7 @@
|
||||||
#undef HAVE_SIGACTION
|
#undef HAVE_SIGACTION
|
||||||
#undef HAVE_SETJMP
|
#undef HAVE_SETJMP
|
||||||
#undef HAVE_NANOSLEEP
|
#undef HAVE_NANOSLEEP
|
||||||
|
#undef HAVE_SYSCTLBYNAME
|
||||||
#undef HAVE_CLOCK_GETTIME
|
#undef HAVE_CLOCK_GETTIME
|
||||||
#undef HAVE_GETPAGESIZE
|
#undef HAVE_GETPAGESIZE
|
||||||
#undef HAVE_MPROTECT
|
#undef HAVE_MPROTECT
|
||||||
|
|
|
@ -106,6 +106,7 @@ typedef unsigned long uintptr_t;
|
||||||
#define HAVE_SIGACTION 1
|
#define HAVE_SIGACTION 1
|
||||||
#define HAVE_SETJMP 1
|
#define HAVE_SETJMP 1
|
||||||
#define HAVE_NANOSLEEP 1
|
#define HAVE_NANOSLEEP 1
|
||||||
|
#define HAVE_SYSCTLBYNAME 1
|
||||||
|
|
||||||
/* enable iPhone version of Core Audio driver */
|
/* enable iPhone version of Core Audio driver */
|
||||||
#define SDL_AUDIO_DRIVER_COREAUDIOIPHONE 1
|
#define SDL_AUDIO_DRIVER_COREAUDIOIPHONE 1
|
||||||
|
|
|
@ -105,6 +105,7 @@
|
||||||
#define HAVE_SIGACTION 1
|
#define HAVE_SIGACTION 1
|
||||||
#define HAVE_SETJMP 1
|
#define HAVE_SETJMP 1
|
||||||
#define HAVE_NANOSLEEP 1
|
#define HAVE_NANOSLEEP 1
|
||||||
|
#define HAVE_SYSCTLBYNAME 1
|
||||||
|
|
||||||
/* Enable various audio drivers */
|
/* Enable various audio drivers */
|
||||||
#define SDL_AUDIO_DRIVER_COREAUDIO 1
|
#define SDL_AUDIO_DRIVER_COREAUDIO 1
|
||||||
|
|
|
@ -39,6 +39,11 @@ extern "C" {
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function returns the number of CPU cores available.
|
||||||
|
*/
|
||||||
|
extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function returns true if the CPU has the RDTSC instruction.
|
* This function returns true if the CPU has the RDTSC instruction.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -25,6 +25,10 @@
|
||||||
|
|
||||||
#include "SDL_cpuinfo.h"
|
#include "SDL_cpuinfo.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_SYSCTLBYNAME
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
#if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))
|
#if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))
|
||||||
#include <sys/sysctl.h> /* For AltiVec check */
|
#include <sys/sysctl.h> /* For AltiVec check */
|
||||||
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
|
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
|
||||||
|
@ -32,14 +36,14 @@
|
||||||
#include <setjmp.h>
|
#include <setjmp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CPU_HAS_RDTSC 0x00000001
|
#define CPU_HAS_RDTSC 0x00000001
|
||||||
#define CPU_HAS_MMX 0x00000002
|
#define CPU_HAS_MMX 0x00000002
|
||||||
#define CPU_HAS_MMXEXT 0x00000004
|
#define CPU_HAS_MMXEXT 0x00000004
|
||||||
#define CPU_HAS_3DNOW 0x00000010
|
#define CPU_HAS_3DNOW 0x00000010
|
||||||
#define CPU_HAS_3DNOWEXT 0x00000020
|
#define CPU_HAS_3DNOWEXT 0x00000020
|
||||||
#define CPU_HAS_SSE 0x00000040
|
#define CPU_HAS_SSE 0x00000040
|
||||||
#define CPU_HAS_SSE2 0x00000080
|
#define CPU_HAS_SSE2 0x00000080
|
||||||
#define CPU_HAS_ALTIVEC 0x00000100
|
#define CPU_HAS_ALTIVEC 0x00000100
|
||||||
|
|
||||||
#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__
|
#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__
|
||||||
/* This is the brute force way of detecting instruction sets...
|
/* This is the brute force way of detecting instruction sets...
|
||||||
|
@ -59,7 +63,7 @@ CPU_haveCPUID(void)
|
||||||
int has_CPUID = 0;
|
int has_CPUID = 0;
|
||||||
/* *INDENT-OFF* */
|
/* *INDENT-OFF* */
|
||||||
#if defined(__GNUC__) && defined(i386)
|
#if defined(__GNUC__) && defined(i386)
|
||||||
__asm__ (
|
__asm__ (
|
||||||
" pushfl # Get original EFLAGS \n"
|
" pushfl # Get original EFLAGS \n"
|
||||||
" popl %%eax \n"
|
" popl %%eax \n"
|
||||||
" movl %%eax,%%ecx \n"
|
" movl %%eax,%%ecx \n"
|
||||||
|
@ -72,14 +76,14 @@ CPU_haveCPUID(void)
|
||||||
" jz 1f # Processor=80486 \n"
|
" jz 1f # Processor=80486 \n"
|
||||||
" movl $1,%0 # We have CPUID support \n"
|
" movl $1,%0 # We have CPUID support \n"
|
||||||
"1: \n"
|
"1: \n"
|
||||||
: "=m" (has_CPUID)
|
: "=m" (has_CPUID)
|
||||||
:
|
:
|
||||||
: "%eax", "%ecx"
|
: "%eax", "%ecx"
|
||||||
);
|
);
|
||||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
#elif defined(__GNUC__) && defined(__x86_64__)
|
||||||
/* Technically, if this is being compiled under __x86_64__ then it has
|
/* Technically, if this is being compiled under __x86_64__ then it has
|
||||||
CPUid by definition. But it's nice to be able to prove it. :) */
|
CPUid by definition. But it's nice to be able to prove it. :) */
|
||||||
__asm__ (
|
__asm__ (
|
||||||
" pushfq # Get original EFLAGS \n"
|
" pushfq # Get original EFLAGS \n"
|
||||||
" popq %%rax \n"
|
" popq %%rax \n"
|
||||||
" movq %%rax,%%rcx \n"
|
" movq %%rax,%%rcx \n"
|
||||||
|
@ -92,12 +96,12 @@ CPUid by definition. But it's nice to be able to prove it. :) */
|
||||||
" jz 1f # Processor=80486 \n"
|
" jz 1f # Processor=80486 \n"
|
||||||
" movl $1,%0 # We have CPUID support \n"
|
" movl $1,%0 # We have CPUID support \n"
|
||||||
"1: \n"
|
"1: \n"
|
||||||
: "=m" (has_CPUID)
|
: "=m" (has_CPUID)
|
||||||
:
|
:
|
||||||
: "%rax", "%rcx"
|
: "%rax", "%rcx"
|
||||||
);
|
);
|
||||||
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
|
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
|
||||||
__asm {
|
__asm {
|
||||||
pushfd ; Get original EFLAGS
|
pushfd ; Get original EFLAGS
|
||||||
pop eax
|
pop eax
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
|
@ -110,24 +114,24 @@ CPUid by definition. But it's nice to be able to prove it. :) */
|
||||||
jz done ; Processor=80486
|
jz done ; Processor=80486
|
||||||
mov has_CPUID,1 ; We have CPUID support
|
mov has_CPUID,1 ; We have CPUID support
|
||||||
done:
|
done:
|
||||||
}
|
}
|
||||||
#elif defined(__sun) && defined(__i386)
|
#elif defined(__sun) && defined(__i386)
|
||||||
__asm (
|
__asm (
|
||||||
" pushfl \n"
|
" pushfl \n"
|
||||||
" popl %eax \n"
|
" popl %eax \n"
|
||||||
" movl %eax,%ecx \n"
|
" movl %eax,%ecx \n"
|
||||||
" xorl $0x200000,%eax \n"
|
" xorl $0x200000,%eax \n"
|
||||||
" pushl %eax \n"
|
" pushl %eax \n"
|
||||||
" popfl \n"
|
" popfl \n"
|
||||||
" pushfl \n"
|
" pushfl \n"
|
||||||
" popl %eax \n"
|
" popl %eax \n"
|
||||||
" xorl %ecx,%eax \n"
|
" xorl %ecx,%eax \n"
|
||||||
" jz 1f \n"
|
" jz 1f \n"
|
||||||
" movl $1,-8(%ebp) \n"
|
" movl $1,-8(%ebp) \n"
|
||||||
"1: \n"
|
"1: \n"
|
||||||
);
|
);
|
||||||
#elif defined(__sun) && defined(__amd64)
|
#elif defined(__sun) && defined(__amd64)
|
||||||
__asm (
|
__asm (
|
||||||
" pushfq \n"
|
" pushfq \n"
|
||||||
" popq %rax \n"
|
" popq %rax \n"
|
||||||
" movq %rax,%rcx \n"
|
" movq %rax,%rcx \n"
|
||||||
|
@ -140,92 +144,42 @@ done:
|
||||||
" jz 1f \n"
|
" jz 1f \n"
|
||||||
" movl $1,-8(%rbp) \n"
|
" movl $1,-8(%rbp) \n"
|
||||||
"1: \n"
|
"1: \n"
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
/* *INDENT-ON* */
|
/* *INDENT-ON* */
|
||||||
return has_CPUID;
|
return has_CPUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && (defined(i386) || defined(__x86_64__))
|
||||||
|
#define cpuid(func, ax, bx, cx, dx) \
|
||||||
|
__asm__ __volatile__ ("cpuid": \
|
||||||
|
"=a" (ax), "=b" (bx), "=c" (cx), "=d" (dx) : "a" (func))
|
||||||
|
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
|
||||||
|
#define cpuid(func, ax, bx, cx, dx) \
|
||||||
|
asm { \
|
||||||
|
mov eax, func \
|
||||||
|
cpuid
|
||||||
|
mov ax, eax \
|
||||||
|
mov bx, ebx \
|
||||||
|
mov cx, ecx \
|
||||||
|
mov dx, edx \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define cpuid(func, ax, bx, cx, dx) \
|
||||||
|
ax = bx = cx = dx = 0
|
||||||
|
#endif
|
||||||
|
|
||||||
static __inline__ int
|
static __inline__ int
|
||||||
CPU_getCPUIDFeatures(void)
|
CPU_getCPUIDFeatures(void)
|
||||||
{
|
{
|
||||||
int features = 0;
|
int features = 0;
|
||||||
/* *INDENT-OFF* */
|
int ax, bx, cx, dx;
|
||||||
#if defined(__GNUC__) && defined(i386)
|
|
||||||
__asm__ (
|
cpuid(0, ax, bx, cx, dx);
|
||||||
" xorl %%eax,%%eax # Set up for CPUID instruction \n"
|
if (ax >= 1) {
|
||||||
" pushl %%ebx \n"
|
cpuid(1, ax, bx, cx, dx);
|
||||||
" cpuid # Get and save vendor ID \n"
|
features = dx;
|
||||||
" popl %%ebx \n"
|
}
|
||||||
" cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n"
|
|
||||||
" jl 1f # We dont have the CPUID instruction\n"
|
|
||||||
" xorl %%eax,%%eax \n"
|
|
||||||
" incl %%eax \n"
|
|
||||||
" pushl %%ebx \n"
|
|
||||||
" cpuid # Get family/model/stepping/features\n"
|
|
||||||
" popl %%ebx \n"
|
|
||||||
" movl %%edx,%0 \n"
|
|
||||||
"1: \n"
|
|
||||||
: "=m" (features)
|
|
||||||
:
|
|
||||||
: "%eax", "%ecx", "%edx"
|
|
||||||
);
|
|
||||||
#elif defined(__GNUC__) && defined(__x86_64__)
|
|
||||||
__asm__ (
|
|
||||||
" xorl %%eax,%%eax # Set up for CPUID instruction \n"
|
|
||||||
" pushq %%rbx \n"
|
|
||||||
" cpuid # Get and save vendor ID \n"
|
|
||||||
" popq %%rbx \n"
|
|
||||||
" cmpl $1,%%eax # Make sure 1 is valid input for CPUID\n"
|
|
||||||
" jl 1f # We dont have the CPUID instruction\n"
|
|
||||||
" xorl %%eax,%%eax \n"
|
|
||||||
" incl %%eax \n"
|
|
||||||
" pushq %%rbx \n"
|
|
||||||
" cpuid # Get family/model/stepping/features\n"
|
|
||||||
" popq %%rbx \n"
|
|
||||||
" movl %%edx,%0 \n"
|
|
||||||
"1: \n"
|
|
||||||
: "=m" (features)
|
|
||||||
:
|
|
||||||
: "%rax", "%rcx", "%rdx"
|
|
||||||
);
|
|
||||||
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
|
|
||||||
__asm {
|
|
||||||
xor eax, eax ; Set up for CPUID instruction
|
|
||||||
push ebx
|
|
||||||
cpuid ; Get and save vendor ID
|
|
||||||
pop ebx
|
|
||||||
cmp eax, 1 ; Make sure 1 is valid input for CPUID
|
|
||||||
jl done ; We dont have the CPUID instruction
|
|
||||||
xor eax, eax
|
|
||||||
inc eax
|
|
||||||
push ebx
|
|
||||||
cpuid ; Get family/model/stepping/features
|
|
||||||
pop ebx
|
|
||||||
mov features, edx
|
|
||||||
done:
|
|
||||||
}
|
|
||||||
#elif defined(__sun) && (defined(__i386) || defined(__amd64))
|
|
||||||
__asm(
|
|
||||||
" xorl %eax,%eax \n"
|
|
||||||
" pushl %ebx \n"
|
|
||||||
" cpuid \n"
|
|
||||||
" popl %ebx \n"
|
|
||||||
" cmpl $1,%eax \n"
|
|
||||||
" jl 1f \n"
|
|
||||||
" xorl %eax,%eax \n"
|
|
||||||
" incl %eax \n"
|
|
||||||
" pushl %ebx \n"
|
|
||||||
" cpuid \n"
|
|
||||||
" popl %ebx \n"
|
|
||||||
#ifdef __i386
|
|
||||||
" movl %edx,-8(%ebp) \n"
|
|
||||||
#else
|
|
||||||
" movl %edx,-8(%rbp) \n"
|
|
||||||
#endif
|
|
||||||
"1: \n"
|
|
||||||
#endif
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
return features;
|
return features;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,79 +187,13 @@ static __inline__ int
|
||||||
CPU_getCPUIDFeaturesExt(void)
|
CPU_getCPUIDFeaturesExt(void)
|
||||||
{
|
{
|
||||||
int features = 0;
|
int features = 0;
|
||||||
/* *INDENT-OFF* */
|
int ax, bx, cx, dx;
|
||||||
#if defined(__GNUC__) && defined(i386)
|
|
||||||
__asm__ (
|
cpuid(0x80000000, ax, bx, cx, dx);
|
||||||
" movl $0x80000000,%%eax # Query for extended functions \n"
|
if (ax >= 0x80000001) {
|
||||||
" pushl %%ebx \n"
|
cpuid(0x80000001, ax, bx, cx, dx);
|
||||||
" cpuid # Get extended function limit \n"
|
features = dx;
|
||||||
" popl %%ebx \n"
|
}
|
||||||
" cmpl $0x80000001,%%eax \n"
|
|
||||||
" jl 1f # Nope, we dont have function 800000001h\n"
|
|
||||||
" movl $0x80000001,%%eax # Setup extended function 800000001h\n"
|
|
||||||
" pushl %%ebx \n"
|
|
||||||
" cpuid # and get the information \n"
|
|
||||||
" popl %%ebx \n"
|
|
||||||
" movl %%edx,%0 \n"
|
|
||||||
"1: \n"
|
|
||||||
: "=m" (features)
|
|
||||||
:
|
|
||||||
: "%eax", "%ecx", "%edx"
|
|
||||||
);
|
|
||||||
#elif defined(__GNUC__) && defined (__x86_64__)
|
|
||||||
__asm__ (
|
|
||||||
" movl $0x80000000,%%eax # Query for extended functions \n"
|
|
||||||
" pushq %%rbx \n"
|
|
||||||
" cpuid # Get extended function limit \n"
|
|
||||||
" popq %%rbx \n"
|
|
||||||
" cmpl $0x80000001,%%eax \n"
|
|
||||||
" jl 1f # Nope, we dont have function 800000001h\n"
|
|
||||||
" movl $0x80000001,%%eax # Setup extended function 800000001h\n"
|
|
||||||
" pushq %%rbx \n"
|
|
||||||
" cpuid # and get the information \n"
|
|
||||||
" popq %%rbx \n"
|
|
||||||
" movl %%edx,%0 \n"
|
|
||||||
"1: \n"
|
|
||||||
: "=m" (features)
|
|
||||||
:
|
|
||||||
: "%rax", "%rcx", "%rdx"
|
|
||||||
);
|
|
||||||
#elif (defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)
|
|
||||||
__asm {
|
|
||||||
mov eax,80000000h ; Query for extended functions
|
|
||||||
push ebx
|
|
||||||
cpuid ; Get extended function limit
|
|
||||||
pop ebx
|
|
||||||
cmp eax,80000001h
|
|
||||||
jl done ; Nope, we dont have function 800000001h
|
|
||||||
mov eax,80000001h ; Setup extended function 800000001h
|
|
||||||
push ebx
|
|
||||||
cpuid ; and get the information
|
|
||||||
pop ebx
|
|
||||||
mov features,edx
|
|
||||||
done:
|
|
||||||
}
|
|
||||||
#elif defined(__sun) && ( defined(__i386) || defined(__amd64) )
|
|
||||||
__asm (
|
|
||||||
" movl $0x80000000,%eax \n"
|
|
||||||
" pushl %ebx \n"
|
|
||||||
" cpuid \n"
|
|
||||||
" popl %ebx \n"
|
|
||||||
" cmpl $0x80000001,%eax \n"
|
|
||||||
" jl 1f \n"
|
|
||||||
" movl $0x80000001,%eax \n"
|
|
||||||
" pushl %ebx \n"
|
|
||||||
" cpuid \n"
|
|
||||||
" popl %ebx \n"
|
|
||||||
#ifdef __i386
|
|
||||||
" movl %edx,-8(%ebp) \n"
|
|
||||||
#else
|
|
||||||
" movl %edx,-8(%rbp) \n"
|
|
||||||
#endif
|
|
||||||
"1: \n"
|
|
||||||
);
|
|
||||||
#endif
|
|
||||||
/* *INDENT-ON* */
|
|
||||||
return features;
|
return features;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,6 +283,97 @@ CPU_haveAltiVec(void)
|
||||||
return altivec;
|
return altivec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int SDL_CPUCount = 0;
|
||||||
|
|
||||||
|
int
|
||||||
|
SDL_GetCPUCount()
|
||||||
|
{
|
||||||
|
if (!SDL_CPUCount) {
|
||||||
|
#ifdef HAVE_SYSCTLBYNAME
|
||||||
|
size_t size = sizeof(SDL_CPUCount);
|
||||||
|
sysctlbyname("hw.ncpu", &SDL_CPUCount, &size, NULL, 0);
|
||||||
|
#endif
|
||||||
|
/* There has to be at least 1, right? :) */
|
||||||
|
if (!SDL_CPUCount) {
|
||||||
|
SDL_CPUCount = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SDL_CPUCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Oh, such a sweet sweet trick, just not very useful. :) */
|
||||||
|
const char *
|
||||||
|
SDL_GetCPUType()
|
||||||
|
{
|
||||||
|
static char SDL_CPUType[48];
|
||||||
|
|
||||||
|
if (!SDL_CPUType[0]) {
|
||||||
|
int i = 0;
|
||||||
|
int ax, bx, cx, dx;
|
||||||
|
|
||||||
|
if (CPU_haveCPUID()) {
|
||||||
|
cpuid(0x80000000, ax, bx, cx, dx);
|
||||||
|
if (ax >= 0x80000004) {
|
||||||
|
cpuid(0x80000002, ax, bx, cx, dx);
|
||||||
|
SDL_CPUType[i++] = (char)(ax & 0xff); ax >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(ax & 0xff); ax >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(ax & 0xff); ax >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(ax & 0xff); ax >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(bx & 0xff); bx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(bx & 0xff); bx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(bx & 0xff); bx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(bx & 0xff); bx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(cx & 0xff); cx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(cx & 0xff); cx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(cx & 0xff); cx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(cx & 0xff); cx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(dx & 0xff); dx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(dx & 0xff); dx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(dx & 0xff); dx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(dx & 0xff); dx >>= 8;
|
||||||
|
cpuid(0x80000003, ax, bx, cx, dx);
|
||||||
|
SDL_CPUType[i++] = (char)(ax & 0xff); ax >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(ax & 0xff); ax >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(ax & 0xff); ax >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(ax & 0xff); ax >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(bx & 0xff); bx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(bx & 0xff); bx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(bx & 0xff); bx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(bx & 0xff); bx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(cx & 0xff); cx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(cx & 0xff); cx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(cx & 0xff); cx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(cx & 0xff); cx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(dx & 0xff); dx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(dx & 0xff); dx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(dx & 0xff); dx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(dx & 0xff); dx >>= 8;
|
||||||
|
cpuid(0x80000004, ax, bx, cx, dx);
|
||||||
|
SDL_CPUType[i++] = (char)(ax & 0xff); ax >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(ax & 0xff); ax >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(ax & 0xff); ax >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(ax & 0xff); ax >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(bx & 0xff); bx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(bx & 0xff); bx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(bx & 0xff); bx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(bx & 0xff); bx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(cx & 0xff); cx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(cx & 0xff); cx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(cx & 0xff); cx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(cx & 0xff); cx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(dx & 0xff); dx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(dx & 0xff); dx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(dx & 0xff); dx >>= 8;
|
||||||
|
SDL_CPUType[i++] = (char)(dx & 0xff); dx >>= 8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!SDL_CPUType[0]) {
|
||||||
|
SDL_strlcpy(SDL_CPUType, "Unknown", sizeof(SDL_CPUType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return SDL_CPUType;
|
||||||
|
}
|
||||||
|
|
||||||
static Uint32 SDL_CPUFeatures = 0xFFFFFFFF;
|
static Uint32 SDL_CPUFeatures = 0xFFFFFFFF;
|
||||||
|
|
||||||
static Uint32
|
static Uint32
|
||||||
|
@ -509,6 +488,8 @@ SDL_HasAltiVec(void)
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
|
printf("CPU count: %d\n", SDL_GetCPUCount());
|
||||||
|
printf("CPU name: %s\n", SDL_GetCPUType());
|
||||||
printf("RDTSC: %d\n", SDL_HasRDTSC());
|
printf("RDTSC: %d\n", SDL_HasRDTSC());
|
||||||
printf("MMX: %d\n", SDL_HasMMX());
|
printf("MMX: %d\n", SDL_HasMMX());
|
||||||
printf("MMXExt: %d\n", SDL_HasMMXExt());
|
printf("MMXExt: %d\n", SDL_HasMMXExt());
|
||||||
|
|
|
@ -49,4 +49,5 @@ extern void SDL_SYS_SetupThread(void);
|
||||||
extern void SDL_SYS_WaitThread(SDL_Thread * thread);
|
extern void SDL_SYS_WaitThread(SDL_Thread * thread);
|
||||||
|
|
||||||
#endif /* _SDL_systhread_h */
|
#endif /* _SDL_systhread_h */
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
|
@ -155,6 +155,7 @@ int test_platform (void)
|
||||||
"big"
|
"big"
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
SDL_ATprintVerbose( 1, "CPU count: %d\n", SDL_GetCPUCount());
|
||||||
SDL_ATprintVerbose( 1, "Available extensions:\n" );
|
SDL_ATprintVerbose( 1, "Available extensions:\n" );
|
||||||
SDL_ATprintVerbose( 1, " RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected" );
|
SDL_ATprintVerbose( 1, " RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected" );
|
||||||
SDL_ATprintVerbose( 1, " MMX %s\n", SDL_HasMMX()? "detected" : "not detected" );
|
SDL_ATprintVerbose( 1, " MMX %s\n", SDL_HasMMX()? "detected" : "not detected" );
|
||||||
|
|
|
@ -134,6 +134,7 @@ int
|
||||||
TestCPUInfo(SDL_bool verbose)
|
TestCPUInfo(SDL_bool verbose)
|
||||||
{
|
{
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
|
printf("CPU count: %d\n", SDL_GetCPUCount());
|
||||||
printf("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected");
|
printf("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected");
|
||||||
printf("MMX %s\n", SDL_HasMMX()? "detected" : "not detected");
|
printf("MMX %s\n", SDL_HasMMX()? "detected" : "not detected");
|
||||||
printf("MMX Ext %s\n", SDL_HasMMXExt()? "detected" : "not detected");
|
printf("MMX Ext %s\n", SDL_HasMMXExt()? "detected" : "not detected");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue