* 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.
This commit is contained in:
Thomas Pfaff 2003-06-11 19:08:42 +00:00
parent 0efe117b5c
commit 00e6660b0d
2 changed files with 23 additions and 10 deletions

View File

@ -1,3 +1,13 @@
2003-06-11 Thomas Pfaff <tpfaff@gmx.net>
* 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 <pierre.humblet@ieee.org> 2003-06-09 Pierre Humblet <pierre.humblet@ieee.org>
* spawn.cc (spawn_guts): Call CreateProcess while impersonated, * spawn.cc (spawn_guts): Call CreateProcess while impersonated,

View File

@ -1964,14 +1964,15 @@ pthread::atfork (void (*prepare)(void), void (*parent)(void), void (*child)(void
extern "C" int extern "C" int
pthread_attr_init (pthread_attr_t *attr) pthread_attr_init (pthread_attr_t *attr)
{ {
if (check_valid_pointer (attr)) if (pthread_attr::is_good_object (attr))
return EINVAL; return 0;
*attr = new pthread_attr; *attr = new pthread_attr;
if (!pthread_attr::is_good_object (attr)) if (!pthread_attr::is_good_object (attr))
{ {
delete (*attr); delete (*attr);
*attr = NULL; *attr = NULL;
return EAGAIN; return ENOMEM;
} }
return 0; return 0;
} }
@ -2488,14 +2489,15 @@ pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex)
extern "C" int extern "C" int
pthread_condattr_init (pthread_condattr_t *condattr) pthread_condattr_init (pthread_condattr_t *condattr)
{ {
if (check_valid_pointer (condattr)) if (pthread_condattr::is_good_object (condattr))
return EINVAL; return 0;
*condattr = new pthread_condattr; *condattr = new pthread_condattr;
if (!pthread_condattr::is_good_object (condattr)) if (!pthread_condattr::is_good_object (condattr))
{ {
delete (*condattr); delete (*condattr);
*condattr = NULL; *condattr = NULL;
return EAGAIN; return ENOMEM;
} }
return 0; return 0;
} }
@ -2673,14 +2675,15 @@ pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
extern "C" int extern "C" int
pthread_rwlockattr_init (pthread_rwlockattr_t *rwlockattr) pthread_rwlockattr_init (pthread_rwlockattr_t *rwlockattr)
{ {
if (check_valid_pointer (rwlockattr)) if (pthread_rwlockattr::is_good_object (rwlockattr))
return EINVAL; return 0;
*rwlockattr = new pthread_rwlockattr; *rwlockattr = new pthread_rwlockattr;
if (!pthread_rwlockattr::is_good_object (rwlockattr)) if (!pthread_rwlockattr::is_good_object (rwlockattr))
{ {
delete (*rwlockattr); delete (*rwlockattr);
*rwlockattr = NULL; *rwlockattr = NULL;
return EAGAIN; return ENOMEM;
} }
return 0; return 0;
} }
@ -2933,7 +2936,7 @@ extern "C" int
pthread_mutexattr_init (pthread_mutexattr_t *attr) pthread_mutexattr_init (pthread_mutexattr_t *attr)
{ {
if (pthread_mutexattr::is_good_object (attr)) if (pthread_mutexattr::is_good_object (attr))
return EBUSY; return 0;
*attr = new pthread_mutexattr (); *attr = new pthread_mutexattr ();
if (!pthread_mutexattr::is_good_object (attr)) if (!pthread_mutexattr::is_good_object (attr))