diff options
author | Egor Duda <deo@logos-m.ru> | 2001-11-15 11:10:38 +0000 |
---|---|---|
committer | Egor Duda <deo@logos-m.ru> | 2001-11-15 11:10:38 +0000 |
commit | f38ac9b70c69408b011797cf5b86579e60c5b7df (patch) | |
tree | caf67ea04476231ef37a8f5542089cd4796cfb87 | |
parent | e2b3dc25804ce3688ac69a7249323e90ae82305e (diff) | |
download | newlib-f38ac9b70c69408b011797cf5b86579e60c5b7df.zip newlib-f38ac9b70c69408b011797cf5b86579e60c5b7df.tar.gz newlib-f38ac9b70c69408b011797cf5b86579e60c5b7df.tar.bz2 |
* include/pthread.h (PTHREAD_COND_INITIALIZER): Define.
* thread.cc (__pthread_cond_destroy): Add support for
PTHREAD_COND_INITIALIZER.
(__pthread_cond_init): Ditto.
(__pthread_cond_broadcast): Ditto.
(__pthread_cond_signal): Ditto.
(__pthread_cond_dowait): Ditto.
(__pthread_mutex_init): Handle PTHREAD_MUTEX_INITIALIZER correctly,
don't return error when it's passed as parameter.
* winsup.h (check_null_invalid_struct): Call correct function.
-rw-r--r-- | winsup/cygwin/ChangeLog | 13 | ||||
-rw-r--r-- | winsup/cygwin/include/pthread.h | 3 | ||||
-rw-r--r-- | winsup/cygwin/thread.cc | 12 | ||||
-rw-r--r-- | winsup/cygwin/winsup.h | 2 |
4 files changed, 26 insertions, 4 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9c5fa54..055a52e 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,16 @@ +2001-11-15 Egor Duda <deo@logos-m.ru> + + * include/pthread.h (PTHREAD_COND_INITIALIZER): Define. + * thread.cc (__pthread_cond_destroy): Add support for + PTHREAD_COND_INITIALIZER. + (__pthread_cond_init): Ditto. + (__pthread_cond_broadcast): Ditto. + (__pthread_cond_signal): Ditto. + (__pthread_cond_dowait): Ditto. + (__pthread_mutex_init): Handle PTHREAD_MUTEX_INITIALIZER correctly, + don't return error when it's passed as parameter. + * winsup.h (check_null_invalid_struct): Call correct function. + 2001-11-14 Christopher Faylor <cgf@redhat.com> * exceptions.cc: Add stdlib.h include for alloca declaration. diff --git a/winsup/cygwin/include/pthread.h b/winsup/cygwin/include/pthread.h index 3c51cf1..102ba65 100644 --- a/winsup/cygwin/include/pthread.h +++ b/winsup/cygwin/include/pthread.h @@ -43,7 +43,8 @@ extern "C" #define PTHREAD_CANCEL_DEFERRED 0 #define PTHREAD_CANCEL_DISABLE 1 #define PTHREAD_CANCELED -#define PTHREAD_COND_INITIALIZER +/* this should be a value that can never be a valid address */ +#define PTHREAD_COND_INITIALIZER (void *)21 #define PTHREAD_CREATE_DETACHED 1 /* the default : joinable */ #define PTHREAD_CREATE_JOINABLE 0 diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 87e926d..4b88679 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -1676,6 +1676,8 @@ __pthread_getspecific (pthread_key_t key) int __pthread_cond_destroy (pthread_cond_t *cond) { + if (check_valid_pointer (cond) && (*cond == PTHREAD_COND_INITIALIZER)) + return 0; if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC) != VALID_OBJECT) return EINVAL; @@ -1695,7 +1697,7 @@ __pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr) if (attr && verifyable_object_isvalid (attr, PTHREAD_CONDATTR_MAGIC) != VALID_OBJECT) return EINVAL; - if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC) != INVALID_OBJECT) + if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC, PTHREAD_COND_INITIALIZER) == VALID_OBJECT) return EBUSY; *cond = new pthread_cond (attr ? (*attr) : NULL); @@ -1713,6 +1715,8 @@ __pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr) int __pthread_cond_broadcast (pthread_cond_t *cond) { + if (*cond == PTHREAD_COND_INITIALIZER) + __pthread_cond_init (cond, NULL); if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC) != VALID_OBJECT) return EINVAL; @@ -1724,6 +1728,8 @@ __pthread_cond_broadcast (pthread_cond_t *cond) int __pthread_cond_signal (pthread_cond_t *cond) { + if (*cond == PTHREAD_COND_INITIALIZER) + __pthread_cond_init (cond, NULL); if (verifyable_object_isvalid (cond, PTHREAD_COND_MAGIC) != VALID_OBJECT) return EINVAL; @@ -1743,6 +1749,8 @@ __pthread_cond_dowait (pthread_cond_t *cond, pthread_mutex_t *mutex, if (*mutex == PTHREAD_MUTEX_INITIALIZER) __pthread_mutex_init (mutex, NULL); themutex = mutex; + if (*cond == PTHREAD_COND_INITIALIZER) + __pthread_cond_init (cond, NULL); if (verifyable_object_isvalid (themutex, PTHREAD_MUTEX_MAGIC) != VALID_OBJECT) return EINVAL; @@ -1920,7 +1928,7 @@ __pthread_mutex_init (pthread_mutex_t *mutex, if (attr && verifyable_object_isvalid (attr, PTHREAD_MUTEXATTR_MAGIC) != VALID_OBJECT || check_valid_pointer (mutex)) return EINVAL; - if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC, PTHREAD_MUTEX_INITIALIZER) != INVALID_OBJECT) + if (verifyable_object_isvalid (mutex, PTHREAD_MUTEX_MAGIC, PTHREAD_MUTEX_INITIALIZER) == VALID_OBJECT) return EBUSY; *mutex = new pthread_mutex (attr ? (*attr) : NULL); diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h index fadff2e..7105fb7 100644 --- a/winsup/cygwin/winsup.h +++ b/winsup/cygwin/winsup.h @@ -195,7 +195,7 @@ int __stdcall __check_null_invalid_struct_errno (const void *s, unsigned sz) __a int __stdcall __check_invalid_read_ptr_errno (const void *s, unsigned sz) __attribute__ ((regparm(2))); #define check_null_invalid_struct(s) \ - __check_null_invalid ((s), sizeof (*(s))) + __check_null_invalid_struct ((s), sizeof (*(s))) #define check_null_invalid_struct_errno(s) \ __check_null_invalid_struct_errno ((s), sizeof (*(s))) |