aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-09-23 02:59:15 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-09-23 02:59:15 +0000
commit48addd68a8c8d0c026be2d3b87ea6ce23509da91 (patch)
tree51a4a3f689906393882efed44c3387851a7d3dce
parent5427364410d9be3d29e35b2d9fd4194c3878e3c0 (diff)
downloadioquake3-aero-48addd68a8c8d0c026be2d3b87ea6ce23509da91.tar.gz
ioquake3-aero-48addd68a8c8d0c026be2d3b87ea6ce23509da91.zip
* Replaced lots of __linux__ || __FreeBSD__ with __GNUC__
* MinGW port now uses asm versions of SnapVector and ftol * Improved the handling of mangled symbols in vm_x86.c git-svn-id: svn://svn.icculus.org/quake3/trunk@99 edf5b092-35ff-0310-97b2-ce42778d08ea
-rw-r--r--code/client/cl_keys.c2
-rw-r--r--code/client/snd_mix.c4
-rw-r--r--code/game/bg_lib.c7
-rw-r--r--code/game/q_math.c9
-rw-r--r--code/qcommon/common.c8
-rw-r--r--code/qcommon/vm.c2
-rw-r--r--code/qcommon/vm_x86.c110
-rw-r--r--code/renderer/tr_init.c5
-rw-r--r--code/renderer/tr_local.h2
-rw-r--r--code/renderer/tr_shade_calc.c6
-rw-r--r--code/unix/Makefile4
-rw-r--r--code/win32/win_shared.c26
12 files changed, 52 insertions, 133 deletions
diff --git a/code/client/cl_keys.c b/code/client/cl_keys.c
index cf14d97..9d2a3f5 100644
--- a/code/client/cl_keys.c
+++ b/code/client/cl_keys.c
@@ -1040,7 +1040,7 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
}
}
-#ifdef __linux__
+#ifndef _WIN32
if (key == K_ENTER)
{
if (down)
diff --git a/code/client/snd_mix.c b/code/client/snd_mix.c
index 8426b60..a363c6a 100644
--- a/code/client/snd_mix.c
+++ b/code/client/snd_mix.c
@@ -34,8 +34,8 @@ int* snd_p;
int snd_linear_count;
short* snd_out;
-#if !( (defined __linux__ || defined __FreeBSD__ || defined __MINGW32__ ) && (defined __i386__) ) // rb010123
-#if !id386
+#if !( (defined __GNUC__) && (defined __i386__) ) // if not a GNU x86 target
+#if !id386 // if configured not to use asm
void S_WriteLinearBlastStereo16 (void)
{
diff --git a/code/game/bg_lib.c b/code/game/bg_lib.c
index bf1ac1e..140d18a 100644
--- a/code/game/bg_lib.c
+++ b/code/game/bg_lib.c
@@ -269,9 +269,6 @@ char *strstr( const char *string, const char *strCharSet ) {
}
#endif // bk001211
-// bk001120 - presumably needed for Mac
-//#if !defined(_MSC_VER) && !defined(__linux__)
-// bk001127 - undid undo
#if defined ( Q3_VM )
int tolower( int c ) {
if ( c >= 'A' && c <= 'Z' ) {
@@ -914,10 +911,6 @@ double _atof( const char **stringPtr ) {
}
-// bk001120 - presumably needed for Mac
-//#if !defined ( _MSC_VER ) && ! defined ( __linux__ )
-
-// bk001127 - undid undo
#if defined ( Q3_VM )
int atoi( const char *string ) {
int sign;
diff --git a/code/game/q_math.c b/code/game/q_math.c
index aeed2ab..fd835df 100644
--- a/code/game/q_math.c
+++ b/code/game/q_math.c
@@ -565,11 +565,7 @@ float Q_rsqrt( float number )
y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
// y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
-#ifndef Q3_VM
-#ifdef __linux__
- assert( !isnan(y) ); // bk010122 - FPE?
-#endif
-#endif
+ //assert( !isnan(y) ); // bk010122 - FPE?
return y;
}
@@ -740,7 +736,8 @@ int BoxOnPlaneSide2 (vec3_t emins, vec3_t emaxs, struct cplane_s *p)
==================
*/
-#if !( (defined __linux__ || __FreeBSD__ || __MINGW32__) && (defined __i386__) && (!defined C_ONLY)) // rb010123
+// if not GNU x86 and configured to use asm
+#if !( (defined __GNUC__) && (defined __i386__) && (!defined C_ONLY))
#if defined __LCC__ || defined C_ONLY || !id386 || defined __VECTORC
diff --git a/code/qcommon/common.c b/code/qcommon/common.c
index 1f7a9ab..aeed009 100644
--- a/code/qcommon/common.c
+++ b/code/qcommon/common.c
@@ -24,15 +24,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "../game/q_shared.h"
#include "qcommon.h"
#include <setjmp.h>
-#ifdef __linux__
-#include <netinet/in.h>
-#else
-#if defined(MACOS_X)
+#if defined __linux__ || defined MACOS_X
#include <netinet/in.h>
#else
#include <winsock.h>
#endif
-#endif
int demo_protocols[] =
{ 66, 67, 68, 0 };
@@ -2817,7 +2813,7 @@ void Com_Shutdown (void) {
}
#if !( defined __VECTORC )
-#if !( defined __linux__ || defined __FreeBSD__ || defined __MINGW32__ ) // r010123 - include FreeBSD
+#if !( defined __GNUC__ ) // GNU versions in linux_common.c
#if ((!id386) && (!defined __i386__)) // rcg010212 - for PPC
void Com_Memcpy (void* dest, const void* src, const size_t count)
diff --git a/code/qcommon/vm.c b/code/qcommon/vm.c
index 3f7a182..3ec8221 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 __linux__) && !(defined __i386__))
+#if ((defined __GNUC__) && !(defined __i386__))
// rcg010206 - see commentary above
long args[16];
int i;
diff --git a/code/qcommon/vm_x86.c b/code/qcommon/vm_x86.c
index 7858616..5d2d3a7 100644
--- a/code/qcommon/vm_x86.c
+++ b/code/qcommon/vm_x86.c
@@ -53,20 +53,15 @@ static int *instructionPointers = NULL;
#define FTOL_PTR
-#ifdef _WIN32
+#ifdef _MSC_VER
#if defined( FTOL_PTR )
int _ftol( float );
static int ftolPtr = (int)_ftol;
#endif
-#ifndef __MINGW32__
-void AsmCall( void );
-static int asmCallPtr = (int)AsmCall;
-#else
void doAsmCall( void );
static int asmCallPtr = (int)doAsmCall;
-#endif
#else // _WIN32
@@ -175,6 +170,12 @@ _asm {
#else //!_MSC_VER
+#ifdef __MINGW32__ // _ is prepended to compiled symbols
+#define CMANG(sym) "_"#sym
+#else
+#define CMANG(sym) #sym
+#endif
+
static int callProgramStack;
static int *callOpStack;
static int callSyscallNum;
@@ -197,74 +198,37 @@ void callAsmCall(void)
}
void AsmCall( void ) {
-#ifndef __MINGW32__
- __asm__("doAsmCall: \n\t" \
- " movl (%%edi),%%eax \n\t" \
- " subl $4,%%edi \n\t" \
- " orl %%eax,%%eax \n\t" \
- " jl systemCall \n\t" \
- " shll $2,%%eax \n\t" \
- " addl %3,%%eax \n\t" \
- " call *(%%eax) \n\t" \
- " movl (%%edi),%%eax \n\t" \
- " andl callMask, %%eax \n\t" \
- " jmp doret \n\t" \
- "systemCall: \n\t" \
- " negl %%eax \n\t" \
- " decl %%eax \n\t" \
- " movl %%eax,%0 \n\t" \
- " movl %%esi,%1 \n\t" \
- " movl %%edi,%2 \n\t" \
- " pushl %%ecx \n\t" \
- " pushl %%esi \n\t" \
- " pushl %%edi \n\t" \
- " call callAsmCall \n\t" \
- " popl %%edi \n\t" \
- " popl %%esi \n\t" \
- " popl %%ecx \n\t" \
- " addl $4,%%edi \n\t" \
- "doret: \n\t" \
- " ret \n\t" \
- : "=rm" (callSyscallNum), "=rm" (callProgramStack), "=rm" (callOpStack) \
- : "rm" (instructionPointers) \
- : "ax", "di", "si", "cx" \
- );
-#else
- // The only difference is _ added to the C symbols. It seems mingw
- // mangles all symbols this way, like linux gcc does when producing
- // a.out instead of elf
- __asm__("_doAsmCall: \n\t" \
- " movl (%%edi),%%eax \n\t" \
- " subl $4,%%edi \n\t" \
- " orl %%eax,%%eax \n\t" \
- " jl systemCall \n\t" \
- " shll $2,%%eax \n\t" \
- " addl %3,%%eax \n\t" \
- " call *(%%eax) \n\t" \
- " movl (%%edi),%%eax \n\t" \
- " andl _callMask, %%eax \n\t" \
- " jmp doret \n\t" \
- "systemCall: \n\t" \
- " negl %%eax \n\t" \
- " decl %%eax \n\t" \
- " movl %%eax,%0 \n\t" \
- " movl %%esi,%1 \n\t" \
- " movl %%edi,%2 \n\t" \
- " pushl %%ecx \n\t" \
- " pushl %%esi \n\t" \
- " pushl %%edi \n\t" \
- " call _callAsmCall \n\t" \
- " popl %%edi \n\t" \
- " popl %%esi \n\t" \
- " popl %%ecx \n\t" \
- " addl $4,%%edi \n\t" \
- "doret: \n\t" \
- " ret \n\t" \
- : "=rm" (callSyscallNum), "=rm" (callProgramStack), "=rm" (callOpStack) \
- : "rm" (instructionPointers) \
- : "ax", "di", "si", "cx" \
+ asm( CMANG(doAsmCall) ": \n\t" \
+ " movl (%%edi),%%eax \n\t" \
+ " subl $4,%%edi \n\t" \
+ " orl %%eax,%%eax \n\t" \
+ " jl systemCall \n\t" \
+ " shll $2,%%eax \n\t" \
+ " addl %3,%%eax \n\t" \
+ " call *(%%eax) \n\t" \
+ " movl (%%edi),%%eax \n\t" \
+ " andl " CMANG(callMask) ", %%eax \n\t" \
+ " jmp doret \n\t" \
+ "systemCall: \n\t" \
+ " negl %%eax \n\t" \
+ " decl %%eax \n\t" \
+ " movl %%eax,%0 \n\t" \
+ " movl %%esi,%1 \n\t" \
+ " movl %%edi,%2 \n\t" \
+ " pushl %%ecx \n\t" \
+ " pushl %%esi \n\t" \
+ " pushl %%edi \n\t" \
+ " call " CMANG(callAsmCall) " \n\t" \
+ " popl %%edi \n\t" \
+ " popl %%esi \n\t" \
+ " popl %%ecx \n\t" \
+ " addl $4,%%edi \n\t" \
+ "doret: \n\t" \
+ " ret \n\t" \
+ : "=rm" (callSyscallNum), "=rm" (callProgramStack), "=rm" (callOpStack) \
+ : "rm" (instructionPointers) \
+ : "ax", "di", "si", "cx" \
);
-#endif
}
#endif
diff --git a/code/renderer/tr_init.c b/code/renderer/tr_init.c
index d7e8db5..c27afec 100644
--- a/code/renderer/tr_init.c
+++ b/code/renderer/tr_init.c
@@ -894,12 +894,7 @@ void R_Register( void )
r_vertexLight = ri.Cvar_Get( "r_vertexLight", "0", CVAR_ARCHIVE | CVAR_LATCH );
r_uiFullScreen = ri.Cvar_Get( "r_uifullscreen", "0", 0);
r_subdivisions = ri.Cvar_Get ("r_subdivisions", "4", CVAR_ARCHIVE | CVAR_LATCH);
-#if (defined(MACOS_X) || defined(__linux__)) && defined(SMP)
- // Default to using SMP on Mac OS X or Linux if we have multiple processors
- r_smp = ri.Cvar_Get( "r_smp", Sys_ProcessorCount() > 1 ? "1" : "0", CVAR_ARCHIVE | CVAR_LATCH);
-#else
r_smp = ri.Cvar_Get( "r_smp", "0", CVAR_ARCHIVE | CVAR_LATCH);
-#endif
r_ignoreFastPath = ri.Cvar_Get( "r_ignoreFastPath", "1", CVAR_ARCHIVE | CVAR_LATCH );
//
diff --git a/code/renderer/tr_local.h b/code/renderer/tr_local.h
index d5355b2..fc1b464 100644
--- a/code/renderer/tr_local.h
+++ b/code/renderer/tr_local.h
@@ -34,7 +34,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
typedef unsigned int glIndex_t;
// fast float to int conversion
-#if id386 && !( (defined __linux__ || defined __FreeBSD__ ) && (defined __i386__ ) ) // rb010123
+#if id386 && !( (defined __GNUC__ ) && (defined __i386__ ) ) // rb010123
long myftol( float f );
#else
#define myftol(x) ((int)(x))
diff --git a/code/renderer/tr_shade_calc.c b/code/renderer/tr_shade_calc.c
index ca6f07c..ae33c51 100644
--- a/code/renderer/tr_shade_calc.c
+++ b/code/renderer/tr_shade_calc.c
@@ -1022,17 +1022,13 @@ void RB_CalcRotateTexCoords( float degsPerSecond, float *st )
-#if id386 && !( (defined __linux__ || defined __FreeBSD__ ) && (defined __i386__ ) ) // rb010123
+#if id386 && !( (defined __GNUC__ ) && (defined __i386__ ) ) // rb010123
long myftol( float f ) {
-#ifndef __MINGW32__
static int tmp;
__asm fld f
__asm fistp tmp
__asm mov eax, tmp
-#else
- return (long)f;
-#endif
}
#endif
diff --git a/code/unix/Makefile b/code/unix/Makefile
index 09bc04f..fc37d09 100644
--- a/code/unix/Makefile
+++ b/code/unix/Makefile
@@ -261,7 +261,6 @@ ifeq ($(PLATFORM),mingw32)
ARFLAGS=rv
RANLIB=ranlib
- THREAD_LDFLAGS=-lpthread
LDFLAGS= -mwindows -lwsock32 -lgdi32 -lwinmm -lole32
GLLDFLAGS=
@@ -626,7 +625,6 @@ Q3OBJ = \
ifeq ($(ARCH),i386)
Q3OBJ += $(B)/client/vm_x86.o
endif
-
ifeq ($(ARCH),x86)
Q3OBJ += $(B)/client/vm_x86.o
endif
@@ -673,6 +671,8 @@ ifeq ($(PLATFORM),mingw32)
$(B)/client/linux_common.o \
$(B)/client/snd_mixa.o \
$(B)/client/matha.o \
+ $(B)/client/ftola.o \
+ $(B)/client/snapvectora.o \
$(B)/client/win_gamma.o \
$(B)/client/win_glimp.o \
$(B)/client/win_input.o \
diff --git a/code/win32/win_shared.c b/code/win32/win_shared.c
index 0179edc..cbaa8d4 100644
--- a/code/win32/win_shared.c
+++ b/code/win32/win_shared.c
@@ -53,25 +53,14 @@ int Sys_Milliseconds (void)
return sys_curtime;
}
+#ifndef __GNUC__ //see snapvectora.s
/*
================
Sys_SnapVector
================
*/
-long fastftol( float f ) {
-#ifndef __MINGW32__
- static int tmp;
- __asm fld f
- __asm fistp tmp
- __asm mov eax, tmp
-#else
- return (long)f;
-#endif
-}
-
void Sys_SnapVector( float *v )
{
-#ifndef __MINGW32__
int i;
float f;
@@ -89,19 +78,8 @@ void Sys_SnapVector( float *v )
__asm fld f;
__asm fistp i;
*v = i;
- /*
- *v = fastftol(*v);
- v++;
- *v = fastftol(*v);
- v++;
- *v = fastftol(*v);
- */
-#else
- v[0] = rint(v[0]);
- v[1] = rint(v[1]);
- v[2] = rint(v[2]);
-#endif
}
+#endif
/*