Path: blob/main/system/include/SDL/SDL_cpuinfo.h
6169 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2011 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021/**22* \file SDL_cpuinfo.h23*24* CPU feature detection for SDL.25*/2627#ifndef _SDL_cpuinfo_h28#define _SDL_cpuinfo_h2930#include "SDL_stdinc.h"3132/* Need to do this here because intrin.h has C++ code in it */33/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */34#if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(_WIN32_WCE)35#include <intrin.h>36#ifndef _WIN6437#define __MMX__38#define __3dNOW__39#endif40#define __SSE__41#define __SSE2__42#elif defined(__MINGW64_VERSION_MAJOR)43#include <intrin.h>44#else45#ifdef __ALTIVEC__46#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__)47#include <altivec.h>48#undef pixel49#endif50#endif51#ifdef __MMX__52#include <mmintrin.h>53#endif54#ifdef __3dNOW__55#include <mm3dnow.h>56#endif57#ifdef __SSE__58#include <xmmintrin.h>59#endif60#ifdef __SSE2__61#include <emmintrin.h>62#endif63#endif6465#include "begin_code.h"66/* Set up for C function definitions, even when using C++ */67#ifdef __cplusplus68/* *INDENT-OFF* */69extern "C" {70/* *INDENT-ON* */71#endif7273/* This is a guess for the cacheline size used for padding.74* Most x86 processors have a 64 byte cache line.75* The 64-bit PowerPC processors have a 128 byte cache line.76* We'll use the larger value to be generally safe.77*/78#define SDL_CACHELINE_SIZE 1287980/**81* This function returns the number of CPU cores available.82*/83extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);8485/**86* This function returns the L1 cache line size of the CPU87*88* This is useful for determining multi-threaded structure padding89* or SIMD prefetch sizes.90*/91extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);9293/**94* This function returns true if the CPU has the RDTSC instruction.95*/96extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);9798/**99* This function returns true if the CPU has AltiVec features.100*/101extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void);102103/**104* This function returns true if the CPU has MMX features.105*/106extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void);107extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void);108109/**110* This function returns true if the CPU has 3DNow! features.111*/112extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void);113extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void);114115/**116* This function returns true if the CPU has SSE features.117*/118extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);119extern DECLSPEC SDL_bool SDLCALL SDL_HasSSEExt(void);120121/**122* This function returns true if the CPU has SSE2 features.123*/124extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void);125extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2Ext(void);126127/**128* This function returns true if the CPU has SSE3 features.129*/130extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void);131132/**133* This function returns true if the CPU has SSE4.1 features.134*/135extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void);136137/**138* This function returns true if the CPU has SSE4.2 features.139*/140extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void);141142143/* Ends C function definitions when using C++ */144#ifdef __cplusplus145/* *INDENT-OFF* */146}147/* *INDENT-ON* */148#endif149#include "close_code.h"150151#endif /* _SDL_cpuinfo_h */152153/* vi: set ts=4 sw=4 expandtab: */154155156