win64 fixes (partial)

cherry-picked from 2f734ae2317060edb83021f17cffc966c435ad7b
develop
Vitaly Pronkin 2016-07-27 19:46:49 -04:00 committed by lethosor
parent 709111ea33
commit 8916aba3bf
9 changed files with 43 additions and 8 deletions

@ -48,8 +48,8 @@ if(UNIX)
endif() endif()
if(WIN32) if(WIN32)
if((NOT MSVC) OR (NOT MSVC_VERSION STREQUAL 1600)) if((NOT MSVC) OR (NOT MSVC_VERSION STREQUAL 1900))
message(SEND_ERROR "MSVC 2010 is required") message(SEND_ERROR "MSVC 2015 is required")
endif() endif()
endif() endif()
@ -177,6 +177,7 @@ ELSEIF(MSVC)
# for msvc, tell it to always use 8-byte pointers to member functions to avoid confusion # for msvc, tell it to always use 8-byte pointers to member functions to avoid confusion
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /vmg /vmm /MP") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /vmg /vmm /MP")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od") SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od")
ADD_DEFINITIONS(-D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS)
ENDIF() ENDIF()
# use shared libraries for protobuf # use shared libraries for protobuf

@ -280,7 +280,7 @@ static const char *l_str2d (const char *s, lua_Number *result) {
endptr = l_str2dloc(s, result, mode); /* try to convert */ endptr = l_str2dloc(s, result, mode); /* try to convert */
if (endptr == NULL) { /* failed? may be a different locale */ if (endptr == NULL) { /* failed? may be a different locale */
char buff[L_MAXLENNUM + 1]; char buff[L_MAXLENNUM + 1];
char *pdot = strchr(s, '.'); char *pdot = (char*)strchr(s, '.');
if (strlen(s) > L_MAXLENNUM || pdot == NULL) if (strlen(s) > L_MAXLENNUM || pdot == NULL)
return NULL; /* string too long or no dot; fail */ return NULL; /* string too long or no dot; fail */
strcpy(buff, s); /* copy string to buffer */ strcpy(buff, s); /* copy string to buffer */

@ -39,7 +39,7 @@ freely, subject to the following restrictions:
// Check if we can support the assembly language level implementation (otherwise // Check if we can support the assembly language level implementation (otherwise
// revert to the system API) // revert to the system API)
#if (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || \ #if (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) || \
(defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))) || \ (defined(_MSC_VER) && (defined(_M_IX86) /*|| defined(_M_X64)*/)) || \
(defined(__GNUC__) && (defined(__ppc__))) (defined(__GNUC__) && (defined(__ppc__)))
#define _FAST_MUTEX_ASM_ #define _FAST_MUTEX_ASM_
#else #else

@ -30,8 +30,13 @@ namespace df {
NUMBER_IDENTITY_TRAITS(uint32_t); NUMBER_IDENTITY_TRAITS(uint32_t);
NUMBER_IDENTITY_TRAITS(int64_t); NUMBER_IDENTITY_TRAITS(int64_t);
NUMBER_IDENTITY_TRAITS(uint64_t); NUMBER_IDENTITY_TRAITS(uint64_t);
#ifdef _WIN32
NUMBER_IDENTITY_TRAITS(long);
NUMBER_IDENTITY_TRAITS(unsigned long);
#else
NUMBER_IDENTITY_TRAITS(intptr_t); NUMBER_IDENTITY_TRAITS(intptr_t);
NUMBER_IDENTITY_TRAITS(uintptr_t); NUMBER_IDENTITY_TRAITS(uintptr_t);
#endif
NUMBER_IDENTITY_TRAITS(float); NUMBER_IDENTITY_TRAITS(float);
NUMBER_IDENTITY_TRAITS(double); NUMBER_IDENTITY_TRAITS(double);

@ -726,6 +726,22 @@ DFhackCExport uint32_t SDL_ThreadID(void)
return _SDL_ThreadID(); return _SDL_ThreadID();
} }
static char* (*_SDL_getenv)(const char *name) = 0;
DFhackCExport char* SDL_getenv(const char *name)
{
if(!inited)
FirstCall();
return _SDL_getenv(name);
}
static size_t (*_SDL_strlcat)(char *dst, const char *src, size_t maxlen) = 0;
DFhackCExport size_t SDL_strlcat(char *dst, const char *src, size_t maxlen)
{
if(!inited)
FirstCall();
return _SDL_strlcat(dst, src, maxlen);
}
// FIXME: this has to be thread-safe. // FIXME: this has to be thread-safe.
bool FirstCall() bool FirstCall()
{ {
@ -813,6 +829,10 @@ bool FirstCall()
_SDL_SemWait = (int (*)(void *))GetProcAddress(realSDLlib,"SDL_SemWait"); _SDL_SemWait = (int (*)(void *))GetProcAddress(realSDLlib,"SDL_SemWait");
_SDL_ThreadID = (uint32_t (*)(void))GetProcAddress(realSDLlib,"SDL_ThreadID"); _SDL_ThreadID = (uint32_t (*)(void))GetProcAddress(realSDLlib,"SDL_ThreadID");
// new in DF 0.43.05
_SDL_getenv = (char* (*)(const char*))GetProcAddress(realSDLlib,"SDL_getenv");
_SDL_strlcat = (size_t (*)(char*, const char*, size_t))GetProcAddress(realSDLlib,"SDL_strlcat");
_SDL_EnableUNICODE(1); _SDL_EnableUNICODE(1);
fprintf(stderr,"Initized HOOKS!\n"); fprintf(stderr,"Initized HOOKS!\n");

@ -82,7 +82,7 @@ using namespace DFHack;
// multiple, but not virtual inheritance. // multiple, but not virtual inheritance.
struct MSVC_MPTR { struct MSVC_MPTR {
void *method; void *method;
intptr_t this_shift; uint32_t this_shift; // was intptr_t pre-0.43.05
}; };
// Debug builds sometimes use additional thunks that // Debug builds sometimes use additional thunks that
@ -97,7 +97,11 @@ static uint32_t *follow_jmp(void *ptr)
switch (*p) switch (*p)
{ {
case 0xE9: // jmp near rel32 case 0xE9: // jmp near rel32
#ifdef DFHACK64
p += 5 + *(int32_t*)(p+1) + 1;
#else
p += 5 + *(int32_t*)(p+1); p += 5 + *(int32_t*)(p+1);
#endif
break; break;
case 0xEB: // jmp short rel8 case 0xEB: // jmp short rel8
p += 2 + *(int8_t*)(p+1); p += 2 + *(int8_t*)(p+1);

@ -487,8 +487,13 @@ namespace df
NUMBER_IDENTITY_TRAITS(uint32_t); NUMBER_IDENTITY_TRAITS(uint32_t);
NUMBER_IDENTITY_TRAITS(int64_t); NUMBER_IDENTITY_TRAITS(int64_t);
NUMBER_IDENTITY_TRAITS(uint64_t); NUMBER_IDENTITY_TRAITS(uint64_t);
#ifdef _WIN32
NUMBER_IDENTITY_TRAITS(long);
NUMBER_IDENTITY_TRAITS(unsigned long);
#else
NUMBER_IDENTITY_TRAITS(intptr_t); NUMBER_IDENTITY_TRAITS(intptr_t);
NUMBER_IDENTITY_TRAITS(uintptr_t); NUMBER_IDENTITY_TRAITS(uintptr_t);
#endif
NUMBER_IDENTITY_TRAITS(float); NUMBER_IDENTITY_TRAITS(float);
NUMBER_IDENTITY_TRAITS(double); NUMBER_IDENTITY_TRAITS(double);

@ -53,7 +53,7 @@ namespace DFHack
std::map <std::string, uintptr_t> Addresses; std::map <std::string, uintptr_t> Addresses;
std::map <std::string, uintptr_t> VTables; std::map <std::string, uintptr_t> VTables;
uintptr_t base; uintptr_t base;
int rebase_delta; uintptr_t rebase_delta;
std::string version; std::string version;
OSType OS; OSType OS;
public: public:

@ -91,7 +91,7 @@ if (BUILD_SUPPORTED)
DFHACK_PLUGIN(deramp deramp.cpp) DFHACK_PLUGIN(deramp deramp.cpp)
DFHACK_PLUGIN(dig dig.cpp) DFHACK_PLUGIN(dig dig.cpp)
DFHACK_PLUGIN(digFlood digFlood.cpp) DFHACK_PLUGIN(digFlood digFlood.cpp)
add_subdirectory(diggingInvaders) # add_subdirectory(diggingInvaders)
DFHACK_PLUGIN(dwarfmonitor dwarfmonitor.cpp LINK_LIBRARIES lua) DFHACK_PLUGIN(dwarfmonitor dwarfmonitor.cpp LINK_LIBRARIES lua)
DFHACK_PLUGIN(embark-tools embark-tools.cpp) DFHACK_PLUGIN(embark-tools embark-tools.cpp)
DFHACK_PLUGIN(eventful eventful.cpp LINK_LIBRARIES lua) DFHACK_PLUGIN(eventful eventful.cpp LINK_LIBRARIES lua)