Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 31b7e9e

Browse files
authored
Merge pull request #72 from zboszor/linux-build
Build amx and compiler libraries, install libs+executables+headers, add pkgconfig detection
2 parents e25f70c + af729ec commit 31b7e9e

File tree

16 files changed

+151
-25
lines changed

16 files changed

+151
-25
lines changed

amx/CMakeLists.txt

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ ENDIF(APPLE)
8181
IF(UNIX AND NOT APPLE)
8282
ADD_CUSTOM_COMMAND(TARGET amxArgs POST_BUILD COMMAND strip ARGS -K amx_ArgsInit -K amx_ArgsCleanup -K amx_ArgsSetCmdLine ${CMAKE_BINARY_DIR}/amxArgs.so)
8383
ENDIF(UNIX AND NOT APPLE)
84+
INSTALL(TARGETS amxArgs LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
8485

8586
# amxDGram
8687
SET(DGRAM_SRCS amxdgram.c amx.c)
@@ -102,6 +103,7 @@ ENDIF(APPLE)
102103
IF(UNIX AND NOT APPLE)
103104
ADD_CUSTOM_COMMAND(TARGET amxDGram POST_BUILD COMMAND strip ARGS -K amx_DGramInit -K amx_DGramCleanup ${CMAKE_BINARY_DIR}/amxDGram.so)
104105
ENDIF(UNIX AND NOT APPLE)
106+
INSTALL(TARGETS amxDGram LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
105107

106108
# amxFile
107109
SET(FILE_SRCS amxfile.c amx.c)
@@ -122,6 +124,7 @@ ENDIF(APPLE)
122124
IF(UNIX AND NOT APPLE)
123125
ADD_CUSTOM_COMMAND(TARGET amxFile POST_BUILD COMMAND strip ARGS -K amx_FileInit -K amx_FileCleanup ${CMAKE_BINARY_DIR}/amxFile.so)
124126
ENDIF(UNIX AND NOT APPLE)
127+
INSTALL(TARGETS amxFile LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
125128

126129
# amxFixed
127130
SET(FIXED_SRCS amxfixed.c amx.c)
@@ -143,6 +146,7 @@ IF(UNIX AND NOT APPLE)
143146
TARGET_LINK_LIBRARIES(amxFixed m)
144147
ADD_CUSTOM_COMMAND(TARGET amxFixed POST_BUILD COMMAND strip ARGS -K amx_FixedInit -K amx_FixedCleanup ${CMAKE_BINARY_DIR}/amxFixed.so)
145148
ENDIF(UNIX AND NOT APPLE)
149+
INSTALL(TARGETS amxFixed LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
146150

147151
# amxFloat
148152
SET(FLOAT_SRCS amxfloat.c amx.c)
@@ -164,6 +168,7 @@ IF(UNIX AND NOT APPLE)
164168
TARGET_LINK_LIBRARIES(amxFloat m)
165169
ADD_CUSTOM_COMMAND(TARGET amxFloat POST_BUILD COMMAND strip ARGS -K amx_FloatInit -K amx_FloatCleanup ${CMAKE_BINARY_DIR}/amxFloat.so)
166170
ENDIF(UNIX AND NOT APPLE)
171+
INSTALL(TARGETS amxFloat LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
167172

168173
# amxProcess
169174
SET(PROCESS_SRCS amxprocess.c amx.c)
@@ -190,6 +195,7 @@ IF(UNIX AND NOT APPLE)
190195
TARGET_LINK_LIBRARIES(amxProcess dl)
191196
ADD_CUSTOM_COMMAND(TARGET amxProcess POST_BUILD COMMAND strip ARGS -K amx_ProcessInit -K amx_ProcessCleanup ${CMAKE_BINARY_DIR}/amxProcess.so)
192197
ENDIF(UNIX AND NOT APPLE)
198+
INSTALL(TARGETS amxProcess LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
193199

194200
# amxString
195201
SET(STRING_SRCS amxstring.c amx.c amxcons.c)
@@ -210,7 +216,11 @@ IF(APPLE) #Export list is set at link time
210216
ENDIF(APPLE)
211217
IF(UNIX AND NOT APPLE)
212218
ADD_CUSTOM_COMMAND(TARGET amxString POST_BUILD COMMAND strip ARGS -K amx_StringInit -K amx_StringCleanup ${CMAKE_BINARY_DIR}/amxString.so)
219+
IF(HAVE_CURSES_H)
220+
TARGET_LINK_LIBRARIES(amxString curses)
221+
ENDIF(HAVE_CURSES_H)
213222
ENDIF(UNIX AND NOT APPLE)
223+
INSTALL(TARGETS amxString LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
214224

215225
# amxTime
216226
SET(TIME_SRCS amxtime.c amx.c)
@@ -231,6 +241,7 @@ ENDIF(APPLE)
231241
IF(UNIX AND NOT APPLE)
232242
ADD_CUSTOM_COMMAND(TARGET amxTime POST_BUILD COMMAND strip ARGS -K amx_TimeInit -K amx_TimeCleanup ${CMAKE_BINARY_DIR}/amxTime.so)
233243
ENDIF(UNIX AND NOT APPLE)
244+
INSTALL(TARGETS amxTime LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
234245

235246
# --------------------------------------------------------------------------
236247
# Simple run-time (example program)
@@ -252,6 +263,7 @@ IF (UNIX)
252263
TARGET_LINK_LIBRARIES(pawnrun dl)
253264
ENDIF(HAVE_CURSES_H)
254265
ENDIF (UNIX)
266+
INSTALL(TARGETS pawnrun RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
255267

256268
# --------------------------------------------------------------------------
257269
# Simple console debugger
@@ -273,3 +285,41 @@ IF (UNIX)
273285
TARGET_LINK_LIBRARIES(pawndbg dl)
274286
ENDIF(HAVE_CURSES_H)
275287
ENDIF (UNIX)
288+
INSTALL(TARGETS pawndbg RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
289+
290+
# --------------------------------------------------------------------------
291+
# libamx
292+
293+
SET(AMXLIB_MAJOR "4")
294+
SET(AMXLIB_VER "4.0.0")
295+
SET(AMXLIB_SRCS amx.c amxaux.c amxcore.c amxcons.c amxpool.c amxdbg.c amxstring.c)
296+
IF (UNIX)
297+
SET(AMXLIB_SRCS ${AMXLIB_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c)
298+
IF(NOT HAVE_CURSES_H)
299+
SET(AMXLIB_SRCS ${AMXLIB_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../linux/getch.c)
300+
ENDIF(NOT HAVE_CURSES_H)
301+
ENDIF (UNIX)
302+
ADD_LIBRARY(amx SHARED ${AMXLIB_SRCS})
303+
IF(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
304+
TARGET_COMPILE_DEFINITIONS(amx PUBLIC GCC_HASCLASSVISIBILITY)
305+
TARGET_COMPILE_OPTIONS(amx PUBLIC -fvisibility=hidden)
306+
ENDIF()
307+
SET_TARGET_PROPERTIES(amx PROPERTIES
308+
SOVERSION "${AMXLIB_MAJOR}"
309+
VERSION "${AMXLIB_VER}")
310+
IF(HAVE_CURSES_H)
311+
TARGET_LINK_LIBRARIES(amx curses)
312+
ENDIF()
313+
INSTALL(TARGETS amx LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
314+
315+
# --------------------------------------------------------------------------
316+
# pkgconfig
317+
318+
CONFIGURE_FILE(amx.pc.in amx.pc @ONLY)
319+
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/amx.pc
320+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
321+
322+
# --------------------------------------------------------------------------
323+
# Headers
324+
325+
INSTALL(FILES amx.h amxaux.h amxdbg.h osdefs.h DESTINATION include/pawn/amx)

amx/amx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, const cell *params)
610610
#if defined AMX_NO_PACKED_OPC
611611
#define GETOPCODE(c) (OPCODE)(c)
612612
#else
613-
#define GETOPCODE(c) (OPCODE)((c) & ((1 << sizeof(cell)*4)-1))
613+
#define GETOPCODE(c) (OPCODE)((c) & ((1L << sizeof(cell)*4)-1))
614614
#endif
615615
#endif
616616
#if !defined GETPARAM_P
@@ -656,7 +656,7 @@ static int VerifyPcode(AMX *amx)
656656
#if defined AMX_NO_PACKED_OPC
657657
opmask= ~0;
658658
#else
659-
opmask=(1 << sizeof(cell)*4)-1;
659+
opmask = (1UL << sizeof(cell)*4)-1;
660660
#endif
661661

662662
/* sanity checks */
@@ -2828,7 +2828,7 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
28282828
#if !defined AMX_NO_OVERLAY
28292829
case OP_CALL_OVL:
28302830
offs=(cell)((unsigned char *)cip-amx->code+sizeof(cell)); /* skip address */
2831-
assert(offs>=0 && offs<(1<<(sizeof(cell)*4)));
2831+
assert(offs>=0 && offs<(1L<<(sizeof(cell)*4)));
28322832
PUSH((offs<<(sizeof(cell)*4)) | amx->ovl_index);
28332833
amx->ovl_index=(int)*cip;
28342834
assert(amx->overlay!=NULL);
@@ -3527,7 +3527,7 @@ int AMXAPI amx_StrLen(const cell *cstr, int *length)
35273527
len=len - len % sizeof(cell); /* len = multiple of "cell" bytes */
35283528
while ((c & CHARMASK)!=0) {
35293529
len++;
3530-
c <<= 8*sizeof(char);
3530+
c = (ucell)c << 8*sizeof(char);
35313531
} /* if */
35323532
#endif
35333533
} else {

amx/amx.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ extern "C" {
196196
#define MIN_AMX_VER_JIT 11 /* AMX version supported by the JIT */
197197

198198
#if !defined PAWN_CELL_SIZE
199+
# if __SIZEOF_POINTER__==8
200+
#define PAWN_CELL_SIZE 64 /* use 64-bit cells for 64-bit systems */
201+
# else
199202
#define PAWN_CELL_SIZE 32 /* by default, use 32-bit cells */
203+
# endif
200204
#endif
201205
#if PAWN_CELL_SIZE==16
202206
typedef uint16_t ucell;
@@ -478,6 +482,7 @@ int AMXAPI amx_Allot(AMX *amx, int cells, cell **address);
478482
int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, const cell *params);
479483
int AMXAPI amx_Cleanup(AMX *amx);
480484
int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data);
485+
int AMXAPI amx_ConsoleInit(AMX *amx);
481486
int AMXAPI amx_Exec(AMX *amx, cell *retval, int index);
482487
int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index);
483488
int AMXAPI amx_FindPublic(AMX *amx, const char *name, int *index);
@@ -510,6 +515,7 @@ int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback);
510515
int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug);
511516
int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size);
512517
int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr);
518+
int AMXAPI amx_StringInit(AMX *amx);
513519
int AMXAPI amx_StrLen(const cell *cstring, int *length);
514520
int AMXAPI amx_UTF8Check(const char *string, int *length);
515521
int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value);

amx/amx.pc.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
exec_prefix=${prefix}
3+
includedir=${prefix}/include
4+
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
5+
6+
Name: amx
7+
Description: PAWNAMX library
8+
URL: https://www.compuphase.com/pawn/pawn.htm
9+
Version: @AMXLIB_VER@
10+
Requires:
11+
Libs: -L${libdir} -lamx
12+
Cflags: -I${includedir}/pawn -I${includedir}/pawn/linux

amx/amxfile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
#define _tgetenv getenv
9494
#define _tremove remove
9595
#define _trename rename
96-
#if defined __APPLE__
96+
#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
9797
#define _tmkdir mkdir
9898
#define _trmdir rmdir
9999
#define _tstat stat
@@ -623,7 +623,7 @@ static cell AMX_NATIVE_CALL n_fgetchar(AMX *amx, const cell *params)
623623
#define aligncell amx_Align16
624624
#elif PAWN_CELL_SIZE==32
625625
#define aligncell amx_Align32
626-
#elif PAWN_CELL_SIZE==64 && (defined _I64_MAX || defined HAVE_I64)
626+
#elif PAWN_CELL_SIZE==64 && (defined _I64_MAX || defined HAVE_I64 || __SIZEOF_POINTER__==8)
627627
#define aligncell amx_Align64
628628
#else
629629
#error Unsupported cell size

amx/amxtime.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
two's-complement arithmetic */
3333
#pragma GCC diagnostic ignored "-Wshift-negative-value"
3434
#endif
35-
#define CELLMIN (-1 << (8*sizeof(cell) - 1))
35+
#define CELLMIN (-1L << (8*sizeof(cell) - 1))
3636

3737
#define SECONDS_PER_MINUTE 60
3838
#define SECONDS_PER_HOUR 3600
@@ -157,7 +157,7 @@ static void settime(cell hour,cell minute,cell second)
157157
*/
158158
time_t sec1970;
159159
struct tm gtm;
160-
#if defined __APPLE__ /* also valid for other POSIX systems */
160+
#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
161161
struct timeval tv;
162162
#endif
163163

@@ -170,7 +170,7 @@ static void settime(cell hour,cell minute,cell second)
170170
if (second!=CELLMIN)
171171
gtm.tm_sec=wrap((int)second,0,59);
172172
sec1970=mktime(&gtm);
173-
#if defined __APPLE__ /* also valid for other POSIX systems */
173+
#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
174174
tv.tv_sec = sec1970;
175175
tv.tv_usec = 0;
176176
settimeofday(&tv, 0);
@@ -205,7 +205,7 @@ static void setdate(cell year,cell month,cell day)
205205
*/
206206
time_t sec1970;
207207
struct tm gtm;
208-
#if defined __APPLE__ /* also valid for other POSIX systems */
208+
#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
209209
struct timeval tv;
210210
#endif
211211

@@ -218,7 +218,7 @@ static void setdate(cell year,cell month,cell day)
218218
if (day!=CELLMIN)
219219
gtm.tm_mday=day;
220220
sec1970=mktime(&gtm);
221-
#if defined __APPLE__ /* also valid for other POSIX systems */
221+
#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
222222
tv.tv_sec = sec1970;
223223
tv.tv_usec = 0;
224224
settimeofday(&tv, 0);
@@ -390,7 +390,7 @@ static cell AMX_NATIVE_CALL n_settimestamp(AMX *amx, const cell *params)
390390
* must have "root" permission to call stime(); many POSIX systems will
391391
* have settimeofday() instead
392392
*/
393-
#if defined __APPLE__ /* also valid for other POSIX systems */
393+
#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
394394
struct timeval tv;
395395
tv.tv_sec = params[1];
396396
tv.tv_usec = 0;

compiler/CMakeLists.txt

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,41 @@ ENDIF(WIN32)
4949
IF(UNIX)
5050
SET(PAWNCC_SRCS ${PAWNCC_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/../linux/binreloc.c)
5151
ENDIF(UNIX)
52-
ADD_EXECUTABLE(pawncc ${PAWNCC_SRCS})
5352

53+
FILE(READ svnrev.h SVNREV_STR)
54+
STRING(REGEX REPLACE ".*#define[ \t]+SVN_REV[ \t]+([0-9]+).*" "\\1" PAWNC_REV "${SVNREV_STR}")
55+
FILE(READ sc1.c SC1_STR)
56+
STRING(REGEX REPLACE ".*#define[ \t]+VERSION_STR[ \t]+\"([0-9]+).*" "\\1" PAWNC_MAJOR "${SC1_STR}")
57+
STRING(REGEX REPLACE ".*#define[ \t]+VERSION_STR[ \t]+\"([0-9]+).([0-9]+).*" "\\2" PAWNC_MINOR "${SC1_STR}")
58+
59+
SET(PAWNC_VER "${PAWNC_MAJOR}.${PAWNC_MINOR}.${PAWNC_REV}")
60+
61+
ADD_LIBRARY(pawnc SHARED ${PAWNCC_SRCS})
62+
TARGET_COMPILE_DEFINITIONS(pawnc PUBLIC NO_MAIN)
63+
IF(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
64+
TARGET_COMPILE_DEFINITIONS(pawnc PUBLIC HAVE_VISIBILITY)
65+
TARGET_COMPILE_OPTIONS(pawnc PUBLIC -fvisibility=hidden)
66+
ENDIF()
67+
SET_TARGET_PROPERTIES(pawnc PROPERTIES
68+
SOVERSION "${PAWNC_MAJOR}"
69+
VERSION "${PAWNC_VER}")
70+
71+
CONFIGURE_FILE(pawnc.pc.in pawnc.pc @ONLY)
72+
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pawnc.pc
73+
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
74+
75+
ADD_EXECUTABLE(pawncc ${PAWNCC_SRCS})
5476

5577
# Utility to create GraphViz "dot" files from the XML report (if the report contains states)
56-
ADD_DEFINITIONS(-DEZXML_NOMMAP)
5778
SET(STATEGRAPH_SRCS stategraph.c ezxml.c)
5879
ADD_EXECUTABLE(stategraph ${STATEGRAPH_SRCS})
59-
80+
TARGET_COMPILE_DEFINITIONS(stategraph PUBLIC EZXML_NOMMAP)
6081

6182
# Simple Pawn disassembler
6283
SET(PAWNDISASM_SRCS pawndisasm.c)
6384
ADD_EXECUTABLE(pawndisasm ${PAWNDISASM_SRCS})
85+
86+
INSTALL(TARGETS pawnc LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
87+
INSTALL(TARGETS pawncc stategraph pawndisasm RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
88+
INSTALL(FILES sc.h memfile.h DESTINATION include/pawn/compiler)
89+
INSTALL(FILES ../linux/sclinux.h ../linux/getch.h DESTINATION include/pawn/linux)

compiler/pawnc.pc.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
exec_prefix=${prefix}
3+
includedir=${prefix}/include
4+
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
5+
6+
Name: pawnc
7+
Description: PAWN COMPILER library
8+
URL: https://www.compuphase.com/pawn/pawn.htm
9+
Version: @PAWNC_VER@
10+
Requires:
11+
Libs: -L${libdir} -lpawnc
12+
Cflags: -I${includedir}/pawn -I${includedir}/pawn/linux

compiler/sc1.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767

6868
#if defined __WIN32__ || defined _WIN32 || defined WIN32 || defined __NT__
6969
#define DLLEXPORT __declspec (dllexport)
70+
#elif defined HAVE_VISIBILITY
71+
#define DLLEXPORT __attribute__ ((visibility("default")))
7072
#endif
7173

7274
#include "lstring.h"
@@ -184,6 +186,8 @@ int main(int argc, char *argv[])
184186
return pc_compile(argc,argv);
185187
}
186188

189+
#endif /* !defined NO_MAIN */
190+
187191
/* pc_printf()
188192
* Called for general purpose "console" output. This function prints general
189193
* purpose messages; errors go through pc_error(). The function is modelled
@@ -436,9 +440,6 @@ long pc_lengthbin(void *handle)
436440
return ftell((FILE*)handle);
437441
}
438442

439-
#endif /* !defined NO_MAIN */
440-
441-
442443
#if !(defined __MSDOS__ || defined __WIN32__ || defined _Windows)
443444
int posix_spawnl(char *pgm,...)
444445
{
@@ -554,7 +555,12 @@ int pc_compile(int argc, char *argv[])
554555
tmpname=NULL;
555556
sname=NULL;
556557
#else
557-
tmpname=tempnam(NULL,"pawn");
558+
int tmpfd = mkstemp("pawn.XXXXXX");
559+
char *procname = alloca(64);
560+
tmpname = alloca(PATH_MAX);
561+
sprintf(procname, "/proc/self/fd/%d", tmpfd);
562+
readlink(procname, tmpname, PATH_MAX);
563+
close(tmpfd);
558564
#endif
559565
ftmp=(FILE*)pc_createsrc(tmpname);
560566
for (fidx=0; (sname=get_sourcefile(fidx))!=NULL; fidx++) {
@@ -885,6 +891,9 @@ int pc_compile(int argc, char *argv[])
885891
} else {
886892
retcode=jmpcode;
887893
} /* if */
894+
#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__
895+
br_deinit();
896+
#endif
888897
#if defined FORTIFY
889898
Fortify_ListAllMemory();
890899
#endif
@@ -1686,7 +1695,7 @@ static void setconstants(void)
16861695
add_constant("cellmin",(cell)((ucell)-1<<(8*pc_cellsize-1)),sGLOBAL,0);
16871696
add_constant("charbits",sCHARBITS,sGLOBAL,0);
16881697
add_constant("charmin",0,sGLOBAL,0);
1689-
add_constant("charmax",~(~0 << sCHARBITS),sGLOBAL,0);
1698+
add_constant("charmax",~(~0UL << sCHARBITS),sGLOBAL,0);
16901699
add_constant("ucharmax",((cell)1 << (pc_cellsize-1)*8)-1,sGLOBAL,0);
16911700

16921701
add_constant("__Pawn",VERSION_INT,sGLOBAL,0);

compiler/sc2.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ SC_FUNC void pushstk(stkitem val)
8484
if (newstack==NULL)
8585
error(102,"parser stack"); /* stack overflow (recursive include?) */
8686
/* swap the stacks */
87-
memcpy(newstack,stack,stkidx*sizeof(stkitem));
88-
if (stack!=NULL)
87+
if (stack!=NULL) {
88+
memcpy(newstack,stack,stkidx*sizeof(stkitem));
8989
free(stack);
90+
}
9091
stack=newstack;
9192
stktop=newsize;
9293
} /* if */

0 commit comments

Comments
 (0)