r99 - in trunk/code: client game qcommon renderer unix win32
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Thu Sep 22 22:59:16 EDT 2005
Author: tma
Date: 2005-09-22 22:59:15 -0400 (Thu, 22 Sep 2005)
New Revision: 99
Modified:
trunk/code/client/cl_keys.c
trunk/code/client/snd_mix.c
trunk/code/game/bg_lib.c
trunk/code/game/q_math.c
trunk/code/qcommon/common.c
trunk/code/qcommon/vm.c
trunk/code/qcommon/vm_x86.c
trunk/code/renderer/tr_init.c
trunk/code/renderer/tr_local.h
trunk/code/renderer/tr_shade_calc.c
trunk/code/unix/Makefile
trunk/code/win32/win_shared.c
Log:
* 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
Modified: trunk/code/client/cl_keys.c
===================================================================
--- trunk/code/client/cl_keys.c 2005-09-23 01:59:42 UTC (rev 98)
+++ trunk/code/client/cl_keys.c 2005-09-23 02:59:15 UTC (rev 99)
@@ -1040,7 +1040,7 @@
}
}
-#ifdef __linux__
+#ifndef _WIN32
if (key == K_ENTER)
{
if (down)
Modified: trunk/code/client/snd_mix.c
===================================================================
--- trunk/code/client/snd_mix.c 2005-09-23 01:59:42 UTC (rev 98)
+++ trunk/code/client/snd_mix.c 2005-09-23 02:59:15 UTC (rev 99)
@@ -34,8 +34,8 @@
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)
{
Modified: trunk/code/game/bg_lib.c
===================================================================
--- trunk/code/game/bg_lib.c 2005-09-23 01:59:42 UTC (rev 98)
+++ trunk/code/game/bg_lib.c 2005-09-23 02:59:15 UTC (rev 99)
@@ -269,9 +269,6 @@
}
#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 @@
}
-// 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;
Modified: trunk/code/game/q_math.c
===================================================================
--- trunk/code/game/q_math.c 2005-09-23 01:59:42 UTC (rev 98)
+++ trunk/code/game/q_math.c 2005-09-23 02:59:15 UTC (rev 99)
@@ -565,11 +565,7 @@
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 @@
==================
*/
-#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
Modified: trunk/code/qcommon/common.c
===================================================================
--- trunk/code/qcommon/common.c 2005-09-23 01:59:42 UTC (rev 98)
+++ trunk/code/qcommon/common.c 2005-09-23 02:59:15 UTC (rev 99)
@@ -24,15 +24,11 @@
#include "../game/q_shared.h"
#include "qcommon.h"
#include <setjmp.h>
-#ifdef __linux__
+#if defined __linux__ || defined MACOS_X
#include <netinet/in.h>
#else
-#if defined(MACOS_X)
-#include <netinet/in.h>
-#else
#include <winsock.h>
#endif
-#endif
int demo_protocols[] =
{ 66, 67, 68, 0 };
@@ -2817,7 +2813,7 @@
}
#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)
Modified: trunk/code/qcommon/vm.c
===================================================================
--- trunk/code/qcommon/vm.c 2005-09-23 01:59:42 UTC (rev 98)
+++ trunk/code/qcommon/vm.c 2005-09-23 02:59:15 UTC (rev 99)
@@ -330,7 +330,7 @@
============
*/
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;
Modified: trunk/code/qcommon/vm_x86.c
===================================================================
--- trunk/code/qcommon/vm_x86.c 2005-09-23 01:59:42 UTC (rev 98)
+++ trunk/code/qcommon/vm_x86.c 2005-09-23 02:59:15 UTC (rev 99)
@@ -53,20 +53,15 @@
#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 @@
#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 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" \
+ 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" \
);
-#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" \
- );
-#endif
}
#endif
Modified: trunk/code/renderer/tr_init.c
===================================================================
--- trunk/code/renderer/tr_init.c 2005-09-23 01:59:42 UTC (rev 98)
+++ trunk/code/renderer/tr_init.c 2005-09-23 02:59:15 UTC (rev 99)
@@ -894,12 +894,7 @@
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 );
//
Modified: trunk/code/renderer/tr_local.h
===================================================================
--- trunk/code/renderer/tr_local.h 2005-09-23 01:59:42 UTC (rev 98)
+++ trunk/code/renderer/tr_local.h 2005-09-23 02:59:15 UTC (rev 99)
@@ -34,7 +34,7 @@
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))
Modified: trunk/code/renderer/tr_shade_calc.c
===================================================================
--- trunk/code/renderer/tr_shade_calc.c 2005-09-23 01:59:42 UTC (rev 98)
+++ trunk/code/renderer/tr_shade_calc.c 2005-09-23 02:59:15 UTC (rev 99)
@@ -1022,17 +1022,13 @@
-#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
Modified: trunk/code/unix/Makefile
===================================================================
--- trunk/code/unix/Makefile 2005-09-23 01:59:42 UTC (rev 98)
+++ trunk/code/unix/Makefile 2005-09-23 02:59:15 UTC (rev 99)
@@ -261,7 +261,6 @@
ARFLAGS=rv
RANLIB=ranlib
- THREAD_LDFLAGS=-lpthread
LDFLAGS= -mwindows -lwsock32 -lgdi32 -lwinmm -lole32
GLLDFLAGS=
@@ -626,7 +625,6 @@
ifeq ($(ARCH),i386)
Q3OBJ += $(B)/client/vm_x86.o
endif
-
ifeq ($(ARCH),x86)
Q3OBJ += $(B)/client/vm_x86.o
endif
@@ -673,6 +671,8 @@
$(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 \
Modified: trunk/code/win32/win_shared.c
===================================================================
--- trunk/code/win32/win_shared.c 2005-09-23 01:59:42 UTC (rev 98)
+++ trunk/code/win32/win_shared.c 2005-09-23 02:59:15 UTC (rev 99)
@@ -53,25 +53,14 @@
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 @@
__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
/*
More information about the quake3-commits
mailing list