r287 - in trunk/code: cgame qcommon renderer unix

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sat Nov 5 19:29:59 EST 2005


Author: tma
Date: 2005-11-05 19:29:59 -0500 (Sat, 05 Nov 2005)
New Revision: 287

Modified:
   trunk/code/cgame/cg_particles.c
   trunk/code/qcommon/q_platform.h
   trunk/code/qcommon/vm_interpreted.c
   trunk/code/renderer/tr_model.c
   trunk/code/unix/linux_glimp.c
   trunk/code/unix/sdl_glimp.c
Log:
* 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


Modified: trunk/code/cgame/cg_particles.c
===================================================================
--- trunk/code/cgame/cg_particles.c	2005-11-05 21:40:35 UTC (rev 286)
+++ trunk/code/cgame/cg_particles.c	2005-11-06 00:29:59 UTC (rev 287)
@@ -1252,7 +1252,7 @@
 
 	// 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]) {

Modified: trunk/code/qcommon/q_platform.h
===================================================================
--- trunk/code/qcommon/q_platform.h	2005-11-05 21:40:35 UTC (rev 286)
+++ trunk/code/qcommon/q_platform.h	2005-11-06 00:29:59 UTC (rev 287)
@@ -56,13 +56,8 @@
 #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 @@
 #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,58 +88,18 @@
 
 #if defined(MACOS_X)
 
-#define __cdecl
-#define __declspec(x)
-#define stricmp strcasecmp
+#define OS_STRING "macosx"
 #define ID_INLINE inline
+#define PATH_SEP '/'
 
-#define OS_STRING "macosx"
-
 #ifdef __ppc__
 #define ARCH_STRING "ppc"
 #elif defined __i386__
 #define ARCH_STRING "i386"
-#else
-#error "Unsupported architecture"
 #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
 
 //=================================================================== MAC ===
@@ -171,37 +107,27 @@
 #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 OS_STRING "linux"
 #define ID_INLINE inline
+#define PATH_SEP '/'
 
-#define OS_STRING "linux"
-
 #if defined __i386__
 #define ARCH_STRING "i386"
 #elif defined __x86_64__
@@ -230,26 +156,12 @@
 #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 @@
 
 #ifdef __FreeBSD__ // rb010123
 
-#define stricmp strcasecmp
+#include <machine/endian.h>
 
+#define OS_STRING "freebsd"
 #define ID_INLINE inline
+#define PATH_SEP '/'
 
-#define OS_STRING "freebsd"
-
 #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 @@
 #include <sys/isa_defs.h>
 #include <sys/byteorder.h>
 
-// bk001205 - from Makefile
-#define stricmp strcasecmp
-
+#define OS_STRING "solaris"
 #define ID_INLINE inline
+#define PATH_SEP '/'
 
-#define OS_STRING "solaris"
-
 #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,29 +219,25 @@
 
 #ifdef Q3_VM
 
+#define OS_STRING "q3vm"
 #define ID_INLINE
+#define PATH_SEP '/'
 
-#define OS_STRING "q3vm"
 #define ARCH_STRING "bytecode"
 
-#define PATH_SEP '/'
-
-#define LittleShort
-#define LittleLong
-#define LittleFloat
-#define BigShort
-#define BigLong
-#define BigFloat
-
 #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
 #error "ID_INLINE not defined"
 #endif
@@ -373,10 +246,47 @@
 #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

Modified: trunk/code/qcommon/vm_interpreted.c
===================================================================
--- trunk/code/qcommon/vm_interpreted.c	2005-11-05 21:40:35 UTC (rev 286)
+++ trunk/code/qcommon/vm_interpreted.c	2005-11-06 00:29:59 UTC (rev 287)
@@ -113,17 +113,27 @@
 #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;
 	memcpy(&word, addr, 4);

Modified: trunk/code/renderer/tr_model.c
===================================================================
--- trunk/code/renderer/tr_model.c	2005-11-05 21:40:35 UTC (rev 286)
+++ trunk/code/renderer/tr_model.c	2005-11-06 00:29:59 UTC (rev 287)
@@ -147,7 +147,7 @@
 	}
 
 #ifdef RAVENMD4
-	if(!stricmp(fext, "mdr"))
+	if(!Q_stricmp(fext, "mdr"))
 	{
 		int filesize;
 		

Modified: trunk/code/unix/linux_glimp.c
===================================================================
--- trunk/code/unix/linux_glimp.c	2005-11-05 21:40:35 UTC (rev 286)
+++ trunk/code/unix/linux_glimp.c	2005-11-06 00:29:59 UTC (rev 287)
@@ -1582,7 +1582,7 @@
 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);
   }

Modified: trunk/code/unix/sdl_glimp.c
===================================================================
--- trunk/code/unix/sdl_glimp.c	2005-11-05 21:40:35 UTC (rev 286)
+++ trunk/code/unix/sdl_glimp.c	2005-11-06 00:29:59 UTC (rev 287)
@@ -995,7 +995,7 @@
 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();
   }




More information about the quake3-commits mailing list