mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
* Tidy-up of q_platform.h
* Introduced Q3_BIG_ENDIAN and Q3_LITTLE_ENDIAN #defines * Changed some stricmp to Q_stricmp so that #define stricmp strcasecmp could be removed
This commit is contained in:
parent
64cfdedf09
commit
4eaebe4a31
6 changed files with 103 additions and 183 deletions
|
@ -1252,7 +1252,7 @@ void CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duratio
|
||||||
|
|
||||||
// find the animation string
|
// find the animation string
|
||||||
for (anim=0; shaderAnimNames[anim]; anim++) {
|
for (anim=0; shaderAnimNames[anim]; anim++) {
|
||||||
if (!stricmp( animStr, shaderAnimNames[anim] ))
|
if (!Q_stricmp( animStr, shaderAnimNames[anim] ))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!shaderAnimNames[anim]) {
|
if (!shaderAnimNames[anim]) {
|
||||||
|
|
|
@ -56,13 +56,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#ifndef __ASM_I386__ // don't include the C bits if included from qasm.h
|
#ifndef __ASM_I386__ // don't include the C bits if included from qasm.h
|
||||||
|
|
||||||
// for windows fastcall option
|
// for windows fastcall option
|
||||||
|
|
||||||
#define QDECL
|
#define QDECL
|
||||||
|
|
||||||
short ShortSwap (short l);
|
|
||||||
int LongSwap (int l);
|
|
||||||
float FloatSwap (const float *f);
|
|
||||||
|
|
||||||
//================================================================= WIN32 ===
|
//================================================================= WIN32 ===
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -70,41 +65,22 @@ float FloatSwap (const float *f);
|
||||||
#undef QDECL
|
#undef QDECL
|
||||||
#define QDECL __cdecl
|
#define QDECL __cdecl
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#if defined( _MSC_VER )
|
||||||
#define OS_STRING "win_msvc"
|
#define OS_STRING "win_msvc"
|
||||||
|
#elif defined __MINGW32__
|
||||||
|
#define OS_STRING "win_mingw"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _M_IX86
|
#define ID_INLINE __inline
|
||||||
|
#define PATH_SEP '\\'
|
||||||
|
|
||||||
|
#if defined( _M_IX86 ) || defined( __i386__ )
|
||||||
#define ARCH_STRING "x86"
|
#define ARCH_STRING "x86"
|
||||||
#elif defined _M_ALPHA
|
#elif defined _M_ALPHA
|
||||||
#define ARCH_STRING "AXP"
|
#define ARCH_STRING "AXP"
|
||||||
#else
|
|
||||||
#error "Unsupported architecture"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined __MINGW32__
|
#define Q3_LITTLE_ENDIAN
|
||||||
#define OS_STRING "win_mingw"
|
|
||||||
|
|
||||||
#ifdef __i386__
|
|
||||||
#define ARCH_STRING "x86"
|
|
||||||
#else
|
|
||||||
#error "Unsupported architecture"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error "Unsupported compiler"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#define ID_INLINE __inline
|
|
||||||
|
|
||||||
static ID_INLINE short BigShort( short l) { return ShortSwap(l); }
|
|
||||||
#define LittleShort
|
|
||||||
static ID_INLINE int BigLong(int l) { return LongSwap(l); }
|
|
||||||
#define LittleLong
|
|
||||||
static ID_INLINE float BigFloat(const float l) { return FloatSwap(&l); }
|
|
||||||
#define LittleFloat
|
|
||||||
|
|
||||||
#define PATH_SEP '\\'
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -112,57 +88,17 @@ static ID_INLINE float BigFloat(const float l) { return FloatSwap(&l); }
|
||||||
|
|
||||||
#if defined(MACOS_X)
|
#if defined(MACOS_X)
|
||||||
|
|
||||||
#define __cdecl
|
|
||||||
#define __declspec(x)
|
|
||||||
#define stricmp strcasecmp
|
|
||||||
#define ID_INLINE inline
|
|
||||||
|
|
||||||
#define OS_STRING "macosx"
|
#define OS_STRING "macosx"
|
||||||
|
#define ID_INLINE inline
|
||||||
|
#define PATH_SEP '/'
|
||||||
|
|
||||||
#ifdef __ppc__
|
#ifdef __ppc__
|
||||||
#define ARCH_STRING "ppc"
|
#define ARCH_STRING "ppc"
|
||||||
#elif defined __i386__
|
#elif defined __i386__
|
||||||
#define ARCH_STRING "i386"
|
#define ARCH_STRING "i386"
|
||||||
#else
|
|
||||||
#error "Unsupported architecture"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PATH_SEP '/'
|
#define Q3_BIG_ENDIAN
|
||||||
|
|
||||||
#define __rlwimi(out, in, shift, maskBegin, maskEnd) \
|
|
||||||
asm("rlwimi %0,%1,%2,%3,%4" : "=r" (out) : "r" (in), \
|
|
||||||
"i" (shift), "i" (maskBegin), "i" (maskEnd))
|
|
||||||
#define __dcbt(addr, offset) asm("dcbt %0,%1" : : "b" (addr), "r" (offset))
|
|
||||||
|
|
||||||
static ID_INLINE unsigned int __lwbrx(register void *addr,
|
|
||||||
register int offset) {
|
|
||||||
register unsigned int word;
|
|
||||||
|
|
||||||
asm("lwbrx %0,%2,%1" : "=r" (word) : "r" (addr), "b" (offset));
|
|
||||||
return word;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ID_INLINE unsigned short __lhbrx(register void *addr,
|
|
||||||
register int offset) {
|
|
||||||
register unsigned short halfword;
|
|
||||||
|
|
||||||
asm("lhbrx %0,%2,%1" : "=r" (halfword) : "r" (addr), "b" (offset));
|
|
||||||
return halfword;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ID_INLINE float __fctiw(register float f) {
|
|
||||||
register float fi;
|
|
||||||
|
|
||||||
asm("fctiw %0,%1" : "=f" (fi) : "f" (f));
|
|
||||||
return fi;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define BigShort
|
|
||||||
static ID_INLINE short LittleShort(short l) { return ShortSwap(l); }
|
|
||||||
#define BigLong
|
|
||||||
static ID_INLINE int LittleLong(int l) { return LongSwap(l); }
|
|
||||||
#define BigFloat
|
|
||||||
static ID_INLINE float LittleFloat(const float l) { return FloatSwap(&l); }
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -171,36 +107,26 @@ static ID_INLINE float LittleFloat(const float l) { return FloatSwap(&l); }
|
||||||
#ifdef __MACOS__
|
#ifdef __MACOS__
|
||||||
|
|
||||||
#include <MacTypes.h>
|
#include <MacTypes.h>
|
||||||
#define ID_INLINE inline
|
|
||||||
|
|
||||||
#define OS_STRING "macos"
|
#define OS_STRING "macos"
|
||||||
#define ARCH_STRING "ppc"
|
#define ID_INLINE inline
|
||||||
|
|
||||||
#define PATH_SEP ':'
|
#define PATH_SEP ':'
|
||||||
|
|
||||||
|
#define ARCH_STRING "ppc"
|
||||||
|
|
||||||
void Sys_PumpEvents( void );
|
void Sys_PumpEvents( void );
|
||||||
|
|
||||||
#define BigShort
|
#define Q3_BIG_ENDIAN
|
||||||
static ID_INLINE short LittleShort(short l) { return ShortSwap(l); }
|
|
||||||
#define BigLong
|
|
||||||
static ID_INLINE int LittleLong(int l) { return LongSwap(l); }
|
|
||||||
#define BigFloat
|
|
||||||
static ID_INLINE float LittleFloat(const float l) { return FloatSwap(&l); }
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//================================================================= LINUX ===
|
//================================================================= LINUX ===
|
||||||
|
|
||||||
// the mac compiler can't handle >32k of locals, so we
|
|
||||||
// just waste space and make big arrays static...
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
|
||||||
// bk001205 - from Makefile
|
|
||||||
#define stricmp strcasecmp
|
|
||||||
|
|
||||||
#define ID_INLINE inline
|
|
||||||
|
|
||||||
#define OS_STRING "linux"
|
#define OS_STRING "linux"
|
||||||
|
#define ID_INLINE inline
|
||||||
|
#define PATH_SEP '/'
|
||||||
|
|
||||||
#if defined __i386__
|
#if defined __i386__
|
||||||
#define ARCH_STRING "i386"
|
#define ARCH_STRING "i386"
|
||||||
|
@ -230,26 +156,12 @@ static ID_INLINE float LittleFloat(const float l) { return FloatSwap(&l); }
|
||||||
#define ARCH_STRING "mips"
|
#define ARCH_STRING "mips"
|
||||||
#elif defined __sh__
|
#elif defined __sh__
|
||||||
#define ARCH_STRING "sh"
|
#define ARCH_STRING "sh"
|
||||||
#else
|
|
||||||
#error "Unsupported architecture"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PATH_SEP '/'
|
#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
|
||||||
|
#define Q3_BIG_ENDIAN
|
||||||
#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
|
|
||||||
ID_INLINE static short BigShort( short l) { return ShortSwap(l); }
|
|
||||||
#define LittleShort
|
|
||||||
ID_INLINE static int BigLong(int l) { return LongSwap(l); }
|
|
||||||
#define LittleLong
|
|
||||||
ID_INLINE static float BigFloat(const float l) { return FloatSwap(&l); }
|
|
||||||
#define LittleFloat
|
|
||||||
#else
|
#else
|
||||||
#define BigShort
|
#define Q3_LITTLE_ENDIAN
|
||||||
ID_INLINE static short LittleShort(short l) { return ShortSwap(l); }
|
|
||||||
#define BigLong
|
|
||||||
ID_INLINE static int LittleLong(int l) { return LongSwap(l); }
|
|
||||||
#define BigFloat
|
|
||||||
ID_INLINE static float LittleFloat(const float l) { return FloatSwap(&l); }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -258,36 +170,22 @@ ID_INLINE static float LittleFloat(const float l) { return FloatSwap(&l); }
|
||||||
|
|
||||||
#ifdef __FreeBSD__ // rb010123
|
#ifdef __FreeBSD__ // rb010123
|
||||||
|
|
||||||
#define stricmp strcasecmp
|
#include <machine/endian.h>
|
||||||
|
|
||||||
#define ID_INLINE inline
|
|
||||||
|
|
||||||
#define OS_STRING "freebsd"
|
#define OS_STRING "freebsd"
|
||||||
|
#define ID_INLINE inline
|
||||||
|
#define PATH_SEP '/'
|
||||||
|
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
#define ARCH_STRING "i386"
|
#define ARCH_STRING "i386"
|
||||||
#elif defined __axp__
|
#elif defined __axp__
|
||||||
#define ARCH_STRING "alpha"
|
#define ARCH_STRING "alpha"
|
||||||
#else
|
|
||||||
#error "Unsupported architecture"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PATH_SEP '/'
|
#if BYTE_ORDER == BIG_ENDIAN
|
||||||
|
#define Q3_BIG_ENDIAN
|
||||||
#if !idppc
|
|
||||||
static short BigShort( short l) { return ShortSwap(l); }
|
|
||||||
#define LittleShort
|
|
||||||
static int BigLong(int l) { return LongSwap(l); }
|
|
||||||
#define LittleLong
|
|
||||||
static float BigFloat(const float l) { return FloatSwap(&l); }
|
|
||||||
#define LittleFloat
|
|
||||||
#else
|
#else
|
||||||
#define BigShort
|
#define Q3_LITTLE_ENDIAN
|
||||||
static short LittleShort(short l) { return ShortSwap(l); }
|
|
||||||
#define BigLong
|
|
||||||
static int LittleLong(int l) { return LongSwap(l); }
|
|
||||||
#define BigFloat
|
|
||||||
static float LittleFloat(const float l) { return FloatSwap(&l); }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -299,41 +197,20 @@ static float LittleFloat(const float l) { return FloatSwap(&l); }
|
||||||
#include <sys/isa_defs.h>
|
#include <sys/isa_defs.h>
|
||||||
#include <sys/byteorder.h>
|
#include <sys/byteorder.h>
|
||||||
|
|
||||||
// bk001205 - from Makefile
|
|
||||||
#define stricmp strcasecmp
|
|
||||||
|
|
||||||
#define ID_INLINE inline
|
|
||||||
|
|
||||||
#define OS_STRING "solaris"
|
#define OS_STRING "solaris"
|
||||||
|
#define ID_INLINE inline
|
||||||
|
#define PATH_SEP '/'
|
||||||
|
|
||||||
#ifdef __i386__
|
#ifdef __i386__
|
||||||
#define ARCH_STRING "i386"
|
#define ARCH_STRING "i386"
|
||||||
#elif defined __sparc
|
#elif defined __sparc
|
||||||
#define ARCH_STRING "sparc"
|
#define ARCH_STRING "sparc"
|
||||||
#else
|
|
||||||
#error "Unsupported architecture"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PATH_SEP '/'
|
#if defined( _BIG_ENDIAN )
|
||||||
|
#define Q3_BIG_ENDIAN
|
||||||
#if defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
|
#elif defined( _LITTLE_ENDIAN )
|
||||||
#define BigShort
|
#define Q3_LITTLE_ENDIAN
|
||||||
ID_INLINE static short LittleShort(short l) { return ShortSwap(l); }
|
|
||||||
#define BigLong
|
|
||||||
ID_INLINE static int LittleLong(int l) { return LongSwap(l); }
|
|
||||||
#define BigFloat
|
|
||||||
ID_INLINE static float LittleFloat(const float l) { return FloatSwap(&l); }
|
|
||||||
|
|
||||||
#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
|
|
||||||
ID_INLINE static short BigShort( short l) { return ShortSwap(l); }
|
|
||||||
#define LittleShort
|
|
||||||
ID_INLINE static int BigLong(int l) { return LongSwap(l); }
|
|
||||||
#define LittleLong
|
|
||||||
ID_INLINE static float BigFloat(const float l) { return FloatSwap(&l); }
|
|
||||||
#define LittleFloat
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error "Either _BIG_ENDIAN or _LITTLE_ENDIAN must be #defined, but not both."
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -342,27 +219,23 @@ ID_INLINE static float BigFloat(const float l) { return FloatSwap(&l); }
|
||||||
|
|
||||||
#ifdef Q3_VM
|
#ifdef Q3_VM
|
||||||
|
|
||||||
#define ID_INLINE
|
|
||||||
|
|
||||||
#define OS_STRING "q3vm"
|
#define OS_STRING "q3vm"
|
||||||
#define ARCH_STRING "bytecode"
|
#define ID_INLINE
|
||||||
|
|
||||||
#define PATH_SEP '/'
|
#define PATH_SEP '/'
|
||||||
|
|
||||||
#define LittleShort
|
#define ARCH_STRING "bytecode"
|
||||||
#define LittleLong
|
|
||||||
#define LittleFloat
|
|
||||||
#define BigShort
|
|
||||||
#define BigLong
|
|
||||||
#define BigFloat
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
//catch missing defines in above blocks
|
//catch missing defines in above blocks
|
||||||
#if !defined( OS_STRING ) || !defined( ARCH_STRING )
|
#if !defined( OS_STRING )
|
||||||
#error "OS_STRING or ARCH_STRING not defined"
|
#error "Operating system not supported"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !defined( ARCH_STRING )
|
||||||
|
#error "Architecture not supported"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ID_INLINE
|
#ifndef ID_INLINE
|
||||||
|
@ -373,10 +246,47 @@ ID_INLINE static float BigFloat(const float l) { return FloatSwap(&l); }
|
||||||
#error "PATH_SEP not defined"
|
#error "PATH_SEP not defined"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(BigLong) && !defined(LittleLong)
|
|
||||||
|
//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
|
||||||
#error "Endianness not defined"
|
#error "Endianness not defined"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//platform string
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define PLATFORM_STRING OS_STRING "-" ARCH_STRING
|
#define PLATFORM_STRING OS_STRING "-" ARCH_STRING
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -113,16 +113,26 @@ static char *opnames[256] = {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if idppc
|
#if idppc
|
||||||
#if defined(__GNUC__)
|
|
||||||
static ID_INLINE unsigned int loadWord(void *addr) {
|
//FIXME: these, um... look the same to me
|
||||||
unsigned int word;
|
#if defined(__GNUC__)
|
||||||
|
static ID_INLINE unsigned int loadWord(void *addr) {
|
||||||
asm("lwbrx %0,0,%1" : "=r" (word) : "r" (addr));
|
unsigned int word;
|
||||||
return word;
|
|
||||||
}
|
asm("lwbrx %0,0,%1" : "=r" (word) : "r" (addr));
|
||||||
#else
|
return word;
|
||||||
#define loadWord(addr) __lwbrx(addr,0)
|
}
|
||||||
#endif
|
#else
|
||||||
|
static ID_INLINE unsigned int __lwbrx(register void *addr,
|
||||||
|
register int offset) {
|
||||||
|
register unsigned int word;
|
||||||
|
|
||||||
|
asm("lwbrx %0,%2,%1" : "=r" (word) : "r" (addr), "b" (offset));
|
||||||
|
return word;
|
||||||
|
}
|
||||||
|
#define loadWord(addr) __lwbrx(addr,0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
static ID_INLINE int loadWord(void *addr) {
|
static ID_INLINE int loadWord(void *addr) {
|
||||||
int word;
|
int word;
|
||||||
|
|
|
@ -147,7 +147,7 @@ qhandle_t RE_RegisterModel( const char *name ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RAVENMD4
|
#ifdef RAVENMD4
|
||||||
if(!stricmp(fext, "mdr"))
|
if(!Q_stricmp(fext, "mdr"))
|
||||||
{
|
{
|
||||||
int filesize;
|
int filesize;
|
||||||
|
|
||||||
|
|
|
@ -1582,7 +1582,7 @@ void GLimp_Init( void )
|
||||||
void GLimp_EndFrame (void)
|
void GLimp_EndFrame (void)
|
||||||
{
|
{
|
||||||
// don't flip if drawing to front buffer
|
// don't flip if drawing to front buffer
|
||||||
if ( stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 )
|
if ( Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 )
|
||||||
{
|
{
|
||||||
qglXSwapBuffers(dpy, win);
|
qglXSwapBuffers(dpy, win);
|
||||||
}
|
}
|
||||||
|
|
|
@ -995,7 +995,7 @@ void GLimp_Init( void )
|
||||||
void GLimp_EndFrame (void)
|
void GLimp_EndFrame (void)
|
||||||
{
|
{
|
||||||
// don't flip if drawing to front buffer
|
// don't flip if drawing to front buffer
|
||||||
if ( stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 )
|
if ( Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 )
|
||||||
{
|
{
|
||||||
SDL_GL_SwapBuffers();
|
SDL_GL_SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue