Added API function to get CPU cache line size.

This commit is contained in:
Sam Lantinga 2011-01-27 20:46:45 -08:00
parent b0a2a8957e
commit b2ff9dc39f
2 changed files with 13 additions and 5 deletions

View file

@ -51,6 +51,14 @@ extern "C" {
*/ */
extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
/**
* This function returns the L1 cache line size of the CPU
*
* This is useful for determining multi-threaded structure padding
* or SIMD prefetch sizes.
*/
extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
/** /**
* This function returns true if the CPU has the RDTSC instruction. * This function returns true if the CPU has the RDTSC instruction.
*/ */

View file

@ -304,7 +304,7 @@ CPU_haveAltiVec(void)
static int SDL_CPUCount = 0; static int SDL_CPUCount = 0;
int int
SDL_GetCPUCount() SDL_GetCPUCount(void)
{ {
if (!SDL_CPUCount) { if (!SDL_CPUCount) {
#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
@ -335,7 +335,7 @@ SDL_GetCPUCount()
/* Oh, such a sweet sweet trick, just not very useful. :) */ /* Oh, such a sweet sweet trick, just not very useful. :) */
static const char * static const char *
SDL_GetCPUType() SDL_GetCPUType(void)
{ {
static char SDL_CPUType[13]; static char SDL_CPUType[13];
@ -366,7 +366,7 @@ SDL_GetCPUType()
} }
static const char * static const char *
SDL_GetCPUName() SDL_GetCPUName(void)
{ {
static char SDL_CPUName[48]; static char SDL_CPUName[48];
@ -437,8 +437,8 @@ SDL_GetCPUName()
return SDL_CPUName; return SDL_CPUName;
} }
static int int
SDL_GetCPUCacheLineSize() SDL_GetCPUCacheLineSize(void)
{ {
const char *cpuType = SDL_GetCPUType(); const char *cpuType = SDL_GetCPUType();