Added macro to check if the malloc hooks should be volatile.

The malloc hooks changed in glibc 2.14, and are now volatile.
Note also that the malloc hooks are now marked as deprecated.

Ref:
http://sourceware.org/bugzilla/show_bug.cgi?id=11781
a33c44639a
cf6bbbd701
7d17596c19

Change-Id: Iab80bea7a7f5d72ac96cacd75468eefbfd9b8326
Reviewed-on: http://codereview.qt.nokia.com/1497
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
This commit is contained in:
Christian Strømme 2011-07-12 09:09:53 +02:00 committed by Qt by Nokia
parent 82454b6014
commit f8ad76417d

View File

@ -64,6 +64,13 @@ static void my_terminate_handler()
#ifdef __GLIBC__
/* Use glibc's memory allocation hooks */
// From glibc 2.14, the malloc hook variables are declared volatile.
// Note: The malloc hook implementation is marked as deprecated.
#if !defined(__MALLOC_HOOK_VOLATILE)
# define __MALLOC_HOOK_VOLATILE
#endif
/* our hooks */
static void *my_malloc_hook(size_t, const void *);
static void *my_realloc_hook(void *, size_t, const void *);
@ -71,16 +78,17 @@ static void *my_memalign_hook(size_t, size_t, const void *);
static void my_free_hook(void *, const void *);
/* original hooks. */
static void *(*old_malloc_hook)(size_t, const void *);
static void *(*old_realloc_hook)(void *, size_t, const void *);
static void *(*old_memalign_hook)(size_t, size_t, const void *);
static void (*old_free_hook)(void *, const void *);
static void *(*__MALLOC_HOOK_VOLATILE old_malloc_hook)(size_t, const void *);
static void *(*__MALLOC_HOOK_VOLATILE old_realloc_hook)(void *, size_t, const void *);
static void *(*__MALLOC_HOOK_VOLATILE old_memalign_hook)(size_t, size_t, const void *);
static void (*__MALLOC_HOOK_VOLATILE old_free_hook)(void *, const void *);
/* initializer function */
static void my_init_hook();
/* Override initialising hook from the C library. */
void (*__malloc_initialize_hook) (void) = my_init_hook;
void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) (void) = my_init_hook;
static void disableHooks()
{