mirror of
https://github.com/alliedmodders/amxmodx.git
synced 2025-01-12 06:48:04 +03:00
Touching up new system for linux support
This commit is contained in:
parent
a7fb4e85c9
commit
13ed6ed2d6
@ -89,8 +89,8 @@ public:
|
|||||||
inline void setAuthor( const char* n ) { author.assign(n); }
|
inline void setAuthor( const char* n ) { author.assign(n); }
|
||||||
inline void setVersion( const char* n ) { version.assign(n); }
|
inline void setVersion( const char* n ) { version.assign(n); }
|
||||||
inline void setError( const char* n ) { errorMsg.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 isValid() const { return ((status == ps_running) && (status != ps_locked)); }
|
||||||
inline bool isPaused() const { return ( (status == ps_paused) || (status == ps_stopped)); }
|
inline bool isPaused() const { return ( (status == ps_paused) ); }
|
||||||
//inline bool isFunctionPaused( int id ) const { return (paused_fun & (1<<id)) ? true : false; }
|
//inline bool isFunctionPaused( int id ) const { return (paused_fun & (1<<id)) ? true : false; }
|
||||||
inline bool isExecutable(int id) const { return (isValid() && !isPaused()); }
|
inline bool isExecutable(int id) const { return (isValid() && !isPaused()); }
|
||||||
void Finalize();
|
void Finalize();
|
||||||
|
@ -15,7 +15,7 @@ OBJECTS = meta_api.cpp CFile.cpp CVault.cpp vault.cpp float.cpp file.cpp modules
|
|||||||
CMisc.cpp CTask.cpp string.cpp amxmodx.cpp CEvent.cpp CCmd.cpp CLogEvent.cpp \
|
CMisc.cpp CTask.cpp string.cpp amxmodx.cpp CEvent.cpp CCmd.cpp CLogEvent.cpp \
|
||||||
srvcmd.cpp strptime.cpp amxcore.cpp amxtime.cpp power.cpp amxxlog.cpp fakemeta.cpp \
|
srvcmd.cpp strptime.cpp amxcore.cpp amxtime.cpp power.cpp amxxlog.cpp fakemeta.cpp \
|
||||||
amxxfile.cpp CLang.cpp md5.cpp emsg.cpp CForward.cpp CPlugin.cpp CModule.cpp \
|
amxxfile.cpp CLang.cpp md5.cpp emsg.cpp CForward.cpp CPlugin.cpp CModule.cpp \
|
||||||
CMenu.cpp util.cpp amx.cpp amxdbg.cpp
|
CMenu.cpp util.cpp amx.cpp amxdbg.cpp natives.cpp newmenus.cpp \
|
||||||
|
|
||||||
LINK = -lz
|
LINK = -lz
|
||||||
|
|
||||||
@ -38,10 +38,12 @@ CFLAGS += -DLINUX -DNDEBUG -fPIC -Wno-deprecated -fno-exceptions -DHAVE_STDINT_H
|
|||||||
|
|
||||||
ifeq "$(AMD64)" "true"
|
ifeq "$(AMD64)" "true"
|
||||||
BINARY = $(NAME)_amd64.so
|
BINARY = $(NAME)_amd64.so
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -m64
|
||||||
|
OBJECTS += JIT/natives-amd64.o
|
||||||
|
LINK += -lstdc++
|
||||||
else
|
else
|
||||||
BINARY = $(NAME)_i386.so
|
BINARY = $(NAME)_i386.so
|
||||||
OBJECTS += JIT/amxexecn.o JIT/amxjitsn.o
|
OBJECTS += JIT/amxexecn.o JIT/amxjitsn.o JIT/natives-x86.o
|
||||||
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
|
CFLAGS += -DPAWN_CELL_SIZE=32 -DJIT -DASM32
|
||||||
OPT_FLAGS += -march=i686
|
OPT_FLAGS += -march=i686
|
||||||
endif
|
endif
|
||||||
|
@ -377,12 +377,16 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
|
|||||||
|
|
||||||
if (will_be_debugged)
|
if (will_be_debugged)
|
||||||
{
|
{
|
||||||
|
#ifdef JIT
|
||||||
amx->flags |= AMX_FLAG_DEBUG;
|
amx->flags |= AMX_FLAG_DEBUG;
|
||||||
|
#endif
|
||||||
amx_SetDebugHook(amx, amxx_DebugHook);
|
amx_SetDebugHook(amx, amxx_DebugHook);
|
||||||
} else {
|
} else {
|
||||||
//set this again because amx_Init() erases it!
|
//set this again because amx_Init() erases it!
|
||||||
|
#ifdef JIT
|
||||||
amx->flags |= AMX_FLAG_JITC;
|
amx->flags |= AMX_FLAG_JITC;
|
||||||
amx->sysreq_d = NULL;
|
amx->sysreq_d = NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef JIT
|
#ifdef JIT
|
||||||
|
@ -20,7 +20,8 @@ global amxx_DynaInit, _amxx_DynaInit
|
|||||||
amxx_DynaInit:
|
amxx_DynaInit:
|
||||||
_amxx_DynaInit:
|
_amxx_DynaInit:
|
||||||
mov rax, rdi ;get pointer, first param is in rdi
|
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
|
mov rax, 1
|
||||||
ret
|
ret
|
||||||
@ -67,7 +68,7 @@ _amxx_DynaFuncStart:
|
|||||||
;this old trick, we'll move in the real pointer in a bit.
|
;this old trick, we'll move in the real pointer in a bit.
|
||||||
_amxx_DynaMoveOffset:
|
_amxx_DynaMoveOffset:
|
||||||
mov rsi, qword 1234567812345678h
|
mov rsi, qword 1234567812345678h
|
||||||
call [GLOBAL_GATE] ;pass through teh global gateway.
|
call [GLOBAL_GATE wrt rip] ;pass through teh global gateway.
|
||||||
|
|
||||||
pop rbp
|
pop rbp
|
||||||
ret
|
ret
|
||||||
@ -83,3 +84,4 @@ _amxx_DynaCodesize:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
GLOBAL_GATE DQ 0
|
GLOBAL_GATE DQ 0
|
||||||
|
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
#include "amxmodx.h"
|
#include "amxmodx.h"
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include "CStack.h"
|
#include "CStack.h"
|
||||||
#include "natives.h"
|
#include "natives.h"
|
||||||
|
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
CVector<regnative *> g_RegNatives;
|
CVector<regnative *> g_RegNatives;
|
||||||
CStack<regnative *> g_NativeStack;
|
CStack<regnative *> g_NativeStack;
|
||||||
CVector<String> g_Libraries;
|
CVector<String> g_Libraries;
|
||||||
@ -76,7 +82,7 @@ AMX_NATIVE_INFO *BuildNativeTable()
|
|||||||
{
|
{
|
||||||
pNative = g_RegNatives[i];
|
pNative = g_RegNatives[i];
|
||||||
info.name = pNative->name.c_str();
|
info.name = pNative->name.c_str();
|
||||||
info.func = reinterpret_cast<AMX_NATIVE>(pNative->pfn);
|
info.func = (AMX_NATIVE)((void *)(pNative->pfn));
|
||||||
pNatives[i] = info;
|
pNatives[i] = info;
|
||||||
}
|
}
|
||||||
pNatives[g_RegNatives.size()].name = NULL;
|
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)
|
static cell AMX_NATIVE_CALL register_native(AMX *amx, cell *params)
|
||||||
{
|
{
|
||||||
if (!g_Initialized)
|
if (!g_Initialized)
|
||||||
amxx_DynaInit(static_cast<void *>(amxx_DynaCallback));
|
amxx_DynaInit((void *)(amxx_DynaCallback));
|
||||||
|
|
||||||
g_Initialized = true;
|
g_Initialized = true;
|
||||||
|
|
||||||
@ -328,7 +334,7 @@ static cell AMX_NATIVE_CALL register_native(AMX *amx, cell *params)
|
|||||||
pNative->pfn = new char[size + 10];
|
pNative->pfn = new char[size + 10];
|
||||||
VirtualProtect(pNative->pfn, size+10, PAGE_EXECUTE_READWRITE, &temp);
|
VirtualProtect(pNative->pfn, size+10, PAGE_EXECUTE_READWRITE, &temp);
|
||||||
#else
|
#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);
|
mprotect((void *)pNative->pfn, size+10, PROT_READ|PROT_WRITE|PROT_EXEC);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user