Changeset 57 for trunk/malloc.c

Show
Ignore:
Timestamp:
04/30/10 21:31:37 (4 years ago)
Author:
wez
Message:

Apparently, the glibc malloc hooks are now deprecated due to thread safety
issues, so we simply eliminate the glibc specific code from our malloc
preload to resolve this issue.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/malloc.c

    r55 r57  
    4242#include "misc.h" 
    4343 
    44 #ifdef __GLIBC__ 
    45 # include <malloc.h> 
    46 #endif 
    47  
    4844/* 
    4945 * malloc_data_t is an 8-byte structure which is located "before" the pointer 
     
    6359} malloc_data_t; 
    6460 
    65 #ifdef __GLIBC__ 
    66 static void *umem_malloc_hook(size_t size_arg, const void *caller) 
    67 #else 
    6861void * 
    6962malloc(size_t size_arg) 
    70 #endif 
    7163{ 
    7264#ifdef _LP64 
     
    129121} 
    130122 
    131 #ifndef __GLIBC__ 
    132123void * 
    133124calloc(size_t nelem, size_t elsize) 
     
    148139        return (retval); 
    149140} 
    150 #endif 
    151141 
    152142/* 
     
    157147 */ 
    158148 
    159 #ifdef __GLIBC__ 
    160 static void *umem_memalign_hook(size_t align, size_t size_arg, const void *caller) 
    161 #else 
    162149void * 
    163150memalign(size_t align, size_t size_arg) 
    164 #endif 
    165151{ 
    166152        size_t size; 
     
    241227} 
    242228 
    243 #ifndef __GLIBC__ 
    244229void * 
    245230valloc(size_t size) 
     
    247232        return (memalign(pagesize, size)); 
    248233} 
    249 #endif 
    250234 
    251235/* 
     
    393377} 
    394378 
    395 #ifdef __GLIBC__ 
    396 static void umem_free_hook(void *buf, const void *caller) 
    397 #else 
    398379void 
    399380free(void *buf) 
    400 #endif 
    401381{ 
    402382        if (buf == NULL) 
     
    409389} 
    410390 
    411 #ifdef __GLIBC__ 
    412 static void *umem_realloc_hook(void *buf_arg, size_t newsize, const void *caller) 
    413 #else 
    414391void * 
    415392realloc(void *buf_arg, size_t newsize) 
    416 #endif 
    417393{ 
    418394        size_t oldsize; 
     
    442418} 
    443419 
    444 #ifdef __GLIBC__ 
    445 static void __attribute__((constructor)) umem_malloc_init_hook(void) 
    446 { 
    447         if (__malloc_hook != umem_malloc_hook) { 
    448                 umem_startup(NULL, 0, 0, NULL, NULL); 
    449                 __malloc_hook = umem_malloc_hook; 
    450                 __free_hook = umem_free_hook; 
    451                 __realloc_hook = umem_realloc_hook; 
    452                 __memalign_hook = umem_memalign_hook; 
    453         } 
    454 } 
    455  
    456 void (*__malloc_initialize_hook)(void) = umem_malloc_init_hook; 
    457  
    458 #else 
    459420void __attribute__((constructor)) 
    460421__malloc_umem_init (void) 
     
    462423        umem_startup(NULL, 0, 0, NULL, NULL); 
    463424} 
    464 #endif 
    465  
     425