diff --git a/source/lib/file/common/trace.cpp b/source/lib/file/common/trace.cpp index 103142ff4b..6ef0bc2033 100644 --- a/source/lib/file/common/trace.cpp +++ b/source/lib/file/common/trace.cpp @@ -31,8 +31,6 @@ TraceEntry::TraceEntry(EAction action, const char* pathname, size_t size) } -#define STRINGIZE(number) #number - TraceEntry::TraceEntry(const char* text) { const char* fmt = "%f: %c \"" STRINGIZE(PATH_MAX) "[^\"]\" %d\n"; diff --git a/source/lib/ogl.h b/source/lib/ogl.h index 243dd125b5..306bcccf4a 100644 --- a/source/lib/ogl.h +++ b/source/lib/ogl.h @@ -60,7 +60,7 @@ * call before using any other function, and after each video mode change. * fails if OpenGL not ready for use. **/ -extern void ogl_Init(void); +extern void ogl_Init(); //----------------------------------------------------------------------------- diff --git a/source/lib/precompiled.h b/source/lib/precompiled.h index 256ff445db..4cfdfd2f35 100644 --- a/source/lib/precompiled.h +++ b/source/lib/precompiled.h @@ -60,7 +60,7 @@ // using Boost via DLL. (otherwise, we would have to ensure the exact same // compiler is used, which is a pain because MSC8, MSC9 and ICC 10 are in use) #ifndef LIB_STATIC_LINK -//# define BOOST_ALL_DYN_LINK +# define BOOST_ALL_DYN_LINK #endif #include // noncopyable // the following boost libraries have been included in TR1 and are diff --git a/source/lib/sysdep/arch/x86_x64/x86_x64.cpp b/source/lib/sysdep/arch/x86_x64/x86_x64.cpp index 1987d08c6b..9a2568b8db 100644 --- a/source/lib/sysdep/arch/x86_x64/x86_x64.cpp +++ b/source/lib/sysdep/arch/x86_x64/x86_x64.cpp @@ -23,10 +23,10 @@ #include "lib/sysdep/cpu.h" #include "lib/sysdep/os_cpu.h" -#if ARCH_IA32 -# include "../ia32/ia32_asm.h" -#else +#if ARCH_AMD64 # include "../amd64/amd64_asm.h" +#else +# include "../ia32/ia32_asm.h" #endif #if MSC_VERSION @@ -43,10 +43,10 @@ // in assembly for both IA-32 and AMD64. static void cpuid_impl(x86_x64_CpuidRegs* regs) { -#if ARCH_IA32 - ia32_asm_cpuid(regs); -#else +#if ARCH_AMD64 amd64_asm_cpuid(regs); +#else + ia32_asm_cpuid(regs); #endif } diff --git a/source/lib/sysdep/compiler.h b/source/lib/sysdep/compiler.h index b494e011eb..5e64ba5479 100644 --- a/source/lib/sysdep/compiler.h +++ b/source/lib/sysdep/compiler.h @@ -185,4 +185,15 @@ # define CALL_CONV #endif +#if MSC_VERSION && !ARCH_AMD64 +# define DECORATED_NAME(name) _##name +#else +# define DECORATED_NAME(name) name +#endif + +// workaround for preprocessor limitation: macro args aren't expanded +// before being pasted. +#define STRINGIZE2(id) # id +#define STRINGIZE(id) STRINGIZE2(id) + #endif // #ifndef INCLUDED_COMPILER diff --git a/source/lib/sysdep/dir_watch.h b/source/lib/sysdep/dir_watch.h index 8e2f82a43d..10f23a900c 100644 --- a/source/lib/sysdep/dir_watch.h +++ b/source/lib/sysdep/dir_watch.h @@ -19,8 +19,6 @@ typedef shared_ptr PDirWatch; * * @param path native path of the directory to watch. * @param dirWatch receives a smart pointer to the watch object. - * note: freeing it does not prevent any previously queued notifications - * from being returned. * * note: the FAM backend can only watch single directories, so that is * all we can guarantee. the Win32 implementation watches entire trees; @@ -28,6 +26,13 @@ typedef shared_ptr PDirWatch; **/ LIB_API LibError dir_watch_Add(const fs::wpath& path, PDirWatch& dirWatch); +/** + * stop watching a directory. + * + * note: any previously queued notifications will still be returned. + **/ +LIB_API void dir_watch_Remove(PDirWatch& dirWatch); + class DirWatchNotification { public: diff --git a/source/lib/sysdep/os/win/manifest.cpp b/source/lib/sysdep/os/win/manifest.cpp index f90ce4f6e1..4ddbf74588 100644 --- a/source/lib/sysdep/os/win/manifest.cpp +++ b/source/lib/sysdep/os/win/manifest.cpp @@ -15,6 +15,6 @@ is currently disabled there. # if ARCH_IA32 # pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df'\"") # elif ARCH_AMD64 -# pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x64' publicKeyToken='6595b64144ccf1df'\"") +# pragma comment(linker, "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df'\"") # endif #endif diff --git a/source/lib/sysdep/os/win/wdbg_heap.cpp b/source/lib/sysdep/os/win/wdbg_heap.cpp index 5dd9acd973..86c25ed35f 100644 --- a/source/lib/sysdep/os/win/wdbg_heap.cpp +++ b/source/lib/sysdep/os/win/wdbg_heap.cpp @@ -61,7 +61,15 @@ void wdbg_heap_Validate() // (this relies on the debug CRT; not compiling it at all in release builds // avoids unreferenced local function warnings) -#ifndef NDEBUG +// (this has only been tested on IA32 and seems to have trouble with larger +// pointers, so it's disabled for now.) +#if !defined(NDEBUG) && ARCH_IA32 +# define ENABLE_LEAK_INSTRUMENTATION 1 +#else +# define ENABLE_LEAK_INSTRUMENTATION 0 +#endif + +#if ENABLE_LEAK_INSTRUMENTATION // leak detectors often rely on macro redirection to determine the file and // line of allocation owners (see _CRTDBG_MAP_ALLOC). unfortunately this @@ -473,7 +481,7 @@ public: size_t outputBitsLeft = numOutputBits; while(outputBitsLeft > 0) { - const size_t numBits = std::min(outputBitsLeft, 8u); + const size_t numBits = std::min(outputBitsLeft, size_t(8)); m_bitsLeft -= numBits; // (NB: there is no need to extract exactly numBits because @@ -527,7 +535,7 @@ public: size_t inputBitsLeft = numInputBits; while(inputBitsLeft > 0) { - const size_t numBits = std::min(inputBitsLeft, 8u); + const size_t numBits = std::min(inputBitsLeft, size_t(8)); m_bitsLeft -= numBits; if(m_numRemainderBits < numBits) @@ -901,13 +909,13 @@ intptr_t wdbg_heap_NumberOfAllocations() //----------------------------------------------------------------------------- -#ifndef NDEBUG +#if ENABLE_LEAK_INSTRUMENTATION static AllocationTracker* s_tracker; #endif static LibError wdbg_heap_Init() { -#ifndef NDEBUG +#if ENABLE_LEAK_INSTRUMENTATION FindCodeSegment(); // load symbol information now (fails if it happens during shutdown) @@ -928,7 +936,7 @@ static LibError wdbg_heap_Init() static LibError wdbg_heap_Shutdown() { -#ifndef NDEBUG +#if ENABLE_LEAK_INSTRUMENTATION SAFE_DELETE(s_tracker); #endif diff --git a/source/lib/sysdep/os/win/wdir_watch.cpp b/source/lib/sysdep/os/win/wdir_watch.cpp index b772cf54c9..a066b10ef9 100644 --- a/source/lib/sysdep/os/win/wdir_watch.cpp +++ b/source/lib/sysdep/os/win/wdir_watch.cpp @@ -149,10 +149,6 @@ private: //----------------------------------------------------------------------------- -// (watches are removed by resetting shared_ptr; the DirWatch dtor must -// notify DirWatchManager and remove itself from the list there) -static void RemoveFromList(DirWatch* dirWatch); - class DirWatch { public: @@ -185,8 +181,6 @@ public: CloseHandle(m_hDir); m_hDir = INVALID_HANDLE_VALUE; - - RemoveFromList(this); } void Issue() @@ -333,16 +327,9 @@ public: return INFO::OK; } - void Remove(DirWatch* dirWatch) + void Remove(PDirWatch& dirWatch) { - for(Watches::iterator it = m_watches.begin(); it != m_watches.end(); ++it) - { - if(it->get() == dirWatch) - { - m_watches.erase(it); - break; - } - } + m_watches.remove(dirWatch); } LibError Poll(DirWatchNotification& notification) @@ -381,7 +368,7 @@ LibError dir_watch_Add(const fs::wpath& path, PDirWatch& dirWatch) return s_dirWatchManager->Add(path, dirWatch); } -static void RemoveFromList(DirWatch* dirWatch) +void dir_watch_Remove(PDirWatch& dirWatch) { WinScopedLock lock(WDIR_WATCH_CS); return s_dirWatchManager->Remove(dirWatch); diff --git a/source/lib/sysdep/os/win/wdll_ver.cpp b/source/lib/sysdep/os/win/wdll_ver.cpp index ac86de8df3..08335d7a8e 100644 --- a/source/lib/sysdep/os/win/wdll_ver.cpp +++ b/source/lib/sysdep/os/win/wdll_ver.cpp @@ -52,7 +52,7 @@ static LibError ReadVersionString(const OsPath& modulePathname_, char* out_ver, WARN_RETURN(ERR::FAIL); u16* lang; // -> 16 bit language ID, 16 bit codepage - size_t lang_len; + UINT lang_len; const BOOL ok = VerQueryValue(mem.get(), "\\VarFileInfo\\Translation", (void**)&lang, &lang_len); if(!ok || !lang || lang_len != 4) WARN_RETURN(ERR::FAIL); @@ -60,7 +60,7 @@ static LibError ReadVersionString(const OsPath& modulePathname_, char* out_ver, char subblock[64]; sprintf(subblock, "\\StringFileInfo\\%04X%04X\\FileVersion", lang[0], lang[1]); const char* in_ver; - size_t in_ver_len; + UINT in_ver_len; if(!VerQueryValue(mem.get(), subblock, (void**)&in_ver, &in_ver_len)) WARN_RETURN(ERR::FAIL); diff --git a/source/lib/sysdep/os/win/winit.h b/source/lib/sysdep/os/win/winit.h index 04ca04832c..49dbaf9a22 100644 --- a/source/lib/sysdep/os/win/winit.h +++ b/source/lib/sysdep/os/win/winit.h @@ -117,30 +117,29 @@ Several methods of module init are possible: (see Large Scale C++ Design) // very early init; must not fail, since error handling code *crashes* // if called before these have completed. -#define WINIT_REGISTER_CRITICAL_INIT(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I0")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:_p"#func)) +#define WINIT_REGISTER_CRITICAL_INIT(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I0")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) // meant for modules with dependents but whose init is complicated and may // raise error/warning messages (=> can't go in WINIT_REGISTER_CRITICAL_INIT) -#define WINIT_REGISTER_EARLY_INIT(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I1")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:_p"#func)) +#define WINIT_REGISTER_EARLY_INIT(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I1")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) // available for dependents of WINIT_REGISTER_EARLY_INIT-modules that // must still come before WINIT_REGISTER_MAIN_INIT. -#define WINIT_REGISTER_EARLY_INIT2(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I2")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:_p"#func)) +#define WINIT_REGISTER_EARLY_INIT2(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I2")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) // most modules will go here unless they are often used or // have many dependents. -#define WINIT_REGISTER_MAIN_INIT(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I6")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:_p"#func)) +#define WINIT_REGISTER_MAIN_INIT(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I6")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) // available for any modules that may need to come after // WINIT_REGISTER_MAIN_INIT (unlikely) -#define WINIT_REGISTER_LATE_INIT(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I7")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:_p"#func)) - -#define WINIT_REGISTER_EARLY_SHUTDOWN(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S0")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:_p"#func)) -#define WINIT_REGISTER_EARLY_SHUTDOWN2(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S1")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:_p"#func)) -#define WINIT_REGISTER_MAIN_SHUTDOWN(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S6")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:_p"#func)) -#define WINIT_REGISTER_LATE_SHUTDOWN(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S7")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:_p"#func)) -#define WINIT_REGISTER_LATE_SHUTDOWN2(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S8")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:_p"#func)) +#define WINIT_REGISTER_LATE_INIT(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$I7")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) +#define WINIT_REGISTER_EARLY_SHUTDOWN(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S0")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) +#define WINIT_REGISTER_EARLY_SHUTDOWN2(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S1")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) +#define WINIT_REGISTER_MAIN_SHUTDOWN(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S6")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) +#define WINIT_REGISTER_LATE_SHUTDOWN(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S7")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) +#define WINIT_REGISTER_LATE_SHUTDOWN2(func) static LibError func(void); EXTERN_C __declspec(allocate(".WINIT$S8")) LibError (*p##func)(void) = func; __pragma(comment(linker, "/include:" STRINGIZE(DECORATED_NAME(p##func)))) //----------------------------------------------------------------------------- diff --git a/source/lib/sysdep/os/win/wposix/wposix_types.h b/source/lib/sysdep/os/win/wposix/wposix_types.h index 4bd2425882..375bb2d159 100644 --- a/source/lib/sysdep/os/win/wposix/wposix_types.h +++ b/source/lib/sysdep/os/win/wposix/wposix_types.h @@ -55,6 +55,7 @@ typedef unsigned long long uint64_t; typedef long ssize_t; // prevent wxWidgets from (incompatibly) redefining it #define HAVE_SSIZE_T +typedef long off_t; // diff --git a/source/lib/sysdep/os/win/wprintf.cpp b/source/lib/sysdep/os/win/wprintf.cpp index 55a266839c..d25dea220e 100644 --- a/source/lib/sysdep/os/win/wprintf.cpp +++ b/source/lib/sysdep/os/win/wprintf.cpp @@ -8,6 +8,8 @@ #include "precompiled.h" +#if ARCH_IA32 + /* See http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html for the specification (apparently an extension to ISO C) that was used @@ -486,3 +488,5 @@ finished_reading: return ret; } + +#endif diff --git a/source/lib/sysdep/os/win/wstartup.cpp b/source/lib/sysdep/os/win/wstartup.cpp index 84624ae4fc..33f3ba3c47 100644 --- a/source/lib/sysdep/os/win/wstartup.cpp +++ b/source/lib/sysdep/os/win/wstartup.cpp @@ -104,4 +104,4 @@ EXTERN_C int wstartup_InitAndRegisterShutdown() #pragma section(".CRT$XIV", long,SECTION_ATTRIBUTES) #undef SECTION_ATTRIBUTES EXTERN_C __declspec(allocate(".CRT$XIV")) int(*wstartup_pInitAndRegisterShutdown)() = wstartup_InitAndRegisterShutdown; -#pragma comment(linker, "/include:_wstartup_pInitAndRegisterShutdown") +#pragma comment(linker, "/include:" STRINGIZE(DECORATED_NAME(wstartup_pInitAndRegisterShutdown))) diff --git a/source/lib/sysdep/os/win/wutil.cpp b/source/lib/sysdep/os/win/wutil.cpp index 2cf2a0a67c..b775c514a4 100644 --- a/source/lib/sysdep/os/win/wutil.cpp +++ b/source/lib/sysdep/os/win/wutil.cpp @@ -301,7 +301,7 @@ static void DetectWindowsVersion() DWORD size = ARRAY_SIZE(windowsVersionString); (void)RegQueryValueEx(hKey, "CurrentVersion", 0, 0, (LPBYTE)windowsVersionString, &size); - size_t major = 0, minor = 0; + int major = 0, minor = 0; int ret = sscanf(windowsVersionString, "%d.%d", &major, &minor); debug_assert(ret == 2); debug_assert(major <= 0xFF && minor <= 0xFF);