Replace malloc force_reg by atomic_forced_read.

This commit is contained in:
Ondřej Bílka 2013-12-09 17:14:12 +01:00
parent caecf2a0ce
commit f3eeb3fc56
4 changed files with 19 additions and 17 deletions

View File

@ -1,3 +1,12 @@
2013-12-09 Ondřej Bílka <neleai@seznam.cz>
* malloc/malloc.c: (force_reg): Remove.
(__malloc_assert, __libc_malloc, __libc_free, __libc_realloc,
_mid_memalign, __libc_calloc, sysmalloc, systrim): Replace
force_reg by atomic_forced_read.
* malloc/arena.c (ptmalloc_init): Likewise.
* malloc/hooks.c (top_check): Likewise.
2013-12-09 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* sysdeps/powerpc/fpu/libm-test-ulps: Update.

View File

@ -457,7 +457,7 @@ ptmalloc_init (void)
if (check_action != 0)
__malloc_check_init();
}
void (*hook) (void) = force_reg (__malloc_initialize_hook);
void (*hook) (void) = atomic_forced_read (__malloc_initialize_hook);
if (hook != NULL)
(*hook)();
__malloc_initialized = 1;

View File

@ -236,7 +236,7 @@ top_check(void)
return -1;
}
/* Call the `morecore' hook if necessary. */
void (*hook) (void) = force_reg (__after_morecore_hook);
void (*hook) (void) = atomic_forced_read (__after_morecore_hook);
if (hook)
(*hook) ();
main_arena.system_mem = (new_brk - mp_.sbrk_base) + sbrk_size;

View File

@ -406,13 +406,6 @@ void *(*__morecore)(ptrdiff_t) = __default_morecore;
#include <string.h>
/* Force a value to be in a register and stop the compiler referring
to the source (mostly memory location) again. */
#define force_reg(val) \
({ __typeof (val) _v; asm ("" : "=r" (_v) : "0" (val)); _v; })
/*
MORECORE-related declarations. By default, rely on sbrk
*/
@ -2448,7 +2441,7 @@ static void* sysmalloc(INTERNAL_SIZE_T nb, mstate av)
if (brk != (char*)(MORECORE_FAILURE)) {
/* Call the `morecore' hook if necessary. */
void (*hook) (void) = force_reg (__after_morecore_hook);
void (*hook) (void) = atomic_forced_read (__after_morecore_hook);
if (__builtin_expect (hook != NULL, 0))
(*hook) ();
} else {
@ -2586,7 +2579,7 @@ static void* sysmalloc(INTERNAL_SIZE_T nb, mstate av)
snd_brk = (char*)(MORECORE(0));
} else {
/* Call the `morecore' hook if necessary. */
void (*hook) (void) = force_reg (__after_morecore_hook);
void (*hook) (void) = atomic_forced_read (__after_morecore_hook);
if (__builtin_expect (hook != NULL, 0))
(*hook) ();
}
@ -2740,7 +2733,7 @@ static int systrim(size_t pad, mstate av)
MORECORE(-extra);
/* Call the `morecore' hook if necessary. */
void (*hook) (void) = force_reg (__after_morecore_hook);
void (*hook) (void) = atomic_forced_read (__after_morecore_hook);
if (__builtin_expect (hook != NULL, 0))
(*hook) ();
new_brk = (char*)(MORECORE(0));
@ -2844,7 +2837,7 @@ __libc_malloc(size_t bytes)
void *victim;
void *(*hook) (size_t, const void *)
= force_reg (__malloc_hook);
= atomic_forced_read (__malloc_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(bytes, RETURN_ADDRESS (0));
@ -2876,7 +2869,7 @@ __libc_free(void* mem)
mchunkptr p; /* chunk corresponding to mem */
void (*hook) (void *, const void *)
= force_reg (__free_hook);
= atomic_forced_read (__free_hook);
if (__builtin_expect (hook != NULL, 0)) {
(*hook)(mem, RETURN_ADDRESS (0));
return;
@ -2917,7 +2910,7 @@ __libc_realloc(void* oldmem, size_t bytes)
void* newp; /* chunk to return */
void *(*hook) (void *, size_t, const void *) =
force_reg (__realloc_hook);
atomic_forced_read (__realloc_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(oldmem, bytes, RETURN_ADDRESS (0));
@ -3018,7 +3011,7 @@ _mid_memalign (size_t alignment, size_t bytes, void *address)
void *p;
void *(*hook) (size_t, size_t, const void *) =
force_reg (__memalign_hook);
atomic_forced_read (__memalign_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(alignment, bytes, address);
@ -3128,7 +3121,7 @@ __libc_calloc(size_t n, size_t elem_size)
}
void *(*hook) (size_t, const void *) =
force_reg (__malloc_hook);
atomic_forced_read (__malloc_hook);
if (__builtin_expect (hook != NULL, 0)) {
sz = bytes;
mem = (*hook)(sz, RETURN_ADDRESS (0));