From 6e4f09366e3ae21e59aae5ca013d1560b90a6db3 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Fri, 8 Feb 2013 00:35:59 -0800 Subject: [PATCH] Ditch amxxpc64. AMXX files will now only contain 32-bit code. --- compiler/amxxpc/amxxpc.cpp | 76 ++++++--------------------------- compiler/libpc300/Makefile | 24 +++-------- installer/amxmodx-installer.nsi | 4 -- 3 files changed, 20 insertions(+), 84 deletions(-) diff --git a/compiler/amxxpc/amxxpc.cpp b/compiler/amxxpc/amxxpc.cpp index 0f333352..c8d83ea8 100755 --- a/compiler/amxxpc/amxxpc.cpp +++ b/compiler/amxxpc/amxxpc.cpp @@ -48,9 +48,9 @@ int main(int argc, char **argv) if (!lib) { #ifdef __linux__ - printf("32bit compiler failed to instantiate: %s\n", dlerror()); + printf("compiler failed to instantiate: %s\n", dlerror()); #else - printf("32bit compiler failed to instantiate: %d\n", GetLastError()); + printf("compiler failed to instantiate: %d\n", GetLastError()); #endif exit(0); } @@ -61,9 +61,9 @@ int main(int argc, char **argv) if (!sc32 || !pc_printf) { #ifdef __linux__ - printf("32bit compiler failed to link: %p.\n",sc32); + printf("compiler failed to link: %p.\n",sc32); #else - printf("32bit compiler failed to link: %d.\n", GetLastError()); + printf("compiler failed to link: %d.\n", GetLastError()); #endif exit(0); } @@ -112,61 +112,12 @@ int main(int argc, char **argv) unlink(file); - HINSTANCE lib64 = NULL; -#ifdef __linux__ - if (FileExists("./amxxpc64.so")) - lib64 = dlmount("./amxxpc64.so"); - else - lib64 = dlmount("amxxpc64.so"); -#else - lib64 = dlmount("amxxpc64.dll"); -#endif - if (!lib64) - { - pc_printf("64bit compiler failed to instantiate.\n"); - exit(0); - } - - COMPILER sc64 = (COMPILER)dlsym(lib64, "Compile64"); - - if (!sc64) - { -#ifdef __linux__ - pc_printf("64bit compiler failed to link: %s.\n", dlerror()); -#else - pc_printf("64bit compiler failed to link: %d.\n", GetLastError()); -#endif - exit(0); - } - - sc64(argc, argv); - - dlclose(lib64); - - if (file == NULL) - { - pc_printf("Could not locate the output file on second pass.\n"); - exit(0); - } else { - FILE *fp = fopen(file, "rb"); - if (fp == NULL) - { - pc_printf("Could not locate output file on second pass (compile failed).\n"); - exit(0); - } - ReadFileIntoPl(&pl64, fp); - pl64.cellsize = 8; - fclose(fp); - } - ///////////// // COMPRSSION ///////////// CompressPl(&pl32); - CompressPl(&pl64); - char *newfile = new char[strlen(file)+3]; strcpy(newfile, file); if (!strstr(file, ".amxx") && !strstr(file, ".AMXX")) @@ -179,34 +130,33 @@ int main(int argc, char **argv) exit(0); } - BinPlugin bh32, bh64; + BinPlugin bh32; Pl2Bh(&pl32, &bh32); - Pl2Bh(&pl64, &bh64); try { + static const int kEntries = 1; + + //entry is 4 ints and a byte + static const int kEntrySize = (sizeof(int32_t) * 4) + sizeof(int8_t); + BinaryWriter bw(fp); bw.WriteUInt32(MAGIC_HEADER2); bw.WriteUInt16(MAGIC_VERSION); - bw.WriteUInt8(2); + bw.WriteUInt8(kEntries); //base header int baseaddr = sizeof(int32_t) + sizeof(int16_t) + sizeof(int8_t); - //entry is 4 ints and a byte - int entrysize = (sizeof(int32_t) * 4) + sizeof(int8_t); - //extend this by the two entries we have - baseaddr += entrysize * 2; + //extend this by the entries we have + baseaddr += kEntrySize * kEntries; bh32.offs = baseaddr; - bh64.offs = bh32.offs + bh32.disksize; WriteBh(&bw, &bh32); - WriteBh(&bw, &bh64); bw.WriteChars(pl32.cmp, pl32.cmpsize); - bw.WriteChars(pl64.cmp, pl64.cmpsize); } catch (...) { fclose(fp); unlink(file); diff --git a/compiler/libpc300/Makefile b/compiler/libpc300/Makefile index cd579e0e..7fa066cc 100755 --- a/compiler/libpc300/Makefile +++ b/compiler/libpc300/Makefile @@ -6,7 +6,7 @@ OPT_FLAGS = -O3 -funroll-loops -s -pipe -fno-strict-aliasing -fvisibility=hidden DEBUG_FLAGS = -g -ggdb3 CPP = gcc-4.1 -NAME = amxxpc +NAME = 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 \ @@ -16,15 +16,9 @@ LINK = -lpthread INCLUDE = -I. -ifeq "$(PAWN64)" "true" - BINARY = $(NAME)64.so - BIN_DIR = Release64 - CFLAGS += -DPAWN_CELL_SIZE=64 -DHAVE_I64 -Dpc_printf=pc_printf64 -else - BINARY = $(NAME)32.so - BIN_DIR = Release32 - CFLAGS += -DPAWN_CELL_SIZE=32 -endif +BINARY = $(NAME).so +BIN_DIR = Release +CFLAGS += -DPAWN_CELL_SIZE=32 CFLAGS += -DLINUX -DNDEBUG -DHAVE_STDINT_H -DENABLE_BINRELOC -DNO_MAIN -DPAWNC_DLL -static-libgcc @@ -35,10 +29,8 @@ $(BIN_DIR)/%.o: %.c $(CPP) $(INCLUDE) $(CFLAGS) -m32 -o $@ -c $< all: - mkdir -p Release32 - mkdir -p Release64 + mkdir -p Release $(MAKE) pawn_make - $(MAKE) pawn_make PAWN64=true pawn_make: $(OBJ_LINUX) $(CPP) $(INCLUDE) $(CFLAGS) -m32 $(OBJ_LINUX) $(LINK) -shared -ldl -lm -o$(BIN_DIR)/$(BINARY) @@ -49,8 +41,6 @@ debug: default: all clean: - rm -rf Release32/*.o - rm -rf Release32/$(BINARY) - rm -rf Release64/*.o - rm -rf Release64/$(BINARY) + rm -rf Release/*.o + rm -rf Release/$(BINARY) diff --git a/installer/amxmodx-installer.nsi b/installer/amxmodx-installer.nsi index a35c13dd..b73c2f29 100755 --- a/installer/amxmodx-installer.nsi +++ b/installer/amxmodx-installer.nsi @@ -208,8 +208,6 @@ Section "MainSection" SEC01 File "installer\files\base\addons\amxmodx\scripting\amxxpc.exe" File "installer\files\base\addons\amxmodx\scripting\amxxpc32.dll" File "installer\files\base\addons\amxmodx\scripting\amxxpc32.so" - File "installer\files\base\addons\amxmodx\scripting\amxxpc64.dll" - File "installer\files\base\addons\amxmodx\scripting\amxxpc64.so" File "installer\files\base\addons\amxmodx\scripting\antiflood.sma" File "installer\files\base\addons\amxmodx\scripting\cmdmenu.sma" File "installer\files\base\addons\amxmodx\scripting\compile.exe" @@ -708,8 +706,6 @@ Section Uninstall Delete "$INSTDIR\files\base\addons\amxmodx\scripting\compile.exe" Delete "$INSTDIR\files\base\addons\amxmodx\scripting\cmdmenu.sma" Delete "$INSTDIR\files\base\addons\amxmodx\scripting\antiflood.sma" - Delete "$INSTDIR\files\base\addons\amxmodx\scripting\amxxpc64.so" - Delete "$INSTDIR\files\base\addons\amxmodx\scripting\amxxpc64.dll" Delete "$INSTDIR\files\base\addons\amxmodx\scripting\amxxpc32.so" Delete "$INSTDIR\files\base\addons\amxmodx\scripting\amxxpc32.dll" Delete "$INSTDIR\files\base\addons\amxmodx\scripting\amxxpc.exe"