Fixed JIT on Linux
This commit is contained in:
parent
e73b3bbbb7
commit
32b07e4c0c
@ -1989,7 +1989,7 @@ err_stacklow:
|
||||
|
||||
_CHKMARGIN_STACK: ; some run-time check routines
|
||||
cmp esp,stp
|
||||
lea ebp,[esp-STACKRESERVE]
|
||||
lea ebp,[esp-STACKRESERVE]
|
||||
jg err_stacklow
|
||||
sub ebp,edi
|
||||
cmp hea,ebp
|
||||
|
Binary file not shown.
@ -64,13 +64,12 @@ while ($cmd = shift)
|
||||
$gcc = `$gccf --version`;
|
||||
if ($gcc =~ /2\.9/)
|
||||
{
|
||||
`ln -s amx.cpp amx.c`;
|
||||
push(@C_SOURCE_FILES, "amx.c");
|
||||
push(@CPP_SOURCE_FILES, "amx.cpp");
|
||||
$OPT{"opt"} .= " -malign-loops=2 -malign-jumps=2 -malign-functions=2";
|
||||
} else {
|
||||
if ($OPTIONS{"amd64"})
|
||||
{
|
||||
`cp amx.cpp amx.c`;
|
||||
`ln -s amx.cpp amx.c`;
|
||||
push(@C_SOURCE_FILES, "amx.c");
|
||||
} else {
|
||||
push(@CPP_SOURCE_FILES, "amx.cpp");
|
||||
@ -220,6 +219,6 @@ for ($i=0; $i<=$#CPP_SOURCE_FILES; $i++)
|
||||
}
|
||||
}
|
||||
|
||||
$gcc = "$gccf $cflags -Lzlib/ -shared -ldl -lm @LINK -lz -o $outdir/$bin";
|
||||
$gcc = "$gccf $cflags -Lzlib/ -shared -ldl -lstdc++ @LINK -lm -lz -o $outdir/$bin";
|
||||
print "$gcc\n";
|
||||
`$gcc`;
|
||||
|
@ -21,7 +21,7 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
// not used
|
||||
#define AMX_NODYNALOAD
|
||||
|
||||
// bad bad workaround but we have to prevent a compiler crash :/
|
||||
@ -51,27 +51,30 @@
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
#endif
|
||||
#if defined __LCC__ || defined __linux__
|
||||
#if defined __LCC__ || defined __GNUC__
|
||||
#include <wchar.h> /* for wcslen() */
|
||||
#endif
|
||||
#if (defined _Windows && !defined AMX_NODYNALOAD) || (defined JIT && !defined __linux__)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
// this file does not include amxmodx.h so we have to include the mem mngr here
|
||||
// this file does not include amxmodx.h, so we have to include the memory manager here
|
||||
#ifdef MEMORY_TEST
|
||||
#include "mmgr/mmgr.h"
|
||||
#endif //MEMORY_TEST
|
||||
#endif // MEMORY_TEST
|
||||
|
||||
#include "amx.h"
|
||||
|
||||
#ifdef JIT
|
||||
# ifdef __WIN32__
|
||||
# include <windows.h>
|
||||
# include <windows.h> // DWORD, VirtualProtect, ...
|
||||
# elif defined __linux__
|
||||
# include <sys/mman.h>
|
||||
# include <sys/mman.h> // mprotect, PROT_*
|
||||
# include <unistd.h>
|
||||
# else
|
||||
// :TODO:
|
||||
# endif
|
||||
#endif //JIT
|
||||
#endif // JIT
|
||||
|
||||
/* When one or more of the AMX_funcname macris are defined, we want
|
||||
* to compile only those functions. However, when none of these macros
|
||||
@ -477,14 +480,9 @@ int AMXAPI amx_Debug(AMX *amx)
|
||||
}
|
||||
|
||||
#if defined JIT
|
||||
#if _cplusplus
|
||||
extern "C" int AMXAPI getMaxCodeSize(void);
|
||||
extern "C" int AMXAPI asm_runJIT(void *sourceAMXbase, void *jumparray, void *compiledAMXbase);
|
||||
#else
|
||||
int AMXAPI getMaxCodeSize(void);
|
||||
int AMXAPI asm_runJIT(void *sourceAMXbase, void *jumparray, void *compiledAMXbase);
|
||||
#endif //_cplusplus
|
||||
#endif //JIT
|
||||
#endif
|
||||
|
||||
#if SMALL_CELL_SIZE==16
|
||||
#define JUMPABS(base,ip) ((cell *)(base+*ip))
|
||||
@ -540,19 +538,16 @@ static int amx_BrowseRelocate(AMX *amx)
|
||||
if (debug)
|
||||
amx->flags|=AMX_FLAG_DEBUG;
|
||||
|
||||
#if (defined __GNUC__ || defined ASM32 || defined JIT) && !defined __64BIT__
|
||||
#if defined __GNUC__ || defined ASM32 || defined JIT && !defined __64BIT__
|
||||
amx_Exec(amx, (cell*)&opcode_list, 0, 0);
|
||||
#if !defined JIT
|
||||
/* to use direct system requests, a function pointer must fit in a cell;
|
||||
* because the native function's address will be stored as the parameter
|
||||
* of SYSREQ.D
|
||||
*/
|
||||
amx->sysreq_d= (sizeof(AMX_NATIVE)<=sizeof(cell)) ? opcode_list[OP_SYSREQ_D] : 0;
|
||||
amx->sysreq_d=(sizeof(AMX_NATIVE)<=sizeof(cell)) ? opcode_list[OP_SYSREQ_D] : 0;
|
||||
#endif
|
||||
#else
|
||||
/* ANSI C
|
||||
* to use direct system requests, a function pointer must fit in a cell;
|
||||
* see the comment above
|
||||
* because the native function's address will be stored as the parameter
|
||||
* of SYSREQ.D
|
||||
*/
|
||||
amx->sysreq_d= (sizeof(AMX_NATIVE)<=sizeof(cell)) ? OP_SYSREQ_D : 0;
|
||||
#endif
|
||||
@ -1054,19 +1049,16 @@ int AMXAPI amx_Init(AMX *amx,void *program)
|
||||
}
|
||||
|
||||
#else /* #if defined __WIN32 __ */
|
||||
// DOS32 has no imposed limits on its segments.
|
||||
#if defined __BORLANDC__ || defined __WATCOMC__
|
||||
#pragma argsused
|
||||
#endif
|
||||
int memoryFullAccess( void* addr, int len ) { return 1; }
|
||||
|
||||
// TODO: Add cases for Linux, Unix, OS/2, ...
|
||||
|
||||
// DOS32 has no imposed limits on its segments.
|
||||
#if defined __BORLANDC__ || defined __WATCOMC__
|
||||
#pragma argsused
|
||||
#endif
|
||||
int memoryFullAccess( void* addr, int len ) { return 1; }
|
||||
|
||||
#if defined __BORLANDC__ || defined __WATCOMC__
|
||||
#pragma argsused
|
||||
#endif
|
||||
int memorySetAccess( void* addr, int len, int access ) { return 1; }
|
||||
#if defined __BORLANDC__ || defined __WATCOMC__
|
||||
#pragma argsused
|
||||
#endif
|
||||
int memorySetAccess( void* addr, int len, int access ) { return 1; }
|
||||
|
||||
#endif /* #if defined __WIN32 __ */
|
||||
|
||||
@ -1108,7 +1100,7 @@ int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code)
|
||||
*(cell *)((char*)native_code + hdr->dat + hdr->stp - sizeof(cell)) = 0;
|
||||
amx->stk = amx->stp;
|
||||
|
||||
memorySetAccess( asm_runJIT, 20000, mac );
|
||||
memorySetAccess( (void*)asm_runJIT, 20000, mac );
|
||||
return AMX_ERR_NONE;
|
||||
}
|
||||
|
||||
@ -1578,8 +1570,7 @@ static AMX_NATIVE findfunction(const char *name, AMX_NATIVE_INFO *list, int numb
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *no_function;
|
||||
|
||||
const char *no_function; // PM: Nice hack ;)
|
||||
int AMXAPI amx_Register(AMX *amx, AMX_NATIVE_INFO *list, int number)
|
||||
{
|
||||
AMX_FUNCSTUB *func;
|
||||
@ -1599,15 +1590,11 @@ int AMXAPI amx_Register(AMX *amx, AMX_NATIVE_INFO *list, int number)
|
||||
if (func->address==0) {
|
||||
/* this function is not yet located */
|
||||
funcptr=(list!=NULL) ? findfunction(GETENTRYNAME(hdr,func),list,number) : NULL;
|
||||
/* on 64-bit architectures with, only the lower 32-bits of the address
|
||||
* can be stored; hopefully, all addresses can be assumed to have the
|
||||
* same value for the upper 32-bits
|
||||
*/
|
||||
if (funcptr!=NULL)
|
||||
func->address=(ucell)funcptr;
|
||||
else
|
||||
{
|
||||
no_function = GETENTRYNAME(hdr,func);
|
||||
no_function = GETENTRYNAME(hdr,func);
|
||||
err=AMX_ERR_NOTFOUND;
|
||||
}
|
||||
} /* if */
|
||||
@ -1639,7 +1626,7 @@ AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func)
|
||||
#define CHKSTACK() if (stk>amx->stp) return AMX_ERR_STACKLOW
|
||||
#define CHKHEAP() if (hea<amx->hlw) return AMX_ERR_HEAPLOW
|
||||
|
||||
#if defined __GNUC__ && !defined ASM32
|
||||
#if defined __GNUC__ && !defined ASM32 && !defined JIT
|
||||
/* GNU C version uses the "labels as values" extension to create
|
||||
* fast "indirect threaded" interpreter.
|
||||
*/
|
||||
@ -2750,7 +2737,7 @@ static void *amx_opcodelist_nodebug[] = {
|
||||
|
||||
#if defined ASM32 || defined JIT
|
||||
extern "C" void *amx_opcodelist[];
|
||||
extern "C" void *amx_opcodelist_nodebug[];
|
||||
extern "C" void *amx_opcodelist_nodebug[];
|
||||
#endif
|
||||
|
||||
int AMXAPI amx_Exec(AMX *amx, cell *retval, int index, int numparams, ...)
|
||||
@ -4044,7 +4031,7 @@ static long utf8_lowmark[5] = { 0x80, 0x800, 0x10000, 0x200000, 0x4000000 };
|
||||
*/
|
||||
if (result<utf8_lowmark[followup])
|
||||
goto error;
|
||||
if (result>=0xd800 && result<=0xdfff || result==0xfffe || result==0xffff)
|
||||
if ((result>=0xd800 && result<=0xdfff) || result==0xfffe || result==0xffff)
|
||||
goto error;
|
||||
} /* if */
|
||||
|
||||
|
@ -22,14 +22,12 @@
|
||||
*/
|
||||
|
||||
#if defined __linux__
|
||||
#include "sclinux.h"
|
||||
#include <sclinux.h>
|
||||
#endif
|
||||
|
||||
#ifndef AMX_H_INCLUDED
|
||||
#define AMX_H_INCLUDED
|
||||
|
||||
//#define JIT
|
||||
|
||||
#if defined __LCC__ || defined __DMC__ || defined __linux__
|
||||
#include <stdint.h>
|
||||
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
|
||||
@ -337,6 +335,7 @@ uint32_t * AMXAPI amx_Align32(uint32_t *v);
|
||||
#if defined _I64_MAX || defined HAVE_I64
|
||||
uint64_t * AMXAPI amx_Align64(uint64_t *v);
|
||||
#endif
|
||||
|
||||
#if SMALL_CELL_SIZE==32
|
||||
#define amx_AlignCell amx_Align32
|
||||
#elif SMALL_CELL_SIZE==64
|
||||
@ -344,6 +343,7 @@ uint32_t * AMXAPI amx_Align32(uint32_t *v);
|
||||
#else
|
||||
#error Unsupported cell size
|
||||
#endif
|
||||
|
||||
int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr);
|
||||
int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params);
|
||||
int AMXAPI amx_Cleanup(AMX *amx);
|
||||
|
@ -165,8 +165,13 @@ void amx_command(){
|
||||
}
|
||||
|
||||
print_srvconsole( "%d modules, %d correct\n",modules,running);
|
||||
}
|
||||
else if (!strcmp(cmd, "gpl"))
|
||||
} else if (!strcmp(cmd, "jit")) {
|
||||
#ifdef JIT
|
||||
print_srvconsole("Using the JIT.\n");
|
||||
#else
|
||||
print_srvconsole("Not using the JIT.\n");
|
||||
#endif
|
||||
} else if (!strcmp(cmd, "gpl"))
|
||||
{
|
||||
print_srvconsole("AMX Mod X\n");
|
||||
print_srvconsole("\n");
|
||||
|
Loading…
Reference in New Issue
Block a user