include/SDL_cpuinfo.h
author Ryan C. Gordon <icculus@icculus.org>
Mon, 23 Jan 2017 01:05:44 -0500
changeset 10835 0e9e7a128391
parent 10737 3406a0f8b041
child 11330 6ae35c5f7f7b
permissions -rw-r--r--
audio: Wired up new SSE code to build system.
slouken@739
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@10737
     3
  Copyright (C) 1997-2017 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@10638
    28
#ifndef SDL_cpuinfo_h_
slouken@10638
    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
icculus@10835
    64
#ifdef __SSE3__
icculus@10835
    65
#include <pmmintrin.h>
icculus@10835
    66
#endif
slouken@5389
    67
#endif
slouken@5389
    68
slouken@739
    69
#include "begin_code.h"
slouken@739
    70
/* Set up for C function definitions, even when using C++ */
slouken@739
    71
#ifdef __cplusplus
slouken@739
    72
extern "C" {
slouken@739
    73
#endif
slouken@739
    74
slouken@5116
    75
/* This is a guess for the cacheline size used for padding.
slouken@5116
    76
 * Most x86 processors have a 64 byte cache line.
slouken@5116
    77
 * The 64-bit PowerPC processors have a 128 byte cache line.
slouken@5116
    78
 * We'll use the larger value to be generally safe.
slouken@5115
    79
 */
slouken@5116
    80
#define SDL_CACHELINE_SIZE  128
slouken@5115
    81
slouken@3407
    82
/**
slouken@3579
    83
 *  This function returns the number of CPU cores available.
slouken@3579
    84
 */
slouken@3579
    85
extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
slouken@3579
    86
slouken@3579
    87
/**
slouken@5120
    88
 *  This function returns the L1 cache line size of the CPU
slouken@5120
    89
 *
slouken@5120
    90
 *  This is useful for determining multi-threaded structure padding
slouken@5120
    91
 *  or SIMD prefetch sizes.
slouken@5120
    92
 */
slouken@5120
    93
extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
slouken@5120
    94
slouken@5120
    95
/**
slouken@3407
    96
 *  This function returns true if the CPU has the RDTSC instruction.
slouken@745
    97
 */
slouken@1426
    98
extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
slouken@745
    99
slouken@3407
   100
/**
slouken@5389
   101
 *  This function returns true if the CPU has AltiVec features.
slouken@5389
   102
 */
slouken@5389
   103
extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
slouken@5389
   104
slouken@5389
   105
/**
slouken@3407
   106
 *  This function returns true if the CPU has MMX features.
slouken@739
   107
 */
slouken@1426
   108
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
slouken@739
   109
slouken@3407
   110
/**
slouken@5389
   111
 *  This function returns true if the CPU has 3DNow! features.
slouken@5389
   112
 */
slouken@5389
   113
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
slouken@5389
   114
slouken@5389
   115
/**
slouken@3407
   116
 *  This function returns true if the CPU has SSE features.
slouken@739
   117
 */
slouken@1426
   118
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
slouken@739
   119
slouken@3407
   120
/**
slouken@3407
   121
 *  This function returns true if the CPU has SSE2 features.
slouken@785
   122
 */
slouken@1426
   123
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
slouken@785
   124
slouken@3407
   125
/**
slouken@5259
   126
 *  This function returns true if the CPU has SSE3 features.
slouken@778
   127
 */
slouken@5259
   128
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
slouken@5259
   129
slouken@5259
   130
/**
slouken@5263
   131
 *  This function returns true if the CPU has SSE4.1 features.
slouken@5259
   132
 */
slouken@5263
   133
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
slouken@5263
   134
slouken@5263
   135
/**
slouken@5263
   136
 *  This function returns true if the CPU has SSE4.2 features.
slouken@5263
   137
 */
slouken@5263
   138
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
slouken@5259
   139
slouken@7821
   140
/**
slouken@8148
   141
 *  This function returns true if the CPU has AVX features.
slouken@8148
   142
 */
slouken@8148
   143
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX(void);
slouken@8148
   144
slouken@8148
   145
/**
slouken@9003
   146
 *  This function returns true if the CPU has AVX2 features.
slouken@9003
   147
 */
slouken@9003
   148
extern DECLSPEC SDL_bool SDLCALL SDL_HasAVX2(void);
slouken@9003
   149
slouken@9003
   150
/**
icculus@10620
   151
 *  This function returns true if the CPU has NEON (ARM SIMD) features.
icculus@10620
   152
 */
icculus@10620
   153
extern DECLSPEC SDL_bool SDLCALL SDL_HasNEON(void);
icculus@10620
   154
icculus@10620
   155
/**
slouken@7821
   156
 *  This function returns the amount of RAM configured in the system, in MB.
slouken@7821
   157
 */
slouken@7821
   158
extern DECLSPEC int SDLCALL SDL_GetSystemRAM(void);
slouken@7821
   159
slouken@778
   160
slouken@739
   161
/* Ends C function definitions when using C++ */
slouken@739
   162
#ifdef __cplusplus
slouken@739
   163
}
slouken@739
   164
#endif
slouken@739
   165
#include "close_code.h"
slouken@739
   166
slouken@10638
   167
#endif /* SDL_cpuinfo_h_ */
slouken@1895
   168
slouken@1895
   169
/* vi: set ts=4 sw=4 expandtab: */