aboutsummaryrefslogtreecommitdiffstats
path: root/code/qcommon
diff options
context:
space:
mode:
authorludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-02-18 19:07:23 +0000
committerludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2006-02-18 19:07:23 +0000
commitc9d6b2beb19f80e43fec9aa61d80cc8a62233c33 (patch)
tree2f6ce39235e215b3905fe4c4f0f8651a6e6793df /code/qcommon
parente89fbb8fbef8c74d202565c100ff57b04f1a60dc (diff)
downloadioquake3-aero-c9d6b2beb19f80e43fec9aa61d80cc8a62233c33.tar.gz
ioquake3-aero-c9d6b2beb19f80e43fec9aa61d80cc8a62233c33.zip
- change long to intptr_t for 64bit windows compatability
- change vmMain arguments back to int. 64bit types are apparently not needed there. Only the syscall function needs them. git-svn-id: svn://svn.icculus.org/quake3/trunk@550 edf5b092-35ff-0310-97b2-ce42778d08ea
Diffstat (limited to 'code/qcommon')
-rw-r--r--code/qcommon/common.c6
-rw-r--r--code/qcommon/q_shared.h6
-rw-r--r--code/qcommon/qcommon.h16
-rw-r--r--code/qcommon/vm.c26
-rw-r--r--code/qcommon/vm_interpreted.c8
-rw-r--r--code/qcommon/vm_local.h5
-rw-r--r--code/qcommon/vm_x86.c2
7 files changed, 38 insertions, 31 deletions
diff --git a/code/qcommon/common.c b/code/qcommon/common.c
index 7848dee..a464125 100644
--- a/code/qcommon/common.c
+++ b/code/qcommon/common.c
@@ -928,7 +928,7 @@ void *Z_TagMalloc( int size, int tag ) {
//
size += sizeof(memblock_t); // account for size of block header
size += 4; // space for memory trash tester
- size = PAD(size, sizeof(long)); // align to 32/64 bit boundary
+ size = PAD(size, sizeof(intptr_t)); // align to 32/64 bit boundary
base = rover = zone->rover;
start = base->prev;
@@ -1530,7 +1530,7 @@ void Com_InitHunkMemory( void ) {
Com_Error( ERR_FATAL, "Hunk data failed to allocate %i megs", s_hunkTotal / (1024*1024) );
}
// cacheline align
- s_hunkData = (byte *) ( ( (long)s_hunkData + 31 ) & ~31 );
+ s_hunkData = (byte *) ( ( (intptr_t)s_hunkData + 31 ) & ~31 );
Hunk_Clear();
Cmd_AddCommand( "meminfo", Com_Meminfo_f );
@@ -1750,7 +1750,7 @@ void *Hunk_AllocateTempMemory( int size ) {
Hunk_SwapBanks();
- size = PAD(size, sizeof(long)) + sizeof( hunkHeader_t );
+ size = PAD(size, sizeof(intptr_t)) + sizeof( hunkHeader_t );
if ( hunk_temp->temp + hunk_permanent->permanent + size > s_hunkTotal ) {
Com_Error( ERR_DROP, "Hunk_AllocateTempMemory: failed on %i", size );
diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h
index 6e55a4d..ec1df78 100644
--- a/code/qcommon/q_shared.h
+++ b/code/qcommon/q_shared.h
@@ -102,6 +102,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
//=============================================================
+#ifdef Q3_VM
+typedef int intptr_t;
+#else
+#include <inttypes.h>
+#endif
+
typedef unsigned char byte;
typedef enum {qfalse, qtrue} qboolean;
diff --git a/code/qcommon/qcommon.h b/code/qcommon/qcommon.h
index 21c74e9..5de428f 100644
--- a/code/qcommon/qcommon.h
+++ b/code/qcommon/qcommon.h
@@ -317,7 +317,7 @@ typedef enum {
} sharedTraps_t;
void VM_Init( void );
-vm_t *VM_Create( const char *module, long (*systemCalls)(long *),
+vm_t *VM_Create( const char *module, intptr_t (*systemCalls)(intptr_t *),
vmInterpret_t interpret );
// module should be bare: "cgame", not "cgame.dll" or "vm/cgame.qvm"
@@ -325,18 +325,18 @@ void VM_Free( vm_t *vm );
void VM_Clear(void);
vm_t *VM_Restart( vm_t *vm );
-long QDECL VM_Call( vm_t *vm, long callNum, ... );
+intptr_t QDECL VM_Call( vm_t *vm, int callNum, ... );
void VM_Debug( int level );
-void *VM_ArgPtr( long intValue );
-void *VM_ExplicitArgPtr( vm_t *vm, long intValue );
+void *VM_ArgPtr( intptr_t intValue );
+void *VM_ExplicitArgPtr( vm_t *vm, intptr_t intValue );
#define VMA(x) VM_ArgPtr(args[x])
-static ID_INLINE float _vmf(long x)
+static ID_INLINE float _vmf(intptr_t x)
{
union {
- long l;
+ intptr_t l;
float f;
} t;
t.l = x;
@@ -963,8 +963,8 @@ void Sys_Init (void);
// general development dll loading for virtual machine testing
// fqpath param added 7/20/02 by T.Ray - Sys_LoadDll is only called in vm.c at this time
-void * QDECL Sys_LoadDll( const char *name, char *fqpath , long (QDECL **entryPoint)(long, ...),
- long (QDECL *systemcalls)(long, ...) );
+void * QDECL Sys_LoadDll( const char *name, char *fqpath , intptr_t (QDECL **entryPoint)(int, ...),
+ intptr_t (QDECL *systemcalls)(intptr_t, ...) );
void Sys_UnloadDll( void *dllHandle );
void Sys_UnloadGame( void );
diff --git a/code/qcommon/vm.c b/code/qcommon/vm.c
index d241af8..ed38ad0 100644
--- a/code/qcommon/vm.c
+++ b/code/qcommon/vm.c
@@ -329,10 +329,10 @@ Dlls will call this directly
============
*/
-long QDECL VM_DllSyscall( long arg, ... ) {
+intptr_t QDECL VM_DllSyscall( intptr_t arg, ... ) {
#if !id386
// rcg010206 - see commentary above
- long args[16];
+ intptr_t args[16];
int i;
va_list ap;
@@ -340,7 +340,7 @@ long QDECL VM_DllSyscall( long arg, ... ) {
va_start(ap, arg);
for (i = 1; i < sizeof (args) / sizeof (args[i]); i++)
- args[i] = va_arg(ap, long);
+ args[i] = va_arg(ap, intptr_t);
va_end(ap);
return currentVM->systemCall( args );
@@ -471,7 +471,7 @@ vm_t *VM_Restart( vm_t *vm ) {
// DLL's can't be restarted in place
if ( vm->dllHandle ) {
char name[MAX_QPATH];
- long (*systemCall)( long *parms );
+ intptr_t (*systemCall)( intptr_t *parms );
systemCall = vm->systemCall;
Q_strncpyz( name, vm->name, sizeof( name ) );
@@ -507,7 +507,7 @@ it will attempt to load as a system dll
#define STACK_SIZE 0x20000
-vm_t *VM_Create( const char *module, long (*systemCalls)(long *),
+vm_t *VM_Create( const char *module, intptr_t (*systemCalls)(intptr_t *),
vmInterpret_t interpret ) {
vm_t *vm;
vmHeader_t *header;
@@ -648,7 +648,7 @@ void VM_Clear(void) {
lastVM = NULL;
}
-void *VM_ArgPtr( long intValue ) {
+void *VM_ArgPtr( intptr_t intValue ) {
if ( !intValue ) {
return NULL;
}
@@ -664,7 +664,7 @@ void *VM_ArgPtr( long intValue ) {
}
}
-void *VM_ExplicitArgPtr( vm_t *vm, long intValue ) {
+void *VM_ExplicitArgPtr( vm_t *vm, intptr_t intValue ) {
if ( !intValue ) {
return NULL;
}
@@ -709,9 +709,9 @@ locals from sp
#define MAX_STACK 256
#define STACK_MASK (MAX_STACK-1)
-long QDECL VM_Call( vm_t *vm, long callnum, ... ) {
+intptr_t QDECL VM_Call( vm_t *vm, int callnum, ... ) {
vm_t *oldVM;
- int r;
+ intptr_t r;
int i;
if ( !vm ) {
@@ -729,11 +729,11 @@ long QDECL VM_Call( vm_t *vm, long callnum, ... ) {
// if we have a dll loaded, call it directly
if ( vm->entryPoint ) {
//rcg010207 - see dissertation at top of VM_DllSyscall() in this file.
- long args[10];
+ int args[10];
va_list ap;
va_start(ap, callnum);
for (i = 0; i < sizeof (args) / sizeof (args[i]); i++) {
- args[i] = va_arg(ap, long);
+ args[i] = va_arg(ap, int);
}
va_end(ap);
@@ -758,7 +758,7 @@ long QDECL VM_Call( vm_t *vm, long callnum, ... ) {
a.callnum = callnum;
va_start(ap, callnum);
for (i = 0; i < sizeof (a.args) / sizeof (a.args[0]); i++) {
- a.args[i] = va_arg(ap, long);
+ a.args[i] = va_arg(ap, int);
}
va_end(ap);
#ifndef NO_VM_COMPILED
@@ -886,6 +886,6 @@ void VM_LogSyscalls( int *args ) {
f = fopen("syscalls.log", "w" );
}
callnum++;
- fprintf(f, "%i: %li (%i) = %i %i %i %i\n", callnum, (long)(args - (int *)currentVM->dataBase),
+ fprintf(f, "%i: %"PRIiPTR" (%i) = %i %i %i %i\n", callnum, (intptr_t)(args - (int *)currentVM->dataBase),
args[0], args[1], args[2], args[3], args[4] );
}
diff --git a/code/qcommon/vm_interpreted.c b/code/qcommon/vm_interpreted.c
index 4a9ff5b..12fcfae 100644
--- a/code/qcommon/vm_interpreted.c
+++ b/code/qcommon/vm_interpreted.c
@@ -493,7 +493,7 @@ nextInstruction2:
src = (int *)&image[ r0&dataMask ];
dest = (int *)&image[ r1&dataMask ];
- if ( ( (long)src | (long)dest | count ) & 3 ) {
+ if ( ( (intptr_t)src | (intptr_t)dest | count ) & 3 ) {
// happens in westernq3
Com_Printf( S_COLOR_YELLOW "Warning: OP_BLOCK_COPY not dword aligned\n");
}
@@ -534,16 +534,16 @@ nextInstruction2:
//VM_LogSyscalls( (int *)&image[ programStack + 4 ] );
{
- long* argptr = (long *)&image[ programStack + 4 ];
+ intptr_t* argptr = (intptr_t *)&image[ programStack + 4 ];
#if __WORDSIZE == 64
// the vm has ints on the stack, we expect
// longs so we have to convert it
- long argarr[16];
+ intptr_t argarr[16];
int i;
for (i = 0; i < 16; ++i) {
argarr[i] = *(int*)&image[ programStack + 4 + 4*i ];
- argptr = argarr;
}
+ argptr = argarr;
#endif
r = vm->systemCall( argptr );
}
diff --git a/code/qcommon/vm_local.h b/code/qcommon/vm_local.h
index a3d5caa..24f996a 100644
--- a/code/qcommon/vm_local.h
+++ b/code/qcommon/vm_local.h
@@ -127,7 +127,7 @@ struct vm_s {
// DO NOT MOVE OR CHANGE THESE WITHOUT CHANGING THE VM_OFFSET_* DEFINES
// USED BY THE ASM CODE
int programStack; // the vm may be recursively entered
- long (*systemCall)( long *parms );
+ intptr_t (*systemCall)( intptr_t *parms );
//------------------------------------
@@ -135,7 +135,8 @@ struct vm_s {
// for dynamic linked modules
void *dllHandle;
- long (QDECL *entryPoint)( long callNum, ... );
+ intptr_t (QDECL *entryPoint)( int callNum, ... );
+ void (*destroy)(vm_t* self);
// for interpreted modules
qboolean currentlyInterpreting;
diff --git a/code/qcommon/vm_x86.c b/code/qcommon/vm_x86.c
index 79074d9..f9677e9 100644
--- a/code/qcommon/vm_x86.c
+++ b/code/qcommon/vm_x86.c
@@ -192,7 +192,7 @@ void callAsmCall(void)
currentVM->programStack = callProgramStack - 4;
*(int *)((byte *)currentVM->dataBase + callProgramStack + 4) = callSyscallNum;
//VM_LogSyscalls((int *)((byte *)currentVM->dataBase + callProgramStack + 4) );
- *(callOpStack2+1) = currentVM->systemCall( (long *)((byte *)currentVM->dataBase + callProgramStack + 4) );
+ *(callOpStack2+1) = currentVM->systemCall( (intptr_t *)((byte *)currentVM->dataBase + callProgramStack + 4) );
currentVM = savedVM;
}