diff --git a/Core/Core.h b/Core/Core.h index 9a2e8c28..f6b08942 100644 --- a/Core/Core.h +++ b/Core/Core.h @@ -121,7 +121,7 @@ template<> struct CompileTimeError {}; # if _MSC_VER >= 1400 # define IS_POD(T) __is_pod(T) # endif -# pragma warning(disable : 4291) // no matched operator delete found +//# pragma warning(disable : 4291) // no matched operator delete found // this functions are smaller, when in intrinsic form (and, of course, faster): # pragma intrinsic(memcpy, memset, memcmp, abs, fabs, _rotl8, _rotl, _rotr8, _rotr) // allow nested inline expansions @@ -218,15 +218,16 @@ typedef size_t address_t; #define S_WHITE "^7" +// Using size_t typecasts - that's platform integer type template inline T OffsetPointer(const T ptr, int offset) { - return (T) ((unsigned)ptr + offset); + return (T) ((size_t)ptr + offset); } // Align integer or pointer of any type template inline T Align(const T ptr, int alignment) { - return (T) (((unsigned)ptr + alignment - 1) & ~(alignment - 1)); + return (T) (((size_t)ptr + alignment - 1) & ~(alignment - 1)); } template inline void Exchange(T& A, T& B) @@ -395,6 +396,12 @@ void appDumpMemoryAllocations(); unsigned win32ExceptFilter2(); #define EXCEPT_FILTER win32ExceptFilter2() // may use 1==EXCEPTION_EXECUTE_HANDLER or win32ExceptFilter2() +#if _WIN64 +//!! todo +#undef EXCEPT_FILTER +#define EXCEPT_FILTER 1 // EXCEPTION_EXECUTE_HANDLER +#endif + #define guard(func) \ { \ static const char __FUNC__[] = #func; \ diff --git a/Core/CoreWin32.cpp b/Core/CoreWin32.cpp index 4b6dc962..8a1ff8c9 100644 --- a/Core/CoreWin32.cpp +++ b/Core/CoreWin32.cpp @@ -31,6 +31,9 @@ #endif // VSTUDIO_INTEGRATION +#ifdef _WIN64 +#undef UNWIND_EBP_FRAMES //!! should review the code and perhaps adopt to Win64 +#endif #if USE_DBGHELP #include @@ -165,7 +168,7 @@ const char *appSymbolName(address_t addr) // *s = 0; if (s = strrchr(moduleName, '\\')) strcpy(moduleName, s+1); // remove "path\" part - appSprintf(ARRAY_ARG(buf), "%s+0x%X", moduleName, addr - (int)hModule); + appSprintf(ARRAY_ARG(buf), "%s+0x%X", moduleName, (int)(addr - (size_t)hModule)); return buf; #endif // GET_EXTENDED_INFO @@ -288,6 +291,7 @@ static void DumpSEH() static void DropSEHFrames() { +#ifndef _WIN64 __asm { push edx @@ -306,6 +310,7 @@ static void DropSEHFrames() pop ebx pop edx } +#endif // _WIN64 } @@ -432,9 +437,15 @@ long WINAPI win32ExceptFilter(struct _EXCEPTION_POINTERS *info) // log error CONTEXT* ctx = info->ContextRecord; +#ifndef _WIN64 appSprintf(ARRAY_ARG(GErrorHistory), "%s (%08X) at %s\n", excName, info->ExceptionRecord->ExceptionCode, appSymbolName(ctx->Eip) ); +#else + appSprintf(ARRAY_ARG(GErrorHistory), "%s (%08X) at %s\n", + excName, info->ExceptionRecord->ExceptionCode, appSymbolName(ctx->Rip) + ); +#endif // _WIN64 #if UNWIND_EBP_FRAMES UnwindEbpFrame((address_t*) ctx->Ebp); #endif // UNWIND_EBP_FRAMES @@ -445,6 +456,7 @@ long WINAPI win32ExceptFilter(struct _EXCEPTION_POINTERS *info) return EXCEPTION_EXECUTE_HANDLER; } +#ifndef _WIN64 __declspec(naked) unsigned win32ExceptFilter2() { __asm { @@ -453,6 +465,7 @@ __declspec(naked) unsigned win32ExceptFilter2() retn // return value from win32ExceptFilter() } } +#endif // _WIN64 #endif // WIN32_USE_SEH diff --git a/Core/Win32Types.h b/Core/Win32Types.h index 620bff5a..94760d24 100644 --- a/Core/Win32Types.h +++ b/Core/Win32Types.h @@ -19,23 +19,26 @@ # endif # ifndef WINGDIAPI # define WINGDIAPI -# ifdef _WIN64 -# error Review these types! -# endif + typedef void* HANDLE; + #ifndef _WIN64 + typedef int INT_PTR; + typedef long LONG_PTR; + #else + typedef __int64 INT_PTR; + typedef __int64 LONG_PTR; + #endif typedef unsigned HDC; - typedef unsigned HGLRC; + typedef HANDLE HGLRC; typedef const char * LPCSTR; typedef int BOOL; typedef unsigned char BYTE; typedef unsigned short WORD; typedef unsigned int DWORD; typedef unsigned int UINT; - typedef void* HANDLE; - typedef void* HWND; - typedef void* HMENU; - typedef size_t WPARAM; - typedef long LPARAM; - typedef int INT_PTR; + typedef HANDLE HWND; + typedef HANDLE HMENU; + typedef INT_PTR WPARAM; + typedef LONG_PTR LPARAM; typedef int (APIENTRY *PROC)(); typedef void PIXELFORMATDESCRIPTOR; // structure typedef PIXELFORMATDESCRIPTOR * LPPIXELFORMATDESCRIPTOR; diff --git a/Exporters/Exporters.cpp b/Exporters/Exporters.cpp index 725aa5b3..28d99cc1 100644 --- a/Exporters/Exporters.cpp +++ b/Exporters/Exporters.cpp @@ -61,7 +61,7 @@ struct ExportedObjectEntry int GetHash() const { - return ( ((int)Package >> 3) ^ ExportIndex ^ (ExportIndex << 4) ) & (EXPORTED_LIST_HASH_SIZE - 1); + return ( ((size_t)Package >> 3) ^ ExportIndex ^ (ExportIndex << 4) ) & (EXPORTED_LIST_HASH_SIZE - 1); } }; diff --git a/Tools/genmake b/Tools/genmake index c498d55f..6dda54da 100644 --- a/Tools/genmake +++ b/Tools/genmake @@ -54,9 +54,9 @@ defined(var) will be replaced with 0 or 1 3. System variables: platform specification: - PLATFORM = win32 | cygwin | unix + PLATFORM = win32 | win64 | cygwin | unix COMPILER = VisualC | GnuC - TARGET = vc-win32 | mingw32 | cygwin | linux + TARGET = vc-win32 | vc-win64 | mingw32 | cygwin | linux Should specify either "TARGET" or "PLATFORM"+"COMPILER" global: @@ -451,6 +451,9 @@ sub InitCompiler { if ($TARGET eq "vc-win32") { $COMPILER = "VisualC"; $PLATFORM = "win32"; + } elsif ($TARGET eq "vc-win64") { + $COMPILER = "VisualC"; + $PLATFORM = "win64"; } elsif ($TARGET eq "mingw32") { $COMPILER = "GnuC"; $PLATFORM = "win32"; @@ -478,7 +481,7 @@ sub InitCompiler { } } elsif (defined($PLATFORM)) { # defaults for PLATFORM - if ($PLATFORM eq "win32") { + if ($PLATFORM eq "win32" || $PLATFORM eq "win64") { $COMPILER = "VisualC"; } elsif ($PLATFORM eq "cygwin") { $COMPILER = "GnuC"; @@ -507,7 +510,7 @@ sub InitCompiler { if ($PLATFORM eq "unix") { $ExeFileExt = ""; $DllFileExt = ".so"; - } elsif ($PLATFORM eq "win32" || $PLATFORM eq "cygwin") { + } elsif ($PLATFORM eq "win32" || $PLATFORM eq "win64" || $PLATFORM eq "cygwin") { $ExeFileExt = ".exe"; $DllFileExt = ".dll"; } @@ -518,7 +521,9 @@ sub EmitCompilerDefs { Splitter ("Compiler definitions"); if ($COMPILER eq "VisualC") { print "CPP = cl.exe -nologo -c -D WIN32 -D _WINDOWS\n"; - print "LINK = link.exe -nologo -filealign:512 -incremental:no\n"; + my $machine = "X86"; + $machine = "X64" if $PLATFORM eq "win64"; + print "LINK = link.exe -nologo -filealign:512 -incremental:no -machine:$machine\n"; print "AR = link.exe -lib -nologo\n"; # cannot use "LIB" name } elsif ($COMPILER eq "GnuC") { my $platf = "gcc"; @@ -1027,6 +1032,11 @@ sub FlushObjectFile { my $defs = ""; $inc = " ".GenerateOptions ($includes, "-I ") if $includes ne ""; $defs = " ".GenerateOptions ($defines, "-D ") if $defines ne ""; + if ($PLATFORM eq "win32") { + $defs .= " -D _WIN32 -D WIN32"; + } else { + $defs .= " -D _WIN64 -D WIN64"; + } $line = "rc.exe -l 0x409 -i ${srcDir}${inc}${defs} -fo\"$objFile\" -dNDEBUG"; } else { # C/C++ file diff --git a/UI/BaseDialog.cpp b/UI/BaseDialog.cpp index f9e9f184..83bd51d1 100644 --- a/UI/BaseDialog.cpp +++ b/UI/BaseDialog.cpp @@ -207,7 +207,7 @@ HWND UIElement::Window(const char* className, const char* text, DWORD style, DWO if (Visible) style |= WS_VISIBLE; HWND wnd = CreateWindowEx(exstyle, className, text, style | WS_CHILDWINDOW, x, y, w, h, - dialogWnd, (HMENU)id, hInstance, NULL); + dialogWnd, (HMENU)(size_t)id, hInstance, NULL); // convert int -> size_t -> HANDLE to avoid warnings on 64-bit platform #if DEBUG_WINDOWS_ERRORS if (!wnd) appNotify("CreateWindow failed, GetLastError returned %d\n", GetLastError()); #endif @@ -229,7 +229,7 @@ HWND UIElement::Window(const wchar_t* className, const wchar_t* text, DWORD styl if (Visible) style |= WS_VISIBLE; HWND wnd = CreateWindowExW(exstyle, className, text, style | WS_CHILDWINDOW, x, y, w, h, - dialogWnd, (HMENU)id, hInstance, NULL); + dialogWnd, (HMENU)(size_t)id, hInstance, NULL); #if DEBUG_WINDOWS_ERRORS if (!wnd) appNotify("CreateWindow failed, GetLastError returned %d\n", GetLastError()); #endif diff --git a/UmodelTool/res/umodel.manifest b/UmodelTool/res/umodel.manifest index c5026a0e..2cac7af5 100644 --- a/UmodelTool/res/umodel.manifest +++ b/UmodelTool/res/umodel.manifest @@ -3,7 +3,7 @@ wxWindows application diff --git a/UmodelTool/res/umodel.rc b/UmodelTool/res/umodel.rc index 9395a35d..90a27934 100644 --- a/UmodelTool/res/umodel.rc +++ b/UmodelTool/res/umodel.rc @@ -3,5 +3,10 @@ // Enable themes for GUI elements // http://www.angelfire.com/hi5/delphizeus/theme_xp.html +#ifndef _WIN64 1 RT_MANIFEST "umodel.manifest" +#else +1 RT_MANIFEST "umodel64.manifest" +#endif + IDC_MAIN_ICON ICON "umodel.ico" diff --git a/UmodelTool/res/umodel64.manifest b/UmodelTool/res/umodel64.manifest new file mode 100644 index 00000000..8d16e342 --- /dev/null +++ b/UmodelTool/res/umodel64.manifest @@ -0,0 +1,22 @@ + + + +wxWindows application + + + + + + diff --git a/UmodelTool/umodel.project b/UmodelTool/umodel.project index f88d462e..88af4870 100644 --- a/UmodelTool/umodel.project +++ b/UmodelTool/umodel.project @@ -16,7 +16,7 @@ sources(MAIN) = { Core/*.cpp UI/*.cpp $UMODEL/*.cpp -!if "$PLATFORM" eq "win32" +!if "$PLATFORM" eq "win32" || "$PLATFORM" eq "win64" $UMODEL/res/umodel.rc !endif } diff --git a/Unreal/UnCoreCompression.cpp b/Unreal/UnCoreCompression.cpp index aef7e495..3059a175 100644 --- a/Unreal/UnCoreCompression.cpp +++ b/Unreal/UnCoreCompression.cpp @@ -232,7 +232,7 @@ int appDecompress(byte *CompressedBuffer, int CompressedSize, byte *Uncompressed int r; r = lzo_init(); if (r != LZO_E_OK) appError("lzo_init() returned %d", r); - unsigned long newLen = UncompressedSize; + lzo_uint newLen = UncompressedSize; r = lzo1x_decompress_safe(CompressedBuffer, CompressedSize, UncompressedBuffer, &newLen, NULL); if (r != LZO_E_OK) appError("lzo_decompress(%d,%d) returned %d", CompressedSize, UncompressedSize, r); if (newLen != UncompressedSize) appError("len mismatch: %d != %d", newLen, UncompressedSize); diff --git a/build.sh b/build.sh index 11bf4222..25c00438 100644 --- a/build.sh +++ b/build.sh @@ -33,7 +33,8 @@ last_revision=${last_revision##* } # cut "#define ..." #------------------------------------------------------------- PLATFORM="vc-win32" -#PLATFORM="mingw32" +#PLATFORM="vc-win64" +#PLATFORM="mingw32" - not implemented yet # force PLATFORM=linux under Linux OS #?? check this, when cross-compile under wine @@ -65,6 +66,9 @@ case "$PLATFORM" in "vc-win32") vc32tools --make $makefile || exit 1 ;; + "vc-win64") + vc32tools --64 --make $makefile || exit 1 + ;; "mingw32"|"cygwin") PATH=/bin:/usr/bin:$PATH # configure paths for Cygwin gccfilt make -f $makefile || exit 1 diff --git a/common.project b/common.project index 94bb880c..24213200 100644 --- a/common.project +++ b/common.project @@ -13,7 +13,7 @@ OLDCRT = 1 # Compiler-specific options #------------------------------------------------ -!if "$PLATFORM" ne "win32" +!if ("$PLATFORM" ne "win32") && ("$PLATFORM" ne "win64") # linux/cygwin + GCC STDLIBS = stdc++ m GL # libm for math.h functions !if "$PLATFORM" ne "cygwin" @@ -24,6 +24,11 @@ OLDCRT = 1 !if "$COMPILER" eq "VisualC" CPP_EXCEPT = 0 # used with WIN32_USE_SEH in Core.h OPTIONS = -GS- -GR- #?? VC8+ + # -Wp64 enables 64-bit portability warnings. Note: this option is deprecated, it will display a command line warning. + # More information here: + # https://connect.microsoft.com/VisualStudio/feedback/details/806763/warnings-c4311-and-c4312-require-wp64-which-is-documented-as-deprecated + # http://blogs.msdn.com/b/vcblog/archive/2014/06/13/compiler-switch-deprecation-removal-changes-in-visual-studio-14.aspx +# OPTIONS += -Wp64 # 64-bit portability warnings; note: deprecated option, will display a command line warning # OPTIONS += -FS # VS2013+, required for parallel build to work (jom.exe) DEFINES += _USING_V110_SDK71_ # avoid some warnings, perhaps affects something else # see http://tedwvc.wordpress.com/2014/01/01/how-to-target-xp-with-vc2012-or-vc2013-and-continue-to-use-the-windows-8-x-sdk/ @@ -108,10 +113,13 @@ sources(IOS_LIBS) = { #------------------------------------------------ OBJDIR = $R/obj/$PRJ-$PLATFORM -LIBRARIES = $R/libs STDLIBS += SDL2 SDL2main INCLUDES += . $R/Core $R/Unreal $R/libs/include $R/libs/nvtt $R/libs/PowerVR !if "$PLATFORM" eq "win32" INCLUDES += $R/libs/includewin32 + LIBRARIES = $R/libs/SDL2/x86 +!elif "$PLATFORM" eq "win64" + INCLUDES += $R/libs/includewin32 + LIBRARIES = $R/libs/SDL2/x64 !endif diff --git a/libs/SDL2/x64/SDL2.lib b/libs/SDL2/x64/SDL2.lib new file mode 100644 index 00000000..6faf131f Binary files /dev/null and b/libs/SDL2/x64/SDL2.lib differ diff --git a/libs/SDL2/x64/SDL2main.lib b/libs/SDL2/x64/SDL2main.lib new file mode 100644 index 00000000..699f8f6d Binary files /dev/null and b/libs/SDL2/x64/SDL2main.lib differ diff --git a/libs/SDL2/x86/SDL2.lib b/libs/SDL2/x86/SDL2.lib new file mode 100644 index 00000000..05a108b1 Binary files /dev/null and b/libs/SDL2/x86/SDL2.lib differ diff --git a/libs/SDL2/x86/SDL2main.lib b/libs/SDL2/x86/SDL2main.lib new file mode 100644 index 00000000..37c2c8b4 Binary files /dev/null and b/libs/SDL2/x86/SDL2main.lib differ diff --git a/makefile-vc-win32 b/makefile-vc-win32 index 818ce571..c8ba08f8 100644 --- a/makefile-vc-win32 +++ b/makefile-vc-win32 @@ -6,7 +6,7 @@ #------------------------------------------------------------------------------ CPP = cl.exe -nologo -c -D WIN32 -D _WINDOWS -LINK = link.exe -nologo -filealign:512 -incremental:no +LINK = link.exe -nologo -filealign:512 -incremental:no -machine:X86 AR = link.exe -lib -nologo #------------------------------------------------------------------------------ @@ -113,7 +113,7 @@ IOS_LIBS_FILES = \ umodel.exe : $(OUT) $(OUT_1) $(MAIN_FILES) $(NV_LIBS_FILES) $(UE3_LIBS_FILES) $(IOS_LIBS_FILES) echo Creating executable "umodel.exe" ... - $(LINK) -out:"umodel.exe" -libpath:./libs SDL2.lib SDL2main.lib -debug -pdb:"umodel.pdb" -opt:ref -opt:icf $(MAIN_FILES) $(NV_LIBS_FILES) $(UE3_LIBS_FILES) $(IOS_LIBS_FILES) -nodefaultlib:libcmt.lib -nodefaultlib:msvcprt.lib -manifest:no ./../Libs/msvcrt/startup/crtexe2.obj ./../Libs/msvcrt/lib/Win32/msvcrt.lib ./../Libs/msvcrt/lib/Win32/wdk_msvcrt_win2000.obj -subsystem:console + $(LINK) -out:"umodel.exe" -libpath:./libs/SDL2/x86 SDL2.lib SDL2main.lib -debug -pdb:"umodel.pdb" -opt:ref -opt:icf $(MAIN_FILES) $(NV_LIBS_FILES) $(UE3_LIBS_FILES) $(IOS_LIBS_FILES) -nodefaultlib:libcmt.lib -nodefaultlib:msvcprt.lib -manifest:no ./../Libs/msvcrt/startup/crtexe2.obj ./../Libs/msvcrt/lib/Win32/msvcrt.lib ./../Libs/msvcrt/lib/Win32/wdk_msvcrt_win2000.obj -subsystem:console #------------------------------------------------------------------------------ # compiling source files @@ -1191,7 +1191,7 @@ DEPENDS = \ UmodelTool/res/resource.h $(OUT_1)/umodel.res : UmodelTool/res/umodel.rc $(DEPENDS) - rc.exe -l 0x409 -i UmodelTool/res/ -I . -I ./Core -I ./Unreal -I ./libs/include -I ./libs/nvtt -I ./libs/PowerVR -I ./libs/includewin32 -I UmodelTool -I UI -D _USING_V110_SDK71_ -D OLDCRT -fo"$(OUT_1)/umodel.res" -dNDEBUG UmodelTool/res/umodel.rc + rc.exe -l 0x409 -i UmodelTool/res/ -I . -I ./Core -I ./Unreal -I ./libs/include -I ./libs/nvtt -I ./libs/PowerVR -I ./libs/includewin32 -I UmodelTool -I UI -D _USING_V110_SDK71_ -D OLDCRT -D _WIN32 -D WIN32 -fo"$(OUT_1)/umodel.res" -dNDEBUG UmodelTool/res/umodel.rc OPT_IOS_LIBS = -GS- -GR- -O1 -EHs- -Zi -Fd"$(OUT)/" -D _USING_V110_SDK71_ -D OLDCRT