From 76bfb7efeaddc4d3fbea6366971fb4a44cd2c82d Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Wed, 26 Mar 2025 16:34:50 +0900 Subject: [PATCH 1/4] Fix for NetBSD --- amx/CMakeLists.txt | 17 +++++++++++------ amx/amx.c | 4 ++-- amx/amx.h | 5 ++++- amx/amxdgram.c | 3 ++- amx/amxfile.c | 6 +++--- amx/amxtime.c | 10 +++++----- compiler/CMakeLists.txt | 2 +- compiler/sc1.c | 4 ++-- linux/sclinux.h | 2 +- 9 files changed, 31 insertions(+), 22 deletions(-) diff --git a/amx/CMakeLists.txt b/amx/CMakeLists.txt index ebad8df2..eba3b151 100644 --- a/amx/CMakeLists.txt +++ b/amx/CMakeLists.txt @@ -9,6 +9,11 @@ LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules") SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +SET(dl dl) +IF(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") + SET(dl "") +ENDIF() + # check for optional include files INCLUDE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H) @@ -211,7 +216,7 @@ IF(APPLE) #Export list is set at link time SET_PROPERTY(TARGET amxProcess APPEND_STRING PROPERTY LINK_FLAGS " -Wl,-exported_symbol,_amx_ProcessCleanup ") ENDIF(APPLE) IF(UNIX AND NOT APPLE) - TARGET_LINK_LIBRARIES(amxProcess dl) + TARGET_LINK_LIBRARIES(amxProcess ${dl}) ADD_CUSTOM_COMMAND(TARGET amxProcess POST_BUILD COMMAND strip ARGS -K amx_ProcessInit -K amx_ProcessCleanup ${CMAKE_BINARY_DIR}/amxProcess.so) ENDIF(UNIX AND NOT APPLE) INSTALL(TARGETS amxProcess LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) @@ -283,9 +288,9 @@ SET_TARGET_PROPERTIES(pawnrun PROPERTIES COMPILE_FLAGS -DAMXDBG COMPILE_FLAGS -D IF (UNIX) IF(HAVE_CURSES_H) # SET_TARGET_PROPERTIES(pawnrun PROPERTIES COMPILE_FLAGS -DUSE_CURSES) - TARGET_LINK_LIBRARIES(pawnrun dl curses) + TARGET_LINK_LIBRARIES(pawnrun ${dl} curses) ELSE(HAVE_CURSES_H) - TARGET_LINK_LIBRARIES(pawnrun dl) + TARGET_LINK_LIBRARIES(pawnrun ${dl}) ENDIF(HAVE_CURSES_H) ENDIF (UNIX) INSTALL(TARGETS pawnrun RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) @@ -305,9 +310,9 @@ SET_TARGET_PROPERTIES(pawndbg PROPERTIES COMPILE_FLAGS -DENABLE_BINRELOC) IF (UNIX) IF(HAVE_CURSES_H) # SET_TARGET_PROPERTIES(pawndbg PROPERTIES COMPILE_FLAGS -DUSE_CURSES) - TARGET_LINK_LIBRARIES(pawndbg dl curses) + TARGET_LINK_LIBRARIES(pawndbg ${dl} curses) ELSE(HAVE_CURSES_H) - TARGET_LINK_LIBRARIES(pawndbg dl) + TARGET_LINK_LIBRARIES(pawndbg ${dl}) ENDIF(HAVE_CURSES_H) ENDIF (UNIX) INSTALL(TARGETS pawndbg RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) @@ -342,7 +347,7 @@ INSTALL(TARGETS amx LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) CONFIGURE_FILE(amx.pc.in amx.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/amx.pc - DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + DESTINATION lib/pkgconfig) # -------------------------------------------------------------------------- # Headers diff --git a/amx/amx.c b/amx/amx.c index de7bfc36..5b8d8b37 100644 --- a/amx/amx.c +++ b/amx/amx.c @@ -33,7 +33,7 @@ #include /* for getenv() */ #include #include "osdefs.h" -#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ +#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined(__NetBSD__) #include #if !defined AMX_NODYNALOAD #include @@ -48,7 +48,7 @@ #include #endif #endif -#if !defined AMX_ANSIONLY && (defined __LCC__ || defined __LINUX__ || defined __APPLE__) +#if !defined AMX_ANSIONLY && (defined __LCC__ || defined __LINUX__ || defined __APPLE__ || defined(__NetBSD__)) #include /* for wcslen() */ #endif diff --git a/amx/amx.h b/amx/amx.h index 09c9f355..15621985 100644 --- a/amx/amx.h +++ b/amx/amx.h @@ -29,7 +29,7 @@ #if defined FREEBSD && !defined __FreeBSD__ #define __FreeBSD__ #endif -#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ +#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined(__NetBSD__) #include #endif @@ -107,6 +107,9 @@ #define HAVE_ALLOCA_H 1 #endif #endif +#ifdef __NetBSD__ +#undef HAVE_ALLOCA_H +#endif #if defined HAVE_ALLOCA_H && HAVE_ALLOCA_H #include #elif defined __BORLANDC__ diff --git a/amx/amxdgram.c b/amx/amxdgram.c index 6f889ef6..ba42db56 100644 --- a/amx/amxdgram.c +++ b/amx/amxdgram.c @@ -23,7 +23,7 @@ #include #include #include "osdefs.h" -#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ +#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ #include #include #include @@ -31,6 +31,7 @@ #include #include #include +#include #else #include #include diff --git a/amx/amxfile.c b/amx/amxfile.c index a4376538..52a0ffda 100644 --- a/amx/amxfile.c +++ b/amx/amxfile.c @@ -37,7 +37,7 @@ #if defined __BORLANDC__ #include #endif -#if defined __BORLANDC__ || defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined MACOS || defined __APPLE__ +#if defined __BORLANDC__ || defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined MACOS || defined __APPLE__ || defined(__NetBSD__) #include #else #include @@ -48,7 +48,7 @@ #if defined __WATCOMC__ || defined _MSC_VER #include #endif -#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined MACOS || defined __APPLE__ +#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined MACOS || defined __APPLE__ || defined(__NetBSD__) #include #else #include @@ -93,7 +93,7 @@ #define _tgetenv getenv #define _tremove remove #define _trename rename - #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ #define _tmkdir mkdir #define _trmdir rmdir #define _tstat stat diff --git a/amx/amxtime.c b/amx/amxtime.c index ec727c1a..12771703 100644 --- a/amx/amxtime.c +++ b/amx/amxtime.c @@ -157,7 +157,7 @@ static void settime(cell hour,cell minute,cell second) */ time_t sec1970; struct tm gtm; - #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ struct timeval tv; #endif @@ -170,7 +170,7 @@ static void settime(cell hour,cell minute,cell second) if (second!=CELLMIN) gtm.tm_sec=wrap((int)second,0,59); sec1970=mktime(>m); - #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ tv.tv_sec = sec1970; tv.tv_usec = 0; settimeofday(&tv, 0); @@ -205,7 +205,7 @@ static void setdate(cell year,cell month,cell day) */ time_t sec1970; struct tm gtm; - #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ struct timeval tv; #endif @@ -218,7 +218,7 @@ static void setdate(cell year,cell month,cell day) if (day!=CELLMIN) gtm.tm_mday=day; sec1970=mktime(>m); - #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ tv.tv_sec = sec1970; tv.tv_usec = 0; settimeofday(&tv, 0); @@ -390,7 +390,7 @@ static cell AMX_NATIVE_CALL n_settimestamp(AMX *amx, const cell *params) * must have "root" permission to call stime(); many POSIX systems will * have settimeofday() instead */ - #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ struct timeval tv; tv.tv_sec = params[1]; tv.tv_usec = 0; diff --git a/compiler/CMakeLists.txt b/compiler/CMakeLists.txt index d19777cb..bea9b62f 100644 --- a/compiler/CMakeLists.txt +++ b/compiler/CMakeLists.txt @@ -70,7 +70,7 @@ SET_TARGET_PROPERTIES(pawnc PROPERTIES CONFIGURE_FILE(pawnc.pc.in pawnc.pc @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pawnc.pc - DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + DESTINATION lib/pkgconfig) ADD_EXECUTABLE(pawncc ${PAWNCC_SRCS}) diff --git a/compiler/sc1.c b/compiler/sc1.c index 82aaae93..135be6f3 100644 --- a/compiler/sc1.c +++ b/compiler/sc1.c @@ -73,7 +73,7 @@ #include "lstring.h" #include "sc.h" -#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ +#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ #include #include #include /* from BinReloc, see www.autopackage.org */ @@ -1536,7 +1536,7 @@ static void setconfig(const char *root) getcwd(path,sizeof path); #elif defined __WIN32__ || defined _WIN32 GetModuleFileName(NULL,path,_MAX_PATH); - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ /* see www.autopackage.org (now Listaller) for the BinReloc module */ br_init(NULL); ptr=br_find_exe("/opt/Pawn/bin/pawncc"); diff --git a/linux/sclinux.h b/linux/sclinux.h index 6c0f9d5b..612cdbad 100644 --- a/linux/sclinux.h +++ b/linux/sclinux.h @@ -36,7 +36,7 @@ # include #endif -#if defined __OpenBSD__ || defined __FreeBSD__ || defined __APPLE__ +#if defined __OpenBSD__ || defined __FreeBSD__ || defined __APPLE__ || defined(__NetBSD__) # define __BYTE_ORDER BYTE_ORDER # define __LITTLE_ENDIAN LITTLE_ENDIAN # define __BIG_ENDIAN BIG_ENDIAN From 4b5656942f6d60f58a017aaa1f7c01b91100b537 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Wed, 26 Mar 2025 19:05:58 +0900 Subject: [PATCH 2/4] Compile with MinGW --- amx/amxargs.def | 8 +++----- amx/amxfile.c | 5 ++++- amx/amxfile.def | 7 ++----- amx/amxstring.def | 9 ++++----- compiler/CMakeLists.txt | 2 +- compiler/libpawnc.c | 10 +++++----- compiler/libpawnc.rc | 2 +- compiler/pawncc.rc | 2 +- compiler/sc1.c | 4 ++++ 9 files changed, 25 insertions(+), 24 deletions(-) diff --git a/amx/amxargs.def b/amx/amxargs.def index 5ec007af..1a22eb46 100644 --- a/amx/amxargs.def +++ b/amx/amxargs.def @@ -1,6 +1,4 @@ -NAME amxArgs -DESCRIPTION 'Pawn AMX: Script Arguments support' - EXPORTS - amx_ArgsInit - amx_ArgsCleanup + amx_ArgsCleanup @1 + amx_ArgsInit @2 + amx_ArgsSetCmdLine @3 diff --git a/amx/amxfile.c b/amx/amxfile.c index 52a0ffda..c6622c9e 100644 --- a/amx/amxfile.c +++ b/amx/amxfile.c @@ -48,11 +48,14 @@ #if defined __WATCOMC__ || defined _MSC_VER #include #endif -#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined MACOS || defined __APPLE__ || defined(__NetBSD__) +#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined MACOS || defined __APPLE__ || defined __NetBSD__ || defined __MINGW32__ #include #else #include #endif +#if defined __MINGW32__ +#include +#endif #if defined __GNUC__ || defined __clang__ #include #endif diff --git a/amx/amxfile.def b/amx/amxfile.def index 3811e157..8a989e6c 100644 --- a/amx/amxfile.def +++ b/amx/amxfile.def @@ -1,6 +1,3 @@ -NAME amxFile -DESCRIPTION 'File I/O support library' - EXPORTS - amx_FileInit - amx_FileCleanup + amx_FileCleanup @1 + amx_FileInit @2 diff --git a/amx/amxstring.def b/amx/amxstring.def index 9c464e18..9753d792 100644 --- a/amx/amxstring.def +++ b/amx/amxstring.def @@ -1,6 +1,5 @@ -NAME amxString -DESCRIPTION 'Pawn AMX: string manipulation routines' - EXPORTS - amx_StringInit - amx_StringCleanup + amx_ConsoleCleanup @1 + amx_ConsoleInit @2 + amx_StringCleanup @3 + amx_StringInit @4 diff --git a/compiler/CMakeLists.txt b/compiler/CMakeLists.txt index bea9b62f..0a542316 100644 --- a/compiler/CMakeLists.txt +++ b/compiler/CMakeLists.txt @@ -41,7 +41,7 @@ ENDIF(APPLE) # The Pawn compiler SET(PAWNCC_SRCS sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c scexpand.c sci18n.c sclist.c scmemfil.c scstate.c scvars.c - lstring.c memfile.c + lstring.c memfile.c libpawnc.c ${CMAKE_CURRENT_SOURCE_DIR}/../amx/keeloq.c) IF(WIN32) SET(PAWNCC_SRCS ${PAWNCC_SRCS} pawncc.rc) diff --git a/compiler/libpawnc.c b/compiler/libpawnc.c index cf6650b5..be8825a6 100644 --- a/compiler/libpawnc.c +++ b/compiler/libpawnc.c @@ -269,8 +269,8 @@ void pc_closeasm(void *handle, int deletefile) #else if (handle!=NULL) { if (!deletefile) - mfdump((MEMFILE*)handle); - mfclose((MEMFILE*)handle); + mfdump((memfile_t*)handle); + mfclose((memfile_t*)handle); } /* if */ #endif } @@ -282,7 +282,7 @@ void pc_resetasm(void *handle) fflush((FILE*)handle); fseek((FILE*)handle,0,SEEK_SET); #else - mfseek((MEMFILE*)handle,0,SEEK_SET); + mfseek((memfile_t*)handle,0,SEEK_SET); #endif } @@ -291,7 +291,7 @@ int pc_writeasm(void *handle,const char *string) #if defined __MSDOS__ || defined PAWN_LIGHT return fputs(string,(FILE*)handle) >= 0; #else - return mfputs((MEMFILE*)handle,string); + return mfputs((memfile_t*)handle,string); #endif } @@ -300,7 +300,7 @@ char *pc_readasm(void *handle, char *string, int maxchars) #if defined __MSDOS__ || defined PAWN_LIGHT return fgets(string,maxchars,(FILE*)handle); #else - return mfgets((MEMFILE*)handle,string,maxchars); + return mfgets((memfile_t*)handle,string,maxchars); #endif } diff --git a/compiler/libpawnc.rc b/compiler/libpawnc.rc index 656536bf..f2c73502 100644 --- a/compiler/libpawnc.rc +++ b/compiler/libpawnc.rc @@ -6,7 +6,7 @@ #endif #include "svnrev.h" -AppIcon ICON "../bin/pawn.ico" +AppIcon ICON "../pawn.ico" /* Version information * diff --git a/compiler/pawncc.rc b/compiler/pawncc.rc index 36db6636..4709041f 100644 --- a/compiler/pawncc.rc +++ b/compiler/pawncc.rc @@ -6,7 +6,7 @@ #endif #include "svnrev.h" -AppIcon ICON "../bin/pawn.ico" +AppIcon ICON "../pawn.ico" /* Version information * diff --git a/compiler/sc1.c b/compiler/sc1.c index 135be6f3..b48c8d44 100644 --- a/compiler/sc1.c +++ b/compiler/sc1.c @@ -187,6 +187,10 @@ int main(int argc, char *argv[]) return pc_compile(argc,argv); } +#endif + +#if 0 + /* pc_printf() * Called for general purpose "console" output. This function prints general * purpose messages; errors go through pc_error(). The function is modelled From c9c6732fa494c5f1cd7e609041d8726214590ade Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Wed, 26 Mar 2025 19:14:28 +0900 Subject: [PATCH 3/4] Compiles with MinGW --- amx/amxargs.def | 6 +++--- amx/amxfile.c | 2 ++ amx/amxfile.def | 4 ++-- amx/amxstring.def | 8 ++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/amx/amxargs.def b/amx/amxargs.def index 1a22eb46..ecbda130 100644 --- a/amx/amxargs.def +++ b/amx/amxargs.def @@ -1,4 +1,4 @@ EXPORTS - amx_ArgsCleanup @1 - amx_ArgsInit @2 - amx_ArgsSetCmdLine @3 + amx_ArgsCleanup@4 @1 + amx_ArgsInit@4 @2 + amx_ArgsSetCmdLine@4 @3 diff --git a/amx/amxfile.c b/amx/amxfile.c index c6622c9e..fe7e46e4 100644 --- a/amx/amxfile.c +++ b/amx/amxfile.c @@ -113,6 +113,8 @@ #elif defined __WIN32__ #if defined __WATCOMC__ #define t_stat _stat + #elif defined __MINGW32__ + #define t_stat _stat #else #define t_stat __stat #endif diff --git a/amx/amxfile.def b/amx/amxfile.def index 8a989e6c..e9c14412 100644 --- a/amx/amxfile.def +++ b/amx/amxfile.def @@ -1,3 +1,3 @@ EXPORTS - amx_FileCleanup @1 - amx_FileInit @2 + amx_FileCleanup@4 @1 + amx_FileInit@4 @2 diff --git a/amx/amxstring.def b/amx/amxstring.def index 9753d792..2d8e2e4b 100644 --- a/amx/amxstring.def +++ b/amx/amxstring.def @@ -1,5 +1,5 @@ EXPORTS - amx_ConsoleCleanup @1 - amx_ConsoleInit @2 - amx_StringCleanup @3 - amx_StringInit @4 + amx_ConsoleCleanup@4 @1 + amx_ConsoleInit@4 @2 + amx_StringCleanup@4 @3 + amx_StringInit@4 @4 From bc0ce306281dcef2be9a016cdc5429aab1532099 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Thu, 27 Mar 2025 00:09:56 +0900 Subject: [PATCH 4/4] Fix NetBSD --- amx/amx.c | 38 +++++++++++++++++++------------------- amx/amxargs.def | 6 +++--- amx/amxfile.def | 4 ++-- amx/amxfixed.c | 4 ++-- amx/amxprocess.c | 16 ++++++++-------- amx/amxstring.def | 8 ++++---- amx/amxtime.c | 2 +- amx/minIni.c | 4 ++-- amx/pawndbg.c | 4 ++-- amx/pawnrun.c | 6 +++--- 10 files changed, 46 insertions(+), 46 deletions(-) diff --git a/amx/amx.c b/amx/amx.c index 5b8d8b37..83bb2ac2 100644 --- a/amx/amx.c +++ b/amx/amx.c @@ -33,7 +33,7 @@ #include /* for getenv() */ #include #include "osdefs.h" -#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined(__NetBSD__) +#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ #include #if !defined AMX_NODYNALOAD #include @@ -620,7 +620,7 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, const cell *params) #if defined AMX_NO_PACKED_OPC #define GETOPCODE(c) (OPCODE)(c) #else - #define GETOPCODE(c) (OPCODE)((c) & ((1UL << sizeof(cell)*4)-1)) + #define GETOPCODE(c) (OPCODE)((c) & (((ucell)1 << sizeof(cell)*4)-1)) #endif #endif #if !defined GETPARAM_P @@ -666,7 +666,7 @@ static int VerifyPcode(AMX *amx) #if defined AMX_NO_PACKED_OPC opmask= ~0; #else - opmask=(1UL << sizeof(cell)*4)-1; + opmask=((ucell)1 << sizeof(cell)*4)-1; #endif /* sanity checks */ @@ -1108,18 +1108,18 @@ static int VerifyPcode(AMX *amx) } /* definitions used for amx_Init() and amx_Cleanup() */ -#if (defined _Windows || defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) && !defined AMX_NODYNALOAD +#if (defined _Windows || defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__) && !defined AMX_NODYNALOAD typedef int AMXEXPORT (AMXAPI _FAR *AMX_ENTRY)(AMX _FAR *amx); static void getlibname(char *libname,const char *source) { - #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ char *root=getenv("AMXLIB"); #endif assert(libname!=NULL && source!=NULL); libname[0]='\0'; - #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ if (root!=NULL && *root!='\0') { strcpy(libname,root); if (libname[strlen(libname)-1]!='/') @@ -1130,7 +1130,7 @@ static int VerifyPcode(AMX *amx) strcat(libname,source); #if defined _Windows strcat(libname,".dll"); - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ strcat(libname,".so"); #elif defined __APPLE__ strcat(libname,".dylib"); @@ -1307,12 +1307,12 @@ int AMXAPI amx_Init(AMX *amx,void *program) return err; /* load any extension modules that the AMX refers to */ - #if (defined _Windows || defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) && !defined AMX_NODYNALOAD + #if (defined _Windows || defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__) && !defined AMX_NODYNALOAD { /* local */ #if defined _Windows char libname[sNAMEMAX+8]; /* +1 for '\0', +3 for 'amx' prefix, +4 for extension */ HINSTANCE hlib; - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ char libname[_MAX_PATH]; void *hlib; #endif @@ -1332,7 +1332,7 @@ int AMXAPI amx_Init(AMX *amx,void *program) if (hlib<=HINSTANCE_ERROR) hlib=NULL; #endif - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ hlib=dlopen(libname,RTLD_NOW); #elif defined __APPLE__ /* try to search library in pidpath */ @@ -1362,7 +1362,7 @@ int AMXAPI amx_Init(AMX *amx,void *program) strcat(funcname,"Init"); #if defined _Windows libinit=(AMX_ENTRY)GetProcAddress(hlib,funcname); - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ libinit=(AMX_ENTRY)dlsym(hlib,funcname); #endif if (libinit!=NULL) @@ -1399,7 +1399,7 @@ int AMXAPI amx_Init(AMX *amx,void *program) return !VirtualProtect(addr, len, p, &prev); } - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ /* Linux, BSD and OSX already have mprotect() */ #define ALIGN(addr) (char *)(((long)addr + sysconf(_SC_PAGESIZE)-1) & ~(sysconf(_SC_PAGESIZE)-1)) @@ -1469,11 +1469,11 @@ int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code) #if defined AMX_CLEANUP int AMXAPI amx_Cleanup(AMX *amx) { - #if (defined _Windows || defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) && !defined AMX_NODYNALOAD + #if (defined _Windows || defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__) && !defined AMX_NODYNALOAD #if defined _Windows char libname[sNAMEMAX+8]; /* +1 for '\0', +3 for 'amx' prefix, +4 for extension */ HINSTANCE hlib; - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ char libname[_MAX_PATH]; void *hlib; #endif @@ -1484,7 +1484,7 @@ int AMXAPI amx_Cleanup(AMX *amx) #endif /* unload all extension modules */ - #if (defined _Windows || defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) && !defined AMX_NODYNALOAD + #if (defined _Windows || defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__) && !defined AMX_NODYNALOAD hdr=(AMX_HEADER *)amx->base; assert(hdr->magic==AMX_MAGIC); numlibraries=NUMENTRIES(hdr,libraries,pubvars); @@ -1500,7 +1500,7 @@ int AMXAPI amx_Cleanup(AMX *amx) if (hlib<=HINSTANCE_ERROR) hlib=NULL; #endif - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ hlib=dlopen(libname,RTLD_NOLOAD); #endif if (hlib!=NULL) { @@ -1510,14 +1510,14 @@ int AMXAPI amx_Cleanup(AMX *amx) strcat(funcname,"Cleanup"); #if defined _Windows libcleanup=(AMX_ENTRY)GetProcAddress(hlib,funcname); - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ libcleanup=(AMX_ENTRY)dlsym(hlib,funcname); #endif if (libcleanup!=NULL) libcleanup(amx); #if defined _Windows FreeLibrary(hlib); - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ dlclose(hlib); #endif } /* if (hlib!=NULL) */ @@ -2847,7 +2847,7 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index) #if !defined AMX_NO_OVERLAY case OP_CALL_OVL: offs=(cell)((unsigned char *)cip-amx->code+sizeof(cell)); /* skip address */ - assert(offs>=0 && offs<(1L<<(sizeof(cell)*4))); + assert(offs>=0 && offs<((cell)1<<(sizeof(cell)*4))); PUSH((offs<<(sizeof(cell)*4)) | amx->ovl_index); amx->ovl_index=(int)*cip; assert(amx->overlay!=NULL); diff --git a/amx/amxargs.def b/amx/amxargs.def index ecbda130..1a22eb46 100644 --- a/amx/amxargs.def +++ b/amx/amxargs.def @@ -1,4 +1,4 @@ EXPORTS - amx_ArgsCleanup@4 @1 - amx_ArgsInit@4 @2 - amx_ArgsSetCmdLine@4 @3 + amx_ArgsCleanup @1 + amx_ArgsInit @2 + amx_ArgsSetCmdLine @3 diff --git a/amx/amxfile.def b/amx/amxfile.def index e9c14412..8a989e6c 100644 --- a/amx/amxfile.def +++ b/amx/amxfile.def @@ -1,3 +1,3 @@ EXPORTS - amx_FileCleanup@4 @1 - amx_FileInit@4 @2 + amx_FileCleanup @1 + amx_FileInit @2 diff --git a/amx/amxfixed.c b/amx/amxfixed.c index 952b9ecf..ea3fc8f2 100644 --- a/amx/amxfixed.c +++ b/amx/amxfixed.c @@ -278,7 +278,7 @@ static cell AMX_NATIVE_CALL n_fmul(AMX *amx,const cell *params) cell sign=1; (void)amx; - assert(MULTIPLIER<=(1L<> WORDSHIFT; + b[1]=(ucell)(HIWORD(dividend)*MULTIPLIER) >> WORDSHIFT; /* add half of the divisor, to round the data */ b[0]+=(ucell)divisor/2; diff --git a/amx/amxprocess.c b/amx/amxprocess.c index 3b06a6ef..6f99b986 100644 --- a/amx/amxprocess.c +++ b/amx/amxprocess.c @@ -37,7 +37,7 @@ #endif #if defined __WIN32__ || defined _Windows #include -#elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ +#elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ #include #include #include @@ -653,7 +653,7 @@ static cell AMX_NATIVE_CALL n_libfree(AMX *amx, const cell *params) /* pipes for I/O redirection */ #if defined __WIN32__ || defined _WIN32 || defined WIN32 static HANDLE newstdin,newstdout,read_stdout,write_stdin; -#elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ +#elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ static int pipe_to[2]={-1,-1}; static int pipe_from[2]={-1,-1}; #endif @@ -677,7 +677,7 @@ static void closepipe(void) CloseHandle(write_stdin); write_stdin=NULL; } /* if */ - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ if (pipe_to[0]>=0) { close(pipe_to[0]); pipe_to[0]=-1; @@ -713,7 +713,7 @@ static cell AMX_NATIVE_CALL n_procexec(AMX *amx, const cell *params) PROCESS_INFORMATION pi; #elif defined _Windows HINSTANCE hinst; - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ pid_t pid; #endif @@ -770,7 +770,7 @@ static cell AMX_NATIVE_CALL n_procexec(AMX *amx, const cell *params) if (hinst<=32) hinst=0; return (cell)hinst; - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ /* set up communication pipes first */ closepipe(); if (pipe(pipe_to)!=0 || pipe(pipe_from)!=0) { @@ -840,7 +840,7 @@ static cell AMX_NATIVE_CALL n_procwrite(AMX *amx, const cell *params) WriteFile(write_stdin,line,(DWORD)_tcslen(line),&num,NULL); //send it to stdin if (params[2]) WriteFile(write_stdin,__T("\n"),1,&num,NULL); - #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #elif defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__ if (pipe_to[1]<0) return 0; write(pipe_to[1],line,_tcslen(line)); @@ -868,7 +868,7 @@ static cell AMX_NATIVE_CALL n_procread(AMX *amx, const cell *params) break; index++; } while (index #endif -#if !defined AMX_NODYNALOAD && defined ENABLE_BINRELOC && (defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) +#if !defined AMX_NODYNALOAD && defined ENABLE_BINRELOC && (defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__) #include /* from BinReloc, see www.autopackage.org */ #endif @@ -2905,7 +2905,7 @@ extern AMX_NATIVE_INFO console_Natives[]; unsigned short flags; char *ptr; - #if !defined AMX_NODYNALOAD && defined ENABLE_BINRELOC && (defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) + #if !defined AMX_NODYNALOAD && defined ENABLE_BINRELOC && (defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__) /* see www.autopackage.org (now Listaller) for the BinReloc module */ if (br_init(NULL)) { char *libroot=br_find_exe_dir(""); diff --git a/amx/pawnrun.c b/amx/pawnrun.c index 52edbaa4..36df4dce 100644 --- a/amx/pawnrun.c +++ b/amx/pawnrun.c @@ -30,7 +30,7 @@ #define CLOCKS_PER_SEC CLK_TCK #endif -#if !defined AMX_NODYNALOAD && defined ENABLE_BINRELOC && (defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) +#if !defined AMX_NODYNALOAD && defined ENABLE_BINRELOC && (defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__) #include /* from BinReloc, see www.autopackage.org */ #endif @@ -203,7 +203,7 @@ int AMXAPI aux_LoadProgram(AMX *amx, char *filename) result = amx_Init(amx, datablock); /* free the memory block on error, if it was allocated here */ - if (result != AMX_ERR_NONE) { + if (result != AMX_ERR_NONE) {printf("%d\n", result); free(datablock); amx->base = NULL; /* avoid a double free */ } /* if */ @@ -320,7 +320,7 @@ int main(int argc,char *argv[]) if (argc < 2) PrintUsage(argv[0]); /* function "usage" aborts the program */ - #if !defined AMX_NODYNALOAD && defined ENABLE_BINRELOC && (defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) + #if !defined AMX_NODYNALOAD && defined ENABLE_BINRELOC && (defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ || defined __NetBSD__) /* see www.autopackage.org (now Listaller) for the BinReloc module */ if (br_init(NULL)) { char *libroot=br_find_exe_dir("");