From f22f044d2da704ae739f74a1968f062857348e3f Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 27 Jan 2011 20:46:45 -0800 Subject: [PATCH] Added API function to get CPU cache line size. --- include/SDL_cpuinfo.h | 8 ++++++++ src/cpuinfo/SDL_cpuinfo.c | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/SDL_cpuinfo.h b/include/SDL_cpuinfo.h index f63140688..b15393834 100644 --- a/include/SDL_cpuinfo.h +++ b/include/SDL_cpuinfo.h @@ -51,6 +51,14 @@ extern "C" { */ 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. */ diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 443d5c188..e365ad76f 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -304,7 +304,7 @@ CPU_haveAltiVec(void) static int SDL_CPUCount = 0; int -SDL_GetCPUCount() +SDL_GetCPUCount(void) { if (!SDL_CPUCount) { #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) @@ -335,7 +335,7 @@ SDL_GetCPUCount() /* Oh, such a sweet sweet trick, just not very useful. :) */ static const char * -SDL_GetCPUType() +SDL_GetCPUType(void) { static char SDL_CPUType[13]; @@ -366,7 +366,7 @@ SDL_GetCPUType() } static const char * -SDL_GetCPUName() +SDL_GetCPUName(void) { static char SDL_CPUName[48]; @@ -437,8 +437,8 @@ SDL_GetCPUName() return SDL_CPUName; } -static int -SDL_GetCPUCacheLineSize() +int +SDL_GetCPUCacheLineSize(void) { const char *cpuType = SDL_GetCPUType();