include/SDL_cpuinfo.h
author Sam Lantinga <slouken@libsdl.org>
Mon, 07 Mar 2011 22:04:10 -0800
changeset 5450 58630b98eb63
parent 5407 40c9d744e595
child 5535 96594ac5fd1a
permissions -rw-r--r--
The MMX and 3DNow! instructions can't be compiled by 64-bit Visual Studio.
slouken@739
     1
/*
slouken@739
     2
    SDL - Simple DirectMedia Layer
slouken@5262
     3
    Copyright (C) 1997-2011 Sam Lantinga
slouken@739
     4
slouken@739
     5
    This library is free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@739
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@739
     9
slouken@739
    10
    This library is distributed in the hope that it will be useful,
slouken@739
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@739
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@739
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@739
    18
slouken@739
    19
    Sam Lantinga
slouken@739
    20
    slouken@libsdl.org
slouken@739
    21
*/
slouken@739
    22
slouken@1895
    23
/**
slouken@3407
    24
 *  \file SDL_cpuinfo.h
slouken@3407
    25
 *  
slouken@3407
    26
 *  CPU feature detection for SDL.
slouken@1895
    27
 */
slouken@739
    28
slouken@739
    29
#ifndef _SDL_cpuinfo_h
slouken@739
    30
#define _SDL_cpuinfo_h
slouken@739
    31
slouken@1402
    32
#include "SDL_stdinc.h"
slouken@1402
    33
slouken@5389
    34
/* Need to do this here because intrin.h has C++ code in it */
slouken@5389
    35
/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
slouken@5389
    36
#if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(_WIN32_WCE)
slouken@5389
    37
#include <intrin.h>
slouken@5450
    38
#ifndef _WIN64
slouken@5389
    39
#define __MMX__
slouken@5389
    40
#define __3dNOW__
slouken@5450
    41
#endif
slouken@5389
    42
#define __SSE__
slouken@5389
    43
#define __SSE2__
slouken@5389
    44
#elif defined(__MINGW64_VERSION_MAJOR)
slouken@5389
    45
#include <intrin.h>
slouken@5389
    46
#else
slouken@5390
    47
#ifdef __ALTIVEC__
slouken@5390
    48
#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__)
slouken@5390
    49
#include <altivec.h>
slouken@5390
    50
#undef pixel
slouken@5390
    51
#endif
slouken@5390
    52
#endif
slouken@5389
    53
#ifdef __MMX__
slouken@5389
    54
#include <mmintrin.h>
slouken@5389
    55
#endif
slouken@5389
    56
#ifdef __3dNOW__
slouken@5389
    57
#include <mm3dnow.h>
slouken@5389
    58
#endif
slouken@5389
    59
#ifdef __SSE__
slouken@5389
    60
#include <xmmintrin.h>
slouken@5389
    61
#endif
slouken@5389
    62
#ifdef __SSE2__
slouken@5389
    63
#include <emmintrin.h>
slouken@5389
    64
#endif
slouken@5389
    65
#endif
slouken@5389
    66
slouken@739
    67
#include "begin_code.h"
slouken@739
    68
/* Set up for C function definitions, even when using C++ */
slouken@739
    69
#ifdef __cplusplus
slouken@1895
    70
/* *INDENT-OFF* */
slouken@739
    71
extern "C" {
slouken@1895
    72
/* *INDENT-ON* */
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@778
   140
slouken@739
   141
/* Ends C function definitions when using C++ */
slouken@739
   142
#ifdef __cplusplus
slouken@1895
   143
/* *INDENT-OFF* */
slouken@739
   144
}
slouken@1895
   145
/* *INDENT-ON* */
slouken@739
   146
#endif
slouken@739
   147
#include "close_code.h"
slouken@739
   148
slouken@739
   149
#endif /* _SDL_cpuinfo_h */
slouken@1895
   150
slouken@1895
   151
/* vi: set ts=4 sw=4 expandtab: */