From 0c84e4bff3ee8db9a6b8cb89af39ef2870ec0b90 Mon Sep 17 00:00:00 2001 From: dhewg Date: Thu, 1 Dec 2011 10:40:40 +0100 Subject: [PATCH] Fix shared library loading for x86_64 Library handles are "void *" on posix. --- neo/TypeInfo/main.cpp | 6 +++--- neo/d3xp/anim/Anim_Import.cpp | 2 +- neo/framework/Common.cpp | 2 +- neo/game/anim/Anim_Import.cpp | 2 +- neo/sys/posix/posix_main.cpp | 8 ++++---- neo/sys/sys_local.cpp | 6 +++--- neo/sys/sys_local.h | 6 +++--- neo/sys/sys_public.h | 12 ++++++------ neo/sys/win32/win_main.cpp | 8 ++++---- 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/neo/TypeInfo/main.cpp b/neo/TypeInfo/main.cpp index e4a3ccf9..5cb9bf60 100644 --- a/neo/TypeInfo/main.cpp +++ b/neo/TypeInfo/main.cpp @@ -226,9 +226,9 @@ const char * idSysLocal::GetCallStackStr( const address_t *callStack, const int const char * idSysLocal::GetCallStackCurStr( int depth ) { return ""; } void idSysLocal::ShutdownSymbols( void ) {} -int idSysLocal::DLL_Load( const char *dllName ) { return 0; } -void * idSysLocal::DLL_GetProcAddress( int dllHandle, const char *procName ) { return NULL; } -void idSysLocal::DLL_Unload( int dllHandle ) { } +uintptr_t idSysLocal::DLL_Load( const char *dllName ) { return 0; } +void * idSysLocal::DLL_GetProcAddress( uintptr_t dllHandle, const char *procName ) { return NULL; } +void idSysLocal::DLL_Unload( uintptr_t dllHandle ) { } void idSysLocal::DLL_GetFileName( const char *baseName, char *dllName, int maxLength ) { } sysEvent_t idSysLocal::GenerateMouseButtonEvent( int button, bool down ) { sysEvent_t ev; memset( &ev, 0, sizeof( ev ) ); return ev; } diff --git a/neo/d3xp/anim/Anim_Import.cpp b/neo/d3xp/anim/Anim_Import.cpp index 80d05714..49dee842 100644 --- a/neo/d3xp/anim/Anim_Import.cpp +++ b/neo/d3xp/anim/Anim_Import.cpp @@ -42,7 +42,7 @@ static idStr Maya_Error; static exporterInterface_t Maya_ConvertModel = NULL; static exporterShutdown_t Maya_Shutdown = NULL; -static int importDLL = 0; +static uintptr_t importDLL = 0; bool idModelExport::initialized = false; diff --git a/neo/framework/Common.cpp b/neo/framework/Common.cpp index 21c01737..468ecc67 100644 --- a/neo/framework/Common.cpp +++ b/neo/framework/Common.cpp @@ -193,7 +193,7 @@ private: idStrList warningList; idStrList errorList; - int gameDLL; + uintptr_t gameDLL; idLangDict languageDict; diff --git a/neo/game/anim/Anim_Import.cpp b/neo/game/anim/Anim_Import.cpp index cf97f92b..6a7bf3b9 100644 --- a/neo/game/anim/Anim_Import.cpp +++ b/neo/game/anim/Anim_Import.cpp @@ -42,7 +42,7 @@ static idStr Maya_Error; static exporterInterface_t Maya_ConvertModel = NULL; static exporterShutdown_t Maya_Shutdown = NULL; -static int importDLL = 0; +static uintptr_t importDLL = 0; bool idModelExport::initialized = false; diff --git a/neo/sys/posix/posix_main.cpp b/neo/sys/posix/posix_main.cpp index 7f64994f..a7932dd1 100644 --- a/neo/sys/posix/posix_main.cpp +++ b/neo/sys/posix/posix_main.cpp @@ -387,12 +387,12 @@ Sys_DLL_Load TODO: OSX - use the native API instead? NSModule ================= */ -int Sys_DLL_Load( const char *path ) { +uintptr_t Sys_DLL_Load( const char *path ) { void *handle = dlopen( path, RTLD_NOW ); if ( !handle ) { Sys_Printf( "dlopen '%s' failed: %s\n", path, dlerror() ); } - return (int)handle; + return (uintptr_t)handle; } /* @@ -400,7 +400,7 @@ int Sys_DLL_Load( const char *path ) { Sys_DLL_GetProcAddress ================= */ -void* Sys_DLL_GetProcAddress( int handle, const char *sym ) { +void* Sys_DLL_GetProcAddress( uintptr_t handle, const char *sym ) { const char *error; void *ret = dlsym( (void *)handle, sym ); if ((error = dlerror()) != NULL) { @@ -414,7 +414,7 @@ void* Sys_DLL_GetProcAddress( int handle, const char *sym ) { Sys_DLL_Unload ================= */ -void Sys_DLL_Unload( int handle ) { +void Sys_DLL_Unload( uintptr_t handle ) { dlclose( (void *)handle ); } diff --git a/neo/sys/sys_local.cpp b/neo/sys/sys_local.cpp index 0cfca73e..d4785ea0 100644 --- a/neo/sys/sys_local.cpp +++ b/neo/sys/sys_local.cpp @@ -108,15 +108,15 @@ void idSysLocal::ShutdownSymbols( void ) { Sys_ShutdownSymbols(); } -int idSysLocal::DLL_Load( const char *dllName ) { +uintptr_t idSysLocal::DLL_Load( const char *dllName ) { return Sys_DLL_Load( dllName ); } -void *idSysLocal::DLL_GetProcAddress( int dllHandle, const char *procName ) { +void *idSysLocal::DLL_GetProcAddress( uintptr_t dllHandle, const char *procName ) { return Sys_DLL_GetProcAddress( dllHandle, procName ); } -void idSysLocal::DLL_Unload( int dllHandle ) { +void idSysLocal::DLL_Unload( uintptr_t dllHandle ) { Sys_DLL_Unload( dllHandle ); } diff --git a/neo/sys/sys_local.h b/neo/sys/sys_local.h index 16b5134b..8bb79ba8 100644 --- a/neo/sys/sys_local.h +++ b/neo/sys/sys_local.h @@ -61,9 +61,9 @@ public: virtual bool LockMemory( void *ptr, int bytes ); virtual bool UnlockMemory( void *ptr, int bytes ); - virtual int DLL_Load( const char *dllName ); - virtual void * DLL_GetProcAddress( int dllHandle, const char *procName ); - virtual void DLL_Unload( int dllHandle ); + virtual uintptr_t DLL_Load( const char *dllName ); + virtual void * DLL_GetProcAddress( uintptr_t dllHandle, const char *procName ); + virtual void DLL_Unload( uintptr_t dllHandle ); virtual void DLL_GetFileName( const char *baseName, char *dllName, int maxLength ); virtual sysEvent_t GenerateMouseButtonEvent( int button, bool down ); diff --git a/neo/sys/sys_public.h b/neo/sys/sys_public.h index 3df930d4..ba5d90fb 100644 --- a/neo/sys/sys_public.h +++ b/neo/sys/sys_public.h @@ -331,9 +331,9 @@ const char * Sys_GetCallStackCurAddressStr( int depth ); void Sys_ShutdownSymbols( void ); // DLL loading, the path should be a fully qualified OS path to the DLL file to be loaded -int Sys_DLL_Load( const char *dllName ); -void * Sys_DLL_GetProcAddress( int dllHandle, const char *procName ); -void Sys_DLL_Unload( int dllHandle ); +uintptr_t Sys_DLL_Load( const char *dllName ); +void * Sys_DLL_GetProcAddress( uintptr_t dllHandle, const char *procName ); +void Sys_DLL_Unload( uintptr_t dllHandle ); // event generation void Sys_GenerateEvents( void ); @@ -563,9 +563,9 @@ public: virtual const char * GetCallStackCurStr( int depth ) = 0; virtual void ShutdownSymbols( void ) = 0; - virtual int DLL_Load( const char *dllName ) = 0; - virtual void * DLL_GetProcAddress( int dllHandle, const char *procName ) = 0; - virtual void DLL_Unload( int dllHandle ) = 0; + virtual uintptr_t DLL_Load( const char *dllName ) = 0; + virtual void * DLL_GetProcAddress( uintptr_t dllHandle, const char *procName ) = 0; + virtual void DLL_Unload( uintptr_t dllHandle ) = 0; virtual void DLL_GetFileName( const char *baseName, char *dllName, int maxLength ) = 0; virtual sysEvent_t GenerateMouseButtonEvent( int button, bool down ) = 0; diff --git a/neo/sys/win32/win_main.cpp b/neo/sys/win32/win_main.cpp index bd871199..773f5be4 100644 --- a/neo/sys/win32/win_main.cpp +++ b/neo/sys/win32/win_main.cpp @@ -655,7 +655,7 @@ DLL Loading Sys_DLL_Load ===================== */ -int Sys_DLL_Load( const char *dllName ) { +uintptr_t Sys_DLL_Load( const char *dllName ) { HINSTANCE libHandle; libHandle = LoadLibrary( dllName ); if ( libHandle ) { @@ -668,7 +668,7 @@ int Sys_DLL_Load( const char *dllName ) { return 0; } } - return (int)libHandle; + return (uintptr_t)libHandle; } /* @@ -676,7 +676,7 @@ int Sys_DLL_Load( const char *dllName ) { Sys_DLL_GetProcAddress ===================== */ -void *Sys_DLL_GetProcAddress( int dllHandle, const char *procName ) { +void *Sys_DLL_GetProcAddress( uintptr_t dllHandle, const char *procName ) { return GetProcAddress( (HINSTANCE)dllHandle, procName ); } @@ -685,7 +685,7 @@ void *Sys_DLL_GetProcAddress( int dllHandle, const char *procName ) { Sys_DLL_Unload ===================== */ -void Sys_DLL_Unload( int dllHandle ) { +void Sys_DLL_Unload( uintptr_t dllHandle ) { if ( !dllHandle ) { return; }