Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Added API function to get CPU cache line size.
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jan 28, 2011
1 parent b9261ce commit f22f044
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions include/SDL_cpuinfo.h
Expand Up @@ -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.
*/
Expand Down
10 changes: 5 additions & 5 deletions src/cpuinfo/SDL_cpuinfo.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -366,7 +366,7 @@ SDL_GetCPUType()
}

static const char *
SDL_GetCPUName()
SDL_GetCPUName(void)
{
static char SDL_CPUName[48];

Expand Down Expand Up @@ -437,8 +437,8 @@ SDL_GetCPUName()
return SDL_CPUName;
}

static int
SDL_GetCPUCacheLineSize()
int
SDL_GetCPUCacheLineSize(void)
{
const char *cpuType = SDL_GetCPUType();

Expand Down

0 comments on commit f22f044

Please sign in to comment.