From b4ff9663cc5b239ef816487eb7610b0a04d28ddf Mon Sep 17 00:00:00 2001 From: Kevin Shanahan Date: Fri, 15 Mar 2013 21:49:16 +1030 Subject: [PATCH] build: add ability to compile for WIN64 using MinGW64 Fix a few minor int<->pointer size warnings. Signed-off-by: Kevin Shanahan --- Makefile | 21 ++++++++++++++++++++- common/threads.c | 4 +++- light/light.c | 4 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index bc0b2d07..3e047991 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,17 @@ EXT=.exe DPTHREAD= LPTHREAD= ifneq ($(HOST_OS),WIN32) +TARGET ?= $(MINGW32_CROSS_GUESS) +CC = $(TARGET)-gcc +STRIP = $(TARGET)-strip +endif +else +ifeq ($(TARGET_OS),WIN64) +EXT=.exe +DPTHREAD= +LPTHREAD= +ifneq ($(HOST_OS),WIN64) +TARGET ?= $(MINGW64_CROSS_GUESS) CC = $(TARGET)-gcc STRIP = $(TARGET)-strip endif @@ -51,6 +62,7 @@ EXT= DPTHREAD=-DUSE_PTHREADS -pthread LPTHREAD=-lpthread endif +endif #BIN_PFX ?= tyr- BIN_PFX ?= @@ -87,7 +99,7 @@ endif # i486-mingw32 (Arch). # ------------------------------------------------------------------------ -MINGW_CROSS_GUESS := $(shell \ +MINGW32_CROSS_GUESS := $(shell \ if which i486-mingw32-gcc > /dev/null 2>&1; then \ echo i486-mingw32; \ elif which i586-mingw32msvc-gcc > /dev/null 2>&1; then \ @@ -96,6 +108,13 @@ MINGW_CROSS_GUESS := $(shell \ echo i386-mingw32msvc; \ fi) +MINGW64_CROSS_GUESS := $(shell \ + if which x86_64-w64-mingw32-gcc > /dev/null 2>&1; then \ + echo x86_64-w64-mingw32; \ + else \ + echo x86_64-w64-mingw32; \ + fi) + # -------------------------------- # GCC option checking # -------------------------------- diff --git a/common/threads.c b/common/threads.c index 98edb161..b55f8f5f 100644 --- a/common/threads.c +++ b/common/threads.c @@ -1,5 +1,7 @@ /* common/threads.c */ +#include + #include #include #include @@ -103,7 +105,7 @@ ThreadUnlock(void) void RunThreadsOn(int start, int workcnt, void *(func)(void *)) { - int i; + uintptr_t i; /* avoid warning due to cast for the CreateThread API */ DWORD *threadid; HANDLE *threadhandle; diff --git a/light/light.c b/light/light.c index f499f1a8..9abee52b 100644 --- a/light/light.c +++ b/light/light.c @@ -190,12 +190,12 @@ LightWorld(void) lightdatasize /= 4; /* align filebase to a 4 byte boundary */ - filebase = file_p = (byte *)(((unsigned long)dlightdata + 3) & ~3); + filebase = file_p = (byte *)(((uintptr_t)dlightdata + 3) & ~3); file_end = filebase + lightdatasize; if (colored) { /* litfile data stored in dlightdata, after the white light */ - lit_filebase = file_end + 12 - ((unsigned long)file_end % 12); + lit_filebase = file_end + 12 - ((uintptr_t)file_end % 12); lit_file_p = lit_filebase; lit_file_end = lit_filebase + 3 * (MAX_MAP_LIGHTING / 4); }