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
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@5389
    38
#define __MMX__
slouken@5389
    39
#define __3dNOW__
slouken@5389
    40
#define __SSE__
slouken@5389
    41
#define __SSE2__
slouken@5389
    42
#elif defined(__MINGW64_VERSION_MAJOR)
slouken@5389
    43
#include <intrin.h>
slouken@5389
    44
#else
slouken@5390
    45
#ifdef __ALTIVEC__
slouken@5390
    46
#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__)
slouken@5390
    47
#include <altivec.h>
slouken@5390
    48
#undef pixel
slouken@5390
    49
#endif
slouken@5390
    50
#endif
slouken@5389
    51
#ifdef __MMX__
slouken@5389
    52
#include <mmintrin.h>
slouken@5389
    53
#endif
slouken@5389
    54
#ifdef __3dNOW__
slouken@5389
    55
#include <mm3dnow.h>
slouken@5389
    56
#endif
slouken@5389
    57
#ifdef __SSE__
slouken@5389
    58
#include <xmmintrin.h>
slouken@5389
    59
#endif
slouken@5389
    60
#ifdef __SSE2__
slouken@5389
    61
#include <emmintrin.h>
slouken@5389
    62
#endif
slouken@5389
    63
#endif
slouken@5389
    64
slouken@739
    65
#include "begin_code.h"
slouken@739
    66
/* Set up for C function definitions, even when using C++ */
slouken@739
    67
#ifdef __cplusplus
slouken@1895
    68
/* *INDENT-OFF* */
slouken@739
    69
extern "C" {
slouken@1895
    70
/* *INDENT-ON* */
slouken@739
    71
#endif
slouken@739
    72
slouken@5116
    73
/* This is a guess for the cacheline size used for padding.
slouken@5116
    74
 * Most x86 processors have a 64 byte cache line.
slouken@5116
    75
 * The 64-bit PowerPC processors have a 128 byte cache line.
slouken@5116
    76
 * We'll use the larger value to be generally safe.
slouken@5115
    77
 */
slouken@5116
    78
#define SDL_CACHELINE_SIZE  128
slouken@5115
    79
slouken@3407
    80
/**
slouken@3579
    81
 *  This function returns the number of CPU cores available.
slouken@3579
    82
 */
slouken@3579
    83
extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
slouken@3579
    84
slouken@3579
    85
/**
slouken@5120
    86
 *  This function returns the L1 cache line size of the CPU
slouken@5120
    87
 *
slouken@5120
    88
 *  This is useful for determining multi-threaded structure padding
slouken@5120
    89
 *  or SIMD prefetch sizes.
slouken@5120
    90
 */
slouken@5120
    91
extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
slouken@5120
    92
slouken@5120
    93
/**
slouken@3407
    94
 *  This function returns true if the CPU has the RDTSC instruction.
slouken@745
    95
 */
slouken@1426
    96
extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
slouken@745
    97
slouken@3407
    98
/**
slouken@5389
    99
 *  This function returns true if the CPU has AltiVec features.
slouken@5389
   100
 */
slouken@5389
   101
extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);
slouken@5389
   102
slouken@5389
   103
/**
slouken@3407
   104
 *  This function returns true if the CPU has MMX features.
slouken@739
   105
 */
slouken@1426
   106
extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);
slouken@739
   107
slouken@3407
   108
/**
slouken@5389
   109
 *  This function returns true if the CPU has 3DNow! features.
slouken@5389
   110
 */
slouken@5389
   111
extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);
slouken@5389
   112
slouken@5389
   113
/**
slouken@3407
   114
 *  This function returns true if the CPU has SSE features.
slouken@739
   115
 */
slouken@1426
   116
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
slouken@739
   117
slouken@3407
   118
/**
slouken@3407
   119
 *  This function returns true if the CPU has SSE2 features.
slouken@785
   120
 */
slouken@1426
   121
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);
slouken@785
   122
slouken@3407
   123
/**
slouken@5259
   124
 *  This function returns true if the CPU has SSE3 features.
slouken@778
   125
 */
slouken@5259
   126
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);
slouken@5259
   127
slouken@5259
   128
/**
slouken@5263
   129
 *  This function returns true if the CPU has SSE4.1 features.
slouken@5259
   130
 */
slouken@5263
   131
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);
slouken@5263
   132
slouken@5263
   133
/**
slouken@5263
   134
 *  This function returns true if the CPU has SSE4.2 features.
slouken@5263
   135
 */
slouken@5263
   136
extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);
slouken@5259
   137
slouken@778
   138
slouken@739
   139
/* Ends C function definitions when using C++ */
slouken@739
   140
#ifdef __cplusplus
slouken@1895
   141
/* *INDENT-OFF* */
slouken@739
   142
}
slouken@1895
   143
/* *INDENT-ON* */
slouken@739
   144
#endif
slouken@739
   145
#include "close_code.h"
slouken@739
   146
slouken@739
   147
#endif /* _SDL_cpuinfo_h */
slouken@1895
   148
slouken@1895
   149
/* vi: set ts=4 sw=4 expandtab: */