From 13ed6ed2d6a6fe2bcee10af99e268a1938d5f144 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sun, 31 Jul 2005 22:16:54 +0000 Subject: [PATCH] Touching up new system for linux support --- amxmodx/CPlugin.h | 4 ++-- amxmodx/Makefile | 8 +++++--- amxmodx/modules.cpp | 4 ++++ amxmodx/natives-amd64.asm | 6 ++++-- amxmodx/natives.cpp | 12 +++++++++--- 5 files changed, 24 insertions(+), 10 deletions(-) diff --git a/amxmodx/CPlugin.h b/amxmodx/CPlugin.h index 8d4df856..897cfc12 100755 --- a/amxmodx/CPlugin.h +++ b/amxmodx/CPlugin.h @@ -89,8 +89,8 @@ public: inline void setAuthor( const char* n ) { author.assign(n); } inline void setVersion( const char* n ) { version.assign(n); } inline void setError( const char* n ) { errorMsg.assign(n); } - inline bool isValid() const { return ((status != ps_bad_load) && (status != ps_locked)); } - inline bool isPaused() const { return ( (status == ps_paused) || (status == ps_stopped)); } + inline bool isValid() const { return ((status == ps_running) && (status != ps_locked)); } + inline bool isPaused() const { return ( (status == ps_paused) ); } //inline bool isFunctionPaused( int id ) const { return (paused_fun & (1<flags |= AMX_FLAG_DEBUG; +#endif amx_SetDebugHook(amx, amxx_DebugHook); } else { //set this again because amx_Init() erases it! +#ifdef JIT amx->flags |= AMX_FLAG_JITC; amx->sysreq_d = NULL; +#endif } #ifdef JIT diff --git a/amxmodx/natives-amd64.asm b/amxmodx/natives-amd64.asm index 446233a7..862ea325 100755 --- a/amxmodx/natives-amd64.asm +++ b/amxmodx/natives-amd64.asm @@ -20,7 +20,8 @@ global amxx_DynaInit, _amxx_DynaInit amxx_DynaInit: _amxx_DynaInit: mov rax, rdi ;get pointer, first param is in rdi - mov [GLOBAL_GATE], rax ;store + lea rdi, [GLOBAL_GATE wrt rip] + mov [rdi], rax ;store mov rax, 1 ret @@ -67,7 +68,7 @@ _amxx_DynaFuncStart: ;this old trick, we'll move in the real pointer in a bit. _amxx_DynaMoveOffset: mov rsi, qword 1234567812345678h - call [GLOBAL_GATE] ;pass through teh global gateway. + call [GLOBAL_GATE wrt rip] ;pass through teh global gateway. pop rbp ret @@ -83,3 +84,4 @@ _amxx_DynaCodesize: ret GLOBAL_GATE DQ 0 + diff --git a/amxmodx/natives.cpp b/amxmodx/natives.cpp index 53e4ac25..9b8af5dd 100755 --- a/amxmodx/natives.cpp +++ b/amxmodx/natives.cpp @@ -1,7 +1,13 @@ #include "amxmodx.h" +#include +#include #include "CStack.h" #include "natives.h" +#ifdef __linux__ +#include +#endif + CVector g_RegNatives; CStack g_NativeStack; CVector g_Libraries; @@ -76,7 +82,7 @@ AMX_NATIVE_INFO *BuildNativeTable() { pNative = g_RegNatives[i]; info.name = pNative->name.c_str(); - info.func = reinterpret_cast(pNative->pfn); + info.func = (AMX_NATIVE)((void *)(pNative->pfn)); pNatives[i] = info; } pNatives[g_RegNatives.size()].name = NULL; @@ -301,7 +307,7 @@ static cell AMX_NATIVE_CALL register_library(AMX *amx, cell *params) static cell AMX_NATIVE_CALL register_native(AMX *amx, cell *params) { if (!g_Initialized) - amxx_DynaInit(static_cast(amxx_DynaCallback)); + amxx_DynaInit((void *)(amxx_DynaCallback)); g_Initialized = true; @@ -328,7 +334,7 @@ static cell AMX_NATIVE_CALL register_native(AMX *amx, cell *params) pNative->pfn = new char[size + 10]; VirtualProtect(pNative->pfn, size+10, PAGE_EXECUTE_READWRITE, &temp); #else - pNative->pfn = (unsigned char *)memalign(sysconf(_SC_PAGESIZE), amx->code_size); + pNative->pfn = (char *)memalign(sysconf(_SC_PAGESIZE), amx->code_size); mprotect((void *)pNative->pfn, size+10, PROT_READ|PROT_WRITE|PROT_EXEC); #endif