mirror of
https://github.com/UberGames/ioef.git
synced 2024-11-27 14:32:55 +00:00
* 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
This commit is contained in:
parent
fa9b864abe
commit
2b8395a4d0
12 changed files with 52 additions and 133 deletions
|
@ -1040,7 +1040,7 @@ void CL_KeyEvent (int key, qboolean down, unsigned time) {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
#ifndef _WIN32
|
||||
if (key == K_ENTER)
|
||||
{
|
||||
if (down)
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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" \
|
||||
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
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
||||
//
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue