From: Ivan Maidanski Date: Sun, 25 Nov 2012 08:07:13 +0000 (+0400) Subject: Recognize REDIRECT_MALLOC_IN_HEADER macro X-Git-Tag: gc7_6_0~199^2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25d17297f9e258185e2f8ca29029ef3c89dba83d;p=gc Recognize REDIRECT_MALLOC_IN_HEADER macro * include/private/gcconfig.h: Do not issue error on REDIRECT_MALLOC and THREADS if REDIRECT_MALLOC_IN_HEADER defined. * malloc.c (malloc, calloc, strdup, strndup, free): Do not define if REDIRECT_MALLOC_IN_HEADER. * mallocx.c (realloc): Likewise. Conflicts: include/gc.h include/private/gcconfig.h malloc.c mallocx.c --- diff --git a/include/private/gcconfig.h b/include/private/gcconfig.h index 9dfcc064..79978f2e 100644 --- a/include/private/gcconfig.h +++ b/include/private/gcconfig.h @@ -2965,7 +2965,8 @@ # error "One of STACK_GROWS_UP and STACK_GROWS_DOWN should be defd." #endif -#if defined(REDIRECT_MALLOC) && defined(THREADS) && !defined(LINUX) +#if defined(REDIRECT_MALLOC) && defined(THREADS) && !defined(LINUX) \ + && !defined(REDIRECT_MALLOC_IN_HEADER) # error "REDIRECT_MALLOC with THREADS works at most on Linux." #endif diff --git a/malloc.c b/malloc.c index a4dd437f..3e086573 100644 --- a/malloc.c +++ b/malloc.c @@ -351,6 +351,7 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_uncollectable(size_t lb) /* but it is admittedly quite ugly. */ # define GC_debug_malloc_replacement(lb) GC_debug_malloc(lb, GC_DBG_EXTRAS) +#if !defined(REDIRECT_MALLOC_IN_HEADER) void * malloc(size_t lb) { /* It might help to manually inline the GC_malloc call here. */ @@ -464,6 +465,8 @@ void * calloc(size_t n, size_t lb) } #endif /* !strndup */ +#endif /* !REDIRECT_MALLOC_IN_HEADER */ + #undef GC_debug_malloc_replacement #endif /* REDIRECT_MALLOC */ @@ -574,7 +577,7 @@ GC_API void GC_CALL GC_free(void * p) # define REDIRECT_FREE GC_free #endif -#ifdef REDIRECT_FREE +#if defined(REDIRECT_FREE) && !defined(REDIRECT_MALLOC_IN_HEADER) void free(void * p) { # if defined(GC_LINUX_THREADS) && !defined(USE_PROC_FOR_LIBRARIES) diff --git a/mallocx.c b/mallocx.c index c851fcb9..d1928805 100644 --- a/mallocx.c +++ b/mallocx.c @@ -165,10 +165,12 @@ GC_API void * GC_CALL GC_realloc(void * p, size_t lb) # define GC_debug_realloc_replacement(p, lb) \ GC_debug_realloc(p, lb, GC_DBG_EXTRAS) -void * realloc(void * p, size_t lb) - { - return(REDIRECT_REALLOC(p, lb)); - } +# if !defined(REDIRECT_MALLOC_IN_HEADER) + void * realloc(void * p, size_t lb) + { + return(REDIRECT_REALLOC(p, lb)); + } +# endif # undef GC_debug_realloc_replacement # endif /* REDIRECT_REALLOC */