about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--malloc/arena.c2
-rw-r--r--malloc/hooks.c2
-rw-r--r--malloc/malloc.c23
4 files changed, 19 insertions, 17 deletions
diff --git a/ChangeLog b/ChangeLog
index a6ba57c233..e04ee34711 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/malloc/arena.c b/malloc/arena.c
index d81ed0d680..4e83fdba3d 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -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;
diff --git a/malloc/hooks.c b/malloc/hooks.c
index 89fbd3c948..fdacdeff0b 100644
--- a/malloc/hooks.c
+++ b/malloc/hooks.c
@@ -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;
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));