aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaroline Tice <cmtice@google.com>2012-08-08 22:33:34 +0000
committerCaroline Tice <cmtice@google.com>2012-08-08 22:33:34 +0000
commit9b5d904942d0442f75d9434750be201e29ca8948 (patch)
tree3684a570c39cca7083163f5d84833a9bd7e5f68c
parent6df72c7ccf9bf3fd36aa8182e1ee396b7b308ed4 (diff)
Change from using pthreads to using __gthreads.
git-svn-id: https://gcc.gnu.org/svn/gcc/branches/google/gcc-4_6-mobile@190240 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--vtable-security/ChangeLog.vtable-security18
-rw-r--r--vtable-security/libstdc++-v3/libsupc++/vtv_rts.cc15
-rw-r--r--vtable-security/libstdc++-v3/libsupc++/vtv_threaded_hash.cc13
-rw-r--r--vtable-security/libstdc++-v3/libsupc++/vtv_threaded_hash.h5
4 files changed, 40 insertions, 11 deletions
diff --git a/vtable-security/ChangeLog.vtable-security b/vtable-security/ChangeLog.vtable-security
index bbd4d838690..ae0d230bcac 100644
--- a/vtable-security/ChangeLog.vtable-security
+++ b/vtable-security/ChangeLog.vtable-security
@@ -1,3 +1,21 @@
+2012-08-08 Caroline Tice <cmtice@google.com>
+
+ * libstdc++-v3/libsupc++/vtv_rts.cc (__VLTRegisterPair): Replace
+ PTHREAD_MUTEX_INITIALIZER with __GTHREAD_MUTEX_INIT or
+ __GTHREAD_MUTEX_INIT_FUNCTION. Replace pthred_mutex_lock and
+ pthread_mutex_unlock with __thread_mutex_lock and
+ __gthread_mutex_unlock. Use __gthread_mutex_t for the mutex type.
+ * libstdc++-v3/libsupc++/vtv_threaded_hash.cc (vlt_hash_init_table):
+ Use __gthread_mutex_t for the mutex type. Replace
+ PTHREAD_MUTEX_INITIALIZER with __GTHREAD_MUTEX_INIT or
+ __GTHREAD_MUTEX_INIT_FUNCTION.
+ (vlt_hash_insert): Replace pthred_mutex_lock and
+ pthread_mutex_unlock with __thread_mutex_lock and
+ __gthread_mutex_unlock.
+ * libstdc++-v3/libsupc++/vtv_threaded_hash.h: Remove include for
+ pthread.h. Add includes for <bits/c++config.h> and <ext/concurrence.h>.
+ (struct vlt_hashtable): Change type of mutex to __gthread_mutex_t.
+
2012-08-06 Caroline Tice <cmtice@google.com>
* gcc/cp/vtable-class-hierarchy.c (vtv_generate_init_routine):
diff --git a/vtable-security/libstdc++-v3/libsupc++/vtv_rts.cc b/vtable-security/libstdc++-v3/libsupc++/vtv_rts.cc
index 12f15d28e31..d4334d43704 100644
--- a/vtable-security/libstdc++-v3/libsupc++/vtv_rts.cc
+++ b/vtable-security/libstdc++-v3/libsupc++/vtv_rts.cc
@@ -236,19 +236,24 @@ __VLTRegisterPair (void **data_pointer, void *test_value, int size_hint,
int len2)
{
vptr vtbl_ptr = (vptr) test_value;
- struct vlt_hashtable * volatile *tmp_volatile_ptr =
+ struct vlt_hashtable * volatile *tmp_volatile_ptr =
(struct vlt_hashtable **) data_pointer;
- static pthread_mutex_t map_var_mutex VTV_PROTECTED_VAR
- = PTHREAD_MUTEX_INITIALIZER;
+ 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);
+#endif
if ((*tmp_volatile_ptr) == NULL)
{
- pthread_mutex_lock (&map_var_mutex);
+ __gthread_mutex_lock (&map_var_mutex);
if ((*tmp_volatile_ptr) == NULL)
*tmp_volatile_ptr = vlt_hash_init_table (size_hint);
- pthread_mutex_unlock (&map_var_mutex);
+ __gthread_mutex_unlock (&map_var_mutex);
}
if (debug_functions && base_ptr_var_name && vtable_name)
diff --git a/vtable-security/libstdc++-v3/libsupc++/vtv_threaded_hash.cc b/vtable-security/libstdc++-v3/libsupc++/vtv_threaded_hash.cc
index d05b4c9ed07..4c88c5c352f 100644
--- a/vtable-security/libstdc++-v3/libsupc++/vtv_threaded_hash.cc
+++ b/vtable-security/libstdc++-v3/libsupc++/vtv_threaded_hash.cc
@@ -103,7 +103,7 @@ static void
grow_table (struct vlt_hashtable *table)
{
/* IMPORTANT NOTE!! This function assumes that you have already
- acquired the lock on TABLE's pthread mutex before calling this
+ acquired the lock on TABLE's gthread mutex before calling this
function. If you call this function without first acquiring the
lock, something bad may happen to you. YOU HAVE BEEN
WARNED! */
@@ -181,7 +181,12 @@ vlt_hash_init_table (int initial_size_hint)
new_table->data_size = initial_size;
new_table->power_of_2 = initial_power;
new_table->num_elts = 0;
- pthread_mutex_init (&(new_table->mutex), NULL);
+
+#if defined __GTHREAD_MUTEX_INIT
+ new_table->mutex = __GTHREAD_MUTEX_INIT;
+#else
+ __GTHREAD_MUTEX_INIT_FUNCTION(&(new_table->mutex));
+#endif
num_tables_allocated++; /* Debug */
num_bucket_pointers_allocated += initial_size; /* Debug */
@@ -244,7 +249,7 @@ vlt_hash_insert (struct vlt_hashtable *table, void *value)
{
/* Grab the mutex before doing the comparison below to make sure
nothing being compared changes in the middle of the comparison. */
- pthread_mutex_lock (&(table->mutex));
+ __gthread_mutex_lock (&(table->mutex));
/* Re-calculate the index in case the table grew between the
initial check above and when we grabbed the lock. Before
@@ -284,7 +289,7 @@ vlt_hash_insert (struct vlt_hashtable *table, void *value)
table->num_elts++;
}
- pthread_mutex_unlock (&(table->mutex));
+ __gthread_mutex_unlock (&(table->mutex));
}
}
diff --git a/vtable-security/libstdc++-v3/libsupc++/vtv_threaded_hash.h b/vtable-security/libstdc++-v3/libsupc++/vtv_threaded_hash.h
index 6fb365bf8e4..12fcc80fd5e 100644
--- a/vtable-security/libstdc++-v3/libsupc++/vtv_threaded_hash.h
+++ b/vtable-security/libstdc++-v3/libsupc++/vtv_threaded_hash.h
@@ -25,7 +25,8 @@
#ifndef _VTV_THREADED_HASH_H
#define _VTV_THREADED_HASH_H 1
-#include <pthread.h>
+#include <bits/c++config.h>
+#include <ext/concurrence.h>
#include <inttypes.h>
#ifdef __cplusplus
@@ -41,7 +42,7 @@ struct vlt_hashtable {
volatile uint32_t data_size;
uint32_t num_elts;
uint32_t power_of_2;
- pthread_mutex_t mutex;
+ __gthread_mutex_t mutex;
struct vlt_hash_bucket ** volatile data;
};