include/SDL_cpuinfo.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 27 Feb 2011 22:22:58 -0800
changeset 5407 40c9d744e595
parent 5390 fefd4f7b5214
child 5450 58630b98eb63
permissions -rw-r--r--
Fixed compiling AltiVec blitters
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2011 Sam Lantinga
     4 
     5     This library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9 
    10     This library is distributed in the hope that it will be useful,
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    13     Lesser General Public License for more details.
    14 
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with this library; if not, write to the Free Software
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    18 
    19     Sam Lantinga
    20     slouken@libsdl.org
    21 */
    22 
    23 /**
    24  *  \file SDL_cpuinfo.h
    25  *  
    26  *  CPU feature detection for SDL.
    27  */
    28 
    29 #ifndef _SDL_cpuinfo_h
    30 #define _SDL_cpuinfo_h
    31 
    32 #include "SDL_stdinc.h"
    33 
    34 /* Need to do this here because intrin.h has C++ code in it */
    35 /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
    36 #if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(_WIN32_WCE)
    37 #include <intrin.h>
    38 #define __MMX__
    39 #define __3dNOW__
    40 #define __SSE__
    41 #define __SSE2__
    42 #elif defined(__MINGW64_VERSION_MAJOR)
    43 #include <intrin.h>
    44 #else
    45 #ifdef __ALTIVEC__
    46 #if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__)
    47 #include <altivec.h>
    48 #undef pixel
    49 #endif
    50 #endif
    51 #ifdef __MMX__
    52 #include <mmintrin.h>
    53 #endif
    54 #ifdef __3dNOW__
    55 #include <mm3dnow.h>
    56 #endif
    57 #ifdef __SSE__
    58 #include <xmmintrin.h>
    59 #endif
    60 #ifdef __SSE2__
    61 #include <emmintrin.h>
    62 #endif
    63 #endif
    64 
    65 #include "begin_code.h"
    66 /* Set up for C function definitions, even when using C++ */
    67 #ifdef __cplusplus
    68 /* *INDENT-OFF* */
    69 extern "C" {
    70 /* *INDENT-ON* */
    71 #endif
    72 
    73 /* This is a guess for the cacheline size used for padding.
    74  * Most x86 processors have a 64 byte cache line.
    75  * The 64-bit PowerPC processors have a 128 byte cache line.
    76  * We'll use the larger value to be generally safe.
    77  */
    78 #define SDL_CACHELINE_SIZE  128
    79 
    80 /**
    81  *  This function returns the number of CPU cores available.
    82  */
    83 extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
    84 
    85 /**
    86  *  This function returns the L1 cache line size of the CPU
    87  *
    88  *  This is useful for determining multi-threaded structure padding
    89  *  or SIMD prefetch sizes.
    90  */
    91 extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
    92 
    93 /**
    94  *  This function returns true if the CPU has the RDTSC instruction.
    95  */
    96 extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
    97 
    98 /**
    99  *  This function returns true if the CPU has AltiVec features.
   100  */
   101 extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
   102 
   103 /**
   104  *  This function returns true if the CPU has MMX features.
   105  */
   106 extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
   107 
   108 /**
   109  *  This function returns true if the CPU has 3DNow! features.
   110  */
   111 extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
   112 
   113 /**
   114  *  This function returns true if the CPU has SSE features.
   115  */
   116 extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
   117 
   118 /**
   119  *  This function returns true if the CPU has SSE2 features.
   120  */
   121 extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
   122 
   123 /**
   124  *  This function returns true if the CPU has SSE3 features.
   125  */
   126 extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
   127 
   128 /**
   129  *  This function returns true if the CPU has SSE4.1 features.
   130  */
   131 extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
   132 
   133 /**
   134  *  This function returns true if the CPU has SSE4.2 features.
   135  */
   136 extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
   137 
   138 
   139 /* Ends C function definitions when using C++ */
   140 #ifdef __cplusplus
   141 /* *INDENT-OFF* */
   142 }
   143 /* *INDENT-ON* */
   144 #endif
   145 #include "close_code.h"
   146 
   147 #endif /* _SDL_cpuinfo_h */
   148 
   149 /* vi: set ts=4 sw=4 expandtab: */