aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hotmail.com>2002-10-17 08:44:18 +0000
committerRobert Collins <rbtcollins@hotmail.com>2002-10-17 08:44:18 +0000
commite9350b6575f296f1e46a867480112300498b467b (patch)
tree802a101a5cf9d2e2be1a95d61e3c54b2db4086c9 /winsup/cygwin
parent841cf30bc32103486acd84d5407782f64dd9d6b3 (diff)
downloadnewlib-e9350b6575f296f1e46a867480112300498b467b.zip
newlib-e9350b6575f296f1e46a867480112300498b467b.tar.gz
newlib-e9350b6575f296f1e46a867480112300498b467b.tar.bz2
2002-10-17 Robert Collins <rbtcollins@hotmail.com>
* thread.h (pthread_mutex::isGoodInitializerOrBadObject): Declare. * thread.cc (pthread_mutex::isGoodInitializerOrBadObject): Implement. (pthread_mutex::init): Use isGoodInitializerOrBadObject to avoid unneeded SEGV's during debugging.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/thread.cc12
-rw-r--r--winsup/cygwin/thread.h1
3 files changed, 18 insertions, 2 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 2143aec..4c170f2 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+2002-10-17 Robert Collins <rbtcollins@hotmail.com>
+
+ * thread.h (pthread_mutex::isGoodInitializerOrBadObject): Declare.
+ * thread.cc (pthread_mutex::isGoodInitializerOrBadObject): Implement.
+ (pthread_mutex::init): Use isGoodInitializerOrBadObject to avoid
+ unneeded SEGV's during debugging.
+
2002-10-17 Thomas Pfaff <tpfaff@gmx.net>
* thread.cc (verifyable_object_isvalid): Test for static object first.
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 75dd7d3..bf44faa 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -1098,6 +1098,15 @@ pthread_mutex::isGoodInitializerOrObject (pthread_mutex_t const *mutex)
return true;
}
+bool
+pthread_mutex::isGoodInitializerOrBadObject (pthread_mutex_t const *mutex)
+{
+ verifyable_object_state objectState = verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC, PTHREAD_MUTEX_INITIALIZER);
+ if (objectState == VALID_OBJECT)
+ return false;
+ return true;
+}
+
/* This is used for mutex creation protection within a single process only */
pthread_mutex::nativeMutex pthread_mutex::mutexInitializationLock NO_COPY;
@@ -2256,8 +2265,7 @@ pthread_mutex::init (pthread_mutex_t *mutex,
if (!mutexInitializationLock.lock ())
return EINVAL;
- /* FIXME: bugfix: we should check *mutex being a valid address */
- if (isGoodObject (mutex))
+ if (!isGoodInitializerOrBadObject (mutex))
{
mutexInitializationLock.unlock ();
return EBUSY;
diff --git a/winsup/cygwin/thread.h b/winsup/cygwin/thread.h
index c23e5a0..73e57ed 100644
--- a/winsup/cygwin/thread.h
+++ b/winsup/cygwin/thread.h
@@ -291,6 +291,7 @@ public:
static bool isGoodObject(pthread_mutex_t const *);
static bool isGoodInitializer(pthread_mutex_t const *);
static bool isGoodInitializerOrObject(pthread_mutex_t const *);
+ static bool isGoodInitializerOrBadObject (pthread_mutex_t const *mutex);
static void initMutex ();
static int init (pthread_mutex_t *, const pthread_mutexattr_t *);