aboutsummaryrefslogtreecommitdiffstats
path: root/code/qcommon/vm_x86.c
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/vm_x86.c
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/vm_x86.c')
-rw-r--r--code/qcommon/vm_x86.c50
1 files changed, 46 insertions, 4 deletions
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;