Backed out changeset 1eec75c27e2f
authorVladimir Vukicevic <vladimir@pobox.com>
Fri, 24 Apr 2009 10:43:19 -0700
changeset 27808 0870c18962f4922bcbe553266af2908592be155f
parent 27806 1eec75c27e2f7ffefe7beeb9da57236a9c543300
child 27809 02c78d0b834f8d61fc39a4fba52d711e8e64d3ba
push id6722
push uservladimir@mozilla.com
push dateFri, 24 Apr 2009 17:43:49 +0000
treeherderautoland@02c78d0b834f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.2a1pre
backs out1eec75c27e2f7ffefe7beeb9da57236a9c543300
Backed out changeset 1eec75c27e2f
build/wince/shunt/Makefile.in
build/wince/shunt/include/mozce_shunt.h
build/wince/shunt/include/stdlib.h.in
build/wince/shunt/memory.cpp
build/wince/shunt/mozce_shunt.def
config/config.mk
configure.in
js/src/Makefile.in
js/src/shell/Makefile.in
memory/jemalloc/Makefile.in
memory/jemalloc/jemalloc.c
memory/jemalloc/jemalloc.h
--- a/build/wince/shunt/Makefile.in
+++ b/build/wince/shunt/Makefile.in
@@ -67,31 +67,22 @@ EXPORTS = include/windows.h \
   $(NULL)
 
 DIRS += include/sys
 
 ifdef MOZ_MEMORY
 REQUIRES = jemalloc 
 CFLAGS += -DMOZ_MEMORY
 CXXFLAGS += -DMOZ_MEMORY
-EXPORTS += $(topsrcdir)/memory/jemalloc/jemalloc.h
 endif
 
-DEFFILE = mozce_shunt.def
-
-# We have to include the obj file directly, because we want to export
-# some of its symbols through our def file
-EXTRA_LIBS += $(OBJDIR)/memory/jemalloc/jemalloc.obj
+EXTRA_LIBS += $(JEMALLOC_LIBS)
 
 CPPSRCS = \
 	shunt.cpp \
 	environment.cpp \
 	time.cpp \
 	memory.cpp \
 	$(NULL)
 
 DEFINES += -DMOZCE_SHUNT_EXPORTS
 
 include $(topsrcdir)/config/rules.mk
-
-mozce_shunt.def: mozce_shunt.def.in
-	$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $^ > $@
-
--- a/build/wince/shunt/include/mozce_shunt.h
+++ b/build/wince/shunt/include/mozce_shunt.h
@@ -30,68 +30,83 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+
 #ifndef MOZCE_SHUNT_H
 #define MOZCE_SHUNT_H
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _WCHAR_T_DEFINED
-typedef unsigned short wchar_t;
-#define _WCHAR_T_DEFINED
-#endif
-
-#ifdef __cplusplus
-}   //extern "C" 
+#ifdef MOZCE_SHUNT_EXPORTS
+#define _CRTIMP __declspec(dllexport)
 #endif
 
 #ifdef MOZ_MEMORY
+#ifdef __cplusplus
 
-#ifdef __cplusplus
+
 #define _NEW_
 void * operator new(size_t _Size);
 void operator delete(void * ptr);
 void *operator new[](size_t size);
 void operator delete[](void *ptr);
 
 extern "C" {
 #endif
 
+extern void* moz_malloc(size_t);
+extern void* moz_valloc(size_t);
+extern void* moz_calloc(size_t, size_t);
+extern void* moz_realloc(void*, unsigned int);
+extern void moz_free(void*);
+  
+void* __cdecl  malloc(size_t);
+void* __cdecl  valloc(size_t);
+void* __cdecl  calloc(size_t, size_t);
+void* __cdecl  realloc(void*, unsigned int);
+void __cdecl  free(void*);
+
+ 
+char*
+mozce_strdup(const char*);
+
+MOZCE_SHUNT_API unsigned short* 
+mozce_wcsdup(const unsigned short* );
+
+MOZCE_SHUNT_API char*
+mozce_strndup(const char *, unsigned int);
+
+MOZCE_SHUNT_API unsigned short* 
+mozce_wcsndup(const unsigned short*, unsigned int);
+  
+#ifdef __cplusplus
+}   //extern "C" 
+#endif
+
+
 #undef _strdup
 #undef strdup
 #undef _strndup
 #undef strndup
 #undef _wcsdup
 #undef wcsdup
 #undef _wcsndup
 #undef wcsndup
 
-char * __cdecl
-_strdup(const char*);
 
-wchar_t * __cdecl
-_wcsdup(const wchar_t *);
 
-char * __cdecl
-_strndup(const char *, unsigned int);
+#define _strdup mozce_strdup
+#define _strndup mozce_strndup
 
-wchar_t * __cdecl
-_wcsndup(const wchar_t *, unsigned int);
-  
-#ifdef __cplusplus
-}   //extern "C" 
-#endif
+#define _wcsdup mozce_wcsdup
+#define _wcsndup mozce_wcsndup
 
 #endif
 
 #define strdup  _strdup
 #define strndup _strndup
 #define wcsdup _wcsdup
 #define wcsndup _wcsndup
 
@@ -105,61 +120,61 @@ wchar_t * __cdecl
 #define SHGetPathFromIDListW    SHGetPathFromIDList
 #define FONTENUMPROCW           FONTENUMPROC
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 /* errno and family */
-extern int errno;
-char* strerror(int);
+extern MOZCE_SHUNT_IMPORT_API int errno;
+MOZCE_SHUNT_IMPORT_API char* strerror(int);
 
 /* abort */
-void abort(void);
+MOZCE_SHUNT_API void abort(void);
   
 /* Environment stuff */
-char* getenv(const char* inName);
-int putenv(const char *a);
-char SetEnvironmentVariableW(const unsigned short * name, const unsigned short * value );
-char GetEnvironmentVariableW(const unsigned short * lpName, unsigned short* lpBuffer, unsigned long nSize);
+MOZCE_SHUNT_API char* getenv(const char* inName);
+MOZCE_SHUNT_API int putenv(const char *a);
+MOZCE_SHUNT_API char SetEnvironmentVariableW(const unsigned short * name, const unsigned short * value );
+MOZCE_SHUNT_API char GetEnvironmentVariableW(const unsigned short * lpName, unsigned short* lpBuffer, unsigned long nSize);
   
-unsigned int ExpandEnvironmentStringsW(const unsigned short* lpSrc,
-				       unsigned short* lpDst,
-				       unsigned int nSize);
+MOZCE_SHUNT_API unsigned int ExpandEnvironmentStringsW(const unsigned short* lpSrc,
+                                                       unsigned short* lpDst,
+                                                       unsigned int nSize);
 
 /* File system stuff */
-unsigned short * _wgetcwd(unsigned short* dir, unsigned long size);
-unsigned short *_wfullpath( unsigned short *absPath, const unsigned short *relPath, unsigned long maxLength );
-int _unlink(const char *filename );
+MOZCE_SHUNT_API unsigned short * _wgetcwd(unsigned short* dir, unsigned long size);
+MOZCE_SHUNT_API unsigned short *_wfullpath( unsigned short *absPath, const unsigned short *relPath, unsigned long maxLength );
+MOZCE_SHUNT_API int _unlink(const char *filename );
   
 /* The time stuff should be defined here, but it can't be because it
    is already defined in time.h.
   
- size_t strftime(char *, size_t, const char *, const struct tm *)
- struct tm* localtime(const time_t* inTimeT)
- struct tm* mozce_gmtime_r(const time_t* inTimeT, struct tm* outRetval)
- struct tm* gmtime(const time_t* inTimeT)
- time_t mktime(struct tm* inTM)
- time_t time(time_t *)
- clock_t clock() 
+ MOZCE_SHUNT_API size_t strftime(char *, size_t, const char *, const struct tm *)
+ MOZCE_SHUNT_API struct tm* localtime(const time_t* inTimeT)
+ MOZCE_SHUNT_API struct tm* mozce_gmtime_r(const time_t* inTimeT, struct tm* outRetval)
+ MOZCE_SHUNT_API struct tm* gmtime(const time_t* inTimeT)
+ MOZCE_SHUNT_API time_t mktime(struct tm* inTM)
+ MOZCE_SHUNT_API time_t time(time_t *)
+ MOZCE_SHUNT_API clock_t clock() 
   
 */
   
 /* Locale Stuff */
   
 /* The locale stuff should be defined here, but it can't be because it
    is already defined in locale.h.
   
- struct lconv * localeconv(void)
+ MOZCE_SHUNT_API struct lconv * localeconv(void)
   
 */
 
 
-unsigned short* mozce_GetEnvironmentCL();
+MOZCE_SHUNT_API unsigned short* mozce_GetEnvironmentCL();
 
   /* square root of 1/2, missing from math.h */ 
 #define M_SQRT1_2  0.707106781186547524401
 
 #ifdef __cplusplus
 };
 #endif
 
--- a/build/wince/shunt/include/stdlib.h.in
+++ b/build/wince/shunt/include/stdlib.h.in
@@ -43,46 +43,34 @@
 #undef _strdup
 #undef wcsdup
 #undef _wcsdup
 #undef strndup
 #undef _strndup
 #undef wcsndup
 #undef _wcsndup
 
-#define free orig_free
-#define malloc orig_malloc
-#define calloc orig_calloc
-#define realloc orig_realloc
-#define _wcsdup orig_wcsdup
-#define _strdup orig_strup
-
 #endif
 
 #include "@WINCE_SDK_DIR@/Include/Armv4i/stdlib.h"
 
 #ifdef MOZ_MEMORY
-
-#undef free
-#undef malloc
-#undef calloc
-#undef realloc
-
 #undef strdup
 #undef _strdup
 #undef wcsdup
 #undef _wcsdup
 #undef strndup
 #undef _strndup
 #undef wcsndup
 #undef _wcsndup
 
+#define _strdup mozce_strdup
 #define strdup _strdup
+#define _strndup mozce_strndup
 #define strndup _strndup
+#define _wcsdup mozce_wcsdup
 #define wcsdup _wcsdup
+#define _wcsndup mozce_wcsndup
 #define wcsndup _wcsndup
 
-/* now include jemalloc.h to get the real malloc, free, etc. */
-#include "jemalloc.h"
-
 #endif
 
 #endif
--- a/build/wince/shunt/memory.cpp
+++ b/build/wince/shunt/memory.cpp
@@ -37,56 +37,71 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "include/mozce_shunt.h"
 #include <stdlib.h>
 
 #ifdef MOZ_MEMORY
 void * operator new(size_t _Size)
 {
-  void *p = malloc(_Size);
-  return (p);
+   void *p =  moz_malloc(_Size);
+   return (p);
 }
 
 void operator delete(void * ptr)
 {
-  free(ptr);  
+  moz_free(ptr);  
 }
 void *operator new[](size_t size)
 {
-  void* p = malloc(size);
+  void* p = moz_malloc(size);
   return (p);
 }
 void operator delete[](void *ptr)
 {
-  free(ptr);
+  moz_free(ptr);
 }
 
 char*
-_strndup(const char *src, size_t len) {
-  char* dst = (char*)malloc(len + 1);
+mozce_strndup( const char *src, size_t len ) {
+  char* dst = (char*)moz_malloc(len + 1);
   if(dst)
     strncpy(dst, src, len + 1);
   return dst;
 }
 
 
 char*
-_strdup(const char *src) {
+mozce_strdup(const char *src ) {
   size_t len = strlen(src);
-  return _strndup(src, len );
+  return mozce_strndup(src, len );
 }
 
-wchar_t * 
-_wcsndup(const wchar_t *src, size_t len) {
-  wchar_t* dst = (wchar_t*)malloc(sizeof(wchar_t) * (len + 1));
+unsigned short* 
+mozce_wcsndup( const unsigned short *src, size_t len ) {
+  wchar_t* dst = (wchar_t*)moz_malloc(sizeof(wchar_t) * (len + 1));
   if(dst)
     wcsncpy(dst, src, len + 1);
   return dst;
 }
 
-wchar_t * 
-_wcsdup(const wchar_t *src) {
+unsigned short* 
+mozce_wcsdup( const unsigned short *src ) {
   size_t len = wcslen(src);
-  return _wcsndup(src, len);
+  return mozce_wcsndup(src, len);
+}
+void* __cdecl malloc(size_t size) {
+  return moz_malloc(size);
+}
+void* __cdecl valloc(size_t size) {
+  return moz_valloc(size);
+}
+void* __cdecl calloc(size_t size, size_t num) {
+  return moz_calloc(size, num);
+}
+void* __cdecl realloc(void* ptr, size_t size) {
+  return moz_realloc(ptr, size);
+}
+void __cdecl free(void* ptr) {
+  return moz_free(ptr);
 }
 #endif
 
new file mode 100644
--- /dev/null
+++ b/build/wince/shunt/mozce_shunt.def
@@ -0,0 +1,21 @@
+LIBRARY mozce_shunt.dll
+EXPORTS
+ExpandEnvironmentStringsW
+GetEnvironmentVariableW
+SetEnvironmentVariableW
+_unlink
+_wfullpath
+_wgetcwd
+abort
+clock
+errno
+gmtime
+localeconv
+localtime
+mktime
+mozce_GetEnvironmentCL
+putenv
+getenv
+strerror
+strftime
+time
--- a/config/config.mk
+++ b/config/config.mk
@@ -153,17 +153,17 @@ OS_CONFIG	:= $(OS_ARCH)$(OS_RELEASE)
 FINAL_LINK_LIBS = $(DEPTH)/config/final-link-libs
 FINAL_LINK_COMPS = $(DEPTH)/config/final-link-comps
 FINAL_LINK_COMP_NAMES = $(DEPTH)/config/final-link-comp-names
 
 MOZ_UNICHARUTIL_LIBS = $(LIBXUL_DIST)/lib/$(LIB_PREFIX)unicharutil_s.$(LIB_SUFFIX)
 MOZ_WIDGET_SUPPORT_LIBS    = $(DIST)/lib/$(LIB_PREFIX)widgetsupport_s.$(LIB_SUFFIX)
 
 ifdef MOZ_MEMORY
-ifneq (,$(filter-out WINNT WINCE,$(OS_ARCH)))
+ifneq ($(OS_ARCH),WINNT)
 JEMALLOC_LIBS = $(MKSHLIB_FORCE_ALL) $(call EXPAND_LIBNAME_PATH,jemalloc,$(DIST)/lib) $(MKSHLIB_UNFORCE_ALL)
 endif
 endif
 
 # determine debug-related options
 _DEBUG_CFLAGS :=
 _DEBUG_LDFLAGS :=
 
--- a/configure.in
+++ b/configure.in
@@ -263,17 +263,17 @@ case "$target" in
     echo Building Windows CE Shunt Library and Tool Chain
     echo Using SDK in:
     echo $WINCE_SDK_DIR
 
     ac_exeext=.exe
 
     _pwdw=`pwd -W`
     _pwd=`pwd`
-    make WINCE_SDK_DIR="$WINCE_SDK_DIR" TOPSRCDIR="$_pwd/$srcdir" OBJDIR="$_pwdw" -C $srcdir/build/wince/tools
+    make WINCE_SDK_DIR="$WINCE_SDK_DIR" TOPSRCDIR="$srcdir" OBJDIR="$_pwdw" -C $srcdir/build/wince/tools
 
     CC="$_pwd/dist/sdk/bin/arm-wince-gcc"
     CXX="$_pwd/dist/sdk/bin/arm-wince-gcc"
     CPP="$_pwd/dist/sdk/bin/arm-wince-gcc -E -nologo"
     CXXCPP="$_pwd/dist/sdk/bin/arm-wince-gcc -TP -E -nologo"
     LD="$_pwd/dist/sdk/bin/arm-wince-link"
     AR="$_pwd/dist/sdk/bin/arm-wince-lib"
     AS="$_pwd/dist/sdk/bin/arm-wince-as"
@@ -6632,19 +6632,16 @@ if test "$MOZ_MEMORY"; then
     MOZ_MEMORY_LDFLAGS="-MANIFEST:NO -LIBPATH:\"$WIN32_CUSTOM_CRT_DIR\" -NODEFAULTLIB:msvcrt -NODEFAULTLIB:msvcrtd -DEFAULTLIB:mozcrt19"
     dnl Also pass this to NSPR/NSS
     DLLFLAGS="$DLLFLAGS $MOZ_MEMORY_LDFLAGS"
     export DLLFLAGS
     ;;
   *wince)
     AC_DEFINE(MOZ_MEMORY_WINCE)
     AC_DEFINE(MOZ_MEMORY_WINDOWS)
-    if test "$WINCE_WINDOWS_MOBILE"; then
-      AC_DEFINE(MOZ_MEMORY_WINCE6)
-    fi
     ;;
   *)
     AC_MSG_ERROR([--enable-jemalloc not supported on ${target}])
     ;;
   esac
 fi
 AC_SUBST(MOZ_MEMORY)
 AC_SUBST(MOZ_MEMORY_LDFLAGS)
--- a/js/src/Makefile.in
+++ b/js/src/Makefile.in
@@ -58,16 +58,20 @@ DIRS += shell
 
 MODULE		    = js
 LIBRARY_NAME	    = mozjs
 STATIC_LIBRARY_NAME = js_static
 GRE_MODULE	    = 1
 
 LIBS		= $(NSPR_LIBS) 
 
+ifdef WINCE
+EXTRA_LIBS += $(JEMALLOC_LIBS)
+endif
+
 ifdef GNU_CXX
 ifdef INTEL_CXX
 # icc gets special optimize flags
 ifdef MOZ_PROFILE_GENERATE
 MODULE_OPTIMIZE_FLAGS = -O0
 else
 MODULE_OPTIMIZE_FLAGS = -O2 -ip
 #XXX: do we want different INTERP_OPTIMIZER flags here?
--- a/js/src/shell/Makefile.in
+++ b/js/src/shell/Makefile.in
@@ -51,16 +51,17 @@ DEFINES         += -DEXPORT_JS_API
 
 LIBS      = $(NSPR_LIBS) $(EDITLINE_LIBS) $(DEPTH)/$(LIB_PREFIX)js_static.$(LIB_SUFFIX)
 
 LOCAL_INCLUDES += -I$(topsrcdir) -I..
 
 ifdef _MSC_VER
 ifdef WINCE
 WIN32_EXE_LDFLAGS += -ENTRY:mainACRTStartup
+EXTRA_LIBS += $(JEMALLOC_LIBS)
 endif
 endif
 
 include $(topsrcdir)/config/rules.mk
 
 ifdef MOZ_SHARK
 CFLAGS += -F/System/Library/PrivateFrameworks
 CXXFLAGS += -F/System/Library/PrivateFrameworks
--- a/memory/jemalloc/Makefile.in
+++ b/memory/jemalloc/Makefile.in
@@ -44,16 +44,20 @@ VPATH		= @srcdir@
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= jemalloc
 
 # jemalloc.c properly uses 'static', so don't burden it with manually exposing
 # symbols.
 VISIBILITY_FLAGS=
 
+ifeq (WINCE,$(OS_TARGET))
+DEFINES+= -DMOZCE_SHUNT_H
+endif
+
 ifeq (WINNT,$(OS_TARGET))
 # Building the CRT from source
 CRT_OBJ_DIR = $(CURDIR)/crtsrc
 MOZ_CRT_DLL_NAME = mozcrt19
 MOZ_CRT_STATIC_LIBS = libcmt libcpmt
 MOZ_CRT_DLL = $(CRT_OBJ_DIR)/build/intel/$(MOZ_CRT_DLL_NAME).dll
 MOZ_CRT_IMPORT_LIB = $(CRT_OBJ_DIR)/build/intel/$(MOZ_CRT_DLL_NAME).lib
 
@@ -110,18 +114,19 @@ LIBRARY_NAME	= jemalloc
 # init function is used on that platform.
 ifeq ($(OS_ARCH),Darwin)
 FORCE_SHARED_LIB= 1
 else
 DIST_INSTALL = 1
 FORCE_STATIC_LIB= 1
 endif
 
-EXPORTS = jemalloc.h
-CSRCS   = jemalloc.c
+CSRCS		= \
+		jemalloc.c \
+		$(NULL)
 
 #XXX: PGO on Linux causes problems here
 # See bug 419470
 NO_PROFILE_GUIDED_OPTIMIZE = 1
 endif
 
 include $(topsrcdir)/config/rules.mk
 
--- a/memory/jemalloc/jemalloc.c
+++ b/memory/jemalloc/jemalloc.c
@@ -202,17 +202,16 @@
 #include <string.h>
 
 #ifdef MOZ_MEMORY_WINDOWS
 #ifndef MOZ_MEMORY_WINCE
 #include <cruntime.h>
 #include <internal.h>
 #include <io.h>
 #else
-#include <cmnintrin.h>
 #include <crtdefs.h>
 #define SIZE_MAX UINT_MAX
 #endif
 #include <windows.h>
 
 #pragma warning( disable: 4267 4996 4146 )
 
 #define	false FALSE
@@ -258,27 +257,48 @@ getenv(const char *name)
 {
 
 	if (GetEnvironmentVariableA(name, (LPSTR)&mozillaMallocOptionsBuf,
 		    sizeof(mozillaMallocOptionsBuf)) > 0)
 		return (mozillaMallocOptionsBuf);
 
 	return (NULL);
 }
-
-#else /* WIN CE */
-
+#else
+
+static void abort() { 
+	DebugBreak();  
+        exit(-3); 
+}
+
+static int errno = 0;
 #define ENOMEM          12
 #define EINVAL          22
 
-static __forceinline int
+static char *
+getenv(const char *name)
+{
+	return (NULL);
+}
+
+static int
 ffs(int x)
 {
-
-	return 32 - _CountLeadingZeros((-x) & x);
+        int ret;
+
+        if (x == 0)
+                return 0;
+        ret = 2;
+        if ((x & 0x0000ffff) == 0) { ret += 16; x >>= 16;}
+        if ((x & 0x000000ff) == 0) { ret += 8;  x >>= 8;}
+        if ((x & 0x0000000f) == 0) { ret += 4;  x >>= 4;}
+        if ((x & 0x00000003) == 0) { ret += 2;  x >>= 2;}
+        ret -= (x & 1);
+
+        return (ret);
 }
 #endif
 
 typedef unsigned char uint8_t;
 typedef unsigned uint32_t;
 typedef unsigned long long uint64_t;
 typedef unsigned long long uintmax_t;
 typedef long ssize_t;
@@ -363,32 +383,26 @@ typedef long ssize_t;
 #ifndef MOZ_MEMORY
 #include "un-namespace.h"
 #endif
 
 #endif
 
 #include "jemalloc.h"
 
-#ifdef _MSC_VER
-#define bool unsigned char
-#else
-#include <stdbool.h>
-#endif
-
 #ifdef MOZ_MEMORY_DARWIN
 static const bool __isthreaded = true;
 #endif
 
 #if defined(MOZ_MEMORY_SOLARIS) && defined(MAP_ALIGN) && !defined(JEMALLOC_NEVER_USES_MAP_ALIGN)
 #define JEMALLOC_USES_MAP_ALIGN	 /* Required on Solaris 10. Might improve performance elsewhere. */
 #endif
 
-#if defined(MOZ_MEMORY_WINCE) && !defined(MOZ_MEMORY_WINCE6)
-#define JEMALLOC_USES_MAP_ALIGN	 /* Required for Windows CE < 6 */
+#if defined(MOZ_MEMORY_WINCE)
+#define JEMALLOC_USES_MAP_ALIGN	 /* Required for Windows CE */
 #endif
 
 #define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
 
 #include "qr.h"
 #include "ql.h"
 #ifdef MOZ_MEMORY_WINDOWS
    /* MSVC++ does not support C99 variable-length arrays. */
@@ -480,17 +494,17 @@ static const bool __isthreaded = true;
 #    undef MALLOC_BALANCE
 #  endif
 #endif
 
 /*
  * Size and alignment of memory chunks that are allocated by the OS's virtual
  * memory system.
  */
-#if defined(MOZ_MEMORY_WINCE) && !defined(MOZ_MEMORY_WINCE6)
+#ifdef MOZ_MEMORY_WINCE
 #define	CHUNK_2POW_DEFAULT	21
 #else
 #define	CHUNK_2POW_DEFAULT	20
 #endif
 /* Maximum number of dirty pages per arena. */
 #define	DIRTY_MAX_DEFAULT	(1U << 10)
 
 /* Default reserve chunks. */
@@ -2191,35 +2205,35 @@ pages_map_align(size_t size, int pfd, si
 	return (ret);
 }
 #endif
 
 static void *
 pages_map(void *addr, size_t size, int pfd)
 {
 	void *ret = NULL;
-#if defined(MOZ_MEMORY_WINCE) && !defined(MOZ_MEMORY_WINCE6)
+#if defined(MOZ_MEMORY_WINCE)
 	void *va_ret;
 	assert(addr == NULL);
 	va_ret = VirtualAlloc(addr, size, MEM_RESERVE, PAGE_NOACCESS);
 	if (va_ret)
 		ret = VirtualAlloc(va_ret, size, MEM_COMMIT, PAGE_READWRITE);
 	assert(va_ret == ret);
-#else
+#elif defined(MOZ_MEMORY_WINDOWS)
 	ret = VirtualAlloc(addr, size, MEM_COMMIT | MEM_RESERVE,
 	    PAGE_READWRITE);
 #endif
 	return (ret);
 }
 
 static void
 pages_unmap(void *addr, size_t size)
 {
 	if (VirtualFree(addr, 0, MEM_RELEASE) == 0) {
-#if defined(MOZ_MEMORY_WINCE) && !defined(MOZ_MEMORY_WINCE6)
+#ifdef MOZ_MEMORY_WINCE
 		if (GetLastError() == ERROR_INVALID_PARAMETER) {
 			MEMORY_BASIC_INFORMATION info;
 			VirtualQuery(addr, &info, sizeof(info));
 			if (VirtualFree(info.AllocationBase, 0, MEM_RELEASE))
 				return;
 		}
 #endif
 		_malloc_message(_getprogname(),
@@ -6123,17 +6137,17 @@ malloc_shutdown()
 #ifdef MOZ_MEMORY_DARWIN
 #  define ZONE_INLINE	inline
 #else
 #  define ZONE_INLINE
 #endif
 
 /* Mangle standard interfaces on Darwin and Windows CE, 
    in order to avoid linking problems. */
-#if defined(MOZ_MEMORY_DARWIN)
+#if defined(MOZ_MEMORY_DARWIN) || defined(MOZ_MEMORY_WINCE)
 #define	malloc(a)	moz_malloc(a)
 #define	valloc(a)	moz_valloc(a)
 #define	calloc(a, b)	moz_calloc(a, b)
 #define	realloc(a, b)	moz_realloc(a, b)
 #define	free(a)		moz_free(a)
 #endif
 
 ZONE_INLINE
--- a/memory/jemalloc/jemalloc.h
+++ b/memory/jemalloc/jemalloc.h
@@ -1,58 +1,15 @@
-/* -*- Mode: C; tab-width: 8; c-basic-offset: 8 -*- */
-/* vim:set softtabstop=8 shiftwidth=8: */
-/*-
- * Copyright (C) 2006-2008 Jason Evans <jasone@FreeBSD.org>.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice(s), this list of conditions and the following disclaimer as
- *    the first lines of this file unmodified other than the possible
- *    addition of one or more copyright notices.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice(s), this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef _JEMALLOC_H_
-#define _JEMALLOC_H_
-
-/* grab size_t */
-#ifdef _MSC_VER
-#include <crtdefs.h>
+#ifndef MOZ_MEMORY_WINDOWS
+#  include <stdbool.h>
 #else
-#include <stddef.h>
-#endif
-
-#ifndef __cplusplus
-/* define bool for non-C++ in MSVC; it's an 8-bit type */
-#ifdef _MSC_VER
-#define bool unsigned char
-#else
-#include <stdbool.h>
-#endif
-#else
-extern "C" {
+#  include <windows.h>
+#  ifndef bool
+#    define bool BOOL
+#  endif
 #endif
 
 extern const char	*_malloc_options;
 
 /*
  * jemalloc_stats() is not a stable interface.  When using jemalloc_stats_t, be
  * sure that the compiled results of jemalloc.c are in sync with this header
  * file.
@@ -213,18 +170,8 @@ size_t	reserve_min_get(void);
  * Set the minimum acceptable reserve size.
  *
  * min: Reserve threshold.  This value may be internally rounded up.
  * ret: False if the reserve was successfully resized; true otherwise.  Note
  *      that failure to resize the reserve also results in a RESERVE_CND_LOW
  *      condition.
  */
 bool	reserve_min_set(size_t min);
-
-#ifdef __cplusplus
-} /* extern "C" */
-#endif
-
-#ifndef __cplusplus
-#undef bool
-#endif
-
-#endif /* _JEMALLOC_H_ */