]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
malloc: Manual part of conversion to __libc_lock
authorFlorian Weimer <fweimer@redhat.com>
Wed, 21 Sep 2016 14:28:08 +0000 (16:28 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 21 Sep 2016 14:28:08 +0000 (16:28 +0200)
This removes the old mutex_t-related definitions from malloc-machine.h,
too.

ChangeLog
malloc/arena.c
malloc/malloc.c
sysdeps/mach/hurd/malloc-machine.h
sysdeps/nptl/malloc-machine.h

index 5ee24033ab9222304bb92031fd11ed2781885374..b6f97dcca4f689b6427e4a972969d404f94e4f64 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2016-09-21  Florian Weimer  <fweimer@redhat.com>
+
+       malloc: Use __libc_lock wrappers.
+       * malloc/arena.c (list_lock, free_list_lock): Define using
+       __libc_lock_define_initialized.
+       (arena_lock): Adjust formatting.
+       * malloc/malloc.c (struct malloc_state): Define mutex using
+       __libc_lock_define.
+       * sysdeps/generic/malloc-machine.h (mutex_t, mutex_init)
+       (mutex_lock, mutex_trylock, mutex_unlock): Remove.
+       * sysdeps/mach/hurd/malloc-machine.h (mutex_t, mutex_lock)
+       (mutex_unlock, mutex_trylock): Remove.
+       (__pthread_initialize): Remove unused macro.
+       * sysdeps/nptl/malloc-machine.h (mutex_t, mutex_lock)
+       (mutex_unlock, mutex_trylock): Remove.
+
 2016-09-21  Florian Weimer  <fweimer@redhat.com>
 
        [BZ #20592]
index 922ae49e2f5e16ec30ddfc1fd6b719e910925a11..976048370a47c57a94820aaa0f32925ca3f4a1ea 100644 (file)
@@ -73,7 +73,7 @@ static __thread mstate thread_arena attribute_tls_model_ie;
    members of struct malloc_state objects.  No other locks must be
    acquired after free_list_lock has been acquired.  */
 
-static mutex_t free_list_lock = _LIBC_LOCK_INITIALIZER;
+__libc_lock_define_initialized (static, free_list_lock);
 static size_t narenas = 1;
 static mstate free_list;
 
@@ -89,7 +89,7 @@ static mstate free_list;
    acquired, no arena lock must have been acquired, but it is
    permitted to acquire arena locks subsequently, while list_lock is
    acquired.  */
-static mutex_t list_lock = _LIBC_LOCK_INITIALIZER;
+__libc_lock_define_initialized (static, list_lock);
 
 /* Already initialized? */
 int __malloc_initialized = -1;
@@ -112,7 +112,7 @@ int __malloc_initialized = -1;
 
 #define arena_lock(ptr, size) do {                                           \
       if (ptr && !arena_is_corrupt (ptr))                                    \
-        __libc_lock_lock (ptr->mutex);                               \
+        __libc_lock_lock (ptr->mutex);                                       \
       else                                                                   \
         ptr = arena_get2 ((size), NULL);                                     \
   } while (0)
index 20acb73c3ee28cbf288532308c22d014b6f036d6..ef04360b918bceca424482c6db03cc5ec90c3e00 100644 (file)
@@ -1616,7 +1616,7 @@ typedef struct malloc_chunk *mfastbinptr;
 struct malloc_state
 {
   /* Serialize access.  */
-  mutex_t mutex;
+  __libc_lock_define (, mutex);
 
   /* Flags (formerly in max_fast).  */
   int flags;
index f778b0d0251a293fd28700a5ef056ea26ce5b793..87a5d19bcb5ab23d819f5c5fec8eed07789d5f93 100644 (file)
 #include <atomic.h>
 #include <libc-lock.h>
 
-/* Assume hurd, with cthreads */
-
-/* Cthreads `mutex_t' is a pointer to a mutex, and malloc wants just the
-   mutex itself.  */
-#undef mutex_t
-#define mutex_t struct mutex
-
-#undef mutex_init
-#define mutex_init(m) ({ __mutex_init(m); 0; })
-
-#undef mutex_lock
-#define mutex_lock(m) ({ __mutex_lock(m); 0; })
-
-#undef mutex_unlock
-#define mutex_unlock(m) ({ __mutex_unlock(m); 0; })
-
-#define mutex_trylock(m) (!__mutex_trylock(m))
-
-/* No we're *not* using pthreads.  */
-#define __pthread_initialize ((void (*)(void))0)
-
 /* madvise is a stub on Hurd, so don't bother calling it.  */
 
 #include <sys/mman.h>
index 1a2af6f9875033a2278c9af0b1cb1f8b766a8da7..b20c423f60faf43fed0dd5c56d8a0fca2fa19304 100644 (file)
 
 #include <atomic.h>
 #include <libc-lock.h>
-
-__libc_lock_define (typedef, mutex_t)
-
-#define mutex_init(m)          __libc_lock_init (*(m))
-#define mutex_lock(m)          __libc_lock_lock (*(m))
-#define mutex_trylock(m)       __libc_lock_trylock (*(m))
-#define mutex_unlock(m)                __libc_lock_unlock (*(m))
-
 #include <sysdeps/generic/malloc-machine.h>
 
 #endif /* !defined(_MALLOC_MACHINE_H) */