aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2015-11-24 16:37:15 +0100
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2017-01-27 13:16:28 -0200
commit4b31bd831ab205ff24ae3a2b8c4f8135c182c7d7 (patch)
tree11ef0f53fd62da5f9fed6dc447aa71effcc2788a
parent50992336ac40625c363e1514890f92774c65054a (diff)
downloadglibc-4b31bd831ab205ff24ae3a2b8c4f8135c182c7d7.zip
glibc-4b31bd831ab205ff24ae3a2b8c4f8135c182c7d7.tar.gz
glibc-4b31bd831ab205ff24ae3a2b8c4f8135c182c7d7.tar.bz2
Replace MUTEX_INITIALIZER with _LIBC_LOCK_INITIALIZER in generic code
* sysdeps/mach/hurd/libc-lock.h (_LIBC_LOCK_INITIALIZER): Define. (__libc_lock_define_initialized): Use it. * sysdeps/nptl/libc-lockP.h (_LIBC_LOCK_INITIALIZER): Define. * malloc/arena.c (list_lock): Use _LIBC_LOCK_INITIALIZER. * malloc/malloc.c (main_arena): Likewise. * sysdeps/generic/malloc-machine.h (MUTEX_INITIALIZER): Remove. * sysdeps/nptl/malloc-machine.h (MUTEX_INITIALIZER): Remove.
-rw-r--r--ChangeLog11
-rw-r--r--malloc/arena.c2
-rw-r--r--malloc/malloc.c2
-rw-r--r--sysdeps/generic/malloc-machine.h1
-rw-r--r--sysdeps/mach/hurd/bits/libc-lock.h3
-rw-r--r--sysdeps/nptl/bits/libc-lockP.h1
-rw-r--r--sysdeps/nptl/malloc-machine.h1
7 files changed, 16 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 75615ab..311d1f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2015-11-24 Florian Weimer <fweimer@redhat.com>
+
+ Replace MUTEX_INITIALIZER with _LIBC_LOCK_INITIALIZER in generic code.
+ * sysdeps/mach/hurd/libc-lock.h (_LIBC_LOCK_INITIALIZER): Define.
+ (__libc_lock_define_initialized): Use it.
+ * sysdeps/nptl/libc-lockP.h (_LIBC_LOCK_INITIALIZER): Define.
+ * malloc/arena.c (list_lock): Use _LIBC_LOCK_INITIALIZER.
+ * malloc/malloc.c (main_arena): Likewise.
+ * sysdeps/generic/malloc-machine.h (MUTEX_INITIALIZER): Remove.
+ * sysdeps/nptl/malloc-machine.h (MUTEX_INITIALIZER): Remove.
+
2015-10-28 Florian Weimer <fweimer@redhat.com>
[BZ# 19048]
diff --git a/malloc/arena.c b/malloc/arena.c
index dff9870..f8cf182 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -73,7 +73,7 @@ static __thread mstate thread_arena attribute_tls_model_ie;
objects. No other (malloc) locks must be taken while list_lock is
active, otherwise deadlocks may occur. */
-static mutex_t list_lock = MUTEX_INITIALIZER;
+static mutex_t list_lock = _LIBC_LOCK_INITIALIZER;
static size_t narenas = 1;
static mstate free_list;
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 94066d2..eba20cd 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1747,7 +1747,7 @@ struct malloc_par
static struct malloc_state main_arena =
{
- .mutex = MUTEX_INITIALIZER,
+ .mutex = _LIBC_LOCK_INITIALIZER,
.next = &main_arena,
.attached_threads = 1
};
diff --git a/sysdeps/generic/malloc-machine.h b/sysdeps/generic/malloc-machine.h
index 802d1f5..7b7eae8 100644
--- a/sysdeps/generic/malloc-machine.h
+++ b/sysdeps/generic/malloc-machine.h
@@ -38,7 +38,6 @@ typedef int mutex_t;
# define mutex_lock(m) ({ *(m) = 1; 0; })
# define mutex_trylock(m) (*(m) ? 1 : ((*(m) = 1), 0))
# define mutex_unlock(m) (*(m) = 0)
-# define MUTEX_INITIALIZER (0)
#endif /* !defined mutex_init */
diff --git a/sysdeps/mach/hurd/bits/libc-lock.h b/sysdeps/mach/hurd/bits/libc-lock.h
index 24c3aa8..ca9c3e3 100644
--- a/sysdeps/mach/hurd/bits/libc-lock.h
+++ b/sysdeps/mach/hurd/bits/libc-lock.h
@@ -50,8 +50,9 @@ typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
CLASS __libc_lock_t NAME;
/* Define an initialized lock variable NAME with storage class CLASS. */
+#define _LIBC_LOCK_INITIALIZER MUTEX_INITIALIZER
#define __libc_lock_define_initialized(CLASS,NAME) \
- CLASS __libc_lock_t NAME = MUTEX_INITIALIZER;
+ CLASS __libc_lock_t NAME = _LIBC_LOCK_INITIALIZER;
/* Initialize the named lock variable, leaving it in a consistent, unlocked
state. */
diff --git a/sysdeps/nptl/bits/libc-lockP.h b/sysdeps/nptl/bits/libc-lockP.h
index f55f621..fae8a2b 100644
--- a/sysdeps/nptl/bits/libc-lockP.h
+++ b/sysdeps/nptl/bits/libc-lockP.h
@@ -75,6 +75,7 @@ typedef pthread_key_t __libc_key_t;
initialized locks must be set to one due to the lack of normal
atomic operations.) */
+#define _LIBC_LOCK_INITIALIZER LLL_LOCK_INITIALIZER
#if IS_IN (libc) || IS_IN (libpthread)
# if LLL_LOCK_INITIALIZER == 0
# define __libc_lock_define_initialized(CLASS,NAME) \
diff --git a/sysdeps/nptl/malloc-machine.h b/sysdeps/nptl/malloc-machine.h
index 4d44089..0b679b7 100644
--- a/sysdeps/nptl/malloc-machine.h
+++ b/sysdeps/nptl/malloc-machine.h
@@ -31,7 +31,6 @@ __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
/* This is defined by newer gcc version unique for each module. */
extern void *__dso_handle __attribute__ ((__weak__));