2005-11-01 22:09:15 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
Copyright (C) 1999-2005 Id Software, Inc.
|
|
|
|
|
|
|
|
This file is part of Quake III Arena source code.
|
|
|
|
|
|
|
|
Quake III Arena source code is free software; you can redistribute it
|
|
|
|
and/or modify it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the License,
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
Quake III Arena source code 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 General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Quake III Arena source code; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
//
|
|
|
|
#ifndef __Q_PLATFORM_H
|
|
|
|
#define __Q_PLATFORM_H
|
|
|
|
|
2005-11-04 22:32:00 +00:00
|
|
|
// this is for determining if we have an asm version of a C function
|
|
|
|
#ifdef Q3_VM
|
|
|
|
|
|
|
|
#define id386 0
|
|
|
|
#define idppc 0
|
|
|
|
#define idppc_altivec 0
|
|
|
|
|
2005-11-01 22:09:15 +00:00
|
|
|
#else
|
2005-11-04 22:32:00 +00:00
|
|
|
|
2005-11-05 18:41:37 +00:00
|
|
|
#if (defined _M_IX86 || defined __i386__) && !defined(C_ONLY)
|
2005-11-04 22:32:00 +00:00
|
|
|
#define id386 1
|
|
|
|
#else
|
|
|
|
#define id386 0
|
2005-11-01 22:09:15 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-04 22:32:00 +00:00
|
|
|
#if (defined(powerc) || defined(powerpc) || defined(ppc) || \
|
2005-11-26 15:01:28 +00:00
|
|
|
defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY)
|
2005-11-04 22:32:00 +00:00
|
|
|
#define idppc 1
|
2005-11-01 22:09:15 +00:00
|
|
|
#if defined(__VEC__)
|
|
|
|
#define idppc_altivec 1
|
2005-11-26 15:01:28 +00:00
|
|
|
#ifdef MACOS_X // Apple's GCC does this differently than the FSF.
|
|
|
|
#define VECCONST_UINT8(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
|
|
|
|
(vector unsigned char) (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p)
|
2005-11-01 22:09:15 +00:00
|
|
|
#else
|
2005-11-26 15:01:28 +00:00
|
|
|
#define VECCONST_UINT8(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p) \
|
|
|
|
(vector unsigned char) {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}
|
2005-11-01 22:09:15 +00:00
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#define idppc_altivec 0
|
|
|
|
#endif
|
2005-11-26 07:46:21 +00:00
|
|
|
#else
|
2005-11-26 15:01:28 +00:00
|
|
|
#define idppc 0
|
|
|
|
#define idppc_altivec 0
|
2005-11-26 07:46:21 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-04 22:32:00 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef __ASM_I386__ // don't include the C bits if included from qasm.h
|
|
|
|
|
2005-11-01 22:09:15 +00:00
|
|
|
// for windows fastcall option
|
2005-11-04 22:32:00 +00:00
|
|
|
#define QDECL
|
2005-11-01 22:09:15 +00:00
|
|
|
|
2005-11-04 22:32:00 +00:00
|
|
|
//================================================================= WIN32 ===
|
2005-11-01 22:09:15 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
#undef QDECL
|
2005-11-04 22:32:00 +00:00
|
|
|
#define QDECL __cdecl
|
2005-11-01 22:09:15 +00:00
|
|
|
|
2005-11-06 00:29:59 +00:00
|
|
|
#if defined( _MSC_VER )
|
2005-11-05 00:29:40 +00:00
|
|
|
#define OS_STRING "win_msvc"
|
2005-11-01 22:09:15 +00:00
|
|
|
#elif defined __MINGW32__
|
2005-11-05 00:29:40 +00:00
|
|
|
#define OS_STRING "win_mingw"
|
2005-11-01 22:09:15 +00:00
|
|
|
#endif
|
2005-11-05 00:29:40 +00:00
|
|
|
|
2005-11-04 22:32:00 +00:00
|
|
|
#define ID_INLINE __inline
|
2005-11-06 00:29:59 +00:00
|
|
|
#define PATH_SEP '\\'
|
2005-11-01 22:09:15 +00:00
|
|
|
|
2005-11-06 00:29:59 +00:00
|
|
|
#if defined( _M_IX86 ) || defined( __i386__ )
|
|
|
|
#define ARCH_STRING "x86"
|
|
|
|
#elif defined _M_ALPHA
|
|
|
|
#define ARCH_STRING "AXP"
|
|
|
|
#endif
|
2005-11-01 22:09:15 +00:00
|
|
|
|
2005-11-06 00:29:59 +00:00
|
|
|
#define Q3_LITTLE_ENDIAN
|
2005-11-01 22:09:15 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-11-04 22:32:00 +00:00
|
|
|
//============================================================== MAC OS X ===
|
2005-11-01 22:09:15 +00:00
|
|
|
|
2005-11-29 03:31:31 +00:00
|
|
|
#if defined(MACOS_X) || defined(__APPLE_CC__)
|
|
|
|
|
|
|
|
// make sure this is defined, just for sanity's sake...
|
|
|
|
#ifndef MACOS_X
|
|
|
|
#define MACOS_X
|
|
|
|
#endif
|
2005-11-01 22:09:15 +00:00
|
|
|
|
2005-11-05 00:29:40 +00:00
|
|
|
#define OS_STRING "macosx"
|
2005-11-06 00:29:59 +00:00
|
|
|
#define ID_INLINE inline
|
|
|
|
#define PATH_SEP '/'
|
2005-11-05 00:29:40 +00:00
|
|
|
|
2005-11-01 22:09:15 +00:00
|
|
|
#ifdef __ppc__
|
2005-11-05 00:29:40 +00:00
|
|
|
#define ARCH_STRING "ppc"
|
2005-11-29 03:31:31 +00:00
|
|
|
#define Q3_BIG_ENDIAN
|
2005-11-01 22:09:15 +00:00
|
|
|
#elif defined __i386__
|
2005-11-05 00:29:40 +00:00
|
|
|
#define ARCH_STRING "i386"
|
2005-11-29 03:31:31 +00:00
|
|
|
#define Q3_LITTLE_ENDIAN
|
2005-11-01 22:09:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-11-04 22:32:00 +00:00
|
|
|
//=================================================================== MAC ===
|
2005-11-01 22:09:15 +00:00
|
|
|
|
|
|
|
#ifdef __MACOS__
|
|
|
|
|
|
|
|
#include <MacTypes.h>
|
|
|
|
|
2005-11-05 00:29:40 +00:00
|
|
|
#define OS_STRING "macos"
|
2005-11-06 00:29:59 +00:00
|
|
|
#define ID_INLINE inline
|
2005-11-04 22:32:00 +00:00
|
|
|
#define PATH_SEP ':'
|
2005-11-01 22:09:15 +00:00
|
|
|
|
2005-11-06 00:29:59 +00:00
|
|
|
#define ARCH_STRING "ppc"
|
|
|
|
|
2005-11-01 22:09:15 +00:00
|
|
|
void Sys_PumpEvents( void );
|
|
|
|
|
2005-11-06 00:29:59 +00:00
|
|
|
#define Q3_BIG_ENDIAN
|
2005-11-01 22:09:15 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-11-04 22:32:00 +00:00
|
|
|
//================================================================= LINUX ===
|
2005-11-01 22:09:15 +00:00
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
|
2005-11-05 00:29:40 +00:00
|
|
|
#define OS_STRING "linux"
|
2005-11-06 00:29:59 +00:00
|
|
|
#define ID_INLINE inline
|
|
|
|
#define PATH_SEP '/'
|
2005-11-05 00:29:40 +00:00
|
|
|
|
|
|
|
#if defined __i386__
|
|
|
|
#define ARCH_STRING "i386"
|
2005-11-01 22:09:15 +00:00
|
|
|
#elif defined __x86_64__
|
2005-11-05 00:29:40 +00:00
|
|
|
#define ARCH_STRING "x86_64"
|
2005-11-01 22:09:15 +00:00
|
|
|
#elif defined __powerpc64__
|
2005-11-05 00:29:40 +00:00
|
|
|
#define ARCH_STRING "ppc64"
|
2005-11-01 22:09:15 +00:00
|
|
|
#elif defined __powerpc__
|
2005-11-05 00:29:40 +00:00
|
|
|
#define ARCH_STRING "ppc"
|
2005-11-01 22:09:15 +00:00
|
|
|
#elif defined __s390__
|
2005-11-05 00:29:40 +00:00
|
|
|
#define ARCH_STRING "s390"
|
2005-11-01 22:09:15 +00:00
|
|
|
#elif defined __s390x__
|
2005-11-05 00:29:40 +00:00
|
|
|
#define ARCH_STRING "s390x"
|
2005-11-01 22:09:15 +00:00
|
|
|
#elif defined __ia64__
|
2005-11-05 00:29:40 +00:00
|
|
|
#define ARCH_STRING "ia64"
|
|
|
|
#elif defined __alpha__
|
|
|
|
#define ARCH_STRING "alpha"
|
|
|
|
#elif defined __sparc__
|
|
|
|
#define ARCH_STRING "sparc"
|
|
|
|
#elif defined __arm__
|
|
|
|
#define ARCH_STRING "arm"
|
|
|
|
#elif defined __cris__
|
|
|
|
#define ARCH_STRING "cris"
|
|
|
|
#elif defined __hppa__
|
|
|
|
#define ARCH_STRING "hppa"
|
|
|
|
#elif defined __mips__
|
|
|
|
#define ARCH_STRING "mips"
|
|
|
|
#elif defined __sh__
|
|
|
|
#define ARCH_STRING "sh"
|
2005-11-01 22:09:15 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-06 00:29:59 +00:00
|
|
|
#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
|
|
|
|
#define Q3_BIG_ENDIAN
|
2005-11-01 22:09:15 +00:00
|
|
|
#else
|
2005-11-06 00:29:59 +00:00
|
|
|
#define Q3_LITTLE_ENDIAN
|
2005-11-01 22:09:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-11-04 22:32:00 +00:00
|
|
|
//=============================================================== FreeBSD ===
|
|
|
|
|
2005-11-01 22:09:15 +00:00
|
|
|
#ifdef __FreeBSD__ // rb010123
|
|
|
|
|
2005-11-06 00:29:59 +00:00
|
|
|
#include <machine/endian.h>
|
2005-11-01 22:09:15 +00:00
|
|
|
|
2005-11-05 00:29:40 +00:00
|
|
|
#define OS_STRING "freebsd"
|
2005-11-06 00:29:59 +00:00
|
|
|
#define ID_INLINE inline
|
|
|
|
#define PATH_SEP '/'
|
2005-11-05 00:29:40 +00:00
|
|
|
|
2005-11-01 22:09:15 +00:00
|
|
|
#ifdef __i386__
|
2005-11-05 00:29:40 +00:00
|
|
|
#define ARCH_STRING "i386"
|
2005-11-01 22:09:15 +00:00
|
|
|
#elif defined __axp__
|
2005-11-05 00:29:40 +00:00
|
|
|
#define ARCH_STRING "alpha"
|
2005-11-01 22:09:15 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-06 00:29:59 +00:00
|
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
|
|
|
#define Q3_BIG_ENDIAN
|
2005-11-01 22:09:15 +00:00
|
|
|
#else
|
2005-11-06 00:29:59 +00:00
|
|
|
#define Q3_LITTLE_ENDIAN
|
2005-11-01 22:09:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-11-04 22:32:00 +00:00
|
|
|
//================================================================= SUNOS ===
|
2005-11-01 22:09:15 +00:00
|
|
|
|
|
|
|
#ifdef __sun
|
|
|
|
|
|
|
|
#include <sys/isa_defs.h>
|
|
|
|
#include <sys/byteorder.h>
|
|
|
|
|
2005-11-05 00:29:40 +00:00
|
|
|
#define OS_STRING "solaris"
|
2005-11-06 00:29:59 +00:00
|
|
|
#define ID_INLINE inline
|
|
|
|
#define PATH_SEP '/'
|
2005-11-05 00:29:40 +00:00
|
|
|
|
2005-11-01 22:09:15 +00:00
|
|
|
#ifdef __i386__
|
2005-11-05 00:29:40 +00:00
|
|
|
#define ARCH_STRING "i386"
|
2005-11-01 22:09:15 +00:00
|
|
|
#elif defined __sparc
|
2005-11-05 00:29:40 +00:00
|
|
|
#define ARCH_STRING "sparc"
|
2005-11-01 22:09:15 +00:00
|
|
|
#endif
|
|
|
|
|
2005-11-06 00:29:59 +00:00
|
|
|
#if defined( _BIG_ENDIAN )
|
|
|
|
#define Q3_BIG_ENDIAN
|
|
|
|
#elif defined( _LITTLE_ENDIAN )
|
|
|
|
#define Q3_LITTLE_ENDIAN
|
2005-11-01 22:09:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-11-04 22:32:00 +00:00
|
|
|
//================================================================== Q3VM ===
|
|
|
|
|
|
|
|
#ifdef Q3_VM
|
|
|
|
|
2005-11-05 00:29:40 +00:00
|
|
|
#define OS_STRING "q3vm"
|
2005-11-06 00:29:59 +00:00
|
|
|
#define ID_INLINE
|
2005-11-04 22:32:00 +00:00
|
|
|
#define PATH_SEP '/'
|
|
|
|
|
2005-11-06 00:29:59 +00:00
|
|
|
#define ARCH_STRING "bytecode"
|
2005-11-04 22:32:00 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//===========================================================================
|
2005-11-01 22:09:15 +00:00
|
|
|
|
|
|
|
//catch missing defines in above blocks
|
2005-11-06 00:29:59 +00:00
|
|
|
#if !defined( OS_STRING )
|
|
|
|
#error "Operating system not supported"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined( ARCH_STRING )
|
|
|
|
#error "Architecture not supported"
|
2005-11-01 22:09:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef ID_INLINE
|
|
|
|
#error "ID_INLINE not defined"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef PATH_SEP
|
|
|
|
#error "PATH_SEP not defined"
|
|
|
|
#endif
|
|
|
|
|
2005-11-06 00:29:59 +00:00
|
|
|
|
|
|
|
//endianness
|
|
|
|
short ShortSwap (short l);
|
|
|
|
int LongSwap (int l);
|
|
|
|
float FloatSwap (const float *f);
|
|
|
|
|
|
|
|
#if defined( Q3_BIG_ENDIAN ) && defined( Q3_LITTLE_ENDIAN )
|
|
|
|
#error "Endianness defined as both big and little"
|
|
|
|
#elif defined( Q3_BIG_ENDIAN )
|
|
|
|
|
|
|
|
#define LittleShort(x) ShortSwap(x)
|
|
|
|
#define LittleLong(x) LongSwap(x)
|
|
|
|
#define LittleFloat(x) FloatSwap(&x)
|
|
|
|
#define BigShort
|
|
|
|
#define BigLong
|
|
|
|
#define BigFloat
|
|
|
|
|
|
|
|
#elif defined( Q3_LITTLE_ENDIAN )
|
|
|
|
|
|
|
|
#define LittleShort
|
|
|
|
#define LittleLong
|
|
|
|
#define LittleFloat
|
|
|
|
#define BigShort(x) ShortSwap(x)
|
|
|
|
#define BigLong(x) LongSwap(x)
|
|
|
|
#define BigFloat(x) FloatSwap(&x)
|
|
|
|
|
|
|
|
#elif defined( Q3_VM )
|
|
|
|
|
|
|
|
#define LittleShort
|
|
|
|
#define LittleLong
|
|
|
|
#define LittleFloat
|
|
|
|
#define BigShort
|
|
|
|
#define BigLong
|
|
|
|
#define BigFloat
|
|
|
|
|
|
|
|
#else
|
2005-11-01 22:09:15 +00:00
|
|
|
#error "Endianness not defined"
|
|
|
|
#endif
|
|
|
|
|
2005-11-06 00:29:59 +00:00
|
|
|
|
|
|
|
//platform string
|
2005-11-05 00:29:40 +00:00
|
|
|
#ifdef NDEBUG
|
|
|
|
#define PLATFORM_STRING OS_STRING "-" ARCH_STRING
|
|
|
|
#else
|
|
|
|
#define PLATFORM_STRING OS_STRING "-" ARCH_STRING "-debug"
|
|
|
|
#endif
|
|
|
|
|
2005-11-01 22:09:15 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|