Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAWN 4 backported natives #386

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
10 changes: 5 additions & 5 deletions source/amx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ set(FILE_SRCS amxfile.c amx.c)
add_library(amxFile SHARED ${FILE_SRCS})
set_target_properties(amxFile PROPERTIES PREFIX "")
if(WIN32)
set(FILE_SRCS ${FILE_SRCS} dllmain.c amxfile.rc)
set(FILE_SRCS ${FILE_SRCS} dllmain.c amxFile.rc)
if(BORLAND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxfile.def
${CMAKE_BINARY_DIR}/amxfile.def
Expand All @@ -88,14 +88,14 @@ if(WIN32)
endif()

# amxFixed
set(FIXED_SRCS fixed.c amx.c)
set(FIXED_SRCS fixed.c fixed.c amx.c)
add_library(amxFixed SHARED ${FIXED_SRCS})
set_target_properties(amxFixed PROPERTIES PREFIX "")
if(WIN32)
set(FIXED_SRCS ${FIXED_SRCS} dllmain.c amxfixed.rc)
if(BORLAND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxfixed.def
${CMAKE_BINARY_DIR}/amxfixed.def
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/amxFixed.def
${CMAKE_BINARY_DIR}/amxFixed.def
COPYONLY)
else()
set_target_properties(amxFixed PROPERTIES LINK_FLAGS
Expand All @@ -107,7 +107,7 @@ if(UNIX)
endif()

# amxFloat
set(FLOAT_SRCS float.c amx.c)
set(FLOAT_SRCS amxfloat.c amx.c)
add_library(amxFloat SHARED ${FLOAT_SRCS})
set_target_properties(amxFloat PROPERTIES PREFIX "")
if(WIN32)
Expand Down
37 changes: 18 additions & 19 deletions source/amx/amx.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#pragma optimize("g",off)
#endif

#define WIN32_LEAN_AND_MEAN
#if defined _UNICODE || defined __UNICODE__ || defined UNICODE
# if !defined UNICODE /* for Windows API */
# define UNICODE
Expand Down Expand Up @@ -1525,7 +1524,7 @@ int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr)
{
int first,last,mid,result;
char pname[sNAMEMAX+1];
cell paddr;
cell paddr=0;

amx_NumPubVars(amx, &last);
last--; /* last valid index is 1 less than the number of functions */
Expand Down Expand Up @@ -1604,7 +1603,7 @@ int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id)
int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname)
{
int first,last,mid;
cell mid_id;
cell mid_id=tag_id;

#if !defined NDEBUG
/* verify that the tagname table is sorted on the tag_id */
Expand Down Expand Up @@ -3246,14 +3245,14 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
break;
case OP_LOAD_I:
/* verify address */
if (pri>=hea && pri<stk || (ucell)pri>=(ucell)amx->stp)
if ((pri>=hea && pri<stk) || (ucell)pri>=(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
pri=_R(data,pri);
break;
case OP_LODB_I:
GETPARAM(offs);
/* verify address */
if (pri>=hea && pri<stk || (ucell)pri>=(ucell)amx->stp)
if ((pri>=hea && pri<stk) || (ucell)pri>=(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
switch ((int)offs) {
case 1:
Expand Down Expand Up @@ -3319,14 +3318,14 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
break;
case OP_STOR_I:
/* verify address */
if (alt>=hea && alt<stk || (ucell)alt>=(ucell)amx->stp)
if ((alt>=hea && alt<stk) || (ucell)alt>=(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
_W(data,alt,pri);
break;
case OP_STRB_I:
GETPARAM(offs);
/* verify address */
if (alt>=hea && alt<stk || (ucell)alt>=(ucell)amx->stp)
if ((alt>=hea && alt<stk) || (ucell)alt>=(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
switch ((int)offs) {
case 1:
Expand All @@ -3343,15 +3342,15 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
case OP_LIDX:
offs=pri*sizeof(cell)+alt;
/* verify address */
if (offs>=hea && offs<stk || (ucell)offs>=(ucell)amx->stp)
if ((offs>=hea && offs<stk) || (ucell)offs>=(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
pri=_R(data,offs);
break;
case OP_LIDX_B:
GETPARAM(offs);
offs=(pri << (int)offs)+alt;
/* verify address */
if (offs>=hea && offs<stk || (ucell)offs>=(ucell)amx->stp)
if ((offs>=hea && offs<stk) || (ucell)offs>=(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
pri=_R(data,offs);
break;
Expand Down Expand Up @@ -3841,13 +3840,13 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
/* verify top & bottom memory addresses, for both source and destination
* addresses
*/
if (pri>=hea && pri<stk || (ucell)pri>=(ucell)amx->stp)
if ((pri>=hea && pri<stk) || (ucell)pri>=(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
if ((pri+offs)>hea && (pri+offs)<stk || (ucell)(pri+offs)>(ucell)amx->stp)
if (((pri+offs)>hea && (pri+offs)<stk) || (ucell)(pri+offs)>(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
if (alt>=hea && alt<stk || (ucell)alt>=(ucell)amx->stp)
if ((alt>=hea && alt<stk) || (ucell)alt>=(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
if ((alt+offs)>hea && (alt+offs)<stk || (ucell)(alt+offs)>(ucell)amx->stp)
if (((alt+offs)>hea && (alt+offs)<stk) || (ucell)(alt+offs)>(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
#if defined _R_DEFAULT
memcpy(data+(int)alt, data+(int)pri, (int)offs);
Expand All @@ -3867,13 +3866,13 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
/* verify top & bottom memory addresses, for both source and destination
* addresses
*/
if (pri>=hea && pri<stk || (ucell)pri>=(ucell)amx->stp)
if ((pri>=hea && pri<stk) || (ucell)pri>=(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
if ((pri+offs)>hea && (pri+offs)<stk || (ucell)(pri+offs)>(ucell)amx->stp)
if (((pri+offs)>hea && (pri+offs)<stk) || (ucell)(pri+offs)>(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
if (alt>=hea && alt<stk || (ucell)alt>=(ucell)amx->stp)
if ((alt>=hea && alt<stk) || (ucell)alt>=(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
if ((alt+offs)>hea && (alt+offs)<stk || (ucell)(alt+offs)>(ucell)amx->stp)
if (((alt+offs)>hea && (alt+offs)<stk) || (ucell)(alt+offs)>(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
#if defined _R_DEFAULT
pri=memcmp(data+(int)alt, data+(int)pri, (int)offs);
Expand All @@ -3888,9 +3887,9 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
case OP_FILL:
GETPARAM(offs);
/* verify top & bottom memory addresses (destination only) */
if (alt>=hea && alt<stk || (ucell)alt>=(ucell)amx->stp)
if ((alt>=hea && alt<stk) || (ucell)alt>=(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
if ((alt+offs)>hea && (alt+offs)<stk || (ucell)(alt+offs)>(ucell)amx->stp)
if (((alt+offs)>hea && (alt+offs)<stk) || (ucell)(alt+offs)>(ucell)amx->stp)
ABORT(amx,AMX_ERR_MEMACCESS);
for (i=(int)alt; (size_t)offs>=sizeof(cell); i+=sizeof(cell), offs-=sizeof(cell))
_W32(data,i,pri);
Expand Down
Loading