From 906334404fcd3f5ea64de0397c73d81a2e9a047e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= Date: Wed, 6 Mar 2024 11:29:28 +0100 Subject: [PATCH 1/3] Fix building amx.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move including amx.h after the long logic of #defines. amx.h needs to know about at least AMX_JIT, otherwise a compiler error occurs that complains about missing struct members. Move the conditional block that #include because that also depends on the correct definition of AMX_JIT. Move the conditional block with #undef AMX_XXXUSERDATA after including amx.h because the former depends on the default value of AMX_USERNUM which amx.h sets. Fixes another build issue. Add #include for UNIX-like machines so sysconf() is available. Signed-off-by: Zoltán Böszörményi --- amx/amx.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/amx/amx.c b/amx/amx.c index d5b9150..3dc2130 100644 --- a/amx/amx.c +++ b/amx/amx.c @@ -35,13 +35,10 @@ #include "osdefs.h" #if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ #include + #include #if !defined AMX_NODYNALOAD #include #endif - #if defined AMX_JIT - #include - #include - #endif #if defined __APPLE__ #include #include @@ -52,13 +49,6 @@ #include /* for wcslen() */ #endif -#if defined __ECOS__ - /* eCos puts include files in cyg/package_name */ - #include -#else - #include "amx.h" -#endif - #if (defined _Windows && !defined AMX_NODYNALOAD) || (defined AMX_JIT && __WIN32__) #include #endif @@ -127,9 +117,6 @@ #if defined AMX_NO_NATIVEINFO #undef AMX_NATIVEINFO #endif -#if AMX_USERNUM <= 0 - #undef AMX_XXXUSERDATA -#endif #if defined AMX_JIT /* JIT is incompatible with macro instructions, packed opcodes and overlays */ #if !defined AMX_NO_MACRO_INSTR @@ -159,6 +146,24 @@ #define NATIVEADDR(addr,high) (AMX_NATIVE)(intptr_t)(addr) #endif +#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ + #if defined AMX_JIT + #include + #include + #endif +#endif + +#if defined __ECOS__ + /* eCos puts include files in cyg/package_name */ + #include +#else + #include "amx.h" +#endif + +#if AMX_USERNUM <= 0 + #undef AMX_XXXUSERDATA +#endif + #if defined AMX_ALTCORE #if defined __WIN32__ /* For Watcom C/C++ use register calling convention (faster); for From acbe0b11d6eb54521fba527ff0fbe166d29b8b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= Date: Wed, 6 Mar 2024 11:44:42 +0100 Subject: [PATCH 2/3] Add back amx_ConsoleInit and amx_StringInit decls to amx.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These are marked as exported AMXAPI and already used outside pawn. This partially reverts 44b1d71322a92098a9ba643db488fdd844bbeea1 ("Fix for issue #50.") Signed-off-by: Zoltán Böszörményi --- amx/amx.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/amx/amx.h b/amx/amx.h index 26403e5..279c7b7 100644 --- a/amx/amx.h +++ b/amx/amx.h @@ -482,6 +482,7 @@ int AMXAPI amx_Allot(AMX *amx, int cells, cell **address); int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, const cell *params); int AMXAPI amx_Cleanup(AMX *amx); int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data); +int AMXAPI amx_ConsoleInit(AMX *amx); int AMXAPI amx_Exec(AMX *amx, cell *retval, int index); int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index); int AMXAPI amx_FindPublic(AMX *amx, const char *name, int *index); @@ -514,6 +515,7 @@ int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback); int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug); int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size); int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr); +int AMXAPI amx_StringInit(AMX *amx); int AMXAPI amx_StrLen(const cell *cstring, int *length); int AMXAPI amx_UTF8Check(const char *string, int *length); int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value); From f7235d748249b4cc51adb1255b7db673773d22f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20B=C3=B6sz=C3=B6rm=C3=A9nyi?= Date: Wed, 6 Mar 2024 11:59:14 +0100 Subject: [PATCH 3/3] Fix undefined references in libpawnc shared library MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When apps linked to -lpawnc, these undefined reference errors occurred: libpawnc.so: undefined reference to `pc_closebin' libpawnc.so: undefined reference to `pc_readsrc' libpawnc.so: undefined reference to `pc_readasm' libpawnc.so: undefined reference to `pc_opensrc' libpawnc.so: undefined reference to `pc_getpossrc' libpawnc.so: undefined reference to `pc_createsrc' libpawnc.so: undefined reference to `pc_resetsrc' libpawnc.so: undefined reference to `pc_clearpossrc' libpawnc.so: undefined reference to `pc_writebin' libpawnc.so: undefined reference to `pc_closesrc' libpawnc.so: undefined reference to `pc_resetasm' libpawnc.so: undefined reference to `pc_lengthbin' libpawnc.so: undefined reference to `pc_eofsrc' libpawnc.so: undefined reference to `pc_writesrc' libpawnc.so: undefined reference to `pc_error' libpawnc.so: undefined reference to `pc_writeasm' libpawnc.so: undefined reference to `pc_printf' libpawnc.so: undefined reference to `pc_resetbin' libpawnc.so: undefined reference to `pc_openasm' libpawnc.so: undefined reference to `pc_openbin' libpawnc.so: undefined reference to `pc_closeasm' This partially reverts 44b1d71322a92098a9ba643db488fdd844bbeea1 ("Fix for issue #50.") Signed-off-by: Zoltán Böszörményi --- compiler/sc1.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/sc1.c b/compiler/sc1.c index 63f90d9..dfc72af 100644 --- a/compiler/sc1.c +++ b/compiler/sc1.c @@ -187,6 +187,8 @@ int main(int argc, char *argv[]) return pc_compile(argc,argv); } +#endif /* !defined NO_MAIN */ + /* pc_printf() * Called for general purpose "console" output. This function prints general * purpose messages; errors go through pc_error(). The function is modelled @@ -439,9 +441,6 @@ long pc_lengthbin(void *handle) return ftell((FILE*)handle); } -#endif /* !defined NO_MAIN */ - - #if !(defined __MSDOS__ || defined __WIN32__ || defined _Windows) int posix_spawnl(char *pgm,...) {