Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
games
enemy-territory
0007-prepare-for-64bit-support.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0007-prepare-for-64bit-support.diff of Package enemy-territory
From 86afc25702fec5d4761609fb70179ac15857672e Mon Sep 17 00:00:00 2001 From: Ludwig Nussel <ludwig.nussel@suse.de> Date: Sat, 14 Aug 2010 18:37:16 +0200 Subject: [PATCH 7/7] prepare for 64bit support --- src/SConstruct | 2 +- src/cgame/cg_main.c | 2 +- src/cgame/cg_syscalls.c | 4 +- src/client/cl_cgame.c | 10 +-- src/client/cl_cin.c | 141 +++++++++++++++--------------------------- src/client/cl_ui.c | 14 ++--- src/game/bg_animation.c | 2 + src/game/g_local.h | 2 +- src/game/g_main.c | 4 +- src/game/g_syscalls.c | 4 +- src/game/q_shared.h | 17 +++++ src/jpeg-6/jdcoefct.c | 2 +- src/mac/mac_dedicated_main.c | 4 +- src/mac/mac_main.cpp | 2 +- src/qcommon/cm_polylib.c | 2 +- src/qcommon/common.c | 2 +- src/qcommon/files.c | 2 +- src/qcommon/msg.c | 4 +- src/qcommon/qcommon.h | 22 +++++-- src/qcommon/vm.c | 57 ++++++++++------- src/qcommon/vm_local.h | 6 +- src/renderer/tr_init.c | 2 +- src/renderer/tr_main.c | 57 +++++++++++++++++- src/server/sv_client.c | 2 +- src/server/sv_game.c | 12 +--- src/ui/ui_main.c | 2 +- src/ui/ui_syscalls.c | 4 +- src/unix/unix_main.c | 6 +- src/win32/win_main.c | 4 +- 29 files changed, 217 insertions(+), 177 deletions(-) diff --git a/src/SConstruct b/src/SConstruct index 10a350c..0e7e1ec 100644 --- a/src/SConstruct +++ b/src/SConstruct @@ -263,7 +263,7 @@ elif ( BUILD == 'release' ): if ( cpu == 'x86'): OPTCPPFLAGS = [ '-O3', '-march=i686', '-Winline', '-ffast-math', '-fomit-frame-pointer', '-finline-functions', '-fschedule-insns2' ] else: - OPTCPPFLAGS = [ '-O3', '-Winline', '-ffast-math'] + OPTCPPFLAGS = [ '-O2', '-g', '-Winline', '-ffast-math'] elif ( OS == 'Darwin' ): OPTCPPFLAGS = [] else: diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 6839323..af23b05 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -55,7 +55,7 @@ This must be the very first function compiled into the .q3vm file #if __GNUC__ >= 4 #pragma GCC visibility push(default) #endif -int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { +intptr_t vmMain( intptr_t command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7, intptr_t arg8, intptr_t arg9, intptr_t arg10, intptr_t arg11 ) { #if __GNUC__ >= 4 #pragma GCC visibility pop #endif diff --git a/src/cgame/cg_syscalls.c b/src/cgame/cg_syscalls.c index 1057277..96469f9 100644 --- a/src/cgame/cg_syscalls.c +++ b/src/cgame/cg_syscalls.c @@ -30,12 +30,12 @@ If you have questions concerning this license or the applicable additional terms // cg_syscalls.asm is included instead when building a qvm #include "cg_local.h" -static int ( QDECL * syscall )( int arg, ... ) = ( int ( QDECL * )( int, ... ) ) - 1; +static intptr_t ( QDECL * syscall )( intptr_t arg, ... ) = ( intptr_t ( QDECL * )( intptr_t, ... ) ) - 1; #if __GNUC__ >= 4 #pragma GCC visibility push(default) #endif -void dllEntry( int ( QDECL *syscallptr )( int arg,... ) ) { +void dllEntry( intptr_t ( QDECL *syscallptr )( intptr_t arg,... ) ) { syscall = syscallptr; } #if __GNUC__ >= 4 diff --git a/src/client/cl_cgame.c b/src/client/cl_cgame.c index 20d37da..97b096c 100644 --- a/src/client/cl_cgame.c +++ b/src/client/cl_cgame.c @@ -564,10 +564,8 @@ CL_CgameSystemCalls The cgame module is making a system call ==================== */ -#define VMA( x ) VM_ArgPtr( args[x] ) -#define VMF( x ) ( (float *)args )[x] -int CL_CgameSystemCalls( int *args ) { +intptr_t CL_CgameSystemCalls( intptr_t *args ) { switch ( args[0] ) { case CG_PRINT: Com_Printf( "%s", (char *)VMA( 1 ) ); @@ -864,11 +862,11 @@ int CL_CgameSystemCalls( int *args ) { case CG_MEMSET: - return (int)memset( VMA( 1 ), args[2], args[3] ); + return (intptr_t)memset( VMA( 1 ), args[2], args[3] ); case CG_MEMCPY: - return (int)memcpy( VMA( 1 ), VMA( 2 ), args[3] ); + return (intptr_t)memcpy( VMA( 1 ), VMA( 2 ), args[3] ); case CG_STRNCPY: - return (int)strncpy( VMA( 1 ), VMA( 2 ), args[3] ); + return (intptr_t)strncpy( VMA( 1 ), VMA( 2 ), args[3] ); case CG_SIN: return FloatAsInt( sin( VMF( 1 ) ) ); case CG_COS: diff --git a/src/client/cl_cin.c b/src/client/cl_cin.c index cdc5c32..aae689a 100644 --- a/src/client/cl_cin.c +++ b/src/client/cl_cin.c @@ -93,7 +93,7 @@ typedef struct { byte file[65536]; short sqrTable[256]; - unsigned int mcomp[256]; + int mcomp[256]; byte *qStatus[2][32768]; long oldXOff, oldYOff, oldysize, oldxsize; @@ -334,29 +334,16 @@ long RllDecodeStereoToMono( unsigned char *from,short *to,unsigned int size,char * ******************************************************************************/ -static void move8_32( byte *src, byte *dst, int spl ) { - double *dsrc, *ddst; - int dspl; - - dsrc = (double *)src; - ddst = (double *)dst; - dspl = spl >> 3; - - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; +static void move8_32( byte *src, byte *dst, int spl ) +{ + int i; + + for(i = 0; i < 8; ++i) + { + memcpy(dst, src, 32); + src += spl; + dst += spl; + } } /****************************************************************************** @@ -367,21 +354,16 @@ static void move8_32( byte *src, byte *dst, int spl ) { * ******************************************************************************/ -static void move4_32( byte *src, byte *dst, int spl ) { - double *dsrc, *ddst; - int dspl; - - dsrc = (double *)src; - ddst = (double *)dst; - dspl = spl >> 3; - - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; - dsrc += dspl; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; +static void move4_32( byte *src, byte *dst, int spl ) +{ + int i; + + for(i = 0; i < 4; ++i) + { + memcpy(dst, src, 16); + src += spl; + dst += spl; + } } /****************************************************************************** @@ -392,29 +374,16 @@ static void move4_32( byte *src, byte *dst, int spl ) { * ******************************************************************************/ -static void blit8_32( byte *src, byte *dst, int spl ) { - double *dsrc, *ddst; - int dspl; - - dsrc = (double *)src; - ddst = (double *)dst; - dspl = spl >> 3; - - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; - dsrc += 4; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; ddst[2] = dsrc[2]; ddst[3] = dsrc[3]; +static void blit8_32( byte *src, byte *dst, int spl ) +{ + int i; + + for(i = 0; i < 8; ++i) + { + memcpy(dst, src, 32); + src += 32; + dst += spl; + } } /****************************************************************************** @@ -424,22 +393,16 @@ static void blit8_32( byte *src, byte *dst, int spl ) { * Description: * ******************************************************************************/ -#define movs double -static void blit4_32( byte *src, byte *dst, int spl ) { - movs *dsrc, *ddst; - int dspl; - - dsrc = (movs *)src; - ddst = (movs *)dst; - dspl = spl >> 3; - - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; - dsrc += 2; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; - dsrc += 2; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; - dsrc += 2; ddst += dspl; - ddst[0] = dsrc[0]; ddst[1] = dsrc[1]; +static void blit4_32( byte *src, byte *dst, int spl ) +{ + int i; + + for(i = 0; i < 4; ++i) + { + memmove(dst, src, 16); + src += 16; + dst += spl; + } } /****************************************************************************** @@ -450,16 +413,10 @@ static void blit4_32( byte *src, byte *dst, int spl ) { * ******************************************************************************/ -static void blit2_32( byte *src, byte *dst, int spl ) { - double *dsrc, *ddst; - int dspl; - - dsrc = (double *)src; - ddst = (double *)dst; - dspl = spl >> 3; - - ddst[0] = dsrc[0]; - ddst[dspl] = dsrc[1]; +static void blit2_32( byte *src, byte *dst, int spl ) +{ + memcpy(dst, src, 8); + memcpy(dst+spl, src+8, 8); } /****************************************************************************** @@ -1095,8 +1052,8 @@ static void readQuadInfo( byte *qData ) { cinTable[currentHandle].VQ0 = cinTable[currentHandle].VQNormal; cinTable[currentHandle].VQ1 = cinTable[currentHandle].VQBuffer; - cinTable[currentHandle].t[0] = ( 0 - (unsigned int)cin.linbuf ) + (unsigned int)cin.linbuf + cinTable[currentHandle].screenDelta; - cinTable[currentHandle].t[1] = ( 0 - ( (unsigned int)cin.linbuf + cinTable[currentHandle].screenDelta ) ) + (unsigned int)cin.linbuf; + cinTable[currentHandle].t[0] = cinTable[currentHandle].screenDelta; + cinTable[currentHandle].t[1] = -cinTable[currentHandle].screenDelta; cinTable[currentHandle].drawX = cinTable[currentHandle].CIN_WIDTH; cinTable[currentHandle].drawY = cinTable[currentHandle].CIN_HEIGHT; @@ -1327,8 +1284,8 @@ redump: cinTable[currentHandle].roq_id = framedata[0] + framedata[1] * 256; cinTable[currentHandle].RoQFrameSize = framedata[2] + framedata[3] * 256 + framedata[4] * 65536; cinTable[currentHandle].roq_flags = framedata[6] + framedata[7] * 256; - cinTable[currentHandle].roqF0 = (char)framedata[7]; - cinTable[currentHandle].roqF1 = (char)framedata[6]; + cinTable[currentHandle].roqF0 = (signed char)framedata[7]; + cinTable[currentHandle].roqF1 = (signed char)framedata[6]; if ( cinTable[currentHandle].RoQFrameSize > 65536 || cinTable[currentHandle].roq_id == 0x1084 ) { Com_DPrintf( "roq_size>65536||roq_id==0x1084\n" ); diff --git a/src/client/cl_ui.c b/src/client/cl_ui.c index 7165f1b..f7450c2 100644 --- a/src/client/cl_ui.c +++ b/src/client/cl_ui.c @@ -795,10 +795,6 @@ static int FloatAsInt( float f ) { return temp; } -void *VM_ArgPtr( int intValue ); -#define VMA( x ) VM_ArgPtr( args[x] ) -#define VMF( x ) ( (float *)args )[x] - /* ==================== CL_UISystemCalls @@ -806,7 +802,7 @@ CL_UISystemCalls The ui module is making a system call ==================== */ -int CL_UISystemCalls( int *args ) { +intptr_t CL_UISystemCalls( intptr_t *args ) { switch ( args[0] ) { case UI_ERROR: Com_Error( ERR_DROP, "%s", (char *)VMA( 1 ) ); @@ -1123,13 +1119,13 @@ int CL_UISystemCalls( int *args ) { return 0; case UI_MEMSET: - return (int)memset( VMA( 1 ), args[2], args[3] ); + return (intptr_t)memset( VMA( 1 ), args[2], args[3] ); case UI_MEMCPY: - return (int)memcpy( VMA( 1 ), VMA( 2 ), args[3] ); + return (intptr_t)memcpy( VMA( 1 ), VMA( 2 ), args[3] ); case UI_STRNCPY: - return (int)strncpy( VMA( 1 ), VMA( 2 ), args[3] ); + return (intptr_t)strncpy( VMA( 1 ), VMA( 2 ), args[3] ); case UI_SIN: return FloatAsInt( sin( VMF( 1 ) ) ); @@ -1229,7 +1225,7 @@ int CL_UISystemCalls( int *args ) { return 0; default: - Com_Error( ERR_DROP, "Bad UI system trap: %i", args[0] ); + Com_Error( ERR_DROP, "Bad UI system trap: %i", (int)args[0] ); } diff --git a/src/game/bg_animation.c b/src/game/bg_animation.c index 1831cd2..7e2970f 100644 --- a/src/game/bg_animation.c +++ b/src/game/bg_animation.c @@ -1660,6 +1660,8 @@ int BG_GetConditionValue( int client, int condition, qboolean checkConversion ) // nothing found return 0; } else { + Com_Error( ERR_DROP, "FIXME"); + #warning 64bit // xkan, 1/14/2003 - must use COM_BitCheck on the result. return (int)globalScriptData->clientConditions[client][condition]; } diff --git a/src/game/g_local.h b/src/game/g_local.h index 5365ec5..b07f751 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -1627,7 +1627,7 @@ extern gentity_t g_entities[]; //DAJ was explicit set to MAX_ENTITIES extern g_campaignInfo_t g_campaigns[]; extern int saveGamePending; -#define FOFS( x ) ( (int)&( ( (gentity_t *)0 )->x ) ) +#define FOFS( x ) ( (size_t)&( ( (gentity_t *)0 )->x ) ) extern vmCvar_t g_gametype; diff --git a/src/game/g_main.c b/src/game/g_main.c index f672790..0956125 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -479,7 +479,7 @@ This must be the very first function compiled into the .q3vm file #if __GNUC__ >= 4 #pragma GCC visibility push(default) #endif -int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6 ) { +intptr_t vmMain( intptr_t command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6 ) { #if __GNUC__ >= 4 #pragma GCC visibility pop #endif @@ -491,7 +491,7 @@ int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int a G_ShutdownGame( arg0 ); return 0; case GAME_CLIENT_CONNECT: - return (int)ClientConnect( arg0, arg1, arg2 ); + return (intptr_t)ClientConnect( arg0, arg1, arg2 ); case GAME_CLIENT_THINK: ClientThink( arg0 ); return 0; diff --git a/src/game/g_syscalls.c b/src/game/g_syscalls.c index 3187c2a..b9f50a4 100644 --- a/src/game/g_syscalls.c +++ b/src/game/g_syscalls.c @@ -31,12 +31,12 @@ If you have questions concerning this license or the applicable additional terms // this file is only included when building a dll // g_syscalls.asm is included instead when building a qvm -static int ( QDECL * syscall )( int arg, ... ) = ( int ( QDECL * )( int, ... ) ) - 1; +static intptr_t ( QDECL * syscall )( intptr_t arg, ... ) = ( intptr_t ( QDECL * )( intptr_t, ... ) ) - 1; #if __GNUC__ >= 4 #pragma GCC visibility push(default) #endif -void dllEntry( int ( QDECL *syscallptr )( int arg,... ) ) { +void dllEntry( intptr_t ( QDECL *syscallptr )( intptr_t arg,... ) ) { syscall = syscallptr; } #if __GNUC__ >= 4 diff --git a/src/game/q_shared.h b/src/game/q_shared.h index 6e6e5d5..2fe8dad 100644 --- a/src/game/q_shared.h +++ b/src/game/q_shared.h @@ -111,6 +111,8 @@ If you have questions concerning this license or the applicable additional terms #include "bg_lib.h" +typedef int intptr_t; + #else #include <assert.h> @@ -125,6 +127,21 @@ If you have questions concerning this license or the applicable additional terms #include <sys/stat.h> // rain #include <float.h> +#ifdef _MSC_VER + #include <io.h> + + typedef __int64 int64_t; + typedef __int32 int32_t; + typedef __int16 int16_t; + typedef __int8 int8_t; + typedef unsigned __int64 uint64_t; + typedef unsigned __int32 uint32_t; + typedef unsigned __int16 uint16_t; + typedef unsigned __int8 uint8_t; +#else + #include <stdint.h> +#endif + #endif diff --git a/src/jpeg-6/jdcoefct.c b/src/jpeg-6/jdcoefct.c index 8f67b5d..3525b06 100644 --- a/src/jpeg-6/jdcoefct.c +++ b/src/jpeg-6/jdcoefct.c @@ -732,7 +732,7 @@ jinit_d_coef_controller( j_decompress_ptr cinfo, boolean need_full_buffer ) { } else { /* We only need a single-MCU buffer. */ JBLOCKROW buffer; - int i; + unsigned i; buffer = (JBLOCKROW) ( *cinfo->mem->alloc_large ) ( (j_common_ptr) cinfo, JPOOL_IMAGE, diff --git a/src/mac/mac_dedicated_main.c b/src/mac/mac_dedicated_main.c index 5658b74..2c25113 100644 --- a/src/mac/mac_dedicated_main.c +++ b/src/mac/mac_dedicated_main.c @@ -671,9 +671,9 @@ char* Sys_GetDLLName( const char *name ) { #if MAC_WOLF2_MP #pragma mark Sys_LoadDll -void *Sys_LoadDll( const char *name, char *fqpath, int( **entryPoint ) ( int, ... ), int ( *systemCalls )( int, ... ) ) +void *Sys_LoadDll( const char *name, char *fqpath, intptr_t( **entryPoint ) ( int, ... ), intptr_t ( *systemCalls )( intptr_t, ... ) ) #else -void *Sys_LoadDll( const char *name, int( **entryPoint ) ( int, ... ), int ( *systemCalls )( int, ... ) ) +void *Sys_LoadDll( const char *name, intptr_t( **entryPoint ) ( int, ... ), intptr_t ( *systemCalls )( intptr_t, ... ) ) #endif { OSErr err = noErr; diff --git a/src/mac/mac_main.cpp b/src/mac/mac_main.cpp index 441b80c..9332e2d 100644 --- a/src/mac/mac_main.cpp +++ b/src/mac/mac_main.cpp @@ -327,7 +327,7 @@ char* Sys_GetDLLName( const char *name ) { #pragma mark Sys_LoadDll -void *Sys_LoadDll( const char *name, char *fqpath, int( **entryPoint ) ( int, ... ), int ( *systemCalls )( int, ... ) ) { +void *Sys_LoadDll( const char *name, char *fqpath, intptr_t( **entryPoint ) ( int, ... ), intptr_t ( *systemCalls )( intptr_t, ... ) ) { OSErr err = noErr; FSSpec SLSpec; char name2[255]; diff --git a/src/qcommon/cm_polylib.c b/src/qcommon/cm_polylib.c index 5bacc1c..1c6d023 100644 --- a/src/qcommon/cm_polylib.c +++ b/src/qcommon/cm_polylib.c @@ -272,7 +272,7 @@ winding_t *CopyWinding( winding_t *w ) { winding_t *c; c = AllocWinding( w->numpoints ); - size = (int)( (winding_t *)0 )->p[w->numpoints]; + size = (size_t)( (winding_t *)0 )->p[w->numpoints]; memcpy( c, w, size ); return c; } diff --git a/src/qcommon/common.c b/src/qcommon/common.c index 9e55d47..d92f34d 100644 --- a/src/qcommon/common.c +++ b/src/qcommon/common.c @@ -1605,7 +1605,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 * )( ( (int)s_hunkData + 31 ) & ~31 ); + s_hunkData = ( byte * )( ( (intptr_t)s_hunkData + 31 ) & ~31 ); Hunk_Clear(); Cmd_AddCommand( "meminfo", Com_Meminfo_f ); diff --git a/src/qcommon/files.c b/src/qcommon/files.c index 82d8321..401c7da 100644 --- a/src/qcommon/files.c +++ b/src/qcommon/files.c @@ -2912,7 +2912,7 @@ static void FS_AddGameDirectory( const char *path, const char *dir ) { // jpw } - qsort( sorted, numfiles, 4, paksort ); + qsort( sorted, numfiles, sizeof(char*), paksort ); for ( i = 0 ; i < numfiles ; i++ ) { /* if (Q_strncmp(sorted[i],"sp_",3)) { // JPW NERVE -- exclude sp_* diff --git a/src/qcommon/msg.c b/src/qcommon/msg.c index 25ca92a..66ad2af 100644 --- a/src/qcommon/msg.c +++ b/src/qcommon/msg.c @@ -834,7 +834,7 @@ typedef struct { } netField_t; // using the stringizing operator to save typing... -#define NETF( x ) # x,(int)&( (entityState_t*)0 )->x +#define NETF( x ) # x,(size_t)&( (entityState_t*)0 )->x netField_t entityStateFields[] = { { NETF( eType ), 8 }, @@ -1240,7 +1240,7 @@ player_state_t communication */ // using the stringizing operator to save typing... -#define PSF( x ) # x,(int)&( (playerState_t*)0 )->x +#define PSF( x ) # x,(size_t)&( (playerState_t*)0 )->x netField_t playerStateFields[] = { { PSF( commandTime ), 32 }, diff --git a/src/qcommon/qcommon.h b/src/qcommon/qcommon.h index ac51673..0742df7 100644 --- a/src/qcommon/qcommon.h +++ b/src/qcommon/qcommon.h @@ -388,7 +388,7 @@ typedef enum { } sharedTraps_t; void VM_Init( void ); -vm_t *VM_Create( const char *module, int ( *systemCalls )( int * ), +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" @@ -396,12 +396,22 @@ void VM_Free( vm_t *vm ); void VM_Clear( void ); vm_t *VM_Restart( vm_t *vm ); -int QDECL VM_Call( vm_t *vm, int callNum, ... ); +intptr_t QDECL VM_Call( vm_t *vm, int callNum, ... ); void VM_Debug( int level ); -void *VM_ArgPtr( int intValue ); -void *VM_ExplicitArgPtr( vm_t *vm, int intValue ); +void *VM_ArgPtr( intptr_t intValue ); +void *VM_ExplicitArgPtr( vm_t *vm, intptr_t intValue ); + +#define VMA( x ) VM_ArgPtr( args[x] ) +static inline float _vmf(intptr_t x) +{ + int i = x; + float f; + memcpy(&f, &x, sizeof(i)); + return f; +} +#define VMF(x) _vmf(args[x]) /* ============================================================== @@ -1109,8 +1119,8 @@ void Sys_LeaveCriticalSection( void *ptr ); char* Sys_GetDLLName( const char *name ); // fqpath param added 2/15/02 by T.Ray - Sys_LoadDll is only called in vm.c at this time -void * QDECL Sys_LoadDll( const char *name, char *fqpath, int( QDECL * *entryPoint ) ( int, ... ), - int ( QDECL * systemcalls )( int, ... ) ); +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/src/qcommon/vm.c b/src/qcommon/vm.c index 3b16af8..cdbfa18 100644 --- a/src/qcommon/vm.c +++ b/src/qcommon/vm.c @@ -153,6 +153,7 @@ int VM_SymbolToValue( vm_t *vm, const char *symbol ) { } +#if 0 /* ===================== VM_SymbolForCompiledPointer @@ -179,6 +180,7 @@ const char *VM_SymbolForCompiledPointer( vm_t *vm, void *code ) { // now look up the bytecode instruction pointer return VM_ValueToSymbol( vm, i ); } +#endif @@ -331,10 +333,9 @@ Dlls will call this directly ============ */ -int QDECL VM_DllSyscall( int arg, ... ) { -#if ( ( defined __linux__ ) && ( defined __powerpc__ ) ) //|| (defined MACOS_X) - // rcg010206 - see commentary above - int args[16]; +intptr_t QDECL VM_DllSyscall( intptr_t arg, ... ) { +#if !id386 + intptr_t args[16]; int i; va_list ap; @@ -342,7 +343,7 @@ int QDECL VM_DllSyscall( int arg, ... ) { va_start( ap, arg ); for ( i = 1; i < sizeof( args ) / sizeof( args[i] ); i++ ) - args[i] = va_arg( ap, int ); + args[i] = va_arg( ap, intptr_t ); va_end( ap ); return currentVM->systemCall( args ); @@ -369,7 +370,7 @@ vm_t *VM_Restart( vm_t *vm ) { // DLL's can't be restarted in place if ( vm->dllHandle ) { char name[MAX_QPATH]; - int ( *systemCall )( int *parms ); + intptr_t ( *systemCall )( intptr_t *parms ); systemCall = vm->systemCall; Q_strncpyz( name, vm->name, sizeof( name ) ); @@ -439,7 +440,7 @@ it will attempt to load as a system dll #define STACK_SIZE 0x20000 -vm_t *VM_Create( const char *module, int ( *systemCalls )(int *), +vm_t *VM_Create( const char *module, intptr_t ( *systemCalls )(intptr_t *), vmInterpret_t interpret ) { vm_t *vm; vmHeader_t *header; @@ -606,7 +607,7 @@ void VM_Clear( void ) { lastVM = NULL; } -void *VM_ArgPtr( int intValue ) { +void *VM_ArgPtr( intptr_t intValue ) { if ( !intValue ) { return NULL; } @@ -622,7 +623,7 @@ void *VM_ArgPtr( int intValue ) { } } -void *VM_ExplicitArgPtr( vm_t *vm, int intValue ) { +void *VM_ExplicitArgPtr( vm_t *vm, intptr_t intValue ) { if ( !intValue ) { return NULL; } @@ -667,15 +668,12 @@ locals from sp #define MAX_STACK 256 #define STACK_MASK ( MAX_STACK - 1 ) -int QDECL VM_Call( vm_t *vm, int callnum, ... ) { +intptr_t QDECL VM_Call( vm_t *vm, int callnum, ... ) { vm_t *oldVM; - int r; - //rcg010207 see dissertation at top of VM_DllSyscall() in this file. -#if ( ( defined __linux__ ) && ( defined __powerpc__ ) ) || ( defined MACOS_X ) + intptr_t r; int i; - int args[16]; + intptr_t args[16]; va_list ap; -#endif if ( !vm ) { Com_Error( ERR_FATAL, "VM_Call with NULL vm" ); @@ -691,8 +689,6 @@ int QDECL VM_Call( vm_t *vm, int callnum, ... ) { // if we have a dll loaded, call it directly if ( vm->entryPoint ) { - //rcg010207 - see dissertation at top of VM_DllSyscall() in this file. -#if ( ( defined __linux__ ) && ( defined __powerpc__ ) ) || ( defined MACOS_X ) va_start( ap, callnum ); for ( i = 0; i < sizeof( args ) / sizeof( args[i] ); i++ ) args[i] = va_arg( ap, int ); @@ -702,18 +698,35 @@ int QDECL VM_Call( vm_t *vm, int callnum, ... ) { args[4], args[5], args[6], args[7], args[8], args[9], args[10], args[11], args[12], args[13], args[14], args[15] ); -#else // PPC above, original id code below - r = vm->entryPoint( ( &callnum )[0], ( &callnum )[1], ( &callnum )[2], ( &callnum )[3], - ( &callnum )[4], ( &callnum )[5], ( &callnum )[6], ( &callnum )[7], - ( &callnum )[8], ( &callnum )[9], ( &callnum )[10], ( &callnum )[11], ( &callnum )[12] ); -#endif } else { +#if id386 || idsparc // i386/sparc calling convention doesn't need conversion #ifndef NO_VM_COMPILED if ( vm->compiled ) { r = VM_CallCompiled( vm, &callnum ); } else #endif r = VM_CallInterpreted( vm, &callnum ); +#else + struct { + int callnum; + int args[16]; + } a; + va_list ap; + + 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, int); + } + va_end(ap); +#ifndef NO_VM_COMPILED + if ( vm->compiled ) + r = VM_CallCompiled( vm, &a.callnum ); + else +#endif + r = VM_CallInterpreted( vm, &a.callnum ); + +#endif } if ( oldVM != NULL ) { // bk001220 - assert(currentVM!=NULL) for oldVM==NULL diff --git a/src/qcommon/vm_local.h b/src/qcommon/vm_local.h index 94559d4..7ddd55b 100644 --- a/src/qcommon/vm_local.h +++ b/src/qcommon/vm_local.h @@ -118,7 +118,7 @@ typedef enum { -typedef int vmptr_t; +typedef intptr_t vmptr_t; typedef struct vmSymbol_s { struct vmSymbol_s *next; @@ -134,7 +134,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 - int ( *systemCall )( int *parms ); + intptr_t ( *systemCall )( intptr_t *parms ); //------------------------------------ @@ -145,7 +145,7 @@ struct vm_s { // for dynamic linked modules void *dllHandle; - int ( QDECL *entryPoint )( int callNum, ... ); + intptr_t ( QDECL *entryPoint )( int callNum, ... ); // for interpreted modules qboolean currentlyInterpreting; diff --git a/src/renderer/tr_init.c b/src/renderer/tr_init.c index 7f8601d..75df63d 100644 --- a/src/renderer/tr_init.c +++ b/src/renderer/tr_init.c @@ -1146,7 +1146,7 @@ void R_Init( void ) { Swap_Init(); - if ( (int)tess.xyz & 15 ) { + if ( (intptr_t)tess.xyz & 15 ) { Com_Printf( "WARNING: tess.xyz not 16 byte aligned\n" ); } memset( tess.constantColor255, 255, sizeof( tess.constantColor255 ) ); diff --git a/src/renderer/tr_main.c b/src/renderer/tr_main.c index 3f52495..93e0af0 100644 --- a/src/renderer/tr_main.c +++ b/src/renderer/tr_main.c @@ -1368,6 +1368,61 @@ DRAWSURF SORTING ========================================================================================== */ +#warning FIXME +#define Q3_LITTLE_ENDIAN +#define ID_INLINE inline + +/* +=============== +R_Radix +=============== +*/ +static ID_INLINE void R_Radix( int byte, int size, drawSurf_t *source, drawSurf_t *dest ) +{ + int count[ 256 ] = { 0 }; + int index[ 256 ]; + int i; + unsigned char *sortKey = NULL; + unsigned char *end = NULL; + + sortKey = ( (unsigned char *)&source[ 0 ].sort ) + byte; + end = sortKey + ( size * sizeof( drawSurf_t ) ); + for( ; sortKey < end; sortKey += sizeof( drawSurf_t ) ) + ++count[ *sortKey ]; + + index[ 0 ] = 0; + + for( i = 1; i < 256; ++i ) + index[ i ] = index[ i - 1 ] + count[ i - 1 ]; + + sortKey = ( (unsigned char *)&source[ 0 ].sort ) + byte; + for( i = 0; i < size; ++i, sortKey += sizeof( drawSurf_t ) ) + dest[ index[ *sortKey ]++ ] = source[ i ]; +} + +/* +=============== +R_RadixSort + +Radix sort with 4 byte size buckets +=============== +*/ +static void R_RadixSort( drawSurf_t *source, int size ) +{ + static drawSurf_t scratch[ MAX_DRAWSURFS ]; +#ifdef Q3_LITTLE_ENDIAN + R_Radix( 0, size, source, scratch ); + R_Radix( 1, size, scratch, source ); + R_Radix( 2, size, source, scratch ); + R_Radix( 3, size, scratch, source ); +#else + R_Radix( 3, size, source, scratch ); + R_Radix( 2, size, scratch, source ); + R_Radix( 1, size, source, scratch ); + R_Radix( 0, size, scratch, source ); +#endif //Q3_LITTLE_ENDIAN +} + /* ================= qsort replacement @@ -1627,7 +1682,7 @@ void R_SortDrawSurfs( drawSurf_t *drawSurfs, int numDrawSurfs ) { } // sort the drawsurfs by sort type, then orientation, then shader - qsortFast( drawSurfs, numDrawSurfs, sizeof( drawSurf_t ) ); + R_RadixSort( drawSurfs, numDrawSurfs ); // check for any pass through drawing, which // may cause another view to be rendered first diff --git a/src/server/sv_client.c b/src/server/sv_client.c index 9fd7dd2..5b68151 100644 --- a/src/server/sv_client.c +++ b/src/server/sv_client.c @@ -462,7 +462,7 @@ gotnewcl: denied = (char *)VM_Call( gvm, GAME_CLIENT_CONNECT, clientNum, qtrue, qfalse ); // firstTime = qtrue if ( denied ) { // we can't just use VM_ArgPtr, because that is only valid inside a VM_Call - denied = VM_ExplicitArgPtr( gvm, (int)denied ); + denied = VM_ExplicitArgPtr( gvm, (intptr_t)denied ); NET_OutOfBandPrint( NS_SERVER, from, "print\n[err_dialog]%s\n", denied ); Com_DPrintf( "Game rejected a connection: %s.\n", denied ); diff --git a/src/server/sv_game.c b/src/server/sv_game.c index ee017f9..a92486c 100644 --- a/src/server/sv_game.c +++ b/src/server/sv_game.c @@ -364,20 +364,12 @@ SV_GameSystemCalls The module is making a system call ==================== */ -//rcg010207 - see my comments in VM_DllSyscall(), in qcommon/vm.c ... -#if ( ( defined __linux__ ) && ( defined __powerpc__ ) ) || ( defined MACOS_X ) -#define VMA( x ) ( (void *) args[x] ) -#else -#define VMA( x ) VM_ArgPtr( args[x] ) -#endif - -#define VMF( x ) ( (float *)args )[x] // show_bug.cgi?id=574 extern int S_RegisterSound( const char *name, qboolean compressed ); extern int S_GetSoundLength( sfxHandle_t sfxHandle ); -int SV_GameSystemCalls( int *args ) { +intptr_t SV_GameSystemCalls( intptr_t *args ) { switch ( args[0] ) { case G_PRINT: Com_Printf( "%s", (char *)VMA( 1 ) ); @@ -967,7 +959,7 @@ int SV_GameSystemCalls( int *args ) { return 0; case TRAP_STRNCPY: - return (int)strncpy( VMA( 1 ), VMA( 2 ), args[3] ); + return (intptr_t)strncpy( VMA( 1 ), VMA( 2 ), args[3] ); case TRAP_SIN: return FloatAsInt( sin( VMF( 1 ) ) ); diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index a1121b5..1f55c3b 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -269,7 +269,7 @@ qboolean _UI_IsFullscreen( void ); #if __GNUC__ >= 4 #pragma GCC visibility push(default) #endif -int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8, int arg9, int arg10, int arg11 ) { +intptr_t vmMain( intptr_t command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7, intptr_t arg8, intptr_t arg9, intptr_t arg10, intptr_t arg11 ) { #if __GNUC__ >= 4 #pragma GCC visibility pop #endif diff --git a/src/ui/ui_syscalls.c b/src/ui/ui_syscalls.c index 8abc3bb..502a661 100644 --- a/src/ui/ui_syscalls.c +++ b/src/ui/ui_syscalls.c @@ -31,12 +31,12 @@ If you have questions concerning this license or the applicable additional terms // this file is only included when building a dll // syscalls.asm is included instead when building a qvm -static int ( QDECL * syscall )( int arg, ... ) = ( int ( QDECL * )( int, ... ) ) - 1; +static intptr_t ( QDECL * syscall )( intptr_t arg, ... ) = ( intptr_t ( QDECL * )( intptr_t, ... ) ) - 1; #if __GNUC__ >= 4 #pragma GCC visibility push(default) #endif -void dllEntry( int ( QDECL *syscallptr )( int arg,... ) ) { +void dllEntry( intptr_t ( QDECL *syscallptr )( intptr_t arg,... ) ) { syscall = syscallptr; } #if __GNUC__ >= 4 diff --git a/src/unix/unix_main.c b/src/unix/unix_main.c index 1430e44..54cff42 100644 --- a/src/unix/unix_main.c +++ b/src/unix/unix_main.c @@ -721,10 +721,10 @@ char* Sys_GetDLLName( const char *name ) { } void *Sys_LoadDll( const char *name, char *fqpath, - int( **entryPoint ) ( int, ... ), - int ( *systemcalls )( int, ... ) ) { + intptr_t( **entryPoint ) ( int, ... ), + intptr_t ( *systemcalls )( intptr_t, ... ) ) { void *libHandle; - void ( *dllEntry )( int ( *syscallptr )( int, ... ) ); + void ( *dllEntry )( intptr_t ( *syscallptr )( intptr_t, ... ) ); char fname[MAX_OSPATH]; char *pwdpath; char *homepath; diff --git a/src/win32/win_main.c b/src/win32/win_main.c index f5d77c3..08e93c9 100644 --- a/src/win32/win_main.c +++ b/src/win32/win_main.c @@ -617,8 +617,8 @@ void * QDECL Sys_LoadDll( const char *name, char *fqpath, int( QDECL **entryPoin } } else {Q_strncpyz( fqpath, fn, MAX_QPATH ) ; // added 2/15/02 by T.Ray } - dllEntry = ( void ( QDECL * )( int ( QDECL * )( int, ... ) ) )GetProcAddress( libHandle, "dllEntry" ); - *entryPoint = ( int ( QDECL * )( int,... ) )GetProcAddress( libHandle, "vmMain" ); + dllEntry = ( void ( QDECL * )( intptr_t ( QDECL * )( intptr_t, ... ) ) )GetProcAddress( libHandle, "dllEntry" ); + *entryPoint = ( intptr_t ( QDECL * )( intptr_t,... ) )GetProcAddress( libHandle, "vmMain" ); if ( !*entryPoint || !dllEntry ) { FreeLibrary( libHandle ); return NULL; -- 1.6.4.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor