aboutsummaryrefslogtreecommitdiffstats
path: root/code/qcommon/vm_x86.c
diff options
context:
space:
mode:
authortma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-09-23 02:59:15 +0000
committertma <tma@edf5b092-35ff-0310-97b2-ce42778d08ea>2005-09-23 02:59:15 +0000
commit48addd68a8c8d0c026be2d3b87ea6ce23509da91 (patch)
tree51a4a3f689906393882efed44c3387851a7d3dce /code/qcommon/vm_x86.c
parent5427364410d9be3d29e35b2d9fd4194c3878e3c0 (diff)
downloadioquake3-aero-48addd68a8c8d0c026be2d3b87ea6ce23509da91.tar.gz
ioquake3-aero-48addd68a8c8d0c026be2d3b87ea6ce23509da91.zip
* 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 git-svn-id: svn://svn.icculus.org/quake3/trunk@99 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/qcommon/vm_x86.c')
-rw-r--r--code/qcommon/vm_x86.c110
1 files changed, 37 insertions, 73 deletions
diff --git a/code/qcommon/vm_x86.c b/code/qcommon/vm_x86.c
index 7858616..5d2d3a7 100644
--- a/code/qcommon/vm_x86.c
+++ b/code/qcommon/vm_x86.c
@@ -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" \
- );
-#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" \
+ 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" \
);
-#endif
}
#endif