As I’m working with assembly, it becomes very nice to be able to detect
what features are available on the current platform.
So I’m adding an API to SDL to detect these.
Please look this over and send me e-mail with CPU’s and features I’ve missed.
slouken at devolution.com
Thanks!
-Sam Lantinga (slouken at devolution.com)
Lead Programmer, Loki Entertainment Software–
“Any sufficiently advanced bug is indistinguishable from a feature”
– Rich Kulawiec
-------------- next part --------------
/*
SDL - Simple DirectMedia Layer
Copyright © 1997, 1998, 1999, 2000 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken at devolution.com
*/
#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id: SDL_copying.h,v 1.3.2.1 2000/03/16 15:20:37 hercules Exp $";
#endif
/* This file documents the CPU information functions in SDL /
/ NOTE: this information and API may change during SDL 1.1 development */
#ifndef _SDL_cpuinfo_h
#define _SDL_cpuinfo_h
/* The different known classes of CPU
A class of CPU is any set of CPU’s that share a common instruction set.
All of the CPU’s which run SDL should be listed here, as well as a few
that don’t yet run SDL.
*/
typedef enum {
SDL_CPU_CLASS_UNKNOWN = 0,
SDL_CPU_FLAGS_PSX, = 1024 + SDL_CPU_CLASS_UNKNOWN,
SDL_CPU_CLASS_X86, = 1024 + SDL_CPU_FLAGS_PSX,
SDL_CPU_CLASS_PPC, = 1024 + SDL_CPU_CLASS_X86,
SDL_CPU_CLASS_68K = 1024 + SDL_CPU_CLASS_PPC,
SDL_CPU_CLASS_SPARC = 1024 + SDL_CPU_CLASS_68K,
SDL_CPU_CLASS_ALPHA = 1024 + SDL_CPU_CLASS_SPARC,
SDL_CPU_CLASS_ARM = 1024 + SDL_CPU_CLASS_ALPHA,
SDL_CPU_CLASS_MIPS = 1024 + SDL_CPU_CLASS_ARM,
SDL_CPU_CLASS_VAX = 1024 + SDL_CPU_CLASS_MIPS,
SDL_CPU_CLASS_LAST
} SDL_CPU_CLASS;
/* The different known CPUs.
A CPU is a set of CPU models that share a complete unique instruction set.
These are defined so that each CPU is unique.
The actual values associated with the enumerated constants will change
as more CPUs are added to the list. Binary compatibility will only be
guaranteed as of SDL 1.2.0.
/
typedef enum {
SDL_CPU_UNKNOWN,
SDL_CPU_PSX1 = SDL_CPU_CLASS_PSX + 1,
SDL_CPU_PSX2,
SDL_CPU_286 = SDL_CPU_CLASS_X86 + 1,
SDL_CPU_386,
SDL_CPU_486,
SDL_CPU_PENTIUM,
SDL_CPU_PENTIUMPRO,
SDL_CPU_CELERON,
SDL_CPU_CELERONA,
SDL_CPU_PENTIUMII,
SDL_CPU_PENTIUMIII,
SDL_CPU_604 = SDL_CPU_CLASS_PPC + 1,
SDL_CPU_G3,
SDL_CPU_G4,
SDL_CPU_68K = SDL_CPU_CLASS_68K + 1, / ?? /
SDL_CPU_SPARC4 = SDL_CPU_CLASS_SPARC + 1,
SDL_CPU_SPARC5,
SDL_CPU_SPARC10,
SDL_CPU_SPARC20,
SDL_CPU_ULTRASPARC,
SDL_CPU_ALPHAEV4 = SDL_CPU_CLASS_ALPHA + 1,
SDL_CPU_ALPHAEV56,
SDL_CPU_ARM = SDL_CPU_CLASS_ARM + 1; / ?? /
SDL_CPU_MIPS = SDL_CPU_CLASS_MIPS + 1; / ?? /
SDL_CPU_VAX = SDL_CPU_CLASS_VAX + 1; / ?? */
SDL_CPU_LAST
} SDL_CPU;
/* The known useful CPU flags /
#define SDL_CPU_FLAGS_MMX 0x00000001 / PentiumII MMX /
#define SDL_CPU_FLAGS_EMMX 0x00000002 / Cyrix Extended MMX /
#define SDL_CPU_FLAGS_3DNOW 0x00000004 / AMD 3DNow! */
#include “begin_code.h”
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern “C” {
#endif
/* Return the number of CPUs available */
extern DECLSPEC int SDL_NumCPUs(void);
/*
- The following functions assume that all processors in a multiple-CPU
- system are the same. If this is not the case, let me know.
*/
/* Return the class of the system CPUs */
extern DECLSPEC SDL_CPU_CLASS SDL_GetCPUClass(void);
/* Return the type of the system CPUs */
extern DECLSPEC SDL_CPU SDL_GetCPUType(void);
/* Return the flags of the system CPUs */
extern DECLSPEC Uint32 SDL_GetCPUFlags(void);
/* Macros to check CPU flags */
#define SDL_CPU_HAS_MMX() (SDL_GetCPUFlags() & SDL_CPU_FLAGS_MMX)
#define SDL_CPU_HAS_3DNOW() (SDL_GetCPUFlags() & SDL_CPU_FLAGS_3DNOW)
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
};
#endif
#include “close_code.h”
#endif /* _SDL_cpuinfo_h */