aboutsummaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-11-06 00:29:59 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-11-06 00:29:59 +0000
commitc613485929e503ef9b71bdc226e9b504f3640e03 (patch)
treedd75a3f30a3597c25b0bbde33f9ce84ed8eae7ba /code
parentc322f59e69a690e99e69114d4207ce0e7f261a3a (diff)
downloadioquake3-aero-c613485929e503ef9b71bdc226e9b504f3640e03.tar.gz
ioquake3-aero-c613485929e503ef9b71bdc226e9b504f3640e03.zip
* 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 git-svn-id: svn://svn.icculus.org/quake3/trunk@287 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code')
-rw-r--r--code/cgame/cg_particles.c2
-rw-r--r--code/qcommon/q_platform.h246
-rw-r--r--code/qcommon/vm_interpreted.c30
-rw-r--r--code/renderer/tr_model.c2
-rw-r--r--code/unix/linux_glimp.c2
-rw-r--r--code/unix/sdl_glimp.c2
6 files changed, 102 insertions, 182 deletions
diff --git a/code/cgame/cg_particles.c b/code/cgame/cg_particles.c
index 59d8ddc..72c077f 100644
--- a/code/cgame/cg_particles.c
+++ b/code/cgame/cg_particles.c
@@ -1252,7 +1252,7 @@ void CG_ParticleExplosion (char *animStr, vec3_t origin, vec3_t vel, int duratio
// find the animation string
for (anim=0; shaderAnimNames[anim]; anim++) {
- if (!stricmp( animStr, shaderAnimNames[anim] ))
+ if (!Q_stricmp( animStr, shaderAnimNames[anim] ))
break;
}
if (!shaderAnimNames[anim]) {
diff --git a/code/qcommon/q_platform.h b/code/qcommon/q_platform.h
index 13c1c85..870a4cc 100644
--- a/code/qcommon/q_platform.h
+++ b/code/qcommon/q_platform.h
@@ -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
// for windows fastcall option
-
#define QDECL
-short ShortSwap (short l);
-int LongSwap (int l);
-float FloatSwap (const float *f);
-
//================================================================= WIN32 ===
#ifdef _WIN32
@@ -70,41 +65,22 @@ float FloatSwap (const float *f);
#undef QDECL
#define QDECL __cdecl
-#ifdef _MSC_VER
+#if defined( _MSC_VER )
#define OS_STRING "win_msvc"
-
-#ifdef _M_IX86
-#define ARCH_STRING "x86"
-#elif defined _M_ALPHA
-#define ARCH_STRING "AXP"
-#else
-#error "Unsupported architecture"
-#endif
-
#elif defined __MINGW32__
#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
+#define PATH_SEP '\\'
-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
+#if defined( _M_IX86 ) || defined( __i386__ )
+#define ARCH_STRING "x86"
+#elif defined _M_ALPHA
+#define ARCH_STRING "AXP"
+#endif
-#define PATH_SEP '\\'
+#define Q3_LITTLE_ENDIAN
#endif
@@ -112,57 +88,17 @@ static ID_INLINE float BigFloat(const float l) { return FloatSwap(&l); }
#if defined(MACOS_X)
-#define __cdecl
-#define __declspec(x)
-#define stricmp strcasecmp
-#define ID_INLINE inline
-
#define OS_STRING "macosx"
+#define ID_INLINE inline
+#define PATH_SEP '/'
#ifdef __ppc__
#define ARCH_STRING "ppc"
#elif defined __i386__
#define ARCH_STRING "i386"
-#else
-#error "Unsupported architecture"
#endif
-#define PATH_SEP '/'
-
-#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); }
+#define Q3_BIG_ENDIAN
#endif
@@ -171,36 +107,26 @@ static ID_INLINE float LittleFloat(const float l) { return FloatSwap(&l); }
#ifdef __MACOS__
#include <MacTypes.h>
-#define ID_INLINE inline
#define OS_STRING "macos"
-#define ARCH_STRING "ppc"
-
+#define ID_INLINE inline
#define PATH_SEP ':'
+#define ARCH_STRING "ppc"
+
void Sys_PumpEvents( void );
-#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); }
+#define Q3_BIG_ENDIAN
#endif
//================================================================= LINUX ===
-// the mac compiler can't handle >32k of locals, so we
-// just waste space and make big arrays static...
#ifdef __linux__
-// bk001205 - from Makefile
-#define stricmp strcasecmp
-
-#define ID_INLINE inline
-
#define OS_STRING "linux"
+#define ID_INLINE inline
+#define PATH_SEP '/'
#if defined __i386__
#define ARCH_STRING "i386"
@@ -230,26 +156,12 @@ static ID_INLINE float LittleFloat(const float l) { return FloatSwap(&l); }
#define ARCH_STRING "mips"
#elif defined __sh__
#define ARCH_STRING "sh"
-#else
-#error "Unsupported architecture"
#endif
-#define PATH_SEP '/'
-
-#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
+#if __FLOAT_WORD_ORDER == __BIG_ENDIAN
+#define Q3_BIG_ENDIAN
#else
-#define BigShort
-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); }
+#define Q3_LITTLE_ENDIAN
#endif
#endif
@@ -258,36 +170,22 @@ ID_INLINE static float LittleFloat(const float l) { return FloatSwap(&l); }
#ifdef __FreeBSD__ // rb010123
-#define stricmp strcasecmp
-
-#define ID_INLINE inline
+#include <machine/endian.h>
#define OS_STRING "freebsd"
+#define ID_INLINE inline
+#define PATH_SEP '/'
#ifdef __i386__
#define ARCH_STRING "i386"
#elif defined __axp__
#define ARCH_STRING "alpha"
-#else
-#error "Unsupported architecture"
#endif
-#define PATH_SEP '/'
-
-#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
+#if BYTE_ORDER == BIG_ENDIAN
+#define Q3_BIG_ENDIAN
#else
-#define BigShort
-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); }
+#define Q3_LITTLE_ENDIAN
#endif
#endif
@@ -299,41 +197,20 @@ static float LittleFloat(const float l) { return FloatSwap(&l); }
#include <sys/isa_defs.h>
#include <sys/byteorder.h>
-// bk001205 - from Makefile
-#define stricmp strcasecmp
-
-#define ID_INLINE inline
-
#define OS_STRING "solaris"
+#define ID_INLINE inline
+#define PATH_SEP '/'
#ifdef __i386__
#define ARCH_STRING "i386"
#elif defined __sparc
#define ARCH_STRING "sparc"
-#else
-#error "Unsupported architecture"
#endif
-#define PATH_SEP '/'
-
-#if defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
-#define BigShort
-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."
+#if defined( _BIG_ENDIAN )
+#define Q3_BIG_ENDIAN
+#elif defined( _LITTLE_ENDIAN )
+#define Q3_LITTLE_ENDIAN
#endif
#endif
@@ -342,27 +219,23 @@ ID_INLINE static float BigFloat(const float l) { return FloatSwap(&l); }
#ifdef Q3_VM
-#define ID_INLINE
-
#define OS_STRING "q3vm"
-#define ARCH_STRING "bytecode"
-
+#define ID_INLINE
#define PATH_SEP '/'
-#define LittleShort
-#define LittleLong
-#define LittleFloat
-#define BigShort
-#define BigLong
-#define BigFloat
+#define ARCH_STRING "bytecode"
#endif
//===========================================================================
//catch missing defines in above blocks
-#if !defined( OS_STRING ) || !defined( ARCH_STRING )
-#error "OS_STRING or ARCH_STRING not defined"
+#if !defined( OS_STRING )
+#error "Operating system not supported"
+#endif
+
+#if !defined( ARCH_STRING )
+#error "Architecture not supported"
#endif
#ifndef ID_INLINE
@@ -373,10 +246,47 @@ ID_INLINE static float BigFloat(const float l) { return FloatSwap(&l); }
#error "PATH_SEP not defined"
#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"
#endif
+
+//platform string
#ifdef NDEBUG
#define PLATFORM_STRING OS_STRING "-" ARCH_STRING
#else
diff --git a/code/qcommon/vm_interpreted.c b/code/qcommon/vm_interpreted.c
index 1d180aa..4a9ff5b 100644
--- a/code/qcommon/vm_interpreted.c
+++ b/code/qcommon/vm_interpreted.c
@@ -113,16 +113,26 @@ static char *opnames[256] = {
#endif
#if idppc
- #if defined(__GNUC__)
- static ID_INLINE unsigned int loadWord(void *addr) {
- unsigned int word;
-
- asm("lwbrx %0,0,%1" : "=r" (word) : "r" (addr));
- return word;
- }
- #else
- #define loadWord(addr) __lwbrx(addr,0)
- #endif
+
+//FIXME: these, um... look the same to me
+#if defined(__GNUC__)
+static ID_INLINE unsigned int loadWord(void *addr) {
+ unsigned int word;
+
+ asm("lwbrx %0,0,%1" : "=r" (word) : "r" (addr));
+ return word;
+}
+#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
static ID_INLINE int loadWord(void *addr) {
int word;
diff --git a/code/renderer/tr_model.c b/code/renderer/tr_model.c
index ae780c8..a6bfb5d 100644
--- a/code/renderer/tr_model.c
+++ b/code/renderer/tr_model.c
@@ -147,7 +147,7 @@ qhandle_t RE_RegisterModel( const char *name ) {
}
#ifdef RAVENMD4
- if(!stricmp(fext, "mdr"))
+ if(!Q_stricmp(fext, "mdr"))
{
int filesize;
diff --git a/code/unix/linux_glimp.c b/code/unix/linux_glimp.c
index cc9aa91..e501033 100644
--- a/code/unix/linux_glimp.c
+++ b/code/unix/linux_glimp.c
@@ -1582,7 +1582,7 @@ void GLimp_Init( void )
void GLimp_EndFrame (void)
{
// 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);
}
diff --git a/code/unix/sdl_glimp.c b/code/unix/sdl_glimp.c
index dfc6724..595fdeb 100644
--- a/code/unix/sdl_glimp.c
+++ b/code/unix/sdl_glimp.c
@@ -995,7 +995,7 @@ void GLimp_Init( void )
void GLimp_EndFrame (void)
{
// 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();
}