diff options
Diffstat (limited to 'tdecore/malloc')
-rw-r--r-- | tdecore/malloc/README | 8 | ||||
-rw-r--r-- | tdecore/malloc/configure.in.in | 14 | ||||
-rw-r--r-- | tdecore/malloc/malloc.c | 52 |
3 files changed, 37 insertions, 37 deletions
diff --git a/tdecore/malloc/README b/tdecore/malloc/README index 6a24a39db..eed2c00ba 100644 --- a/tdecore/malloc/README +++ b/tdecore/malloc/README @@ -7,7 +7,7 @@ FreeBSD's libc. There's a new configure switch, --enable-fast-malloc. By default it's turned off, disabling the system libc one and using this one. Using --enable-fast-malloc=full enables this malloc unconditionally, aiming for the maximum performance. By using only --enable-fast-malloc, -it's possible to select both malloc implementations at runtime. When $KDE_MALLOC is set to 0, +it's possible to select both malloc implementations at runtime. When $TDE_MALLOC is set to 0, the system libc malloc is used, otherwise this malloc is used. For now, the requirements are : @@ -31,11 +31,11 @@ changes (against malloc-2.7.0): #define USE_MEMCPY 0 #define MMAP_CLEARS 1 made all functions INLINE -added #ifdef KDE_MALLOC_DEBUG -> #define DEBUG +added #ifdef TDE_MALLOC_DEBUG -> #define DEBUG reordered all functions in order to avoid 'warning: `XYZ' declared inline after being called' especially moved the public_* ones at the end of the file commented out #including malloc.h -added #include <config.h> at the top and enclosed whole file in #ifdef KDE_MALLOC +added #include <config.h> at the top and enclosed whole file in #ifdef TDE_MALLOC taken posix_memalign() from glibc removed public icalloc(),icomalloc(),mtrim(),musable() (they don't exist everywhere anyway) enclosed the pthreads part by #if 0 and replaced it with spinlock from glibc CVS (in x86.h) @@ -45,7 +45,7 @@ static mutex_t spinlock = MUTEX_INITIALIZER; #define MALLOC_PREACTION lock( &spinlock ) #define MALLOC_POSTACTION unlock( &spinlock ) ---------- -public functions call either functions in this malloc or in libc, depending on $KDE_MALLOC +public functions call either functions in this malloc or in libc, depending on $TDE_MALLOC the kde_malloc_is_used hack diff --git a/tdecore/malloc/configure.in.in b/tdecore/malloc/configure.in.in index d669f8daa..e1a0ff528 100644 --- a/tdecore/malloc/configure.in.in +++ b/tdecore/malloc/configure.in.in @@ -1,4 +1,4 @@ -dnl --enable-fast-malloc - depends on $KDE_MALLOC +dnl --enable-fast-malloc - depends on $TDE_MALLOC dnl --disable-fast-malloc - disabled dnl --enable-fast-malloc=full - enabled always dnl @@ -38,7 +38,7 @@ if test "$kde_fast_malloc" != "no"; then dnl platforms for which there's a spinlock implementation case $target_cpu in i?86) - AC_DEFINE(KDE_MALLOC_X86, 1, [The platform is x86]) + AC_DEFINE(TDE_MALLOC_X86, 1, [The platform is x86]) ;; *) if test "$kde_fast_malloc" = "notgiven"; then @@ -63,7 +63,7 @@ dnl warn on untested platforms fi if test "$kde_fast_malloc" = "yes" -o "$kde_fast_malloc" = "notgiven" -o "$kde_fast_malloc" = "debug"; then -dnl $KDE_MALLOC needs glibc (__libc_malloc etc.) +dnl $TDE_MALLOC needs glibc (__libc_malloc etc.) AC_CACHE_CHECK([if the libc is glibc],kde_cv_libc_glibc, [AC_TRY_COMPILE( [#include<stdlib.h>], @@ -76,7 +76,7 @@ dnl $KDE_MALLOC needs glibc (__libc_malloc etc.) [kde_cv_libc_glibc=no]) ]) if test "$kde_cv_libc_glibc" = "yes"; then - AC_DEFINE(KDE_MALLOC_GLIBC, 1, [The libc used is glibc]) + AC_DEFINE(TDE_MALLOC_GLIBC, 1, [The libc used is glibc]) else if test "$kde_fast_malloc" = "notgiven"; then kde_fast_malloc=notgiven_full @@ -116,15 +116,15 @@ else fi if test "$kde_fast_malloc" != "no"; then - AC_DEFINE(KDE_MALLOC, 1, [Use own malloc implementation]) + AC_DEFINE(TDE_MALLOC, 1, [Use own malloc implementation]) fi if test "$kde_fast_malloc" = "debug" -o "$kde_fast_malloc" = "debug_full"; then - AC_DEFINE(KDE_MALLOC_DEBUG, 1, [Enable debugging in fast malloc]) + AC_DEFINE(TDE_MALLOC_DEBUG, 1, [Enable debugging in fast malloc]) fi if test "$kde_fast_malloc" = "full" -o "$kde_fast_malloc" = "debug_full"; then - AC_DEFINE(KDE_MALLOC_FULL, 1, [Make alloc as fast as possible]) + AC_DEFINE(TDE_MALLOC_FULL, 1, [Make alloc as fast as possible]) fi dnl -finline-limit=<large num> is needed for gcc3 in order to inline large functions diff --git a/tdecore/malloc/malloc.c b/tdecore/malloc/malloc.c index dba0fdef0..8f9fbb79b 100644 --- a/tdecore/malloc/malloc.c +++ b/tdecore/malloc/malloc.c @@ -7,9 +7,9 @@ */ int kde_malloc_is_used = 0; -#ifdef KDE_MALLOC +#ifdef TDE_MALLOC -#ifdef KDE_MALLOC_DEBUG +#ifdef TDE_MALLOC_DEBUG #define DEBUG #endif @@ -1559,7 +1559,7 @@ static pthread_mutex_t mALLOC_MUTEx = PTHREAD_MUTEX_INITIALIZER; #else -#ifdef KDE_MALLOC_X86 +#ifdef TDE_MALLOC_X86 #include "x86.h" #else #error Unknown spinlock implementation @@ -5475,9 +5475,9 @@ History: #ifdef USE_PUBLIC_MALLOC_WRAPPERS -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL -#ifdef KDE_MALLOC_GLIBC +#ifdef TDE_MALLOC_GLIBC #include "glibc.h" #else /* cannot use dlsym(RTLD_NEXT,...) here, it calls malloc()*/ @@ -5491,7 +5491,7 @@ extern char* getenv(const char*); static int malloc_type = 0; static void init_malloc_type(void) { - const char* const env = getenv( "KDE_MALLOC" ); + const char* const env = getenv( "TDE_MALLOC" ); if( env == NULL ) malloc_type = 1; else if( env[ 0 ] == '0' || env[ 0 ] == 'n' || env[ 0 ] == 'N' ) @@ -5503,7 +5503,7 @@ static void init_malloc_type(void) #endif Void_t* public_mALLOc(size_t bytes) { -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL if( malloc_type == 1 ) { #endif @@ -5515,7 +5515,7 @@ Void_t* public_mALLOc(size_t bytes) { if (MALLOC_POSTACTION != 0) { } return m; -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL } if( malloc_type == 2 ) return libc_malloc( bytes ); @@ -5525,7 +5525,7 @@ Void_t* public_mALLOc(size_t bytes) { } void public_fREe(Void_t* m) { -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL if( malloc_type == 1 ) { #endif @@ -5535,7 +5535,7 @@ void public_fREe(Void_t* m) { fREe(m); if (MALLOC_POSTACTION != 0) { } -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL return; } if( malloc_type == 2 ) @@ -5549,7 +5549,7 @@ void public_fREe(Void_t* m) { } Void_t* public_rEALLOc(Void_t* m, size_t bytes) { -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL if( malloc_type == 1 ) { #endif @@ -5560,7 +5560,7 @@ Void_t* public_rEALLOc(Void_t* m, size_t bytes) { if (MALLOC_POSTACTION != 0) { } return m; -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL } if( malloc_type == 2 ) return libc_realloc( m, bytes ); @@ -5570,7 +5570,7 @@ Void_t* public_rEALLOc(Void_t* m, size_t bytes) { } Void_t* public_mEMALIGn(size_t alignment, size_t bytes) { -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL if( malloc_type == 1 ) { #endif @@ -5582,7 +5582,7 @@ Void_t* public_mEMALIGn(size_t alignment, size_t bytes) { if (MALLOC_POSTACTION != 0) { } return m; -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL } if( malloc_type == 2 ) return libc_memalign( alignment, bytes ); @@ -5592,7 +5592,7 @@ Void_t* public_mEMALIGn(size_t alignment, size_t bytes) { } Void_t* public_vALLOc(size_t bytes) { -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL if( malloc_type == 1 ) { #endif @@ -5604,7 +5604,7 @@ Void_t* public_vALLOc(size_t bytes) { if (MALLOC_POSTACTION != 0) { } return m; -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL } if( malloc_type == 2 ) return libc_valloc( bytes ); @@ -5614,7 +5614,7 @@ Void_t* public_vALLOc(size_t bytes) { } Void_t* public_pVALLOc(size_t bytes) { -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL if( malloc_type == 1 ) { #endif @@ -5626,7 +5626,7 @@ Void_t* public_pVALLOc(size_t bytes) { if (MALLOC_POSTACTION != 0) { } return m; -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL } if( malloc_type == 2 ) return libc_pvalloc( bytes ); @@ -5636,7 +5636,7 @@ Void_t* public_pVALLOc(size_t bytes) { } Void_t* public_cALLOc(size_t n, size_t elem_size) { -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL if( malloc_type == 1 ) { #endif @@ -5648,7 +5648,7 @@ Void_t* public_cALLOc(size_t n, size_t elem_size) { if (MALLOC_POSTACTION != 0) { } return m; -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL } if( malloc_type == 2 ) return libc_calloc( n, elem_size ); @@ -5658,7 +5658,7 @@ Void_t* public_cALLOc(size_t n, size_t elem_size) { } void public_cFREe(Void_t* m) { -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL if( malloc_type == 1 ) { #endif @@ -5668,7 +5668,7 @@ void public_cFREe(Void_t* m) { cFREe(m); if (MALLOC_POSTACTION != 0) { } -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL return; } if( malloc_type == 2 ) @@ -5682,7 +5682,7 @@ void public_cFREe(Void_t* m) { } struct mallinfo public_mALLINFo() { -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL if( malloc_type == 1 ) { #endif @@ -5695,7 +5695,7 @@ struct mallinfo public_mALLINFo() { if (MALLOC_POSTACTION != 0) { } return m; -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL } if( malloc_type == 2 ) return libc_mallinfo(); @@ -5705,7 +5705,7 @@ struct mallinfo public_mALLINFo() { } int public_mALLOPt(int p, int v) { -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL if( malloc_type == 1 ) { #endif @@ -5717,7 +5717,7 @@ int public_mALLOPt(int p, int v) { if (MALLOC_POSTACTION != 0) { } return result; -#ifndef KDE_MALLOC_FULL +#ifndef TDE_MALLOC_FULL } if( malloc_type == 2 ) return libc_mallopt( p, v ); |