+2009-04-16 Ulrich Drepper <drepper@redhat.com>
+
+ [BZ #9957]
+ * malloc/malloc.c (force_reg): Define.
+ (sYSMALLOc): Load hook variable into variable
+ before test and force into register.
+ (sYSTRIm): Likewise.
+ (public_mALLOc): Force hook value into register.
+ (public_fREe): Likewise.
+ (public_rEALLOc): Likewise.
+ (public_mEMALIGn): Likewise.
+ (public_vALLOc): Likewise.
+ (public_pVALLOc): Likewise.
+ (public_cALLOc): Likewise.
+ (__posix_memalign): Likewise.
+ * malloc/arena.c (ptmalloc_init): Load hook variable into variable
+ before test and force into register.
+ * malloc/hooks.c (top_check): Likewise.
+ (public_s_ET_STATe): Pretty printing.
+
+ * resolv/res_send.c (send_dg): Don't just ignore the result we got
+ in case we only receive one reply in single-request mode.
+
2009-04-16 Jakub Jelinek <jakub@redhat.com>
* elf/dl-open.c (_dl_open): Bump GL(dl_nns) to 1 if no libraries
#endif
#endif
+
+/* 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; })
+
+
/*
MALLOC_FAILURE_ACTION is the action to take before "return 0" when
malloc fails to be able to return memory, either because memory is
if (brk != (char*)(MORECORE_FAILURE)) {
/* Call the `morecore' hook if necessary. */
- if (__builtin_expect (__after_morecore_hook != NULL, 0))
- (*__after_morecore_hook) ();
+ void (*hook) (void) = force_reg (__after_morecore_hook);
+ if (__builtin_expect (hook != NULL, 0))
+ (*hook) ();
} else {
/*
If have mmap, try using it as a backup when MORECORE fails or
if (snd_brk == (char*)(MORECORE_FAILURE)) {
correction = 0;
snd_brk = (char*)(MORECORE(0));
- } else
+ } else {
/* Call the `morecore' hook if necessary. */
- if (__builtin_expect (__after_morecore_hook != NULL, 0))
- (*__after_morecore_hook) ();
+ void (*hook) (void) = force_reg (__after_morecore_hook);
+ if (__builtin_expect (hook != NULL, 0))
+ (*hook) ();
+ }
}
/* handle non-contiguous cases */
MORECORE(-extra);
/* Call the `morecore' hook if necessary. */
- if (__builtin_expect (__after_morecore_hook != NULL, 0))
- (*__after_morecore_hook) ();
+ void (*hook) (void) = force_reg (__after_morecore_hook);
+ if (__builtin_expect (hook != NULL, 0))
+ (*hook) ();
new_brk = (char*)(MORECORE(0));
if (new_brk != (char*)MORECORE_FAILURE) {
mstate ar_ptr;
Void_t *victim;
- __malloc_ptr_t (*hook) (size_t, __const __malloc_ptr_t) = __malloc_hook;
+ __malloc_ptr_t (*hook) (size_t, __const __malloc_ptr_t)
+ = force_reg (__malloc_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(bytes, RETURN_ADDRESS (0));
mstate ar_ptr;
mchunkptr p; /* chunk corresponding to mem */
- void (*hook) (__malloc_ptr_t, __const __malloc_ptr_t) = __free_hook;
+ void (*hook) (__malloc_ptr_t, __const __malloc_ptr_t)
+ = force_reg (__free_hook);
if (__builtin_expect (hook != NULL, 0)) {
(*hook)(mem, RETURN_ADDRESS (0));
return;
Void_t* newp; /* chunk to return */
__malloc_ptr_t (*hook) (__malloc_ptr_t, size_t, __const __malloc_ptr_t) =
- __realloc_hook;
+ force_reg (__realloc_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(oldmem, bytes, RETURN_ADDRESS (0));
__malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t,
__const __malloc_ptr_t)) =
- __memalign_hook;
+ force_reg (__memalign_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(alignment, bytes, RETURN_ADDRESS (0));
__malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t,
__const __malloc_ptr_t)) =
- __memalign_hook;
+ force_reg (__memalign_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(pagesz, bytes, RETURN_ADDRESS (0));
__malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t,
__const __malloc_ptr_t)) =
- __memalign_hook;
+ force_reg (__memalign_hook);
if (__builtin_expect (hook != NULL, 0))
return (*hook)(pagesz, rounded_bytes, RETURN_ADDRESS (0));
unsigned long clearsize;
unsigned long nclears;
INTERNAL_SIZE_T* d;
- __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, __const __malloc_ptr_t)) =
- __malloc_hook;
/* size_t is unsigned so the behavior on overflow is defined. */
bytes = n * elem_size;
}
}
+ __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, __const __malloc_ptr_t)) =
+ force_reg (__malloc_hook);
if (__builtin_expect (hook != NULL, 0)) {
sz = bytes;
mem = (*hook)(sz, RETURN_ADDRESS (0));
__posix_memalign (void **memptr, size_t alignment, size_t size)
{
void *mem;
- __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t,
- __const __malloc_ptr_t)) =
- __memalign_hook;
/* Test whether the SIZE argument is valid. It must be a power of
two multiple of sizeof (void *). */
/* Call the hook here, so that caller is posix_memalign's caller
and not posix_memalign itself. */
+ __malloc_ptr_t (*hook) __MALLOC_PMT ((size_t, size_t,
+ __const __malloc_ptr_t)) =
+ force_reg (__memalign_hook);
if (__builtin_expect (hook != NULL, 0))
mem = (*hook)(alignment, size, RETURN_ADDRESS (0));
else