aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vtable-security/ChangeLog.vtable-security9
-rw-r--r--vtable-security/libstdc++-v3/libsupc++/vtv_rts.cc24
2 files changed, 28 insertions, 5 deletions
diff --git a/vtable-security/ChangeLog.vtable-security b/vtable-security/ChangeLog.vtable-security
index ae0d230bcac..d206fe0ba43 100644
--- a/vtable-security/ChangeLog.vtable-security
+++ b/vtable-security/ChangeLog.vtable-security
@@ -1,3 +1,12 @@
+2010-08-09 Caroline Tice <cmtice@google.com>
+
+ * libstdc++-v3/libsupc++/vtv_rts.cc (map_var_mutex): Move out of
+ __VLTRegisterPair and make this a global static variable.
+ (initialize_mutex_once): New function.
+ (__VLTRegisterPair): Make map_var_mutex a global static variable;
+ add mutex_once, and use to properly initialize map_var_mutex, if
+ needed.
+
2012-08-08 Caroline Tice <cmtice@google.com>
* libstdc++-v3/libsupc++/vtv_rts.cc (__VLTRegisterPair): Replace
diff --git a/vtable-security/libstdc++-v3/libsupc++/vtv_rts.cc b/vtable-security/libstdc++-v3/libsupc++/vtv_rts.cc
index d4334d43704..0c656b1be8b 100644
--- a/vtable-security/libstdc++-v3/libsupc++/vtv_rts.cc
+++ b/vtable-security/libstdc++-v3/libsupc++/vtv_rts.cc
@@ -228,6 +228,21 @@ print_debugging_message (const char *format_string_dummy, int format_arg1,
fprintf (stdout, format_string, str_arg1, str_arg2);
}
+#ifdef __GTHREAD_MUTEX_INIT
+
+static __gthread_mutex_t map_var_mutex VTV_PROTECTED_VAR = __GTHREAD_MUTEX_INIT;
+
+#else
+
+static __gthread_mutex_t map_var_mutex VTV_PROTECTED_VAR;
+
+static void
+initialize_mutex_once ()
+{
+ __GTHREAD_MUTEX_INIT_FUNCTION (&map_var_mutex);
+}
+#endif
+
/* TODO: Why is this returning anything
remove unnecessary arguments */
void *
@@ -238,12 +253,11 @@ __VLTRegisterPair (void **data_pointer, void *test_value, int size_hint,
vptr vtbl_ptr = (vptr) test_value;
struct vlt_hashtable * volatile *tmp_volatile_ptr =
(struct vlt_hashtable **) data_pointer;
- static __gthread_mutex_t map_var_mutex VTV_PROTECTED_VAR;
-#if defined __GTHREAD_MUTEX_INIT
- map_var_mutex = __GTHREAD_MUTEX_INIT;
-#else
- __GTHREAD_MUTEX_INIT_FUNCTION(&map_var_mutex);
+#ifndef __GTHREAD_MUTEX_INIT
+ static __gthread_once_t mutex_once VTV_PROTECTED_VAR = __GTHREAD_ONCE_INIT;
+
+ __gthread_once (&mutex_once, initialize_mutex_once);
#endif
if ((*tmp_volatile_ptr) == NULL)