Replace MUTEX_INITIALIZER with _LIBC_LOCK_INITIALIZER in generic code
Commit Message
Samuel Thibault, on Sat 20 Aug 2016 16:36:10 +0200, wrote:
> And anyway, either malloc should be made to just use libc-lock or lll
> explicitly, or the malloc-machine.h layer should be providing a complete
> interface and users shouldn't be assuming anything about it.
Put another way, I'd tend to commit this.
Samuel
commit 0f0af158aabda65027634a369f4ce25aa0f20c1a
Author: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Sat Aug 20 16:46:59 2016 +0200
malloc: Restore using MUTEX_INITIALIZER
* malloc/malloc.c (main_arena): Use MUTEX_INITIALIZER instead of
_LIBC_LOCK_INITIALIZER.
* sysdeps/nptl/malloc-machine.h (MUTEX_INITIALIZER): Define.
* sysdeps/mach/hurd/malloc-machine.h (MUTEX_INITIALIZER): Comment
about macro definition coming from cthreads.h.
Comments
On 08/20/2016 04:48 PM, Samuel Thibault wrote:
> + * malloc/malloc.c (main_arena): Use MUTEX_INITIALIZER instead of
> + _LIBC_LOCK_INITIALIZER.
No, you need to define _LIBC_LOCK_INITIALIZER in terms of
MUTEX_INITIALIZER. If this is not possible, you need to select a lock
which is compatible with the libc_lock infrastructure for the malloc mutex.
Florian
@@ -1,3 +1,11 @@
+2016-08-20 Samuel Thibault <samuel.thibault@ens-lyon.org>
+
+ * malloc/malloc.c (main_arena): Use MUTEX_INITIALIZER instead of
+ _LIBC_LOCK_INITIALIZER.
+ * sysdeps/nptl/malloc-machine.h (MUTEX_INITIALIZER): Define.
+ * sysdeps/mach/hurd/malloc-machine.h (MUTEX_INITIALIZER): Comment
+ about macro definition coming from cthreads.h.
+
2016-08-16 Joseph Myers <joseph@codesourcery.com>
* soft-fp/extended.h [_FP_W_TYPE_SIZE < 64] (FP_UNPACK_RAW_E):
@@ -1687,7 +1687,7 @@ struct malloc_par
static struct malloc_state main_arena =
{
- .mutex = _LIBC_LOCK_INITIALIZER,
+ .mutex = MUTEX_INITIALIZER,
.next = &main_arena,
.attached_threads = 1
};
@@ -41,6 +41,8 @@
#define mutex_trylock(m) (!__mutex_trylock(m))
+/* MUTEX_INITIALIZER already defined by cthreads.h. */
+
/* No we're *not* using pthreads. */
#define __pthread_initialize ((void (*)(void))0)
@@ -29,6 +29,7 @@ __libc_lock_define (typedef, mutex_t)
#define mutex_lock(m) __libc_lock_lock (*(m))
#define mutex_trylock(m) __libc_lock_trylock (*(m))
#define mutex_unlock(m) __libc_lock_unlock (*(m))
+#define MUTEX_INITIALIZER LLL_LOCK_INITIALIZER
#include <sysdeps/generic/malloc-machine.h>