diff options
author | Caroline Tice <cmtice@google.com> | 2012-08-09 21:41:48 +0000 |
---|---|---|
committer | Caroline Tice <cmtice@google.com> | 2012-08-09 21:41:48 +0000 |
commit | 5a850aac8eccc8591278e9a20354bb20f4a656aa (patch) | |
tree | 15ca70dfe6bcae3fd0b7108c3a6fb991cc9b4a91 | |
parent | 9b5d904942d0442f75d9434750be201e29ca8948 (diff) |
Fix initialization of static _gthread_mutex_t
variable.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/google/gcc-4_6-mobile@190266 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | vtable-security/ChangeLog.vtable-security | 9 | ||||
-rw-r--r-- | vtable-security/libstdc++-v3/libsupc++/vtv_rts.cc | 24 |
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) |