about summary refs log tree commit diff
path: root/malloc/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'malloc/malloc.c')
-rw-r--r--malloc/malloc.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index b3353bd0a3..4821debcbf 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -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));