Added API function to get CPU cache line size.
authorSam Lantinga <slouken@libsdl.org>
Thu, 27 Jan 2011 20:46:45 -0800
changeset 5120b3f075368b1f
parent 5119 edd0f0617be4
child 5121 87f452305db4
Added API function to get CPU cache line size.
include/SDL_cpuinfo.h
src/cpuinfo/SDL_cpuinfo.c
     1.1 --- a/include/SDL_cpuinfo.h	Thu Jan 27 20:37:54 2011 -0800
     1.2 +++ b/include/SDL_cpuinfo.h	Thu Jan 27 20:46:45 2011 -0800
     1.3 @@ -52,6 +52,14 @@
     1.4  extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
     1.5  
     1.6  /**
     1.7 + *  This function returns the L1 cache line size of the CPU
     1.8 + *
     1.9 + *  This is useful for determining multi-threaded structure padding
    1.10 + *  or SIMD prefetch sizes.
    1.11 + */
    1.12 +extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
    1.13 +
    1.14 +/**
    1.15   *  This function returns true if the CPU has the RDTSC instruction.
    1.16   */
    1.17  extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
     2.1 --- a/src/cpuinfo/SDL_cpuinfo.c	Thu Jan 27 20:37:54 2011 -0800
     2.2 +++ b/src/cpuinfo/SDL_cpuinfo.c	Thu Jan 27 20:46:45 2011 -0800
     2.3 @@ -304,7 +304,7 @@
     2.4  static int SDL_CPUCount = 0;
     2.5  
     2.6  int
     2.7 -SDL_GetCPUCount()
     2.8 +SDL_GetCPUCount(void)
     2.9  {
    2.10      if (!SDL_CPUCount) {
    2.11  #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
    2.12 @@ -335,7 +335,7 @@
    2.13  
    2.14  /* Oh, such a sweet sweet trick, just not very useful. :) */
    2.15  static const char *
    2.16 -SDL_GetCPUType()
    2.17 +SDL_GetCPUType(void)
    2.18  {
    2.19      static char SDL_CPUType[13];
    2.20  
    2.21 @@ -366,7 +366,7 @@
    2.22  }
    2.23  
    2.24  static const char *
    2.25 -SDL_GetCPUName()
    2.26 +SDL_GetCPUName(void)
    2.27  {
    2.28      static char SDL_CPUName[48];
    2.29  
    2.30 @@ -437,8 +437,8 @@
    2.31      return SDL_CPUName;
    2.32  }
    2.33  
    2.34 -static int
    2.35 -SDL_GetCPUCacheLineSize()
    2.36 +int
    2.37 +SDL_GetCPUCacheLineSize(void)
    2.38  {
    2.39      const char *cpuType = SDL_GetCPUType();
    2.40