Fixed JIT on Linux
This commit is contained in:
parent
e73b3bbbb7
commit
32b07e4c0c
Binary file not shown.
@ -64,13 +64,12 @@ while ($cmd = shift)
|
|||||||
$gcc = `$gccf --version`;
|
$gcc = `$gccf --version`;
|
||||||
if ($gcc =~ /2\.9/)
|
if ($gcc =~ /2\.9/)
|
||||||
{
|
{
|
||||||
`ln -s amx.cpp amx.c`;
|
push(@CPP_SOURCE_FILES, "amx.cpp");
|
||||||
push(@C_SOURCE_FILES, "amx.c");
|
|
||||||
$OPT{"opt"} .= " -malign-loops=2 -malign-jumps=2 -malign-functions=2";
|
$OPT{"opt"} .= " -malign-loops=2 -malign-jumps=2 -malign-functions=2";
|
||||||
} else {
|
} else {
|
||||||
if ($OPTIONS{"amd64"})
|
if ($OPTIONS{"amd64"})
|
||||||
{
|
{
|
||||||
`cp amx.cpp amx.c`;
|
`ln -s amx.cpp amx.c`;
|
||||||
push(@C_SOURCE_FILES, "amx.c");
|
push(@C_SOURCE_FILES, "amx.c");
|
||||||
} else {
|
} else {
|
||||||
push(@CPP_SOURCE_FILES, "amx.cpp");
|
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";
|
print "$gcc\n";
|
||||||
`$gcc`;
|
`$gcc`;
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
* Version: $Id$
|
* Version: $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
// not used
|
||||||
#define AMX_NODYNALOAD
|
#define AMX_NODYNALOAD
|
||||||
|
|
||||||
// bad bad workaround but we have to prevent a compiler crash :/
|
// bad bad workaround but we have to prevent a compiler crash :/
|
||||||
@ -51,11 +51,14 @@
|
|||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined __LCC__ || defined __linux__
|
#if defined __LCC__ || defined __GNUC__
|
||||||
#include <wchar.h> /* for wcslen() */
|
#include <wchar.h> /* for wcslen() */
|
||||||
#endif
|
#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
|
#ifdef MEMORY_TEST
|
||||||
#include "mmgr/mmgr.h"
|
#include "mmgr/mmgr.h"
|
||||||
#endif // MEMORY_TEST
|
#endif // MEMORY_TEST
|
||||||
@ -64,9 +67,9 @@
|
|||||||
|
|
||||||
#ifdef JIT
|
#ifdef JIT
|
||||||
# ifdef __WIN32__
|
# ifdef __WIN32__
|
||||||
# include <windows.h>
|
# include <windows.h> // DWORD, VirtualProtect, ...
|
||||||
# elif defined __linux__
|
# elif defined __linux__
|
||||||
# include <sys/mman.h>
|
# include <sys/mman.h> // mprotect, PROT_*
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# else
|
# else
|
||||||
// :TODO:
|
// :TODO:
|
||||||
@ -477,14 +480,9 @@ int AMXAPI amx_Debug(AMX *amx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined JIT
|
#if defined JIT
|
||||||
#if _cplusplus
|
|
||||||
extern "C" int AMXAPI getMaxCodeSize(void);
|
extern "C" int AMXAPI getMaxCodeSize(void);
|
||||||
extern "C" int AMXAPI asm_runJIT(void *sourceAMXbase, void *jumparray, void *compiledAMXbase);
|
extern "C" int AMXAPI asm_runJIT(void *sourceAMXbase, void *jumparray, void *compiledAMXbase);
|
||||||
#else
|
#endif
|
||||||
int AMXAPI getMaxCodeSize(void);
|
|
||||||
int AMXAPI asm_runJIT(void *sourceAMXbase, void *jumparray, void *compiledAMXbase);
|
|
||||||
#endif //_cplusplus
|
|
||||||
#endif //JIT
|
|
||||||
|
|
||||||
#if SMALL_CELL_SIZE==16
|
#if SMALL_CELL_SIZE==16
|
||||||
#define JUMPABS(base,ip) ((cell *)(base+*ip))
|
#define JUMPABS(base,ip) ((cell *)(base+*ip))
|
||||||
@ -540,19 +538,16 @@ static int amx_BrowseRelocate(AMX *amx)
|
|||||||
if (debug)
|
if (debug)
|
||||||
amx->flags|=AMX_FLAG_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);
|
amx_Exec(amx, (cell*)&opcode_list, 0, 0);
|
||||||
#if !defined JIT
|
#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
|
#endif
|
||||||
#else
|
#else
|
||||||
/* ANSI C
|
/* ANSI C
|
||||||
* to use direct system requests, a function pointer must fit in a cell;
|
* 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;
|
amx->sysreq_d= (sizeof(AMX_NATIVE)<=sizeof(cell)) ? OP_SYSREQ_D : 0;
|
||||||
#endif
|
#endif
|
||||||
@ -1054,9 +1049,6 @@ int AMXAPI amx_Init(AMX *amx,void *program)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else /* #if defined __WIN32 __ */
|
#else /* #if defined __WIN32 __ */
|
||||||
|
|
||||||
// TODO: Add cases for Linux, Unix, OS/2, ...
|
|
||||||
|
|
||||||
// DOS32 has no imposed limits on its segments.
|
// DOS32 has no imposed limits on its segments.
|
||||||
#if defined __BORLANDC__ || defined __WATCOMC__
|
#if defined __BORLANDC__ || defined __WATCOMC__
|
||||||
#pragma argsused
|
#pragma argsused
|
||||||
@ -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;
|
*(cell *)((char*)native_code + hdr->dat + hdr->stp - sizeof(cell)) = 0;
|
||||||
amx->stk = amx->stp;
|
amx->stk = amx->stp;
|
||||||
|
|
||||||
memorySetAccess( asm_runJIT, 20000, mac );
|
memorySetAccess( (void*)asm_runJIT, 20000, mac );
|
||||||
return AMX_ERR_NONE;
|
return AMX_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1578,8 +1570,7 @@ static AMX_NATIVE findfunction(const char *name, AMX_NATIVE_INFO *list, int numb
|
|||||||
return NULL;
|
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)
|
int AMXAPI amx_Register(AMX *amx, AMX_NATIVE_INFO *list, int number)
|
||||||
{
|
{
|
||||||
AMX_FUNCSTUB *func;
|
AMX_FUNCSTUB *func;
|
||||||
@ -1599,10 +1590,6 @@ int AMXAPI amx_Register(AMX *amx, AMX_NATIVE_INFO *list, int number)
|
|||||||
if (func->address==0) {
|
if (func->address==0) {
|
||||||
/* this function is not yet located */
|
/* this function is not yet located */
|
||||||
funcptr=(list!=NULL) ? findfunction(GETENTRYNAME(hdr,func),list,number) : NULL;
|
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)
|
if (funcptr!=NULL)
|
||||||
func->address=(ucell)funcptr;
|
func->address=(ucell)funcptr;
|
||||||
else
|
else
|
||||||
@ -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 CHKSTACK() if (stk>amx->stp) return AMX_ERR_STACKLOW
|
||||||
#define CHKHEAP() if (hea<amx->hlw) return AMX_ERR_HEAPLOW
|
#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
|
/* GNU C version uses the "labels as values" extension to create
|
||||||
* fast "indirect threaded" interpreter.
|
* fast "indirect threaded" interpreter.
|
||||||
*/
|
*/
|
||||||
@ -4044,7 +4031,7 @@ static long utf8_lowmark[5] = { 0x80, 0x800, 0x10000, 0x200000, 0x4000000 };
|
|||||||
*/
|
*/
|
||||||
if (result<utf8_lowmark[followup])
|
if (result<utf8_lowmark[followup])
|
||||||
goto error;
|
goto error;
|
||||||
if (result>=0xd800 && result<=0xdfff || result==0xfffe || result==0xffff)
|
if ((result>=0xd800 && result<=0xdfff) || result==0xfffe || result==0xffff)
|
||||||
goto error;
|
goto error;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
||||||
|
@ -22,14 +22,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined __linux__
|
#if defined __linux__
|
||||||
#include "sclinux.h"
|
#include <sclinux.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef AMX_H_INCLUDED
|
#ifndef AMX_H_INCLUDED
|
||||||
#define AMX_H_INCLUDED
|
#define AMX_H_INCLUDED
|
||||||
|
|
||||||
//#define JIT
|
|
||||||
|
|
||||||
#if defined __LCC__ || defined __DMC__ || defined __linux__
|
#if defined __LCC__ || defined __DMC__ || defined __linux__
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
|
#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
|
#if defined _I64_MAX || defined HAVE_I64
|
||||||
uint64_t * AMXAPI amx_Align64(uint64_t *v);
|
uint64_t * AMXAPI amx_Align64(uint64_t *v);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SMALL_CELL_SIZE==32
|
#if SMALL_CELL_SIZE==32
|
||||||
#define amx_AlignCell amx_Align32
|
#define amx_AlignCell amx_Align32
|
||||||
#elif SMALL_CELL_SIZE==64
|
#elif SMALL_CELL_SIZE==64
|
||||||
@ -344,6 +343,7 @@ uint32_t * AMXAPI amx_Align32(uint32_t *v);
|
|||||||
#else
|
#else
|
||||||
#error Unsupported cell size
|
#error Unsupported cell size
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr);
|
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_Callback(AMX *amx, cell index, cell *result, cell *params);
|
||||||
int AMXAPI amx_Cleanup(AMX *amx);
|
int AMXAPI amx_Cleanup(AMX *amx);
|
||||||
|
@ -165,8 +165,13 @@ void amx_command(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
print_srvconsole( "%d modules, %d correct\n",modules,running);
|
print_srvconsole( "%d modules, %d correct\n",modules,running);
|
||||||
}
|
} else if (!strcmp(cmd, "jit")) {
|
||||||
else if (!strcmp(cmd, "gpl"))
|
#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("AMX Mod X\n");
|
||||||
print_srvconsole("\n");
|
print_srvconsole("\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user