aboutsummaryrefslogtreecommitdiffstats
path: root/code/qcommon
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-11-04 22:32:00 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-11-04 22:32:00 +0000
commit11e5099eb7abb2e016527795ffd32c5094e5324f (patch)
tree3de0470c8544b681df252ad1c5e3724320b54d9c /code/qcommon
parent657f95c6a5d8a24df0c1a206eb32f54985c7b4fe (diff)
downloadioquake3-aero-11e5099eb7abb2e016527795ffd32c5094e5324f.tar.gz
ioquake3-aero-11e5099eb7abb2e016527795ffd32c5094e5324f.zip
* Replaced a bunch of inline and __inline with ID_INLINE
* Replaced a bunch of __i386__ with id386 * General tidy up of asm preprocessor decisions * Removed C_ONLY from the dedicated server build git-svn-id: svn://svn.icculus.org/quake3/trunk@269 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/qcommon')
-rw-r--r--code/qcommon/common.c4
-rw-r--r--code/qcommon/md4.c5
-rw-r--r--code/qcommon/q_math.c74
-rw-r--r--code/qcommon/q_platform.h209
-rw-r--r--code/qcommon/q_shared.h12
-rw-r--r--code/qcommon/qcommon.h2
-rw-r--r--code/qcommon/vm.c4
-rw-r--r--code/qcommon/vm_interpreted.c4
8 files changed, 142 insertions, 172 deletions
diff --git a/code/qcommon/common.c b/code/qcommon/common.c
index b8424a1..2386098 100644
--- a/code/qcommon/common.c
+++ b/code/qcommon/common.c
@@ -2812,9 +2812,8 @@ void Com_Shutdown (void) {
}
-#if !( defined __VECTORC )
#if !( defined __GNUC__ ) // GNU versions in linux_common.c
-#if ((!id386) && (!defined __i386__)) // rcg010212 - for PPC
+#if !id386
void Com_Memcpy (void* dest, const void* src, const size_t count)
{
@@ -3126,7 +3125,6 @@ skipClamp:
}
#endif
#endif
-#endif // bk001208 - memset/memcpy assembly, Q_acos needed (RC4)
//------------------------------------------------------------------------
diff --git a/code/qcommon/md4.c b/code/qcommon/md4.c
index 5f96838..323798b 100644
--- a/code/qcommon/md4.c
+++ b/code/qcommon/md4.c
@@ -38,13 +38,8 @@ void MD4Init (MD4_CTX *);
void MD4Update (MD4_CTX *, const unsigned char *, unsigned int);
void MD4Final (unsigned char [16], MD4_CTX *);
-#ifndef __VECTORC
void Com_Memset (void* dest, const int val, const size_t count);
void Com_Memcpy (void* dest, const void* src, const size_t count);
-#else
-#define Com_Memset memset
-#define Com_Memcpy memcpy
-#endif
/* MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm */
/* Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved.
diff --git a/code/qcommon/q_math.c b/code/qcommon/q_math.c
index da3044e..de90b8b 100644
--- a/code/qcommon/q_math.c
+++ b/code/qcommon/q_math.c
@@ -21,8 +21,15 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//
// q_math.c -- stateless support routines that are included in each code module
-#include "q_shared.h"
+// Some of the vector functions are static inline in q_shared.h. q3asm
+// doesn't understand static functions though, so we only want them in
+// one file. That's what this is about.
+#ifdef Q3_VM
+#define __Q3_VM_MATH
+#endif
+
+#include "q_shared.h"
vec3_t vec3_origin = {0,0,0};
vec3_t axisDefault[3] = { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
@@ -153,63 +160,6 @@ float Q_crandom( int *seed ) {
return 2.0 * ( Q_random( seed ) - 0.5 );
}
-#ifdef Q3_VM
-
-int VectorCompare( const vec3_t v1, const vec3_t v2 ) {
- if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) {
- return 0;
- }
- return 1;
-}
-
-vec_t VectorLength( const vec3_t v ) {
- return (vec_t)sqrt (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
-}
-
-vec_t VectorLengthSquared( const vec3_t v ) {
- return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
-}
-
-vec_t Distance( const vec3_t p1, const vec3_t p2 ) {
- vec3_t v;
-
- VectorSubtract (p2, p1, v);
- return VectorLength( v );
-}
-
-vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) {
- vec3_t v;
-
- VectorSubtract (p2, p1, v);
- return v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
-}
-
-// fast vector normalize routine that does not check to make sure
-// that length != 0, nor does it return length, uses rsqrt approximation
-void VectorNormalizeFast( vec3_t v )
-{
- float ilength;
-
- ilength = Q_rsqrt( DotProduct( v, v ) );
-
- v[0] *= ilength;
- v[1] *= ilength;
- v[2] *= ilength;
-}
-
-void VectorInverse( vec3_t v ){
- v[0] = -v[0];
- v[1] = -v[1];
- v[2] = -v[2];
-}
-
-void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) {
- cross[0] = v1[1]*v2[2] - v1[2]*v2[1];
- cross[1] = v1[2]*v2[0] - v1[0]*v2[2];
- cross[2] = v1[0]*v2[1] - v1[1]*v2[0];
-}
-#endif
-
//=======================================================
signed char ClampChar( int i ) {
@@ -736,10 +686,7 @@ int BoxOnPlaneSide2 (vec3_t emins, vec3_t emaxs, struct cplane_s *p)
==================
*/
-// if not GNU x86 and configured to use asm
-#if !( (defined __GNUC__) && (defined __i386__) && (!defined C_ONLY))
-
-#if defined Q3_VM || defined C_ONLY || !id386 || defined __VECTORC
+#if !id386
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p)
{
@@ -804,6 +751,8 @@ int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p)
return sides;
}
+#elif __GNUC__
+// use matha.s
#else
#pragma warning( disable: 4035 )
@@ -1039,7 +988,6 @@ Lerror:
#pragma warning( default: 4035 )
#endif
-#endif
/*
=================
diff --git a/code/qcommon/q_platform.h b/code/qcommon/q_platform.h
index 802cbcb..cf8a031 100644
--- a/code/qcommon/q_platform.h
+++ b/code/qcommon/q_platform.h
@@ -23,68 +23,82 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef __Q_PLATFORM_H
#define __Q_PLATFORM_H
-// this is the define for determining if we have an asm version of a C function
-#if (defined _M_IX86 || defined __i386__) && !defined __sun && !defined Q3_VM
-#define id386 1
+// 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
+
#else
-#define id386 0
+
+#if (defined _M_IX86 || defined __i386__) && \
+ !defined __sun && !defined(C_ONLY)
+#define id386 1
+#else
+#define id386 0
#endif
-#if (defined(powerc) || defined(powerpc) || defined(ppc) || defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY)
-#define idppc 1
+#if (defined(powerc) || defined(powerpc) || defined(ppc) || \
+ defined(__ppc) || defined(__ppc__)) && !defined(C_ONLY)
+#define idppc 1
#if defined(__VEC__)
#define idppc_altivec 1
#else
#define idppc_altivec 0
#endif
#else
-#define idppc 0
+#define idppc 0
#define idppc_altivec 0
#endif
+#endif
+
+#ifndef __ASM_I386__ // don't include the C bits if included from qasm.h
+
// for windows fastcall option
-#define QDECL
+#define QDECL
short ShortSwap (short l);
int LongSwap (int l);
float FloatSwap (const float *f);
-//======================= WIN32 DEFINES =================================
+//================================================================= WIN32 ===
#ifdef _WIN32
#undef QDECL
-#define QDECL __cdecl
+#define QDECL __cdecl
// buildstring will be incorporated into the version string
#ifdef _MSC_VER
#ifdef NDEBUG
#ifdef _M_IX86
-#define CPUSTRING "win-x86"
+#define CPUSTRING "win-x86"
#elif defined _M_ALPHA
-#define CPUSTRING "win-AXP"
+#define CPUSTRING "win-AXP"
#endif
#else
#ifdef _M_IX86
-#define CPUSTRING "win-x86-debug"
+#define CPUSTRING "win-x86-debug"
#elif defined _M_ALPHA
-#define CPUSTRING "win-AXP-debug"
+#define CPUSTRING "win-AXP-debug"
#endif
#endif
#elif defined __MINGW32__
#ifdef NDEBUG
#ifdef __i386__
-#define CPUSTRING "mingw-x86"
+#define CPUSTRING "mingw-x86"
#endif
#else
#ifdef __i386__
-#define CPUSTRING "mingw-x86-debug"
+#define CPUSTRING "mingw-x86-debug"
#endif
#endif
#endif
-#define ID_INLINE __inline
+#define ID_INLINE __inline
static ID_INLINE short BigShort( short l) { return ShortSwap(l); }
#define LittleShort
@@ -93,88 +107,89 @@ static ID_INLINE int BigLong(int l) { return LongSwap(l); }
static ID_INLINE float BigFloat(const float l) { return FloatSwap(&l); }
#define LittleFloat
-#define PATH_SEP '\\'
+#define PATH_SEP '\\'
#endif
-//======================= MAC OS X DEFINES =====================
+//============================================================== MAC OS X ===
#if defined(MACOS_X)
#define __cdecl
#define __declspec(x)
#define stricmp strcasecmp
-#define ID_INLINE inline
+#define ID_INLINE inline
#ifdef __ppc__
-#define CPUSTRING "MacOSX-ppc"
+#define CPUSTRING "MacOSX-ppc"
#elif defined __i386__
-#define CPUSTRING "MacOSX-i386"
+#define CPUSTRING "MacOSX-i386"
#else
-#define CPUSTRING "MacOSX-other"
+#define CPUSTRING "MacOSX-other"
#endif
-#define PATH_SEP '/'
+#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 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 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 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 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 inline float __fctiw(register float f) {
- register float fi;
-
- asm("fctiw %0,%1" : "=f" (fi) : "f" (f));
+static ID_INLINE float __fctiw(register float f) {
+ register float fi;
- return fi;
+ asm("fctiw %0,%1" : "=f" (fi) : "f" (f));
+ return fi;
}
#define BigShort
-static inline short LittleShort(short l) { return ShortSwap(l); }
+static ID_INLINE short LittleShort(short l) { return ShortSwap(l); }
#define BigLong
-static inline int LittleLong (int l) { return LongSwap(l); }
+static ID_INLINE int LittleLong(int l) { return LongSwap(l); }
#define BigFloat
-static inline float LittleFloat (const float l) { return FloatSwap(&l); }
+static ID_INLINE float LittleFloat(const float l) { return FloatSwap(&l); }
#endif
-//======================= MAC DEFINES =================================
+//=================================================================== MAC ===
#ifdef __MACOS__
#include <MacTypes.h>
-#define ID_INLINE inline
+#define ID_INLINE inline
-#define CPUSTRING "MacOS-PPC"
+#define CPUSTRING "MacOS-PPC"
-#define PATH_SEP ':'
+#define PATH_SEP ':'
void Sys_PumpEvents( void );
#define BigShort
-static inline short LittleShort(short l) { return ShortSwap(l); }
+static ID_INLINE short LittleShort(short l) { return ShortSwap(l); }
#define BigLong
-static inline int LittleLong (int l) { return LongSwap(l); }
+static ID_INLINE int LittleLong(int l) { return LongSwap(l); }
#define BigFloat
-static inline float LittleFloat (const float l) { return FloatSwap(&l); }
+static ID_INLINE float LittleFloat(const float l) { return FloatSwap(&l); }
#endif
-//======================= LINUX DEFINES =================================
+//================================================================= LINUX ===
// the mac compiler can't handle >32k of locals, so we
// just waste space and make big arrays static...
@@ -183,64 +198,65 @@ static inline float LittleFloat (const float l) { return FloatSwap(&l); }
// bk001205 - from Makefile
#define stricmp strcasecmp
-#define ID_INLINE inline
+#define ID_INLINE inline
#ifdef __i386__
-#define CPUSTRING "linux-i386"
+#define CPUSTRING "linux-i386"
#elif defined __axp__
-#define CPUSTRING "linux-alpha"
+#define CPUSTRING "linux-alpha"
#elif defined __x86_64__
-#define CPUSTRING "linux-x86_64"
+#define CPUSTRING "linux-x86_64"
#elif defined __powerpc64__
-#define CPUSTRING "linux-ppc64"
+#define CPUSTRING "linux-ppc64"
#elif defined __powerpc__
-#define CPUSTRING "linux-ppc"
+#define CPUSTRING "linux-ppc"
#elif defined __s390__
-#define CPUSTRING "linux-s390"
+#define CPUSTRING "linux-s390"
#elif defined __s390x__
-#define CPUSTRING "linux-s390x"
+#define CPUSTRING "linux-s390x"
#elif defined __ia64__
-#define CPUSTRING "linux-ia64"
+#define CPUSTRING "linux-ia64"
#else
-#define CPUSTRING "linux-other"
+#define CPUSTRING "linux-other"
#endif
-#define PATH_SEP '/'
+#define PATH_SEP '/'
#if __FLOAT_WORD_ORDER == __LITTLE_ENDIAN
-inline static short BigShort( short l) { return ShortSwap(l); }
+ID_INLINE static short BigShort( short l) { return ShortSwap(l); }
#define LittleShort
-inline static int BigLong(int l) { return LongSwap(l); }
+ID_INLINE static int BigLong(int l) { return LongSwap(l); }
#define LittleLong
-inline static float BigFloat(const float l) { return FloatSwap(&l); }
+ID_INLINE static float BigFloat(const float l) { return FloatSwap(&l); }
#define LittleFloat
#else
#define BigShort
-inline static short LittleShort(short l) { return ShortSwap(l); }
+ID_INLINE static short LittleShort(short l) { return ShortSwap(l); }
#define BigLong
-inline static int LittleLong (int l) { return LongSwap(l); }
+ID_INLINE static int LittleLong(int l) { return LongSwap(l); }
#define BigFloat
-inline static float LittleFloat (const float l) { return FloatSwap(&l); }
+ID_INLINE static float LittleFloat(const float l) { return FloatSwap(&l); }
#endif
#endif
-//======================= FreeBSD DEFINES =====================
+//=============================================================== FreeBSD ===
+
#ifdef __FreeBSD__ // rb010123
#define stricmp strcasecmp
-#define ID_INLINE inline
+#define ID_INLINE inline
#ifdef __i386__
-#define CPUSTRING "freebsd-i386"
+#define CPUSTRING "freebsd-i386"
#elif defined __axp__
-#define CPUSTRING "freebsd-alpha"
+#define CPUSTRING "freebsd-alpha"
#else
-#define CPUSTRING "freebsd-other"
+#define CPUSTRING "freebsd-other"
#endif
-#define PATH_SEP '/'
+#define PATH_SEP '/'
#if !idppc
static short BigShort( short l) { return ShortSwap(l); }
@@ -253,14 +269,14 @@ static float BigFloat(const float l) { return FloatSwap(&l); }
#define BigShort
static short LittleShort(short l) { return ShortSwap(l); }
#define BigLong
-static int LittleLong (int l) { return LongSwap(l); }
+static int LittleLong(int l) { return LongSwap(l); }
#define BigFloat
-static float LittleFloat (const float l) { return FloatSwap(&l); }
+static float LittleFloat(const float l) { return FloatSwap(&l); }
#endif
#endif
-//======================= SUNOS DEFINES =================================
+//================================================================= SUNOS ===
#ifdef __sun
@@ -270,30 +286,30 @@ static float LittleFloat (const float l) { return FloatSwap(&l); }
// bk001205 - from Makefile
#define stricmp strcasecmp
-#define ID_INLINE inline
+#define ID_INLINE inline
#ifdef __i386__
-#define CPUSTRING "Solaris-i386"
+#define CPUSTRING "Solaris-i386"
#elif defined __sparc
-#define CPUSTRING "Solaris-sparc"
+#define CPUSTRING "Solaris-sparc"
#endif
-#define PATH_SEP '/'
+#define PATH_SEP '/'
#if defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)
#define BigShort
-inline static short LittleShort(short l) { return ShortSwap(l); }
+ID_INLINE static short LittleShort(short l) { return ShortSwap(l); }
#define BigLong
-inline static int LittleLong (int l) { return LongSwap(l); }
+ID_INLINE static int LittleLong(int l) { return LongSwap(l); }
#define BigFloat
-inline static float LittleFloat (const float l) { return FloatSwap(&l); }
+ID_INLINE static float LittleFloat(const float l) { return FloatSwap(&l); }
#elif defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)
-inline static short BigShort( short l) { return ShortSwap(l); }
+ID_INLINE static short BigShort( short l) { return ShortSwap(l); }
#define LittleShort
-inline static int BigLong(int l) { return LongSwap(l); }
+ID_INLINE static int BigLong(int l) { return LongSwap(l); }
#define LittleLong
-inline static float BigFloat(const float l) { return FloatSwap(&l); }
+ID_INLINE static float BigFloat(const float l) { return FloatSwap(&l); }
#define LittleFloat
#else
@@ -302,7 +318,26 @@ inline static float BigFloat(const float l) { return FloatSwap(&l); }
#endif
-#ifndef Q3_VM
+//================================================================== Q3VM ===
+
+#ifdef Q3_VM
+
+#define ID_INLINE
+
+#define CPUSTRING "q3vm"
+
+#define PATH_SEP '/'
+
+#define LittleShort
+#define LittleLong
+#define LittleFloat
+#define BigShort
+#define BigLong
+#define BigFloat
+
+#endif
+
+//===========================================================================
//catch missing defines in above blocks
#ifndef CPUSTRING
diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h
index 698bef0..c981941 100644
--- a/code/qcommon/q_shared.h
+++ b/code/qcommon/q_shared.h
@@ -236,13 +236,8 @@ void Snd_Memset (void* dest, const int val, const size_t count);
#define Snd_Memset Com_Memset
#endif
-#if !( defined __VECTORC )
void Com_Memset (void* dest, const int val, const size_t count);
void Com_Memcpy (void* dest, const void* src, const size_t count);
-#else
-#define Com_Memset memset
-#define Com_Memcpy memcpy
-#endif
#define CIN_system 1
#define CIN_loop 2
@@ -346,7 +341,7 @@ extern vec3_t axisDefault[3];
#if idppc
-static inline float Q_rsqrt( float number ) {
+static ID_INLINE float Q_rsqrt( float number ) {
float x = 0.5f * number;
float y;
#ifdef __GNUC__
@@ -358,7 +353,7 @@ static inline float Q_rsqrt( float number ) {
}
#ifdef __GNUC__
-static inline float Q_fabs(float x) {
+static ID_INLINE float Q_fabs(float x) {
float abs_x;
asm("fabs %0,%1" : "=f" (abs_x) : "f" (x));
@@ -410,7 +405,6 @@ typedef struct {
float v[3];
} vec3struct_t;
#define VectorCopy(a,b) (*(vec3struct_t *)b=*(vec3struct_t *)a)
-#define ID_INLINE static
#endif
#endif
@@ -437,7 +431,7 @@ float RadiusFromBounds( const vec3_t mins, const vec3_t maxs );
void ClearBounds( vec3_t mins, vec3_t maxs );
void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs );
-#ifndef Q3_VM
+#if !defined( Q3_VM ) || ( defined( Q3_VM ) && defined( __Q3_VM_MATH ) )
static ID_INLINE int VectorCompare( const vec3_t v1, const vec3_t v2 ) {
if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) {
return 0;
diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h
index 775923c..c5a67e7 100644
--- a/code/qcommon/qcommon.h
+++ b/code/qcommon/qcommon.h
@@ -333,7 +333,7 @@ void *VM_ArgPtr( long intValue );
void *VM_ExplicitArgPtr( vm_t *vm, long intValue );
#define VMA(x) VM_ArgPtr(args[x])
-static __inline float _vmf(long x)
+static ID_INLINE float _vmf(long x)
{
union {
long l;
diff --git a/code/qcommon/vm.c b/code/qcommon/vm.c
index 86cfeb7..8f3e7a3 100644
--- a/code/qcommon/vm.c
+++ b/code/qcommon/vm.c
@@ -330,7 +330,7 @@ Dlls will call this directly
============
*/
long QDECL VM_DllSyscall( long arg, ... ) {
-#if ((defined __GNUC__) && !(defined __i386__))
+#if !id386
// rcg010206 - see commentary above
long args[16];
int i;
@@ -738,7 +738,7 @@ long QDECL VM_Call( vm_t *vm, long callnum, ... ) {
args[4], args[5], args[6], args[7],
args[8], args[9]);
} else {
-#ifdef __i386__ // i386 calling convention doesn't need conversion
+#if id386 // i386 calling convention doesn't need conversion
#ifndef NO_VM_COMPILED
if ( vm->compiled )
r = VM_CallCompiled( vm, (int*)&callnum );
diff --git a/code/qcommon/vm_interpreted.c b/code/qcommon/vm_interpreted.c
index 4359125..1d180aa 100644
--- a/code/qcommon/vm_interpreted.c
+++ b/code/qcommon/vm_interpreted.c
@@ -114,7 +114,7 @@ static char *opnames[256] = {
#if idppc
#if defined(__GNUC__)
- static inline unsigned int loadWord(void *addr) {
+ static ID_INLINE unsigned int loadWord(void *addr) {
unsigned int word;
asm("lwbrx %0,0,%1" : "=r" (word) : "r" (addr));
@@ -124,7 +124,7 @@ static char *opnames[256] = {
#define loadWord(addr) __lwbrx(addr,0)
#endif
#else
- static inline int loadWord(void *addr) {
+ static ID_INLINE int loadWord(void *addr) {
int word;
memcpy(&word, addr, 4);
return LittleLong(word);