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