From 00e6660b0d17b23a8a48a0e105cb266967b3bb6b Mon Sep 17 00:00:00 2001 From: Thomas Pfaff Date: Wed, 11 Jun 2003 19:08:42 +0000 Subject: [PATCH] * thread.cc (pthread_attr_init): Return 0 if attribute is already initialized. Fix return code if out of memory. (pthread_condattr_init): Ditto. (pthread_rwlockattr_init): Ditto. (pthread_mutexattr_init): Return 0 if attribute is already initialized. --- winsup/cygwin/ChangeLog | 10 ++++++++++ winsup/cygwin/thread.cc | 23 +++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8e92cfdc7..797af106c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +2003-06-11 Thomas Pfaff + + * thread.cc (pthread_attr_init): Return 0 if attribute is already + initialized. + Fix return code if out of memory. + (pthread_condattr_init): Ditto. + (pthread_rwlockattr_init): Ditto. + (pthread_mutexattr_init): Return 0 if attribute is already + initialized. + 2003-06-09 Pierre Humblet * spawn.cc (spawn_guts): Call CreateProcess while impersonated, diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 0321ea47b..dbf5d7f76 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -1964,14 +1964,15 @@ pthread::atfork (void (*prepare)(void), void (*parent)(void), void (*child)(void extern "C" int pthread_attr_init (pthread_attr_t *attr) { - if (check_valid_pointer (attr)) - return EINVAL; + if (pthread_attr::is_good_object (attr)) + return 0; + *attr = new pthread_attr; if (!pthread_attr::is_good_object (attr)) { delete (*attr); *attr = NULL; - return EAGAIN; + return ENOMEM; } return 0; } @@ -2488,14 +2489,15 @@ pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex) extern "C" int pthread_condattr_init (pthread_condattr_t *condattr) { - if (check_valid_pointer (condattr)) - return EINVAL; + if (pthread_condattr::is_good_object (condattr)) + return 0; + *condattr = new pthread_condattr; if (!pthread_condattr::is_good_object (condattr)) { delete (*condattr); *condattr = NULL; - return EAGAIN; + return ENOMEM; } return 0; } @@ -2673,14 +2675,15 @@ pthread_rwlock_unlock (pthread_rwlock_t *rwlock) extern "C" int pthread_rwlockattr_init (pthread_rwlockattr_t *rwlockattr) { - if (check_valid_pointer (rwlockattr)) - return EINVAL; + if (pthread_rwlockattr::is_good_object (rwlockattr)) + return 0; + *rwlockattr = new pthread_rwlockattr; if (!pthread_rwlockattr::is_good_object (rwlockattr)) { delete (*rwlockattr); *rwlockattr = NULL; - return EAGAIN; + return ENOMEM; } return 0; } @@ -2933,7 +2936,7 @@ extern "C" int pthread_mutexattr_init (pthread_mutexattr_t *attr) { if (pthread_mutexattr::is_good_object (attr)) - return EBUSY; + return 0; *attr = new pthread_mutexattr (); if (!pthread_mutexattr::is_good_object (attr))