summaryrefslogtreecommitdiff
path: root/sysdeps/generic/bits/mutex.h
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@gnu.org>2005-05-12 20:55:38 +0000
committerNeal H. Walfield <neal@gnu.org>2005-05-12 20:55:38 +0000
commit1c31ded80a4e76294ba08b2da2117b0af8c5cdaa (patch)
treea33215878ffb82df4f9d8c593112c2b6f8d5b37b /sysdeps/generic/bits/mutex.h
parent4878d30d853a947ea22de2ac8aa2dca6c1035821 (diff)
libpthread/
2005-05-12 Neal H. Walfield <neal@gnu.org> * include/pthread/pthread.h (pthread_exit): Add noreturn attribute. * sysdeps/generic/bits/condition.h (__PTHREAD_COND_INITIALIZER): Don't create a compound literal. * sysdeps/generic/bits/mutex.h (__PTHREAD_MUTEX_INITIALIZER): Don't create a compound literal. (pthread_mutex_init): Don't assign to *__MUTEX directly. Initialize an intermediate local variable and then copy the result. * sysdeps/generic/bits/rwlock.h (__PTHREAD_RWLOCK_INITIALIZER): Don't create a compound literal. (pthread_rwlock_init): Don't assign to *__RWLOCK directly. Initialize an intermediate local variable and then copy the result. * sysdeps/i386/bits/spin-lock.h (__SPIN_LOCK_INITIALIZER): Don't create a compound literal. * pthread/pt-alloc.c (initialize_pthread): Cast PTHREAD_MUTEX_INITIALIZER and PTHREAD_COND_INITIALIZER to create a compound literal. * tests/test-1.c (main): Use pthread_mutex_init, not PTHREAD_MUTEX_INIT for mutex initialization * sysdeps/generic/pt-barrier-init.c (pthread_barrier_init): Remove assert. Copy ATTR if non-defaults are used. * sysdeps/generic/pt-cond-init.c (pthread_cond_init): Include <string.h>. Remove assert. Copy ATTR if non-defaults are used. * sysdeps/generic/pt-mutex-init.c (_pthread_mutex_init): Cast PTHREAD_MUTEX_INITIALIZER to create a compound literal. * sysdeps/generic/pt-rwlock-init.c: Include <string.h>. (_pthread_rwlock_init): Cast __PTHREAD_RWLOCK_INITIALIZER to create a compound literal. Copy ATTR if non-defaults are used. * sysdeps/generic/pt-cond-timedwait.c (__pthread_cond_timedwait_internal): Check that ABSTIME->TV_NSEC is valid. Don't shadow ERR. Don't return before cleaning up. * sysdeps/generic/pt-mutex-timedlock.c (pthread_mutex_timedlock): Move after __pthread_mutex_timedlock_internal. Check that ABSTIME->TV_NSEC is valid. * sysdeps/generic/pt-rwlock-timedrdlock.c (pthread_rwlock_timedrdlock): Move after. __pthread_rwlock_timedrdlock_internal. (__pthread_rwlock_timedrdlock_internal): Check that ABSTIME->TV_NSEC is valid. * sysdeps/generic/pt-rwlock-timedwrlock.c (pthread_rwlock_timedwrlock): Move after __pthread_rwlock_timedwrlock_internal. (__pthread_rwlock_timedwrlock_internal): Check that ABSTIME->TV_NSEC is valid. * sysdeps/generic/sem-timedwait.c (__sem_timedwait_internal): Check that TIMEOUT->TV_NSEC is valid before enqueuing the thread. * sysdeps/generic/pt-rwlock-rdlock.c (__pthread_rwlock_timedrdlock_internal): Fix declaration. * sysdeps/generic/pt-mutex-trylock.c (__pthread_mutex_trylock): Don't return EDEADLK. POSIX does not allow it. * sysdeps/mach/pt-timedblock.c (__pthread_timedblock): Calculate the relative timeout without overflowing. * sysdeps/mach/hurd/i386/pt-setup.c (stack_setup): Cast THREAD.
Diffstat (limited to 'sysdeps/generic/bits/mutex.h')
-rw-r--r--sysdeps/generic/bits/mutex.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/sysdeps/generic/bits/mutex.h b/sysdeps/generic/bits/mutex.h
index 9958b8d1..2e32d783 100644
--- a/sysdeps/generic/bits/mutex.h
+++ b/sysdeps/generic/bits/mutex.h
@@ -1,5 +1,5 @@
/* Mutex type. Generic version.
- Copyright (C) 2000,02 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -52,9 +52,7 @@ struct __pthread_mutex
/* Initializer for a mutex. N.B. this also happens to be compatible
with the cthread mutex initializer. */
# define __PTHREAD_MUTEX_INITIALIZER \
- ((struct __pthread_mutex) \
- { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, NULL, NULL, NULL, \
- NULL, 0, 0 })
+ { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0, 0 }
# endif
#endif /* Not __pthread_mutex_defined. */
@@ -74,13 +72,15 @@ _EXTERN_INLINE int
pthread_mutex_init (struct __pthread_mutex *__mutex,
const pthread_mutexattr_t *attr)
{
+ struct __pthread_mutex initialized_mutex = __PTHREAD_MUTEX_INITIALIZER;
+
extern int _pthread_mutex_init (struct __pthread_mutex *,
const pthread_mutexattr_t *);
if (attr)
return _pthread_mutex_init (__mutex, attr);
- *__mutex = __PTHREAD_MUTEX_INITIALIZER;
+ *__mutex = initialized_mutex;
return 0;
}