aboutsummaryrefslogtreecommitdiffstats
path: root/code/qcommon
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-09-22 03:21:33 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-09-22 03:21:33 +0000
commitdf30c9d13185a525d2c45de3becd39c4a178f484 (patch)
tree3cf10550bfe1d9473252bfc3ad56b8007652e622 /code/qcommon
parent3873056dc5e0a7c314fa42dd70c072027ccccec0 (diff)
downloadioquake3-aero-df30c9d13185a525d2c45de3becd39c4a178f484.tar.gz
ioquake3-aero-df30c9d13185a525d2c45de3becd39c4a178f484.zip
* Port to MinGW
git-svn-id: svn://svn.icculus.org/quake3/trunk@97 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/qcommon')
-rw-r--r--code/qcommon/common.c2
-rw-r--r--code/qcommon/md4.c2
-rw-r--r--code/qcommon/vm.c2
-rw-r--r--code/qcommon/vm_interpreted.c2
-rw-r--r--code/qcommon/vm_x86.c50
5 files changed, 50 insertions, 8 deletions
diff --git a/code/qcommon/common.c b/code/qcommon/common.c
index 49f3721..1f7a9ab 100644
--- a/code/qcommon/common.c
+++ b/code/qcommon/common.c
@@ -2817,7 +2817,7 @@ void Com_Shutdown (void) {
}
#if !( defined __VECTORC )
-#if !( defined __linux__ || defined __FreeBSD__ ) // r010123 - include FreeBSD
+#if !( defined __linux__ || defined __FreeBSD__ || defined __MINGW32__ ) // r010123 - include FreeBSD
#if ((!id386) && (!defined __i386__)) // rcg010212 - for PPC
void Com_Memcpy (void* dest, const void* src, const size_t count)
diff --git a/code/qcommon/md4.c b/code/qcommon/md4.c
index e530b07..5f96838 100644
--- a/code/qcommon/md4.c
+++ b/code/qcommon/md4.c
@@ -1,7 +1,7 @@
/* GLOBAL.H - RSAREF types and constants */
#include <string.h>
-#if defined(_WIN32)
+#ifdef _MSC_VER
#pragma warning(disable : 4711) // selected for automatic inline expansion
#endif
diff --git a/code/qcommon/vm.c b/code/qcommon/vm.c
index 87f0795..3f7a182 100644
--- a/code/qcommon/vm.c
+++ b/code/qcommon/vm.c
@@ -858,7 +858,7 @@ void VM_LogSyscalls( int *args ) {
-#ifdef oDLL_ONLY // bk010215 - for DLL_ONLY dedicated servers/builds w/o VM
+#ifdef DLL_ONLY // bk010215 - for DLL_ONLY dedicated servers/builds w/o VM
int VM_CallCompiled( vm_t *vm, int *args ) {
return(0);
}
diff --git a/code/qcommon/vm_interpreted.c b/code/qcommon/vm_interpreted.c
index fb28011..0d0d90f 100644
--- a/code/qcommon/vm_interpreted.c
+++ b/code/qcommon/vm_interpreted.c
@@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "vm_local.h"
+//#define DEBUG_VM
#ifdef DEBUG_VM // bk001204
static char *opnames[256] = {
"OP_UNDEF",
@@ -306,7 +307,6 @@ locals from sp
*/
#define MAX_STACK 256
#define STACK_MASK (MAX_STACK-1)
-//#define DEBUG_VM
#define DEBUGSTR va("%s%i", VM_Indent(vm), opStack-stack )
diff --git a/code/qcommon/vm_x86.c b/code/qcommon/vm_x86.c
index 04abce9..7858616 100644
--- a/code/qcommon/vm_x86.c
+++ b/code/qcommon/vm_x86.c
@@ -60,8 +60,13 @@ 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
@@ -105,7 +110,7 @@ static ELastCommand LastCommand;
AsmCall
=================
*/
-#ifdef _WIN32
+#ifdef _MSC_VER
__declspec( naked ) void AsmCall( void ) {
int programStack;
int *opStack;
@@ -168,7 +173,7 @@ _asm {
}
-#else //!_WIN32
+#else //!_MSC_VER
static int callProgramStack;
static int *callOpStack;
@@ -185,13 +190,14 @@ void callAsmCall(void)
// save the stack to allow recursive VM entry
currentVM->programStack = callProgramStack - 4;
*(int *)((byte *)currentVM->dataBase + callProgramStack + 4) = callSyscallNum;
-//VM_LogSyscalls( (int *)((byte *)currentVM->dataBase + programStack + 4) );
+ //VM_LogSyscalls((int *)((byte *)currentVM->dataBase + callProgramStack + 4) );
*(callOpStack2+1) = currentVM->systemCall( (int *)((byte *)currentVM->dataBase + callProgramStack + 4) );
currentVM = savedVM;
}
void AsmCall( void ) {
+#ifndef __MINGW32__
__asm__("doAsmCall: \n\t" \
" movl (%%edi),%%eax \n\t" \
" subl $4,%%edi \n\t" \
@@ -223,6 +229,42 @@ void AsmCall( void ) {
: "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
@@ -1140,7 +1182,7 @@ int VM_CallCompiled( vm_t *vm, int *args ) {
entryPoint = vm->codeBase;
opStack = &stack;
-#ifdef _WIN32
+#ifdef _MSC_VER
__asm {
pushad
mov esi, programStack;