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()
if(WIN32)
if((NOT MSVC) OR (NOT MSVC_VERSION STREQUAL 1600))
message(SEND_ERROR "MSVC 2010 is required")
if((NOT MSVC) OR (NOT MSVC_VERSION STREQUAL 1900))
message(SEND_ERROR "MSVC 2015 is required")
endif()
endif()
@ -177,6 +177,7 @@ ELSEIF(MSVC)
# 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_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Od")
ADD_DEFINITIONS(-D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS)
ENDIF()
# 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 */
if (endptr == NULL) { /* failed? may be a different locale */
char buff[L_MAXLENNUM + 1];
char *pdot = strchr(s, '.');
char *pdot = (char*)strchr(s, '.');
if (strlen(s) > L_MAXLENNUM || pdot == NULL)
return NULL; /* string too long or no dot; fail */
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
// revert to the system API)
#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__)))
#define _FAST_MUTEX_ASM_
#else

@ -30,8 +30,13 @@ namespace df {
NUMBER_IDENTITY_TRAITS(uint32_t);
NUMBER_IDENTITY_TRAITS(int64_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(uintptr_t);
#endif
NUMBER_IDENTITY_TRAITS(float);
NUMBER_IDENTITY_TRAITS(double);

@ -726,6 +726,22 @@ DFhackCExport uint32_t SDL_ThreadID(void)
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.
bool FirstCall()
{
@ -813,6 +829,10 @@ bool FirstCall()
_SDL_SemWait = (int (*)(void *))GetProcAddress(realSDLlib,"SDL_SemWait");
_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);
fprintf(stderr,"Initized HOOKS!\n");

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

@ -487,8 +487,13 @@ namespace df
NUMBER_IDENTITY_TRAITS(uint32_t);
NUMBER_IDENTITY_TRAITS(int64_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(uintptr_t);
#endif
NUMBER_IDENTITY_TRAITS(float);
NUMBER_IDENTITY_TRAITS(double);

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

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