* 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:
Tim Angus 2005-09-23 02:59:15 +00:00
parent fa9b864abe
commit 2b8395a4d0
12 changed files with 52 additions and 133 deletions

View file

@ -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)

View file

@ -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;

View file

@ -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