merge in lmp-mr1-release history after reset to lmp-mr1-dev
diff --git a/src/Los-common.c b/src/Los-common.c
index cad43d0..d8f57e3 100644
--- a/src/Los-common.c
+++ b/src/Los-common.c
@@ -30,10 +30,18 @@
extern struct map_info *local_map_list;
extern lock_rdwr_var (local_rdwr_lock);
+static pthread_once_t local_rdwr_lock_init = PTHREAD_ONCE_INIT;
+
+static void
+map_local_init_once (void)
+{
+ lock_rdwr_init (&local_rdwr_lock);
+}
+
HIDDEN void
map_local_init (void)
{
- lock_rdwr_init (&local_rdwr_lock);
+ pthread_once (&local_rdwr_lock_init, map_local_init_once);
}
static void
diff --git a/src/mi/Lmap.c b/src/mi/Lmap.c
index e07a50a..ba93ab9 100644
--- a/src/mi/Lmap.c
+++ b/src/mi/Lmap.c
@@ -36,6 +36,10 @@
{
intrmask_t saved_mask;
+ /* This function can be called before any other unwind code, so make sure
+ the lock has been initialized. */
+ map_local_init ();
+
lock_rdwr_wr_acquire (&local_rdwr_lock, saved_mask);
map_cursor->map_list = local_map_list;
map_cursor->cur_map = local_map_list;
@@ -56,6 +60,10 @@
intrmask_t saved_mask;
int ret_value = 0;
+ /* This function can be called before any other unwind code, so make sure
+ the lock has been initialized. */
+ map_local_init ();
+
lock_rdwr_wr_acquire (&local_rdwr_lock, saved_mask);
if (local_map_list_refs == 0)
{
@@ -76,6 +84,10 @@
{
intrmask_t saved_mask;
+ /* This function can be called before any other unwind code, so make sure
+ the lock has been initialized. */
+ map_local_init ();
+
lock_rdwr_wr_acquire (&local_rdwr_lock, saved_mask);
if (local_map_list != NULL && --local_map_list_refs == 0)
{
@@ -95,6 +107,10 @@
if (map_info == NULL)
return 0;
+ /* This function can be called before any other unwind code, so make sure
+ the lock has been initialized. */
+ map_local_init ();
+
lock_rdwr_rd_acquire (&local_rdwr_lock, saved_mask);
if (map_cursor->map_list != local_map_list)
{