From 9a55db7b612ceaa09a44b63ff0703af0ebe34cf0 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Fri, 4 Jan 2013 13:57:27 -0500 Subject: [PATCH] Bug 826779 - Get DMD to build on Windows; r=bbondy --- memory/replace/dmd/DMD.cpp | 26 ++++++++++++++++++-------- memory/replace/dmd/Makefile.in | 4 ++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/memory/replace/dmd/DMD.cpp b/memory/replace/dmd/DMD.cpp index 24342660033e..e6059182dca0 100644 --- a/memory/replace/dmd/DMD.cpp +++ b/memory/replace/dmd/DMD.cpp @@ -15,10 +15,8 @@ #include #ifdef XP_WIN -#error "Windows not supported yet, sorry." -// XXX: This will be needed when Windows is supported (bug 819839). -//#include -//#define getpid _getpid +#include +#include #else #include #endif @@ -42,7 +40,21 @@ // PAGE_SIZE. Nb: sysconf() is expensive, but it's only used for (the obsolete // and rarely used) valloc. #define MOZ_REPLACE_ONLY_MEMALIGN 1 +#ifdef XP_WIN +#define PAGE_SIZE GetPageSize() +static long GetPageSize() +{ + SYSTEM_INFO si; + GetSystemInfo(&si); + return si.dwPageSize; +} +static void* valloc(size_t size) +{ + return VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); +} +#else #define PAGE_SIZE sysconf(_SC_PAGESIZE) +#endif #include "replace_malloc.h" #undef MOZ_REPLACE_ONLY_MEMALIGN #undef PAGE_SIZE @@ -275,8 +287,6 @@ static const size_t kNoSize = size_t(-1); // MutexBase implements the platform-specific parts of a mutex. #ifdef XP_WIN -#include - class MutexBase { CRITICAL_SECTION mCS; @@ -407,9 +417,9 @@ public: #ifdef XP_WIN #define DMD_TLS_INDEX_TYPE DWORD -#define DMD_CREATE_TLS_INDEX(i_) PR_BEGIN_MACRO \ +#define DMD_CREATE_TLS_INDEX(i_) do { \ (i_) = TlsAlloc(); \ - PR_END_MACRO + } while (0) #define DMD_DESTROY_TLS_INDEX(i_) TlsFree((i_)) #define DMD_GET_TLS_DATA(i_) TlsGetValue((i_)) #define DMD_SET_TLS_DATA(i_, v_) TlsSetValue((i_), (v_)) diff --git a/memory/replace/dmd/Makefile.in b/memory/replace/dmd/Makefile.in index 9d1424f0336a..bfa5f7eafbcd 100644 --- a/memory/replace/dmd/Makefile.in +++ b/memory/replace/dmd/Makefile.in @@ -35,5 +35,9 @@ MOZ_GLUE_LDFLAGS= STL_FLAGS = +ifeq ($(OS_ARCH),WINNT) +OS_LIBS += $(call EXPAND_LIBNAME,dbghelp) +endif + include $(topsrcdir)/config/config.mk include $(topsrcdir)/config/rules.mk