Added support for Mac OS X and building with clang (bug 5601, r=dvander).

This commit is contained in:
Scott Ehlert
2013-02-13 01:14:37 -06:00
parent b0fe6c83e2
commit 40c1fee55a
191 changed files with 3835 additions and 1946 deletions

View File

@ -1,46 +1,107 @@
#(C)2004-2005 AMX Mod X Development Team
# (C)2004-2013 AMX Mod X Development Team
# Makefile written by David "BAILOPAN" Anderson
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################
OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing
DEBUG_FLAGS = -g -ggdb3
CPP = gcc-4.1
BINARY = amxxpc
PROJECT = amxxpc
OBJECTS = amx.cpp amxxpc.cpp Binary.cpp
LINK = -lz /lib32/libstdc++.a
##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
##############################################
INCLUDE = -I. -L.
C_OPT_FLAGS = -DNDEBUG -O2 -funroll-loops -fomit-frame-pointer -pipe
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
C_GCC4_FLAGS = -fvisibility=hidden
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
CPP = gcc
CPP_OSX = clang
LINK =
INCLUDE = -I.
################################################
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
################################################
OS := $(shell uname -s)
ifeq "$(OS)" "Darwin"
CPP = $(CPP_OSX)
LIB_SUFFIX = _osx
CFLAGS += -DOSX
LINK += -lstdc++ -mmacosx-version-min=10.5 -lz-darwin
else
LIB_SUFFIX =
CFLAGS += -DLINUX
LINK += -lz /lib32/libstdc++.a
endif
LINK += -m32 -lm -ldl -L.
CFLAGS += -DAMX_ANSIONLY -DHAVE_STDINT_H -fno-strict-aliasing \
-m32 -Wall -Werror
CPPFLAGS += -fexceptions -fno-rtti
BINARY = $(PROJECT)$(LIB_SUFFIX)
ifeq "$(DEBUG)" "true"
BIN_DIR = Debug
CFLAGS = $(DEBUG_FLAGS)
CFLAGS += $(C_DEBUG_FLAGS)
else
BIN_DIR = Release
CFLAGS = $(OPT_FLAGS)
CFLAGS += $(C_OPT_FLAGS)
endif
CFLAGS += -DLINUX -DNDEBUG -Wno-deprecated -fexceptions -DHAVE_STDINT_H -DAMX_ANSIONLY -fno-rtti -static-libgcc
IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0")
OBJ_LINUX := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
ifeq "$(IS_CLANG)" "1"
CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/")
CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/")
else
CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1)
CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3)
endif
# Clang || GCC >= 4
ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1"
CFLAGS += $(C_GCC4_FLAGS)
CPPFLAGS += $(CPP_GCC4_FLAGS)
endif
# Clang >= 3 || GCC >= 4.7
ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1"
CFLAGS += -Wno-delete-non-virtual-dtor
endif
# OS is Linux and not using clang
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1"
LINK += -static-libgcc
endif
OBJ_BIN := $(OBJECTS:%.cpp=$(BIN_DIR)/%.o)
# This will break if we include other Makefiles, but is fine for now. It allows
# us to make a copy of this file that uses altered paths (ie. Makefile.mine)
# or other changes without mucking up the original.
MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
$(BIN_DIR)/%.o: %.cpp
$(CPP) $(INCLUDE) $(CFLAGS) -m32 -o $@ -c $<
$(CPP) $(INCLUDE) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
all:
mkdir -p $(BIN_DIR)
$(MAKE) amxxpc
$(MAKE) -f $(MAKEFILE_NAME) $(PROJECT)
amxxpc: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) -m32 $(OBJ_LINUX) $(LINK) -ldl -lm -o$(BIN_DIR)/$(BINARY)
$(PROJECT): $(OBJ_BIN)
$(CPP) $(INCLUDE) $(OBJ_BIN) $(LINK) -o $(BIN_DIR)/$(BINARY)
default: all
clean:
rm -rf Release/*.o
rm -rf Release/$(BINARY)
rm -rf Debug/*.o
rm -rf Debug/$(BINARY)
rm -rf $(BIN_DIR)/*.o
rm -f $(BIN_DIR)/$(BINARY)

View File

@ -42,7 +42,7 @@
#include <stddef.h> /* for wchar_t */
#include <string.h>
#include "osdefs.h"
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
#include <sclinux.h>
#if !defined AMX_NODYNALOAD
#include <dlfcn.h>
@ -815,12 +815,12 @@ static void expand(unsigned char *code, long codesize, long memsize)
int AMXAPI amx_Init(AMX *amx,void *program)
{
AMX_HEADER *hdr;
#if (defined _Windows || defined LINUX || defined __FreeBSD__ || defined __OpenBSD__) && !defined AMX_NODYNALOAD
#if (defined _Windows || defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) && !defined AMX_NODYNALOAD
char libname[sNAMEMAX+8]; /* +1 for '\0', +3 for 'amx' prefix, +4 for extension */
#if defined _Windows
typedef int (FAR WINAPI *AMX_ENTRY)(AMX _FAR *amx);
HINSTANCE hlib;
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
typedef int (*AMX_ENTRY)(AMX *amx);
void *hlib;
#endif
@ -965,7 +965,7 @@ int AMXAPI amx_Init(AMX *amx,void *program)
amx_BrowseRelocate(amx);
/* load any extension modules that the AMX refers to */
#if (defined _Windows || defined LINUX || defined __FreeBSD__ || defined __OpenBSD__) && !defined AMX_NODYNALOAD
#if (defined _Windows || defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) && !defined AMX_NODYNALOAD
hdr=(AMX_HEADER *)amx->base;
numlibraries=NUMENTRIES(hdr,libraries,pubvars);
for (i=0; i<numlibraries; i++) {
@ -981,7 +981,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 __APPLE__
strcat(libname,".so");
hlib=dlopen(libname,RTLD_NOW);
#endif
@ -995,7 +995,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__
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
libinit=(AMX_ENTRY)dlsym(hlib,funcname);
#endif
if (libinit!=NULL)
@ -1029,7 +1029,7 @@ int AMXAPI amx_Init(AMX *amx,void *program)
return !VirtualProtect(addr, len, p, &prev);
}
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
/* Linux already has mprotect() */
@ -1104,10 +1104,10 @@ int AMXAPI amx_InitJIT(AMX *amx,void *compiled_program,void *reloc_table)
#if defined AMX_CLEANUP
int AMXAPI amx_Cleanup(AMX *amx)
{
#if (defined _Windows || defined LINUX || defined __FreeBSD__ || defined __OpenBSD__) && !defined AMX_NODYNALOAD
#if (defined _Windows || defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) && !defined AMX_NODYNALOAD
#if defined _Windows
typedef int (FAR WINAPI *AMX_ENTRY)(AMX FAR *amx);
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
typedef int (*AMX_ENTRY)(AMX *amx);
#endif
AMX_HEADER *hdr;
@ -1117,7 +1117,7 @@ int AMXAPI amx_Cleanup(AMX *amx)
#endif
/* unload all extension modules */
#if (defined _Windows || defined LINUX || defined __FreeBSD__ || defined __OpenBSD__) && !defined AMX_NODYNALOAD
#if (defined _Windows || defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__) && !defined AMX_NODYNALOAD
hdr=(AMX_HEADER *)amx->base;
assert(hdr->magic==AMX_MAGIC);
numlibraries=NUMENTRIES(hdr,libraries,pubvars);
@ -1130,14 +1130,14 @@ int AMXAPI amx_Cleanup(AMX *amx)
strcat(funcname,"Cleanup");
#if defined _Windows
libcleanup=(AMX_ENTRY)GetProcAddress((HINSTANCE)lib->address,funcname);
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
libcleanup=(AMX_ENTRY)dlsym((void*)lib->address,funcname);
#endif
if (libcleanup!=NULL)
libcleanup(amx);
#if defined _Windows
FreeLibrary((HINSTANCE)lib->address);
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
dlclose((void*)lib->address);
#endif
} /* if */
@ -1666,7 +1666,7 @@ int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char
* fast "indirect threaded" interpreter.
*/
#define NEXT(cip) goto **cip++
#define NEXT(cip) goto *(const void *)*cip++
int AMXAPI amx_Exec(AMX *amx, cell *retval, int index)
{
@ -1846,14 +1846,14 @@ static const void * const amx_opcodelist[] = {
NEXT(cip);
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= * (cell *)(data+(int)pri);
NEXT(cip);
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 (offs) {
case 1:
@ -1919,14 +1919,14 @@ static const void * const amx_opcodelist[] = {
NEXT(cip);
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);
*(cell *)(data+(int)alt)=pri;
NEXT(cip);
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 (offs) {
case 1:
@ -1943,7 +1943,7 @@ static const void * const amx_opcodelist[] = {
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= * (cell *)(data+(int)offs);
NEXT(cip);
@ -1951,7 +1951,7 @@ static const void * const amx_opcodelist[] = {
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= * (cell *)(data+(int)offs);
NEXT(cip);
@ -2388,13 +2388,13 @@ static const void * const amx_opcodelist[] = {
/* 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);
memcpy(data+(int)alt, data+(int)pri, (int)offs);
NEXT(cip);
@ -2403,22 +2403,22 @@ static const void * const amx_opcodelist[] = {
/* 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);
pri=memcmp(data+(int)alt, data+(int)pri, (int)offs);
NEXT(cip);
op_fill:
GETPARAM(offs);
/* verify top & bottom memory addresses */
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; offs>=(int)sizeof(cell); i+=sizeof(cell), offs-=sizeof(cell))
*(cell *)(data+i) = pri;
@ -3592,7 +3592,7 @@ int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr)
data=(amx->data!=NULL) ? amx->data : amx->base+(int)hdr->dat;
assert(phys_addr!=NULL);
if (amx_addr>=amx->hea && amx_addr<amx->stk || amx_addr<0 || amx_addr>=amx->stp) {
if ((amx_addr>=amx->hea && amx_addr<amx->stk) || amx_addr<0 || amx_addr>=amx->stp) {
*phys_addr=NULL;
return AMX_ERR_MEMACCESS;
} /* if */

View File

@ -24,7 +24,7 @@
#if defined FREEBSD && !defined __FreeBSD__
#define __FreeBSD__
#endif
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
#include <sclinux.h>
#endif
@ -34,7 +34,7 @@
#if defined HAVE_STDINT_H
#include <stdint.h>
#else
#if defined __LCC__ || defined __DMC__ || defined LINUX
#if defined __LCC__ || defined __DMC__ || defined LINUX || defined __APPLE__
#if defined HAVE_INTTYPES_H
#include <inttypes.h>
#else
@ -188,7 +188,7 @@ typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx);
#endif
#if !defined AMX_NO_ALIGN
#if defined LINUX || defined __FreeBSD__
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
#pragma pack(1) /* structures must be packed (byte-aligned) */
#elif defined MACOS && defined __MWERKS__
#pragma options align=mac68k
@ -416,7 +416,7 @@ int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value);
amx_Register((amx), amx_NativeInfo((name),(func)), 1);
#if !defined AMX_NO_ALIGN
#if defined LINUX || defined __FreeBSD__
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
#pragma pack() /* reset default packing */
#elif defined MACOS && defined __MWERKS__
#pragma options align=reset

View File

@ -49,7 +49,7 @@ extern "C" {
#endif
#if !defined AMX_NO_ALIGN
#if defined LINUX || defined __FreeBSD__
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
#pragma pack(1) /* structures must be packed (byte-aligned) */
#elif defined MACOS && defined __MWERKS__
#pragma options align=mac68k
@ -156,7 +156,7 @@ int AMXAPI dbg_GetArrayDim(AMX_DBG *amxdbg, const AMX_DBG_SYMBOL *sym, const AMX
#if !defined AMX_NO_ALIGN
#if defined LINUX || defined __FreeBSD__
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
#pragma pack() /* reset default packing */
#elif defined MACOS && defined __MWERKS__
#pragma options align=reset

View File

@ -1,5 +1,5 @@
#include <stdio.h>
#ifdef __linux__
#if defined(__linux__) | defined (__APPLE__)
#include <unistd.h>
#else
#include <fcntl.h>
@ -29,25 +29,26 @@ void WriteBh(BinaryWriter *bw, BinPlugin *bh);
int main(int argc, char **argv)
{
struct abl pl32;
struct abl pl64;
#ifdef _DEBUG
printf("debug clamp\n");
getchar();
#endif
#ifdef __linux__
#if defined(__linux__)
HINSTANCE lib = NULL;
if (FileExists("./amxxpc32.so"))
lib = dlmount("./amxxpc32.so");
else
lib = dlmount("amxxpc32.so");
#elif defined(__APPLE__)
HINSTANCE lib = dlmount("amxxpc32.dylib");
#else
HINSTANCE lib = dlmount("amxxpc32.dll");
#endif
if (!lib)
{
#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
printf("compiler failed to instantiate: %s\n", dlerror());
#else
printf("compiler failed to instantiate: %d\n", GetLastError());
@ -60,7 +61,7 @@ int main(int argc, char **argv)
if (!sc32 || !pc_printf)
{
#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
printf("compiler failed to link: %p.\n",sc32);
#else
printf("compiler failed to link: %d.\n", GetLastError());
@ -69,7 +70,7 @@ int main(int argc, char **argv)
}
pc_printf("Welcome to the AMX Mod X %s Compiler.\n", VERSION_STRING);
pc_printf("Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team\n\n");
pc_printf("Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team\n\n");
if (argc < 2)
{
@ -243,7 +244,7 @@ char *swiext(const char *file, const char *ext, int isO)
int i = 0, pos = -1, j = 0;
int fileLen = strlen(file);
int extLen = strlen(ext);
int max = 0, odirFlag = -1;
int odirFlag = -1;
for (i=fileLen-1; i>=0; i--)
{
@ -339,7 +340,7 @@ void show_help()
printf("\t-r[name] write cross reference report to console or to specified file\n");
}
#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
bool FileExists(const char *file)
{
FILE *fp = fopen(file, "rb");

View File

@ -5,7 +5,7 @@
#define MAGIC_HEADER2 0x414D5858
#define MAGIC_VERSION 0x0300
#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
# include <dlfcn.h>
#else
# include <windows.h>
@ -13,7 +13,7 @@
#include <string.h>
#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
# define dlmount(x) dlopen(x, RTLD_NOW|RTLD_GLOBAL)
typedef void* HINSTANCE;
#else
@ -65,7 +65,7 @@ struct BinPlugin
int32_t offs; //file offset
};
#ifdef __linux__
#if defined(__linux__) || defined(__APPLE__)
bool FileExists(const char *file);
#endif

View File

@ -39,6 +39,10 @@
#include <endian.h>
#endif
#if defined __APPLE__
#include <sys/types.h>
#endif
/* Linux NOW has these */
#if !defined BIG_ENDIAN
#define BIG_ENDIAN 4321

View File

@ -32,6 +32,10 @@
*/
#if !defined __BYTE_ORDER
# include <stdlib.h>
# if defined __APPLE__
# include <sys/types.h>
# define __BYTE_ORDER BYTE_ORDER
# endif
#endif
#if defined __OpenBSD__ || defined __FreeBSD__

View File

@ -1,46 +1,108 @@
#(C)2004-2005 AMX Mod X Development Team
# (C)2004-2013 AMX Mod X Development Team
# Makefile written by David "BAILOPAN" Anderson
#####################################
### EDIT BELOW FOR OTHER PROJECTS ###
#####################################
OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing -fvisibility=hidden
DEBUG_FLAGS = -g -ggdb3
CPP = gcc-4.1
NAME = amxxpc32
PROJECT = amxxpc32
OBJECTS = sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c scvars.c scmemfil.c scstate.c sclist.c sci18n.c \
scexpand.c pawncc.c libpawnc.c prefix.c memfile.c
OBJECTS = sc1.c sc2.c sc3.c sc4.c sc5.c sc6.c sc7.c scvars.c scmemfil.c \
scstate.c sclist.c sci18n.c scexpand.c pawncc.c libpawnc.c prefix.c \
memfile.c
##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
##############################################
C_OPT_FLAGS = -DNDEBUG -O2 -funroll-loops -fomit-frame-pointer -pipe
C_DEBUG_FLAGS = -D_DEBUG -DDEBUG -g -ggdb3
C_GCC4_FLAGS = -fvisibility=hidden
CPP_GCC4_FLAGS = -fvisibility-inlines-hidden
CPP = gcc
CPP_OSX = clang
LINK = -lpthread
INCLUDE = -I.
INCLUDE = -I.
BINARY = $(NAME).so
BIN_DIR = Release
CFLAGS += -DPAWN_CELL_SIZE=32
################################################
### DO NOT EDIT BELOW HERE FOR MOST PROJECTS ###
################################################
CFLAGS += -DLINUX -DNDEBUG -DHAVE_STDINT_H -DENABLE_BINRELOC -DNO_MAIN -DPAWNC_DLL -static-libgcc
OS := $(shell uname -s)
CFLAGS += $(OPT_FLAGS)
OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o)
ifeq "$(OS)" "Darwin"
CPP = $(CPP_OSX)
LIB_EXT = dylib
CFLAGS += -DOSX
LINK += -dynamiclib -mmacosx-version-min=10.5
else
LIB_EXT = so
CFLAGS += -DLINUX
LINK += -shared
endif
LINK += -m32 -lm -ldl
CFLAGS += -DENABLE_BINRELOC -DNO_MAIN -DPAWNC_DLL -DHAVE_STDINT_H -fno-strict-aliasing -m32 -Wall \
-Werror
CPPFLAGS += -fexceptions -fno-rtti
BINARY = $(PROJECT).$(LIB_EXT)
ifeq "$(DEBUG)" "true"
BIN_DIR = Debug
CFLAGS += $(C_DEBUG_FLAGS)
else
BIN_DIR = Release
CFLAGS += $(C_OPT_FLAGS)
endif
IS_CLANG := $(shell $(CPP) --version | head -1 | grep clang > /dev/null && echo "1" || echo "0")
ifeq "$(IS_CLANG)" "1"
CPP_MAJOR := $(shell $(CPP) --version | grep clang | sed "s/.*version \([0-9]\)*\.[0-9]*.*/\1/")
CPP_MINOR := $(shell $(CPP) --version | grep clang | sed "s/.*version [0-9]*\.\([0-9]\)*.*/\1/")
else
CPP_MAJOR := $(shell $(CPP) -dumpversion >&1 | cut -b1)
CPP_MINOR := $(shell $(CPP) -dumpversion >&1 | cut -b3)
endif
# Clang || GCC >= 4
ifeq "$(shell expr $(IS_CLANG) \| $(CPP_MAJOR) \>= 4)" "1"
CFLAGS += $(C_GCC4_FLAGS)
CPPFLAGS += $(CPP_GCC4_FLAGS)
endif
# Clang >= 3 || GCC >= 4.7
ifeq "$(shell expr $(IS_CLANG) \& $(CPP_MAJOR) \>= 3 \| $(CPP_MAJOR) \>= 4 \& $(CPP_MINOR) \>= 7)" "1"
CFLAGS += -Wno-delete-non-virtual-dtor
endif
# OS is Linux and not using clang
ifeq "$(shell expr $(OS) \= Linux \& $(IS_CLANG) \= 0)" "1"
LINK += -static-libgcc
endif
OBJ_BIN := $(OBJECTS:%.c=$(BIN_DIR)/%.o)
# This will break if we include other Makefiles, but is fine for now. It allows
# us to make a copy of this file that uses altered paths (ie. Makefile.mine)
# or other changes without mucking up the original.
MAKEFILE_NAME := $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
$(BIN_DIR)/%.o: %.c
$(CPP) $(INCLUDE) $(CFLAGS) -m32 -o $@ -c $<
$(CPP) $(INCLUDE) $(CFLAGS) -o $@ -c $<
all:
mkdir -p Release
$(MAKE) pawn_make
mkdir -p $(BIN_DIR)
$(MAKE) -f $(MAKEFILE_NAME) $(PROJECT)
pawn_make: $(OBJ_LINUX)
$(CPP) $(INCLUDE) $(CFLAGS) -m32 $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY)
debug:
$(MAKE) all DEBUG=true
$(PROJECT): $(OBJ_BIN)
$(CPP) $(INCLUDE) $(OBJ_BIN) $(LINK) -o $(BIN_DIR)/$(BINARY)
default: all
clean:
rm -rf Release/*.o
rm -rf Release/$(BINARY)
rm -rf $(BIN_DIR)/*.o
rm -f $(BIN_DIR)/$(BINARY)

View File

@ -33,7 +33,7 @@
#if defined FREEBSD && !defined __FreeBSD__
#define __FreeBSD__
#endif
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
#include <sclinux.h>
#endif
@ -43,7 +43,7 @@
#if defined HAVE_STDINT_H
#include <stdint.h>
#else
#if defined __LCC__ || defined __DMC__ || defined LINUX
#if defined __LCC__ || defined __DMC__ || defined LINUX || defined __APPLE__
#if defined HAVE_INTTYPES_H
#include <inttypes.h>
#else
@ -197,7 +197,7 @@ typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx);
#endif
#if !defined AMX_NO_ALIGN
#if defined LINUX || defined __FreeBSD__
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
#pragma pack(1) /* structures must be packed (byte-aligned) */
#elif defined MACOS && defined __MWERKS__
#pragma options align=mac68k
@ -425,7 +425,7 @@ int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value);
amx_Register((amx), amx_NativeInfo((name),(func)), 1);
#if !defined AMX_NO_ALIGN
#if defined LINUX || defined __FreeBSD__
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
#pragma pack() /* reset default packing */
#elif defined MACOS && defined __MWERKS__
#pragma options align=reset

View File

@ -49,7 +49,7 @@ extern "C" {
#endif
#if !defined AMX_NO_ALIGN
#if defined LINUX || defined __FreeBSD__
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
#pragma pack(1) /* structures must be packed (byte-aligned) */
#elif defined MACOS && defined __MWERKS__
#pragma options align=mac68k
@ -156,7 +156,7 @@ int AMXAPI dbg_GetArrayDim(AMX_DBG *amxdbg, const AMX_DBG_SYMBOL *sym, const AMX
#if !defined AMX_NO_ALIGN
#if defined LINUX || defined __FreeBSD__
#if defined LINUX || defined __FreeBSD__ || defined __APPLE__
#pragma pack() /* reset default packing */
#elif defined MACOS && defined __MWERKS__
#pragma options align=reset

View File

@ -30,7 +30,7 @@
#if defined PAWNC_DLL
#ifndef __linux__
#if !defined(__linux__) && !defined(__APPLE__)
#include "dllmain.c"
#endif
@ -39,9 +39,6 @@
# define UNUSED_PARAM(p) ((void)(p))
# endif
static char *argv[MAX_ARGS];
static int argc;
#if PAWN_CELL_SIZE==32
#define EXCOMPILER Compile32
#else

View File

@ -10,6 +10,7 @@ memfile_t *memfile_creat(const char *name, size_t init)
mf.size = init;
mf.base = (char *)malloc(init);
mf.usedoffs = 0;
mf.name = NULL;
if (!mf.base)
{
return NULL;

View File

@ -9,7 +9,7 @@
#endif
#endif
#include <malloc.h>
#include <stdlib.h>
typedef struct memfile_s
{

View File

@ -41,6 +41,10 @@
#include <endian.h>
#endif
#if defined __APPLE__
#include <sys/types.h>
#endif
/* Linux NOW has these */
#if !defined BIG_ENDIAN
#define BIG_ENDIAN 4321

View File

@ -63,7 +63,7 @@
#define PREPROC_TERM '\x7f'/* termination character for preprocessor expressions (the "DEL" code) */
#define sDEF_PREFIX "default.inc" /* default prefix filename */
#if defined WIN32
#if defined WIN32 || defined __clang__
#define INVISIBLE
#else
#define INVISIBLE __attribute__((visibility("protected")))

View File

@ -35,9 +35,10 @@
#include <io.h>
#endif
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
#include <sclinux.h>
#include <prefix.h> /* from BinReloc, see www.autopackage.org */
#include <unistd.h>
#endif
#if defined FORTIFY
@ -421,7 +422,7 @@ int pc_compile(int argc, char *argv[])
void *inpfmark;
int lcl_packstr,lcl_needsemicolon,lcl_tabsize;
#if !defined SC_LIGHT
int hdrsize;
int hdrsize=0;
#endif
/* set global variables to their initial value */
@ -1248,9 +1249,9 @@ static void setconfig(char *root)
/* add the default "include" directory */
#if defined __WIN32__ || defined _WIN32
GetModuleFileName(NULL,path,_MAX_PATH);
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#elif defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
/* see www.autopackage.org for the BinReloc module */
ptr = SELFPATH;
ptr = (char *)SELFPATH;
if (!ptr)
ptr = root;
strncpy(path,ptr,sizeof path);
@ -1922,7 +1923,7 @@ static int declloc(int fstatic)
int dim[sDIMEN_MAX];
int numdim;
int fconst;
int staging_start;
int staging_start=0;
fconst=matchtoken(tCONST);
do {
@ -1948,7 +1949,7 @@ static int declloc(int fstatic)
* level might indicate a bug.
* NOTE - don't bother with the error if there's no valid function!
*/
if ((sym=findloc(name))!=NULL && sym->compound!=nestlevel || findglb(name)!=NULL)
if (((sym=findloc(name))!=NULL && sym->compound!=nestlevel) || findglb(name)!=NULL)
if (curfunc!=NULL && (curfunc->usage & uNATIVE))
error(219,name); /* variable shadows another symbol */
while (matchtoken('[')){
@ -2863,7 +2864,7 @@ static int operatoradjust(int opertok,symbol *sym,char *opername,int resulttag)
error(62); /* number or placement of the operands does not fit the operator */
} /* switch */
if (tags[0]==0 && (opertok!='=' && tags[1]==0 || opertok=='=' && resulttag==0))
if (tags[0]==0 && ((opertok!='=' && tags[1]==0) || (opertok=='=' && resulttag==0)))
error(64); /* cannot change predefined operators */
/* change the operator name */
@ -3045,7 +3046,7 @@ static void funcstub(int native)
tok=lex(&val,&str);
if (native) {
if (tok==tPUBLIC || tok==tSTOCK || tok==tSTATIC || tok==tSYMBOL && *str==PUBLIC_CHAR)
if (tok==tPUBLIC || tok==tSTOCK || tok==tSTATIC || (tok==tSYMBOL && *str==PUBLIC_CHAR))
error(42); /* invalid combination of class specifiers */
} else {
if (tok==tPUBLIC || tok==tSTOCK || tok==tSTATIC)
@ -3166,7 +3167,7 @@ static int newfunc(char *firstname,int firsttag,int fpublic,int fstatic,int stoc
tag= (firsttag>=0) ? firsttag : pc_addtag(NULL);
tok=lex(&val,&str);
assert(!fpublic);
if (tok==tNATIVE || tok==tPUBLIC && stock)
if (tok==tNATIVE || (tok==tPUBLIC && stock))
error(42); /* invalid combination of class specifiers */
if (tok==tOPERATOR) {
opertok=operatorname(symbolname);
@ -3512,7 +3513,7 @@ static int declargs(symbol *sym)
error(10); /* illegal function or declaration */
} /* switch */
} while (tok=='&' || tok==tLABEL || tok==tCONST
|| tok!=tELLIPS && matchtoken(',')); /* more? */
|| (tok!=tELLIPS && matchtoken(','))); /* more? */
/* if the next token is not ",", it should be ")" */
needtoken(')');
} /* if */
@ -3873,7 +3874,7 @@ static void make_report(symbol *root,FILE *log,char *sourcefile)
continue;
if ((sym->usage & uREAD)==0)
continue;
fprintf(log,"\t\t<member name=\"T:%s\" value=\"%ld\">\n",funcdisplayname(symname,sym->name),sym->addr);
fprintf(log,"\t\t<member name=\"T:%s\" value=\"%ld\">\n",funcdisplayname(symname,sym->name),(long)sym->addr);
if (sym->tag!=0) {
tagsym=find_tag_byval(sym->tag);
assert(tagsym!=NULL);
@ -3883,7 +3884,7 @@ static void make_report(symbol *root,FILE *log,char *sourcefile)
if ((enumroot=sym->dim.enumlist)!=NULL) {
enumroot=enumroot->next; /* skip root */
while (enumroot!=NULL) {
fprintf(log,"\t\t\t<member name=\"C:%s\" value=\"%ld\">\n",funcdisplayname(symname,enumroot->name),enumroot->value);
fprintf(log,"\t\t\t<member name=\"C:%s\" value=\"%ld\">\n",funcdisplayname(symname,enumroot->name),(long)enumroot->value);
/* find the constant with this name and get the tag */
ref=findglb(enumroot->name);
if (ref!=NULL) {
@ -3919,7 +3920,7 @@ static void make_report(symbol *root,FILE *log,char *sourcefile)
continue;
if ((sym->usage & uREAD)==0 || (sym->usage & (uENUMFIELD | uENUMROOT))!=0)
continue;
fprintf(log,"\t\t<member name=\"C:%s\" value=\"%ld\">\n",funcdisplayname(symname,sym->name),sym->addr);
fprintf(log,"\t\t<member name=\"C:%s\" value=\"%ld\">\n",funcdisplayname(symname,sym->name),(long)sym->addr);
if (sym->tag!=0) {
tagsym=find_tag_byval(sym->tag);
assert(tagsym!=NULL);
@ -4039,7 +4040,7 @@ static void make_report(symbol *root,FILE *log,char *sourcefile)
for (arg=0; sym->dim.arglist[arg].ident!=0; arg++) {
int dim,paraminfo;
char *outer_start,*inner_start;
int outer_length,inner_length;
int outer_length=0,inner_length=0;
if (sym->dim.arglist[arg].ident==iVARARGS)
fprintf(log,"\t\t\t<param name=\"...\">\n");
else
@ -5248,7 +5249,7 @@ static void doreturn(void)
if ((rettype & uRETVALUE)!=0) {
int retarray=(ident==iARRAY || ident==iREFARRAY);
/* there was an earlier "return" statement in this function */
if (sub==NULL && retarray || sub!=NULL && !retarray)
if ((sub==NULL && retarray) || (sub!=NULL && !retarray))
error(79); /* mixing "return array;" and "return value;" */
} /* if */
rettype|=uRETVALUE; /* function returns a value */
@ -5257,7 +5258,7 @@ static void doreturn(void)
if (!matchtag(curfunc->tag,tag,TRUE))
error(213); /* tagname mismatch */
if (ident==iARRAY || ident==iREFARRAY) {
int dim[sDIMEN_MAX],numdim;
int dim[sDIMEN_MAX],numdim=0;
cell arraysize;
assert(sym!=NULL);
if (sub!=NULL) {

View File

@ -27,7 +27,7 @@
#include <ctype.h>
#include <math.h>
#include "sc.h"
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
#include <sclinux.h>
#endif
@ -198,7 +198,7 @@ SC_FUNC int plungefile(char *name,int try_currentpath,int try_includepaths)
char path[_MAX_PATH];
strncpy(path,ptr,sizeof path);
path[sizeof path - 1]='\0'; /* force '\0' termination */
strncat(path,name,sizeof(path)-strlen(path));
strncat(path,name,sizeof(path) - strlen(path) - 1);
path[sizeof path - 1]='\0';
result=plungequalifiedfile(path);
} /* while */
@ -408,7 +408,7 @@ static void stripcom(unsigned char *line)
#if !defined SC_LIGHT
/* collect the comment characters in a string */
if (icomment==2) {
if (skipstar && (*line!='\0' && *line<=' ' || *line=='*')) {
if (skipstar && ((*line!='\0' && *line<=' ') || *line=='*')) {
/* ignore leading whitespace and '*' characters */
} else if (commentidx<COMMENT_LIMIT+COMMENT_MARGIN-1) {
comment[commentidx++]=(char)((*line!='\n') ? *line : ' ');
@ -585,22 +585,9 @@ static int htoi(cell *val,const unsigned char *curptr)
}
#if defined __GNUC__
static double pow10(int value)
static double pow10(double d)
{
double res=1.0;
while (value>=4) {
res*=10000.0;
value-=5;
} /* while */
while (value>=2) {
res*=100.0;
value-=2;
} /* while */
while (value>=1) {
res*=10.0;
value-=1;
} /* while */
return res;
return pow(10, d);
}
#endif
@ -1210,7 +1197,7 @@ static int command(void)
sym=findloc(str);
if (sym==NULL)
sym=findglb(str);
if (sym==NULL || sym->ident!=iFUNCTN && sym->ident!=iREFFUNC && (sym->usage & uDEFINE)==0) {
if (sym==NULL || (sym->ident!=iFUNCTN && sym->ident!=iREFFUNC && (sym->usage & uDEFINE)==0)) {
error(17,str); /* undefined symbol */
} else {
outval(sym->addr,FALSE);
@ -1644,7 +1631,7 @@ static void substallpatterns(unsigned char *line,int buffersize)
if (strncmp((char*)start,"defined",7)==0 && !isalpha((char)*(start+7))) {
start+=7; /* skip "defined" */
/* skip white space & parantheses */
while (*start<=' ' && *start!='\0' || *start=='(')
while ((*start<=' ' && *start!='\0') || *start=='(')
start++;
/* skip the symbol behind it */
while (isalpha(*start) || isdigit(*start) || *start=='_')
@ -1946,7 +1933,7 @@ SC_FUNC int lex(cell *lexvalue,char **lexsym)
error(220);
} /* if */
} /* if */
} else if (*lptr=='\"' || *lptr==sc_ctrlchar && *(lptr+1)=='\"')
} else if (*lptr=='\"' || (*lptr==sc_ctrlchar && *(lptr+1)=='\"'))
{ /* unpacked string literal */
_lextok=tSTRING;
stringflags= (*lptr==sc_ctrlchar) ? RAWMODE : 0;
@ -1959,9 +1946,9 @@ SC_FUNC int lex(cell *lexvalue,char **lexsym)
lptr+=1; /* skip final quote */
else
error(37); /* invalid (non-terminated) string */
} else if (*lptr=='!' && *(lptr+1)=='\"'
|| *lptr=='!' && *(lptr+1)==sc_ctrlchar && *(lptr+2)=='\"'
|| *lptr==sc_ctrlchar && *(lptr+1)=='!' && *(lptr+2)=='\"')
} else if ((*lptr=='!' && *(lptr+1)=='\"')
|| (*lptr=='!' && *(lptr+1)==sc_ctrlchar && *(lptr+2)=='\"')
|| (*lptr==sc_ctrlchar && *(lptr+1)=='!' && *(lptr+2)=='\"'))
{ /* packed string literal */
_lextok=tSTRING;
stringflags= (*lptr==sc_ctrlchar || *(lptr+1)==sc_ctrlchar) ? RAWMODE : 0;
@ -2053,7 +2040,7 @@ SC_FUNC int matchtoken(int token)
int tok;
tok=lex(&val,&str);
if (tok==token || token==tTERM && (tok==';' || tok==tENDEXPR)) {
if (tok==token || (token==tTERM && (tok==';' || tok==tENDEXPR))) {
return 1;
} else if (!sc_needsemicolon && token==tTERM && (_lexnewline || !freading)) {
/* Push "tok" back, because it is the token following the implicit statement
@ -2418,7 +2405,7 @@ SC_FUNC void delete_symbols(symbol *root,int level,int delete_labels,int delete_
{
symbol *sym,*parent_sym;
constvalue *stateptr;
int mustdelete;
int mustdelete=0;
/* erase only the symbols with a deeper nesting level than the
* specified nesting level */

View File

@ -929,7 +929,7 @@ static int hier14(value *lval1)
} /* if */
if (lval3.sym->dim.array.level!=level)
return error(48); /* array dimensions must match */
else if (ltlength<val || exactmatch && ltlength>val || val==0)
else if (ltlength<val || (exactmatch && ltlength>val) || val==0)
return error(47); /* array sizes must match */
else if (lval3.ident!=iARRAYCELL && !matchtag(lval3.sym->x.idxtag,idxtag,TRUE))
error(229,(lval2.sym!=NULL) ? lval2.sym->name : lval3.sym->name); /* index tag mismatch */
@ -1124,7 +1124,7 @@ static int hier2(value *lval)
int tag,paranthese;
cell val;
char *st;
symbol *sym;
symbol *sym=NULL;
int saveresult;
tok=lex(&val,&st);
@ -1247,7 +1247,7 @@ static int hier2(value *lval)
lval->constval=1; /* preset */
if (sym->ident==iARRAY || sym->ident==iREFARRAY) {
int level;
symbol *idxsym;
symbol *idxsym=NULL;
for (level=0; matchtoken('['); level++) {
idxsym=NULL;
if (level==sym->dim.array.level && matchtoken(tSYMBOL)) {
@ -1293,7 +1293,7 @@ static int hier2(value *lval)
} /* if */
if (sym->ident==iARRAY || sym->ident==iREFARRAY) {
int level;
symbol *idxsym;
symbol *idxsym=NULL;
for (level=0; matchtoken('['); level++) {
idxsym=NULL;
if (level==sym->dim.array.level && matchtoken(tSYMBOL)) {
@ -1462,7 +1462,7 @@ restart:
} /* if */
if (close==']') {
/* normal array index */
if (lval2.constval<0 || sym->dim.array.length!=0 && sym->dim.array.length<=lval2.constval)
if (lval2.constval<0 || (sym->dim.array.length!=0 && sym->dim.array.length<=lval2.constval))
error(32,sym->name); /* array index out of bounds */
if (lval2.constval!=0) {
/* don't add offsets for zero subscripts */
@ -1479,8 +1479,8 @@ restart:
} /* if */
} else {
/* character index */
if (lval2.constval<0 || sym->dim.array.length!=0
&& sym->dim.array.length*((8*sizeof(cell))/sCHARBITS)<=(ucell)lval2.constval)
if (lval2.constval<0 || (sym->dim.array.length!=0
&& sym->dim.array.length*((8*sizeof(cell))/sCHARBITS)<=(ucell)lval2.constval))
error(32,sym->name); /* array index out of bounds */
if (lval2.constval!=0) {
/* don't add offsets for zero subscripts */
@ -2035,8 +2035,8 @@ static int nesting=0;
* function argument; a literal string may be smaller than
* the function argument.
*/
if (lval.constval>0 && arg[argidx].dim[0]!=lval.constval
|| lval.constval<0 && arg[argidx].dim[0] < -lval.constval)
if ((lval.constval>0 && arg[argidx].dim[0]!=lval.constval)
|| (lval.constval<0 && arg[argidx].dim[0] < -lval.constval))
error(47); /* array sizes must match */
} /* if */
} /* if */

View File

@ -235,7 +235,7 @@ SC_FUNC void begdseg(void)
SC_FUNC void setline(int chkbounds)
{
if ((sc_debug & sSYMBOLIC)!=0 || chkbounds && (sc_debug & sCHKBOUNDS)!=0) {
if ((sc_debug & sSYMBOLIC)!=0 || (chkbounds && (sc_debug & sCHKBOUNDS)!=0)) {
/* generate a "break" (start statement) opcode rather than a "line" opcode
* because earlier versions of Small/Pawn have an incompatible version of the
* line opcode
@ -719,7 +719,7 @@ SC_FUNC void ffcall(symbol *sym,const char *label,int numargs)
stgwrite(sym->name);
} /* if */
if (sc_asmfile
&& (label!=NULL || !isalpha(sym->name[0]) && sym->name[0]!='_' && sym->name[0]!=sc_ctrlchar))
&& (label!=NULL || (!isalpha(sym->name[0]) && sym->name[0]!='_' && sym->name[0]!=sc_ctrlchar)))
{
stgwrite("\t; ");
stgwrite(symname);

View File

@ -25,7 +25,7 @@
#if defined __WIN32__ || defined _WIN32 || defined __MSDOS__
#include <io.h>
#endif
#if defined LINUX || defined __GNUC__
#if defined LINUX || defined __APPLE__ || defined __GNUC__
#include <unistd.h>
#endif
#include <stdio.h>
@ -132,7 +132,7 @@ static short lastfile;
} /* if */
va_end(argptr);
if (number>=100 && number<200 || errnum>25){
if ((number>=100 && number<200) || errnum>25){
if (strlen(errfname)==0) {
va_start(argptr,number);
pc_error(0,"\nCompilation aborted.",NULL,0,0,argptr);

View File

@ -30,7 +30,7 @@
#endif
#include "sc.h"
#include "amxdbg.h"
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
#include <sclinux.h>
#endif
@ -895,7 +895,7 @@ SC_FUNC int assemble(FILE *fout,FILE *fin)
instr=skipwhitespace(line);
/* ignore empty lines and labels (labels have a special syntax, so these
* must be parsed separately) */
if (*instr=='\0' || tolower(*instr)=='l' && *(instr+1)=='.')
if (*instr=='\0' || (tolower(*instr)=='l' && *(instr+1)=='.'))
continue;
/* get to the end of the instruction (make use of the '\n' that fgets()
* added at the end of the line; this way we will *always* drop on a

View File

@ -457,18 +457,18 @@ static int matchsequence(char *start,char *end,char *pattern,
case ' ':
if (*start!='\t' && *start!=' ')
return FALSE;
while (start<end && *start=='\t' || *start==' ')
while ((start<end && *start=='\t') || *start==' ')
start++;
break;
case '!':
while (start<end && *start=='\t' || *start==' ')
while ((start<end && *start=='\t') || *start==' ')
start++; /* skip trailing white space */
if (*start!='\n')
return FALSE;
assert(*(start+1)=='\0');
start+=2; /* skip '\n' and '\0' */
if (*(pattern+1)!='\0')
while (start<end && *start=='\t' || *start==' ')
while ((start<end && *start=='\t') || *start==' ')
start++; /* skip leading white space of next instruction */
break;
default:

View File

@ -47,7 +47,7 @@
#define _MAX_PATH 250
#endif
#if !defined DIRSEP_CHAR
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE___
#define DIRSEP_CHAR '/'
#elif defined macintosh
#define DIRSEP_CHAR ':'
@ -339,7 +339,7 @@ SC_FUNC cell get_utf8_char(const unsigned char *string,const unsigned char **end
/* the code positions 0xd800--0xdfff and 0xfffe & 0xffff do not
* exist in UCS-4 (and hence, they do not exist in Unicode)
*/
if (result>=0xd800 && result<=0xdfff || result==0xfffe || result==0xffff)
if ((result>=0xd800 && result<=0xdfff) || result==0xfffe || result==0xffff)
return -1;
} /* if */
break;

View File

@ -32,6 +32,10 @@
*/
#if !defined __BYTE_ORDER
# include <stdlib.h>
# if defined __APPLE__
# include <sys/types.h>
# define __BYTE_ORDER BYTE_ORDER
# endif
#endif
#if defined __OpenBSD__ || defined __FreeBSD__

View File

@ -238,7 +238,7 @@ SC_FUNC stringlist *insert_path(char *path)
{
char *extra_path = malloc(strlen(path) + 16);
strcpy(extra_path, path);
#if defined __linux__
#if defined __linux__ || defined __APPLE__
strcat(extra_path, "/amxmod_compat/");
#elif defined WIN32 || defined _WIN32
strcat(extra_path, "\\amxmod_compat\\");
@ -444,10 +444,10 @@ SC_FUNC stringlist *insert_dbgsymbol(symbol *sym)
/* address tag:name codestart codeend ident vclass [tag:dim ...] */
#if PAWN_CELL_SIZE==32
if (sym->ident==iFUNCTN)
sprintf(string,"S:%08lx %x:%s %08lx %08lx %x %x",sym->addr,sym->tag,
sprintf(string,"S:%08x %x:%s %08x %08x %x %x",sym->addr,sym->tag,
symname,sym->addr,sym->codeaddr,sym->ident,sym->vclass);
else
sprintf(string,"S:%08lx %x:%s %08lx %08lx %x %x",sym->addr,sym->tag,
sprintf(string,"S:%08x %x:%s %08x %08x %x %x",sym->addr,sym->tag,
symname,sym->codeaddr,code_idx,sym->ident,sym->vclass);
#elif PAWN_CELL_SIZE==64
if (sym->ident==iFUNCTN)

View File

@ -51,7 +51,7 @@
#include <stdlib.h>
#include <string.h>
#include "sc.h"
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__
#include <sclinux.h>
#endif