Skip to content

Commit

Permalink
Bug 826779 - Get DMD to build on Windows; r=bbondy
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan committed Jan 4, 2013
1 parent 827d29c commit fde8e41
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
26 changes: 18 additions & 8 deletions memory/replace/dmd/DMD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
#include <string.h>

#ifdef XP_WIN
#error "Windows not supported yet, sorry."
// XXX: This will be needed when Windows is supported (bug 819839).
//#include <process.h>
//#define getpid _getpid
#include <windows.h>
#include <process.h>
#else
#include <unistd.h>
#endif
Expand All @@ -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
Expand Down Expand Up @@ -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 <windows.h>

class MutexBase
{
CRITICAL_SECTION mCS;
Expand Down Expand Up @@ -407,9 +417,9 @@ class AutoUnlockState
#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_))
Expand Down
4 changes: 4 additions & 0 deletions memory/replace/dmd/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fde8e41

Please sign in to comment.