include/SDL_cpuinfo.h
author Sam Lantinga <slouken@libsdl.org>
Sun, 09 Mar 2014 11:36:47 -0700
changeset 8583 fb2933ca805f
parent 8149 681eb46b8ac4
parent 8535 e8ee0708ef5c
child 9003 446ed0fe0fc3
permissions -rw-r--r--
Integrated David Ludwig's support for Windows RT
slouken@739
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@8149
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
slouken@739
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@739
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@739
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@739
    20
*/
slouken@739
    21
slouken@1895
    22
/**
slouken@3407
    23
 *  \file SDL_cpuinfo.h
slouken@7191
    24
 *
slouken@3407
    25
 *  CPU feature detection for SDL.
slouken@1895
    26
 */
slouken@739
    27
slouken@739
    28
#ifndef _SDL_cpuinfo_h
slouken@739
    29
#define _SDL_cpuinfo_h
slouken@739
    30
slouken@1402
    31
#include "SDL_stdinc.h"
slouken@1402
    32
slouken@5389
    33
/* Need to do this here because intrin.h has C++ code in it */
slouken@5389
    34
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
dludwig@8320
    35
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && (defined(_M_IX86) || defined(_M_X64))
slouken@5389
    36
#include <intrin.h>
slouken@5450
    37
#ifndef _WIN64
slouken@5389
    38
#define __MMX__
slouken@5389
    39
#define __3dNOW__
slouken@5450
    40
#endif
slouken@5389
    41
#define __SSE__
slouken@5389
    42
#define __SSE2__
slouken@5389
    43
#elif defined(__MINGW64_VERSION_MAJOR)
slouken@5389
    44
#include <intrin.h>
slouken@5389
    45
#else
slouken@5390
    46
#ifdef __ALTIVEC__
slouken@5390
    47
#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__)
slouken@5390
    48
#include <altivec.h>
slouken@5390
    49
#undef pixel
slouken@5390
    50
#endif
slouken@5390
    51
#endif
slouken@5389
    52
#ifdef __MMX__
slouken@5389
    53
#include <mmintrin.h>
slouken@5389
    54
#endif
slouken@5389
    55
#ifdef __3dNOW__
slouken@5389
    56
#include <mm3dnow.h>
slouken@5389
    57
#endif
slouken@5389
    58
#ifdef __SSE__
slouken@5389
    59
#include <xmmintrin.h>
slouken@5389
    60
#endif
slouken@5389
    61
#ifdef __SSE2__
slouken@5389
    62
#include <emmintrin.h>
slouken@5389
    63
#endif
slouken@5389
    64
#endif
slouken@5389
    65
slouken@739
    66
#include "begin_code.h"
slouken@739
    67
/* Set up for C function definitions, even when using C++ */
slouken@739
    68
#ifdef __cplusplus
slouken@739
    69
extern "C" {
slouken@739
    70
#endif
slouken@739
    71
slouken@5116
    72
/* This is a guess for the cacheline size used for padding.
slouken@5116
    73
 * Most x86 processors have a 64 byte cache line.
slouken@5116
    74
 * The 64-bit PowerPC processors have a 128 byte cache line.
slouken@5116
    75
 * We'll use the larger value to be generally safe.
slouken@5115
    76
 */
slouken@5116
    77
#define SDL_CACHELINE_SIZE  128
slouken@5115
    78
slouken@3407
    79
/**
slouken@3579
    80
 *  This function returns the number of CPU cores available.
slouken@3579
    81
 */
slouken@3579
    82
extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
slouken@3579
    83
slouken@3579
    84
/**
slouken@5120
    85
 *  This function returns the L1 cache line size of the CPU
slouken@5120
    86
 *
slouken@5120
    87
 *  This is useful for determining multi-threaded structure padding
slouken@5120
    88
 *  or SIMD prefetch sizes.
slouken@5120
    89
 */
slouken@5120
    90
extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
slouken@5120
    91
slouken@5120
    92
/**
slouken@3407
    93
 *  This function returns true if the CPU has the RDTSC instruction.
slouken@745
    94
 */
slouken@1426
    95
extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
slouken@745
    96
slouken@3407
    97
/**
slouken@5389
    98
 *  This function returns true if the CPU has AltiVec features.
slouken@5389
    99
 */
slouken@5389
   100
extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
slouken@5389
   101
slouken@5389
   102
/**
slouken@3407
   103
 *  This function returns true if the CPU has MMX features.
slouken@739
   104
 */
slouken@1426
   105
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
slouken@739
   106
slouken@3407
   107
/**
slouken@5389
   108
 *  This function returns true if the CPU has 3DNow! features.
slouken@5389
   109
 */
slouken@5389
   110
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
slouken@5389
   111
slouken@5389
   112
/**
slouken@3407
   113
 *  This function returns true if the CPU has SSE features.
slouken@739
   114
 */
slouken@1426
   115
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
slouken@739
   116
slouken@3407
   117
/**
slouken@3407
   118
 *  This function returns true if the CPU has SSE2 features.
slouken@785
   119
 */
slouken@1426
   120
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
slouken@785
   121
slouken@3407
   122
/**
slouken@5259
   123
 *  This function returns true if the CPU has SSE3 features.
slouken@778
   124
 */
slouken@5259
   125
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
slouken@5259
   126
slouken@5259
   127
/**
slouken@5263
   128
 *  This function returns true if the CPU has SSE4.1 features.
slouken@5259
   129
 */
slouken@5263
   130
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
slouken@5263
   131
slouken@5263
   132
/**
slouken@5263
   133
 *  This function returns true if the CPU has SSE4.2 features.
slouken@5263
   134
 */
slouken@5263
   135
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
slouken@5259
   136
slouken@7821
   137
/**
slouken@8148
   138
 *  This function returns true if the CPU has AVX features.
slouken@8148
   139
 */
slouken@8148
   140
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void);
slouken@8148
   141
slouken@8148
   142
/**
slouken@7821
   143
 *  This function returns the amount of RAM configured in the system, in MB.
slouken@7821
   144
 */
slouken@7821
   145
extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void);
slouken@7821
   146
slouken@778
   147
slouken@739
   148
/* Ends C function definitions when using C++ */
slouken@739
   149
#ifdef __cplusplus
slouken@739
   150
}
slouken@739
   151
#endif
slouken@739
   152
#include "close_code.h"
slouken@739
   153
slouken@739
   154
#endif /* _SDL_cpuinfo_h */
slouken@1895
   155
slouken@1895
   156
/* vi: set ts=4 sw=4 expandtab: */