Backed out changeset 1eec75c27e2f

This commit is contained in:
Vladimir Vukicevic 2009-04-24 10:43:19 -07:00
Родитель 3611c48168
Коммит 208e4266b7
12 изменённых файлов: 168 добавлений и 170 удалений

Просмотреть файл

@ -72,14 +72,9 @@ 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 \
@ -91,7 +86,3 @@ CPPSRCS = \
DEFINES += -DMOZCE_SHUNT_EXPORTS
include $(topsrcdir)/config/rules.mk
mozce_shunt.def: mozce_shunt.def.in
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $^ > $@

Просмотреть файл

@ -35,25 +35,18 @@
*
* ***** 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
#define _NEW_
void * operator new(size_t _Size);
void operator delete(void * ptr);
@ -63,6 +56,36 @@ 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
@ -72,21 +95,13 @@ extern "C" {
#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
@ -110,37 +125,37 @@ 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()
*/
@ -149,12 +164,12 @@ int _unlink(const char *filename );
/* 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

Просмотреть файл

@ -48,24 +48,11 @@
#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
@ -75,14 +62,15 @@
#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

Просмотреть файл

@ -42,27 +42,27 @@
#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;
@ -70,23 +70,38 @@ _strndup(const char *src, size_t len) {
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

Просмотреть файл

@ -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

Просмотреть файл

@ -158,7 +158,7 @@ MOZ_UNICHARUTIL_LIBS = $(LIBXUL_DIST)/lib/$(LIB_PREFIX)unicharutil_s.$(LIB_SUFFI
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

Просмотреть файл

@ -268,7 +268,7 @@ case "$target" in
_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"
@ -6637,9 +6637,6 @@ if test "$MOZ_MEMORY"; then
*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}])

Просмотреть файл

@ -63,6 +63,10 @@ GRE_MODULE = 1
LIBS = $(NSPR_LIBS)
ifdef WINCE
EXTRA_LIBS += $(JEMALLOC_LIBS)
endif
ifdef GNU_CXX
ifdef INTEL_CXX
# icc gets special optimize flags

Просмотреть файл

@ -56,6 +56,7 @@ LOCAL_INCLUDES += -I$(topsrcdir) -I..
ifdef _MSC_VER
ifdef WINCE
WIN32_EXE_LDFLAGS += -ENTRY:mainACRTStartup
EXTRA_LIBS += $(JEMALLOC_LIBS)
endif
endif

Просмотреть файл

@ -49,6 +49,10 @@ MODULE = jemalloc
# 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
@ -115,8 +119,9 @@ 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

Просмотреть файл

@ -207,7 +207,6 @@
#include <internal.h>
#include <io.h>
#else
#include <cmnintrin.h>
#include <crtdefs.h>
#define SIZE_MAX UINT_MAX
#endif
@ -263,17 +262,38 @@ getenv(const char *name)
return (NULL);
}
#else
#else /* WIN CE */
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)
{
int ret;
return 32 - _CountLeadingZeros((-x) & x);
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
@ -368,12 +388,6 @@ __FBSDID("$FreeBSD: head/lib/libc/stdlib/malloc.c 180599 2008-07-18 19:35:44Z ja
#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
@ -382,8 +396,8 @@ static const bool __isthreaded = true;
#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))
@ -485,7 +499,7 @@ static const bool __isthreaded = true;
* 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
@ -2196,14 +2210,14 @@ 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
@ -2214,7 +2228,7 @@ 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));
@ -6128,7 +6142,7 @@ malloc_shutdown()
/* 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)

Просмотреть файл

@ -1,53 +1,10 @@
/* -*- 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;
@ -218,13 +175,3 @@ size_t reserve_min_get(void);
* condition.
*/
bool reserve_min_set(size_t min);
#ifdef __cplusplus
} /* extern "C" */
#endif
#ifndef __cplusplus
#undef bool
#endif
#endif /* _JEMALLOC_H_ */