From a0cc53efb171fceddc40bae4568cff3e7b17a31b Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Tue, 18 Jan 2005 09:57:35 +0000 Subject: libpthread/ 2005-01-12 Pietro Ferrari * include/pthread/pthread.h (pthread_spin_destroy): Replace extern inline with extern __inline. (pthread_spin_init): Likewise. (pthread_spin_lock): Likewise. (pthread_spin_trylock): Likewise. (pthread_spin_unlock): Likewise. * sysdeps/mach/bits/spin-lock.h (__pthread_spin_lock): Likewise. * sysdeps/i386/bits/spin-lock.h (__pthread_spin_lock): Likewise. * sysdeps/generic/bits/mutex.h (__pthread_mutex_trylock): Likewise. (pthread_mutex_lock): Likewise. (pthread_mutex_trylock): Likewise. * sysdeps/generic/bits/pthread.h (pthread_equal): Likewise. --- include/pthread/pthread.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include/pthread/pthread.h') diff --git a/include/pthread/pthread.h b/include/pthread/pthread.h index cf23d07..8b25811 100644 --- a/include/pthread/pthread.h +++ b/include/pthread/pthread.h @@ -420,31 +420,31 @@ extern int pthread_spin_unlock (pthread_spinlock_t *__lock); # ifdef __USE_EXTERN_INLINES -extern inline int +extern __inline int pthread_spin_destroy (pthread_spinlock_t *__lock) { return __pthread_spin_destroy (__lock); } -extern inline int +extern __inline int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared) { return __pthread_spin_init (__lock, __pshared); } -extern inline int +extern __inline int pthread_spin_lock (pthread_spinlock_t *__lock) { return __pthread_spin_lock (__lock); } -extern inline int +extern __inline int pthread_spin_trylock (pthread_spinlock_t *__lock) { return __pthread_spin_trylock (__lock); } -extern inline int +extern __inline int pthread_spin_unlock (pthread_spinlock_t *__lock) { return __pthread_spin_unlock (__lock); -- cgit v1.2.3 From d3259802444358fa6f917c7d2a049fc8fcc98cc0 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Wed, 20 Apr 2005 15:26:52 +0000 Subject: libpthread/ 2005-04-20 Neal H. Walfield * sysdeps/generic/pt-setschedparam.c: policy's type is int, not int *. * include/pthread/pthread.h: Likewise. Reported by Christopher `Physicman' Bodenstein . --- ChangeLog | 7 +++++++ include/pthread/pthread.h | 2 +- sysdeps/generic/pt-setschedparam.c | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) (limited to 'include/pthread/pthread.h') diff --git a/ChangeLog b/ChangeLog index 272dff6..9ed9b2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-04-20 Neal H. Walfield + + * sysdeps/generic/pt-setschedparam.c: policy's type is int, not + int *. + * include/pthread/pthread.h: Likewise. + Reported by Christopher `Physicman' Bodenstein . + 2005-01-21 Michael Banck * Makefile ($(libdir)/libpthread2.a): Install linker script diff --git a/include/pthread/pthread.h b/include/pthread/pthread.h index 8b25811..7e0e7de 100644 --- a/include/pthread/pthread.h +++ b/include/pthread/pthread.h @@ -680,7 +680,7 @@ extern int pthread_getschedparam (pthread_t thread, int *policy, struct sched_param *param); /* Set thread THREAD's scheduling paramters. */ -extern int pthread_setschedparam (pthread_t thread, int *policy, +extern int pthread_setschedparam (pthread_t thread, int policy, const struct sched_param *param); /* Set thread THREAD's scheduling priority. */ diff --git a/sysdeps/generic/pt-setschedparam.c b/sysdeps/generic/pt-setschedparam.c index 6b624a3..a70b079 100644 --- a/sysdeps/generic/pt-setschedparam.c +++ b/sysdeps/generic/pt-setschedparam.c @@ -1,5 +1,5 @@ /* Set the scheduling parameters for a thread. Generic version. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 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 @@ -21,7 +21,7 @@ #include int -pthread_setschedparam (pthread_t thread, int *policy, +pthread_setschedparam (pthread_t thread, int policy, const struct sched_param *param) { return ENOSYS; -- cgit v1.2.3 From a2c46ac956613c162b5162d2ef2c725229b08aca Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Thu, 12 May 2005 20:55:38 +0000 Subject: libpthread/ 2005-05-12 Neal H. Walfield * 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 . 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 . (_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. --- ChangeLog | 72 +++++++++++++++++++++++++++++++-- include/pthread/pthread.h | 4 +- pthread/pt-alloc.c | 4 +- sysdeps/generic/bits/condition.h | 5 +-- sysdeps/generic/bits/mutex.h | 10 ++--- sysdeps/generic/bits/rwlock.h | 8 ++-- sysdeps/generic/pt-barrier-init.c | 16 ++++++-- sysdeps/generic/pt-cond-init.c | 17 ++++++-- sysdeps/generic/pt-cond-timedwait.c | 9 ++--- sysdeps/generic/pt-mutex-init.c | 4 +- sysdeps/generic/pt-mutex-timedlock.c | 19 +++++---- sysdeps/generic/pt-mutex-trylock.c | 5 ++- sysdeps/generic/pt-rwlock-init.c | 18 ++++++++- sysdeps/generic/pt-rwlock-rdlock.c | 4 +- sysdeps/generic/pt-rwlock-timedrdlock.c | 19 +++++---- sysdeps/generic/pt-rwlock-timedwrlock.c | 19 +++++---- sysdeps/generic/sem-timedwait.c | 12 +++--- sysdeps/i386/bits/spin-lock.h | 4 +- sysdeps/mach/hurd/i386/pt-setup.c | 4 +- sysdeps/mach/pt-timedblock.c | 22 ++++++---- tests/test-1.c | 2 +- 21 files changed, 197 insertions(+), 80 deletions(-) (limited to 'include/pthread/pthread.h') diff --git a/ChangeLog b/ChangeLog index 194b6ff..998ece5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,75 @@ 2005-05-12 Neal H. Walfield - * Makefile (SRCS): Add sem-close.c sem-destroy.c sem-getvalue.c - sem-init.c sem-open.c sem-post.c sem-timedwait.c sem-trywait.c + * 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 + . 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 . + (_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. + +2005-05-12 Neal H. Walfield + + * Makefile (SRCS): Add sem-close.c, sem-destroy.c, sem-getvalue.c, + sem-init.c, sem-open.c, sem-post.c, sem-timedwait.c, sem-trywait.c, sem-unlink.c and sem-wait.c. - (sysdeps_headers): Add semaphore.h bits/semaphore.h. + (sysdeps_headers): Add semaphore.h and bits/semaphore.h. * include/semaphore.h: New file. * sysdeps/generic/sem-close.c: New file. * sysdeps/generic/sem-destroy.c: New file. diff --git a/include/pthread/pthread.h b/include/pthread/pthread.h index 7e0e7de..3e69cd7 100644 --- a/include/pthread/pthread.h +++ b/include/pthread/pthread.h @@ -1,4 +1,4 @@ -/* 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 @@ -185,7 +185,7 @@ extern int pthread_create (pthread_t *__threadp, /* Terminate the current thread and make STATUS available to any thread that might join us. */ -extern void pthread_exit (void *__status); +extern void pthread_exit (void *__status) __attribute__ ((noreturn)); /* Make calling thread wait for termination of thread THREAD. Return the exit status of the thread in *STATUS. */ diff --git a/pthread/pt-alloc.c b/pthread/pt-alloc.c index e8d3c03..30dcede 100644 --- a/pthread/pt-alloc.c +++ b/pthread/pt-alloc.c @@ -69,8 +69,8 @@ initialize_pthread (struct __pthread *new, int recycling) new->stack = 0; - new->state_lock = PTHREAD_MUTEX_INITIALIZER; - new->state_cond = PTHREAD_COND_INITIALIZER; + new->state_lock = (pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER; + new->state_cond = (pthread_cond_t) PTHREAD_COND_INITIALIZER; new->cancelation_handlers = 0; diff --git a/sysdeps/generic/bits/condition.h b/sysdeps/generic/bits/condition.h index cb7e935..f3b09be 100644 --- a/sysdeps/generic/bits/condition.h +++ b/sysdeps/generic/bits/condition.h @@ -1,5 +1,5 @@ /* Condition type. Generic version. - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 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 @@ -34,7 +34,6 @@ struct __pthread_cond /* Initializer for a condition variable. */ #define __PTHREAD_COND_INITIALIZER \ - ((struct __pthread_cond) \ - { __SPIN_LOCK_INITIALIZER, NULL, NULL, NULL, NULL }) + { __SPIN_LOCK_INITIALIZER, NULL, NULL, NULL, NULL } #endif /* bits/condition.h */ diff --git a/sysdeps/generic/bits/mutex.h b/sysdeps/generic/bits/mutex.h index 9958b8d..2e32d78 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; } diff --git a/sysdeps/generic/bits/rwlock.h b/sysdeps/generic/bits/rwlock.h index d089b0c..5793f65 100644 --- a/sysdeps/generic/bits/rwlock.h +++ b/sysdeps/generic/bits/rwlock.h @@ -1,5 +1,5 @@ /* rwlock type. Generic version. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 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 @@ -40,21 +40,21 @@ struct __pthread_rwlock /* Initializer for a rwlock. */ #define __PTHREAD_RWLOCK_INITIALIZER \ - ((struct __pthread_rwlock) \ - { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0 }) + { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0 } _EXTERN_INLINE int pthread_rwlock_init (struct __pthread_rwlock *__rwlock, const struct __pthread_rwlockattr *__attr) { + struct __pthread_rwlock initialized_rwlock = __PTHREAD_RWLOCK_INITIALIZER; extern int _pthread_rwlock_init (struct __pthread_rwlock *, const struct __pthread_rwlockattr *); if (__attr) return _pthread_rwlock_init (__rwlock, __attr); - *__rwlock = __PTHREAD_RWLOCK_INITIALIZER; + *__rwlock = initialized_rwlock; return 0; } diff --git a/sysdeps/generic/pt-barrier-init.c b/sysdeps/generic/pt-barrier-init.c index 57911d5..c42b3bb 100644 --- a/sysdeps/generic/pt-barrier-init.c +++ b/sysdeps/generic/pt-barrier-init.c @@ -1,5 +1,5 @@ /* pthread_barrier_init. Generic version. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 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 @@ -28,8 +28,6 @@ pthread_barrier_init (pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned count) { - assert (attr->pshared == PTHREAD_PROCESS_PRIVATE); - if (count == 0) return EINVAL; @@ -39,5 +37,17 @@ pthread_barrier_init (pthread_barrier_t *barrier, barrier->pending = count; barrier->count = count; + if (! attr + || memcmp (attr, &__pthread_default_barrierattr, sizeof (*attr) == 0)) + /* Use the default attributes. */ + return 0; + + /* Non-default attributes. */ + + barrier->attr = malloc (sizeof *attr); + if (! barrier->attr) + return ENOMEM; + + *barrier->attr = *attr; return 0; } diff --git a/sysdeps/generic/pt-cond-init.c b/sysdeps/generic/pt-cond-init.c index 4afcc94..b9e9fb7 100644 --- a/sysdeps/generic/pt-cond-init.c +++ b/sysdeps/generic/pt-cond-init.c @@ -19,6 +19,7 @@ #include #include +#include #include @@ -26,9 +27,19 @@ int pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t *attr) { - if (attr) - assert (attr->pshared == PTHREAD_PROCESS_PRIVATE); + *cond = (pthread_cond_t) __PTHREAD_COND_INITIALIZER; - *cond = __PTHREAD_COND_INITIALIZER; + if (! attr + || memcmp (attr, &__pthread_default_condattr, sizeof (*attr) == 0)) + /* Use the default attributes. */ + return 0; + + /* Non-default attributes. */ + + cond->__attr = malloc (sizeof *attr); + if (! cond->__attr) + return ENOMEM; + + *cond->__attr = *attr; return 0; } diff --git a/sysdeps/generic/pt-cond-timedwait.c b/sysdeps/generic/pt-cond-timedwait.c index 4abeb71..c10bdb3 100644 --- a/sysdeps/generic/pt-cond-timedwait.c +++ b/sysdeps/generic/pt-cond-timedwait.c @@ -1,5 +1,5 @@ /* Wait on a condition. 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 @@ -58,6 +58,9 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond, __pthread_mutex_lock (mutex); } + if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)) + return EINVAL; + struct __pthread *self = _pthread_self (); /* Add ourselves to the list of waiters. */ @@ -74,8 +77,6 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond, if (abstime) { - error_t err; - err = __pthread_timedblock (self, abstime); if (err) /* We timed out. We may need to disconnect ourself from the @@ -91,8 +92,6 @@ __pthread_cond_timedwait_internal (pthread_cond_t *cond, if (self->prevp) __pthread_dequeue (self); __pthread_spin_unlock (&mutex->__lock); - - return err; } } else diff --git a/sysdeps/generic/pt-mutex-init.c b/sysdeps/generic/pt-mutex-init.c index 2902f6e..23c9f0d 100644 --- a/sysdeps/generic/pt-mutex-init.c +++ b/sysdeps/generic/pt-mutex-init.c @@ -1,5 +1,5 @@ /* Initialize a mutex. 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 @@ -28,7 +28,7 @@ int _pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) { - *mutex = __PTHREAD_MUTEX_INITIALIZER; + *mutex = (pthread_mutex_t) __PTHREAD_MUTEX_INITIALIZER; if (! attr || memcmp (attr, &__pthread_default_mutexattr, sizeof (*attr) == 0)) diff --git a/sysdeps/generic/pt-mutex-timedlock.c b/sysdeps/generic/pt-mutex-timedlock.c index 3603986..5e222bd 100644 --- a/sysdeps/generic/pt-mutex-timedlock.c +++ b/sysdeps/generic/pt-mutex-timedlock.c @@ -1,5 +1,5 @@ /* Lock a mutex with a timeout. 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 @@ -24,13 +24,6 @@ #define LOSE do { * (int *) 0 = 0; } while (1) -int -pthread_mutex_timedlock (struct __pthread_mutex *mutex, - const struct timespec *abstime) -{ - return __pthread_mutex_timedlock_internal (mutex, abstime); -} - /* Try to lock MUTEX, block until *ABSTIME if it is already held. As a GNU extension, if TIMESPEC is NULL then wait forever. */ int @@ -96,6 +89,9 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex, } } + if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)) + return EINVAL; + /* Add ourselves to the queue. */ __pthread_enqueue (&mutex->__queue, self); __pthread_spin_unlock (&mutex->__lock); @@ -146,3 +142,10 @@ __pthread_mutex_timedlock_internal (struct __pthread_mutex *mutex, return 0; } + +int +pthread_mutex_timedlock (struct __pthread_mutex *mutex, + const struct timespec *abstime) +{ + return __pthread_mutex_timedlock_internal (mutex, abstime); +} diff --git a/sysdeps/generic/pt-mutex-trylock.c b/sysdeps/generic/pt-mutex-trylock.c index 9457dda..6fdea1a 100644 --- a/sysdeps/generic/pt-mutex-trylock.c +++ b/sysdeps/generic/pt-mutex-trylock.c @@ -65,8 +65,9 @@ __pthread_mutex_trylock (struct __pthread_mutex *mutex) break; case PTHREAD_MUTEX_ERRORCHECK: - if (mutex->owner == self) - err = EDEADLK; + /* We could check if MUTEX->OWNER is SELF, however, POSIX + does not permit pthread_mutex_trylock to return EDEADLK + instead of EBUSY, only pthread_mutex_lock. */ break; case PTHREAD_MUTEX_RECURSIVE: diff --git a/sysdeps/generic/pt-rwlock-init.c b/sysdeps/generic/pt-rwlock-init.c index 8fe8764..d6c8c1a 100644 --- a/sysdeps/generic/pt-rwlock-init.c +++ b/sysdeps/generic/pt-rwlock-init.c @@ -1,5 +1,5 @@ /* Initialize a rwlock. Generic version. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 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 @@ -18,13 +18,27 @@ Boston, MA 02111-1307, USA. */ #include +#include #include int _pthread_rwlock_init (pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr) { - *rwlock = __PTHREAD_RWLOCK_INITIALIZER; + *rwlock = (pthread_rwlock_t) __PTHREAD_RWLOCK_INITIALIZER; + + if (! attr + || memcmp (attr, &__pthread_default_rwlockattr, sizeof (*attr) == 0)) + /* Use the default attributes. */ + return 0; + + /* Non-default attributes. */ + + rwlock->__attr = malloc (sizeof *attr); + if (! rwlock->__attr) + return ENOMEM; + + *rwlock->__attr = *attr; return 0; } diff --git a/sysdeps/generic/pt-rwlock-rdlock.c b/sysdeps/generic/pt-rwlock-rdlock.c index 22c1120..480cf48 100644 --- a/sysdeps/generic/pt-rwlock-rdlock.c +++ b/sysdeps/generic/pt-rwlock-rdlock.c @@ -1,5 +1,5 @@ /* Acquire a rwlock for reading. Generic version. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 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 @@ -21,7 +21,7 @@ #include /* Implemented in pt-rwlock-timedrdlock.c. */ -extern int __pthread_rwlock_timedrdlock_internal (struct __pthread_mutex *mutex, +extern int __pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *rwlock, const struct timespec *abstime); /* Acquire RWLOCK for reading, block if we can't get it. */ diff --git a/sysdeps/generic/pt-rwlock-timedrdlock.c b/sysdeps/generic/pt-rwlock-timedrdlock.c index 85cb946..ba610fa 100644 --- a/sysdeps/generic/pt-rwlock-timedrdlock.c +++ b/sysdeps/generic/pt-rwlock-timedrdlock.c @@ -1,5 +1,5 @@ /* Acquire a rwlock for reading. Generic version. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 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 @@ -22,13 +22,6 @@ #include -int -pthread_rwlock_timedrdlock (struct __pthread_rwlock *rwlock, - const struct timespec *abstime) -{ - return __pthread_rwlock_timedrdlock_internal (rwlock, abstime); -} - /* Acquire the rwlock *RWLOCK for reading blocking until *ABSTIME if it is already held. As a GNU extension, if TIMESPEC is NULL then wait forever. */ @@ -66,6 +59,9 @@ __pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *rwlock, /* Better be blocked by a writer. */ assert (rwlock->readers == 0); + if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)) + return EINVAL; + self = _pthread_self (); /* Add ourself to the queue. */ @@ -108,3 +104,10 @@ __pthread_rwlock_timedrdlock_internal (struct __pthread_rwlock *rwlock, return 0; } + +int +pthread_rwlock_timedrdlock (struct __pthread_rwlock *rwlock, + const struct timespec *abstime) +{ + return __pthread_rwlock_timedrdlock_internal (rwlock, abstime); +} diff --git a/sysdeps/generic/pt-rwlock-timedwrlock.c b/sysdeps/generic/pt-rwlock-timedwrlock.c index edf6413..04eab51 100644 --- a/sysdeps/generic/pt-rwlock-timedwrlock.c +++ b/sysdeps/generic/pt-rwlock-timedwrlock.c @@ -1,5 +1,5 @@ /* Acquire a rwlock for writing. Generic version. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 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 @@ -22,13 +22,6 @@ #include -int -pthread_rwlock_timedwrlock (struct __pthread_rwlock *rwlock, - const struct timespec *abstime) -{ - return __pthread_rwlock_timedwrlock_internal (rwlock, abstime); -} - /* Acquire RWLOCK for writing blocking until *ABSTIME if we cannot get it. As a special GNU extension, if ABSTIME is NULL then the wait shall not time out. */ @@ -52,6 +45,9 @@ __pthread_rwlock_timedwrlock_internal (struct __pthread_rwlock *rwlock, /* The lock is busy. */ + if (abstime && (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)) + return EINVAL; + self = _pthread_self (); /* Add ourselves to the queue. */ @@ -90,3 +86,10 @@ __pthread_rwlock_timedwrlock_internal (struct __pthread_rwlock *rwlock, return 0; } + +int +pthread_rwlock_timedwrlock (struct __pthread_rwlock *rwlock, + const struct timespec *abstime) +{ + return __pthread_rwlock_timedwrlock_internal (rwlock, abstime); +} diff --git a/sysdeps/generic/sem-timedwait.c b/sysdeps/generic/sem-timedwait.c index f3d280b..0c52111 100644 --- a/sysdeps/generic/sem-timedwait.c +++ b/sysdeps/generic/sem-timedwait.c @@ -39,6 +39,12 @@ __sem_timedwait_internal (sem_t *restrict sem, return 0; } + if (timeout && (timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000)) + { + errno = EINVAL; + return -1; + } + /* Add ourselves to the queue. */ self = _pthread_self (); @@ -50,12 +56,6 @@ __sem_timedwait_internal (sem_t *restrict sem, { error_t err; - if (timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000) - { - errno = EINVAL; - return -1; - } - err = __pthread_timedblock (self, timeout); if (err) /* We timed out. We may need to disconnect ourself from the diff --git a/sysdeps/i386/bits/spin-lock.h b/sysdeps/i386/bits/spin-lock.h index 3176a15..e86bc13 100644 --- a/sysdeps/i386/bits/spin-lock.h +++ b/sysdeps/i386/bits/spin-lock.h @@ -1,5 +1,5 @@ /* Machine-specific definitions for spin locks. i386 version. - Copyright (C) 2000 Free Software Foundation, Inc. + Copyright (C) 2000, 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 @@ -32,7 +32,7 @@ __BEGIN_DECLS typedef __volatile int __pthread_spinlock_t; /* Initializer for a spin lock object. */ -# define __SPIN_LOCK_INITIALIZER ((__pthread_spinlock_t) 0) +# define __SPIN_LOCK_INITIALIZER (0) #if defined __USE_EXTERN_INLINES || defined _FORCE_INLINES diff --git a/sysdeps/mach/hurd/i386/pt-setup.c b/sysdeps/mach/hurd/i386/pt-setup.c index 9a85584..32ace6a 100644 --- a/sysdeps/mach/hurd/i386/pt-setup.c +++ b/sysdeps/mach/hurd/i386/pt-setup.c @@ -1,5 +1,5 @@ /* Setup thread stack. Hurd/i386 version. - Copyright (C) 2000, 2002 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 @@ -58,7 +58,7 @@ stack_setup (struct __pthread *thread, top -= __hurd_threadvar_max; /* Save the self pointer. */ - top[_HURD_THREADVAR_THREAD] = thread; + top[_HURD_THREADVAR_THREAD] = (void *) thread; if (start_routine) { diff --git a/sysdeps/mach/pt-timedblock.c b/sysdeps/mach/pt-timedblock.c index 6324ae7..ddb8bae 100644 --- a/sysdeps/mach/pt-timedblock.c +++ b/sysdeps/mach/pt-timedblock.c @@ -1,5 +1,5 @@ /* Block a thread with a timeout. Mach 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 @@ -34,7 +34,7 @@ __pthread_timedblock (struct __pthread *thread, { error_t err; mach_msg_header_t msg; - mach_msg_timeout_t ms; + mach_msg_timeout_t timeout; struct timeval now; /* We have an absolute time and now we have to convert it to a @@ -43,15 +43,23 @@ __pthread_timedblock (struct __pthread *thread, err = gettimeofday(&now, NULL); assert (! err); - ms = abstime->tv_sec * 1000 + (abstime->tv_nsec + 999999) / 1000000 - - now.tv_sec * 1000 - (now.tv_usec + 999) / 1000; - - if (ms <= 0) + if (now.tv_sec > abstime->tv_sec + || (now.tv_sec == abstime->tv_sec + && now.tv_usec > ((abstime->tv_nsec + 999) / 1000))) return ETIMEDOUT; + timeout = (abstime->tv_sec - now.tv_sec) * 1000; + + if (((abstime->tv_nsec + 999) / 1000) >= now.tv_usec) + timeout -= (((abstime->tv_nsec + 999) / 1000) - now.tv_usec + 999) / 1000; + else + /* Need to do a carry. */ + timeout -= 1000 + ((abstime->tv_nsec + 999999) / 1000000) + - (now.tv_usec + 999) / 1000; + err = __mach_msg (&msg, MACH_RCV_MSG | MACH_RCV_TIMEOUT, 0, sizeof msg, thread->wakeupmsg.msgh_remote_port, - ms, MACH_PORT_NULL); + timeout, MACH_PORT_NULL); if (err == EMACH_RCV_TIMED_OUT) return ETIMEDOUT; diff --git a/tests/test-1.c b/tests/test-1.c index 86c7c97..318fd6e 100644 --- a/tests/test-1.c +++ b/tests/test-1.c @@ -27,7 +27,7 @@ main (int argc, char **argv) for (i = 0; i < THREADS; i ++) { - mutex[i] = PTHREAD_MUTEX_INITIALIZER; + pthread_mutex_init (&mutex[i], 0); pthread_mutex_lock (&mutex[i]); err = pthread_create (&tid[i], 0, foo, &mutex[i]); if (err) -- cgit v1.2.3 From ad327ba4bdcccdfaccde64ba4852220ec99d7b79 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Tue, 17 May 2005 09:40:51 +0000 Subject: libpthread/ 2005-05-17 Neal H. Walfield * include/pthread/pthread.h: Define __need_clockid_t before including . --- ChangeLog | 5 +++++ include/pthread/pthread.h | 1 + 2 files changed, 6 insertions(+) (limited to 'include/pthread/pthread.h') diff --git a/ChangeLog b/ChangeLog index 998ece5..3de3f47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-05-17 Neal H. Walfield + + * include/pthread/pthread.h: Define __need_clockid_t before + including . + 2005-05-12 Neal H. Walfield * include/pthread/pthread.h (pthread_exit): Add noreturn diff --git a/include/pthread/pthread.h b/include/pthread/pthread.h index 3e69cd7..23a5ff4 100644 --- a/include/pthread/pthread.h +++ b/include/pthread/pthread.h @@ -26,6 +26,7 @@ #include #include +#define __need_clockid_t #include __BEGIN_DECLS -- cgit v1.2.3 From 8e18e678afebb38e4208680ae7d7d23172116b41 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Tue, 31 May 2005 17:34:36 +0000 Subject: libpthread/ 2005-05-31 Neal H. Walfield * include/pthread/pthread.h: If clockid_t is still not defined after including , define it manually. --- ChangeLog | 5 +++++ include/pthread/pthread.h | 10 ++++++++++ 2 files changed, 15 insertions(+) (limited to 'include/pthread/pthread.h') diff --git a/ChangeLog b/ChangeLog index 3de3f47..98fcfc9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-05-31 Neal H. Walfield + + * include/pthread/pthread.h: If clockid_t is still not defined + after including , define it manually. + 2005-05-17 Neal H. Walfield * include/pthread/pthread.h: Define __need_clockid_t before diff --git a/include/pthread/pthread.h b/include/pthread/pthread.h index 23a5ff4..891ed32 100644 --- a/include/pthread/pthread.h +++ b/include/pthread/pthread.h @@ -29,6 +29,16 @@ #define __need_clockid_t #include +/* If we are in a mode where clockid_t is not automatically defined + and another header has already included then defining + __need_clockid_t was not enough. */ +#ifndef __clockid_t_defined +# define __clockid_t_defined 1 +# include +/* Clock ID used in clock and timer functions. */ +typedef __clockid_t clockid_t; +#endif + __BEGIN_DECLS #include -- cgit v1.2.3 From 0924954a436fe55698686e4c750e777fb058ad25 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 4 Mar 2007 00:05:21 +0000 Subject: 2006-03-04 Samuel Thibault * libpthread/include/pthread/pthread.h: Add the restrict keyword where appropriate for full compliance. * libpthread/pthread/pt-internal.h: Likewise. * libpthread/sysdeps/generic/bits/mutex.h: Likewise. * libpthread/sysdeps/generic/bits/rwlock.h: Likewise. * libpthread/TODO: Drop that TODO item. --- TODO | 1 - include/pthread/pthread.h | 127 +++++++++++++++++++++--------------------- pthread/pt-internal.h | 20 ++++--- sysdeps/generic/bits/mutex.h | 4 +- sysdeps/generic/bits/rwlock.h | 4 +- 5 files changed, 79 insertions(+), 77 deletions(-) (limited to 'include/pthread/pthread.h') diff --git a/TODO b/TODO index 5f35b67..30ca19c 100644 --- a/TODO +++ b/TODO @@ -5,7 +5,6 @@ pthread_kill and pthread_sigmask are defined in and not as they should be. Once we are compiled with glibc, this should be eaiser. -** Must add the restrict keyword where appropriate for full compliance. * Test cases. Can never have enough. diff --git a/include/pthread/pthread.h b/include/pthread/pthread.h index 891ed32..21a9b51 100644 --- a/include/pthread/pthread.h +++ b/include/pthread/pthread.h @@ -96,8 +96,8 @@ extern int pthread_attr_destroy (pthread_attr_t *attr); /* Return the value of the inheritsched attribute in *ATTR in *INHERITSCHED. */ -extern int pthread_attr_getinheritsched (const pthread_attr_t *attr, - int *inheritsched); +extern int pthread_attr_getinheritsched (const pthread_attr_t *__restrict attr, + int *__restrict inheritsched); /* Set the value of the inheritsched attribute in *ATTR to INHERITSCHED. */ @@ -106,17 +106,17 @@ extern int pthread_attr_setinheritsched (pthread_attr_t *attr, /* Return the value of the schedparam attribute in *ATTR in *PARAM. */ -extern int pthread_attr_getschedparam (const pthread_attr_t *attr, - struct sched_param *param); +extern int pthread_attr_getschedparam (const pthread_attr_t *__restrict attr, + struct sched_param *__restrict param); /* Set the value of the schedparam attribute in *ATTR to PARAM. */ -extern int pthread_attr_setschedparam (pthread_attr_t *attr, - const struct sched_param *param); +extern int pthread_attr_setschedparam (pthread_attr_t *__restrict attr, + const struct sched_param *__restrict param); /* Return the value of the schedpolicy attribute in *ATTR to *POLICY. */ -extern int pthread_attr_getschedpolicy (const pthread_attr_t *attr, - int *policy); +extern int pthread_attr_getschedpolicy (const pthread_attr_t *__restrict attr, + int *__restrict policy); /* Set the value of the schedpolicy attribute in *ATTR to POLICY. */ extern int pthread_attr_setschedpolicy (pthread_attr_t *attr, @@ -125,8 +125,8 @@ extern int pthread_attr_setschedpolicy (pthread_attr_t *attr, /* Return the value of the contentionscope attribute in *ATTR in *CONTENTIONSCOPE. */ -extern int pthread_attr_getscope (const pthread_attr_t *attr, - int *contentionscope); +extern int pthread_attr_getscope (const pthread_attr_t *__restrict attr, + int *__restrict contentionscope); /* Set the value of the contentionscope attribute in *ATTR to CONTENTIONSCOPE. */ @@ -136,8 +136,8 @@ extern int pthread_attr_setscope (pthread_attr_t *attr, /* Return the value of the stackaddr attribute in *ATTR in *STACKADDR. */ -extern int pthread_attr_getstackaddr (const pthread_attr_t *attr, - void **stackaddr); +extern int pthread_attr_getstackaddr (const pthread_attr_t *__restrict attr, + void **__restrict stackaddr); /* Set the value of the stackaddr attribute in *ATTR to STACKADDR. */ extern int pthread_attr_setstackaddr (pthread_attr_t *attr, @@ -146,9 +146,9 @@ extern int pthread_attr_setstackaddr (pthread_attr_t *attr, /* Return the value of the stackaddr and stacksize attributes in *ATTR in *STACKADDR and *STACKSIZE respectively. */ -extern int pthread_attr_getstack (const pthread_attr_t *attr, - void **stackaddr, - size_t *stacksize); +extern int pthread_attr_getstack (const pthread_attr_t *__restrict attr, + void **__restrict stackaddr, + size_t *__restrict stacksize); /* Set the value of the stackaddr and stacksize attributes in *ATTR to STACKADDR and STACKSIZE respectively. */ @@ -170,8 +170,8 @@ extern int pthread_attr_setdetachstate (pthread_attr_t *attr, /* Return the value of the guardsize attribute in *ATTR in *GUARDSIZE. */ -extern int pthread_attr_getguardsize (const pthread_attr_t *attr, - size_t *guardsize); +extern int pthread_attr_getguardsize (const pthread_attr_t *__restrict attr, + size_t *__restrict guardsize); /* Set the value of the guardsize attribute in *ATTR to GUARDSIZE. */ extern int pthread_attr_setguardsize (pthread_attr_t *attr, @@ -180,8 +180,8 @@ extern int pthread_attr_setguardsize (pthread_attr_t *attr, /* Return the value of the stacksize attribute in *ATTR in *STACKSIZE. */ -extern int pthread_attr_getstacksize (const pthread_attr_t *attr, - size_t *stacksize); +extern int pthread_attr_getstacksize (const pthread_attr_t *__restrict attr, + size_t *__restrict stacksize); /* Set the value of the stacksize attribute in *ATTR to STACKSIZE. */ extern int pthread_attr_setstacksize (pthread_attr_t *attr, @@ -190,9 +190,10 @@ extern int pthread_attr_setstacksize (pthread_attr_t *attr, /* Create a thread with attributes given by ATTR, executing START_ROUTINE with argument ARG. */ -extern int pthread_create (pthread_t *__threadp, - __const pthread_attr_t *__attr, - void *(*__start_routine)(void *), void *__arg); +extern int pthread_create (pthread_t *__restrict __threadp, + __const pthread_attr_t *__restrict __attr, + void *(*__start_routine)(void *), + void *__restrict __arg); /* Terminate the current thread and make STATUS available to any thread that might join us. */ @@ -251,8 +252,8 @@ extern int pthread_mutexattr_destroy(pthread_mutexattr_t *attr); /* Return the value of the prioceiling attribute in *ATTR in *PRIOCEILING. */ -extern int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *attr, - int *prioceiling); +extern int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *__restrict attr, + int *__restrict prioceiling); /* Set the value of the prioceiling attribute in *ATTR to PRIOCEILING. */ @@ -262,8 +263,8 @@ extern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *attr, /* Return the value of the protocol attribute in *ATTR in *PROTOCOL. */ -extern int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *attr, - int *protocol); +extern int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *__restrict attr, + int *__restrict protocol); /* Set the value of the protocol attribute in *ATTR to PROTOCOL. */ extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, @@ -272,8 +273,8 @@ extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, /* Return the value of the process shared attribute in *ATTR in *PSHARED. */ -extern int pthread_mutexattr_getpshared(const pthread_mutexattr_t *attr, - int *pshared); +extern int pthread_mutexattr_getpshared(const pthread_mutexattr_t *__restrict attr, + int *__restrict pshared); /* Set the value of the process shared attribute in *ATTR to PSHARED. */ @@ -282,8 +283,8 @@ extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, /* Return the value of the type attribute in *ATTR in *TYPE. */ -extern int pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, - int *type); +extern int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict attr, + int *__restrict type); /* Set the value of the type attribute in *ATTR to TYPE. */ extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, @@ -300,8 +301,8 @@ typedef struct __pthread_mutex pthread_mutex_t; /* Create a mutex with attributes given by ATTR and store it in *__MUTEX. */ -extern int pthread_mutex_init (struct __pthread_mutex *__mutex, - const pthread_mutexattr_t *attr); +extern int pthread_mutex_init (struct __pthread_mutex *__restrict __mutex, + const pthread_mutexattr_t *__restrict attr); /* Destroy the mutex __MUTEX. */ extern int pthread_mutex_destroy (struct __pthread_mutex *__mutex); @@ -313,22 +314,22 @@ extern int pthread_mutex_lock (pthread_mutex_t *__mutex); extern int pthread_mutex_trylock (pthread_mutex_t *__mutex); /* Try to lock MUTEX, block until *ABSTIME if it is already held. */ -extern int pthread_mutex_timedlock (struct __pthread_mutex *mutex, - const struct timespec *abstime); +extern int pthread_mutex_timedlock (struct __pthread_mutex *__restrict mutex, + const struct timespec *__restrict abstime); /* Unlock MUTEX. */ extern int pthread_mutex_unlock (pthread_mutex_t *__mutex); /* Return the priority ceiling of mutex *MUTEX in *PRIOCEILING. */ -extern int pthread_mutex_getprioceiling (const pthread_mutex_t *mutex, - int *prioceiling); +extern int pthread_mutex_getprioceiling (const pthread_mutex_t *__restrict mutex, + int *__restrict prioceiling); /* After acquiring the mutex *MUTEX, set its priority ceiling to PRIO and return the old priority ceiling in *OLDPRIO. Before returning, release the mutex. */ -extern int pthread_mutex_setprioceiling (pthread_mutex_t *mutex, int prio, - int *oldprio); +extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict mutex, + int prio, int *__restrict oldprio); @@ -347,8 +348,8 @@ extern int pthread_condattr_destroy (pthread_condattr_t *attr); /* Return the value of the clock attribute in *ATTR in *CLOCK_ID. */ -extern int pthread_condattr_getclock (const pthread_condattr_t *attr, - clockid_t *clock_id); +extern int pthread_condattr_getclock (const pthread_condattr_t *__restrict attr, + clockid_t *__restrict clock_id); /* Set the value of the clock attribute in *ATTR to CLOCK_ID. */ extern int pthread_condattr_setclock (pthread_condattr_t *attr, @@ -357,8 +358,8 @@ extern int pthread_condattr_setclock (pthread_condattr_t *attr, /* Return the value of the process shared attribute in *ATTR in *PSHARED. */ -extern int pthread_condattr_getpshared (const pthread_condattr_t *attr, - int *pshared); +extern int pthread_condattr_getpshared (const pthread_condattr_t *__restrict attr, + int *__restrict pshared); /* Set the value of the process shared attribute in *ATTR to PSHARED. */ @@ -374,8 +375,8 @@ typedef struct __pthread_cond pthread_cond_t; #define PTHREAD_COND_INITIALIZER __PTHREAD_COND_INITIALIZER -extern int pthread_cond_init (pthread_cond_t *cond, - const pthread_condattr_t *attr); +extern int pthread_cond_init (pthread_cond_t *__restrict cond, + const pthread_condattr_t *__restrict attr); extern int pthread_cond_destroy (pthread_cond_t *cond); @@ -389,16 +390,16 @@ extern int pthread_cond_broadcast (pthread_cond_t *__cond); /* Block on condition variable COND. MUTEX should be held by the calling thread. On success, MUTEX will be held by the calling thread. */ -extern int pthread_cond_wait (pthread_cond_t *__cond, - pthread_mutex_t *__mutex); +extern int pthread_cond_wait (pthread_cond_t *__restrict __cond, + pthread_mutex_t *__restrict __mutex); /* Block on condition variable COND. MUTEX should be held by the calling thread. On success, MUTEX will be held by the calling thread. If the time specified by ABSTIME passes, ETIMEDOUT is returned, and MUTEX will nevertheless be held. */ -extern int pthread_cond_timedwait (pthread_cond_t *__cond, - pthread_mutex_t *__mutex, - __const struct timespec *__abstime); +extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond, + pthread_mutex_t *__restrict __mutex, + __const struct timespec *__restrict __abstime); /* Spin locks. */ @@ -482,8 +483,8 @@ extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *attr); /* Return the value of the process shared attribute in *ATTR in *PSHARED. */ -extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *attr, - int *pshared); +extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *__restrict attr, + int *__restrict pshared); /* Set the value of the process shared atrribute in *ATTR to PSHARED. */ @@ -499,8 +500,8 @@ typedef struct __pthread_rwlock pthread_rwlock_t; /* Create a rwlock object with attributes given by ATTR and strore the result in *RWLOCK. */ -extern int pthread_rwlock_init (pthread_rwlock_t *rwlock, - const pthread_rwlockattr_t *attr); +extern int pthread_rwlock_init (pthread_rwlock_t *__restrict rwlock, + const pthread_rwlockattr_t *__restrict attr); /* Destroy the rwlock *RWLOCK. */ extern int pthread_rwlock_destroy (pthread_rwlock_t *rwlock); @@ -513,8 +514,8 @@ extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock); /* Acquire the rwlock *RWLOCK for reading blocking until *ABSTIME if it is already held. */ -extern int pthread_rwlock_timedrdlock (struct __pthread_rwlock *rwlock, - const struct timespec *abstime); +extern int pthread_rwlock_timedrdlock (struct __pthread_rwlock *__restrict rwlock, + const struct timespec *__restrict abstime); /* Acquire the rwlock *RWLOCK for writing. */ extern int pthread_rwlock_wrlock (pthread_rwlock_t *rwlock); @@ -524,8 +525,8 @@ extern int pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock); /* Acquire the rwlock *RWLOCK for writing blocking until *ABSTIME if it is already held. */ -extern int pthread_rwlock_timedwrlock (struct __pthread_rwlock *rwlock, - const struct timespec *abstime); +extern int pthread_rwlock_timedwrlock (struct __pthread_rwlock *__restrict rwlock, + const struct timespec *__restrict abstime); /* Release the lock held by the current thread on *RWLOCK. */ extern int pthread_rwlock_unlock (pthread_rwlock_t *rwlock); @@ -582,8 +583,8 @@ extern int pthread_barrierattr_destroy (pthread_barrierattr_t *attr); /* Return the value of the process shared attribute in *ATTR in *PSHARED. */ -extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *attr, - int *pshared); +extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *__restrict attr, + int *__restrict pshared); /* Set the value of the process shared atrribute in *ATTR to PSHARED. */ @@ -602,8 +603,8 @@ typedef struct __pthread_barrier pthread_barrier_t; #define PTHREAD_BARRIER_SERIAL_THREAD -1 /* Initialize barrier BARRIER. */ -extern int pthread_barrier_init (pthread_barrier_t *barrier, - const pthread_barrierattr_t *attr, +extern int pthread_barrier_init (pthread_barrier_t *__restrict barrier, + const pthread_barrierattr_t *__restrict attr, unsigned count); /* Destroy barrier BARRIER. */ @@ -687,8 +688,8 @@ extern int pthread_getcpuclockid (pthread_t thread, clockid_t *clock); /* Scheduling. */ /* Return thread THREAD's scheduling paramters. */ -extern int pthread_getschedparam (pthread_t thread, int *policy, - struct sched_param *param); +extern int pthread_getschedparam (pthread_t thread, int *__restrict policy, + struct sched_param *__restrict param); /* Set thread THREAD's scheduling paramters. */ extern int pthread_setschedparam (pthread_t thread, int policy, diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index e908695..efd4ffb 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -165,10 +165,10 @@ extern void __pthread_initialize (void); /* Internal version of pthread_create. Rather than return the new tid, we return the whole __pthread structure in *PTHREAD. */ -extern int __pthread_create_internal (struct __pthread **pthread, - const pthread_attr_t *attr, +extern int __pthread_create_internal (struct __pthread **__restrict pthread, + const pthread_attr_t *__restrict attr, void *(*start_routine)(void *), - void *arg); + void *__restrict arg); /* Allocate a new thread structure and a pthread thread ID (but not a kernel thread or a stack). */ @@ -189,10 +189,11 @@ extern void __pthread_stack_dealloc (void *stackaddr, size_t stacksize); /* Setup thread THREAD's context. */ -extern int __pthread_setup (struct __pthread *thread, +extern int __pthread_setup (struct __pthread *__restrict thread, void (*entry_point)(void *(*)(void *), void *), - void *(*start_routine)(void *), void *arg); + void *(*start_routine)(void *), + void *__restrict arg); /* Allocate a kernel thread (and any miscellaneous system dependent @@ -221,8 +222,8 @@ extern void __pthread_thread_halt (struct __pthread *thread, extern void __pthread_block (struct __pthread *thread); /* Block THREAD until *ABSTIME is reached. */ -extern error_t __pthread_timedblock (struct __pthread *thread, - const struct timespec *abstime); +extern error_t __pthread_timedblock (struct __pthread *__restrict thread, + const struct timespec *__restrict abstime); /* Wakeup THREAD. */ extern void __pthread_wakeup (struct __pthread *thread); @@ -250,8 +251,9 @@ extern error_t __pthread_sigstate_init (struct __pthread *thread); extern void __pthread_sigstate_destroy (struct __pthread *thread); /* Modify thread *THREAD's signal state. */ -extern error_t __pthread_sigstate (struct __pthread *thread, int how, - const sigset_t *set, sigset_t *oset, +extern error_t __pthread_sigstate (struct __pthread *__restrict thread, int how, + const sigset_t *__restrict set, + sigset_t *__restrict oset, int clear_pending); diff --git a/sysdeps/generic/bits/mutex.h b/sysdeps/generic/bits/mutex.h index 2e32d78..feb6d07 100644 --- a/sysdeps/generic/bits/mutex.h +++ b/sysdeps/generic/bits/mutex.h @@ -69,8 +69,8 @@ struct __pthread_mutex # endif _EXTERN_INLINE int -pthread_mutex_init (struct __pthread_mutex *__mutex, - const pthread_mutexattr_t *attr) +pthread_mutex_init (struct __pthread_mutex *__restrict __mutex, + const pthread_mutexattr_t *__restrict attr) { struct __pthread_mutex initialized_mutex = __PTHREAD_MUTEX_INITIALIZER; diff --git a/sysdeps/generic/bits/rwlock.h b/sysdeps/generic/bits/rwlock.h index 5793f65..fc429b4 100644 --- a/sysdeps/generic/bits/rwlock.h +++ b/sysdeps/generic/bits/rwlock.h @@ -44,8 +44,8 @@ struct __pthread_rwlock _EXTERN_INLINE int -pthread_rwlock_init (struct __pthread_rwlock *__rwlock, - const struct __pthread_rwlockattr *__attr) +pthread_rwlock_init (struct __pthread_rwlock *__restrict __rwlock, + const struct __pthread_rwlockattr *__restrict __attr) { struct __pthread_rwlock initialized_rwlock = __PTHREAD_RWLOCK_INITIALIZER; extern int _pthread_rwlock_init (struct __pthread_rwlock *, -- cgit v1.2.3 From 0b48c1e5d1764b5970faa0abeb101f377c3f441c Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 24 Jun 2007 15:11:52 +0000 Subject: 2007-06-24 Samuel Thibault * include/semaphore.h (sem_timedwait): Declare only if __USE_XOPEN2K is defined. * include/pthread/pthread.h (pthread_attr_getstack) (pthread_attr_setstack, pthread_mutex_timedlock) (pthread_condattr_getclock, pthread_condattr_setclock) (pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock) (pthread_barrierattr_t, pthread_barrierattr_init) (pthread_barrierattr_destroy, pthread_barrierattr_getpshared) (pthread_barrierattr_setpshared, pthread_barrier_t) (PTHREAD_BARRIER_SERIAL_THREAD, pthread_barrier_init) (pthread_barrier_destroy, pthread_barrier_wait) (pthread_getcpuclockid): Declare only if __USE_XOPEN2K is defined. (pthread_mutexattr_getprioceiling, pthread_mutexattr_setprioceiling) (pthread_mutexattr_getprotocol, pthread_mutexattr_setprotocol) (pthread_mutexattr_gettype, pthread_mutexattr_settype) (pthread_mutex_getprioceiling, pthread_mutex_setprioceiling) (pthread_setconcurrency, pthread_getconcurrency): Declare only if __USE_UNIX98 is defined. (pthread_rwlockattr_t, pthread_rwlockattr_init) (pthread_rwlockattr_destroy, pthread_rwlockattr_getpshared) (pthread_rwlockattr_setpshared, pthread_rwlock_t, pthread_rwlock_init) (pthread_rwlock_destroy, pthread_rwlock_rdlock) (pthread_rwlock_tryrdlock, pthread_rwlock_wrlock) (pthread_rwlock_trywrlock, pthread_rwlock_unlock): Declare only if __USE_UNIX98 or __USE_XOPEN2K are defined. (PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, PTHREAD_PRIO_PROTECT) (PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_ERRORCHECK) (PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_DEFAULT): Define only if __USE_UNIX98 is defined. (PTHREAD_MUTEX_FAST_NP): Define for compatibility when __USE_GNU is defined. * sysdeps/generic/bits/rwlock.h (pthread_rwlock_init) (pthread_rwlock_destroy): Declare only if __USE_UNIX98 or __USE_XOPEN2K are defined. * TODO: Drop that TODO item. --- ChangeLog | 38 +++++++++++++++++++++++++ TODO | 4 --- include/pthread/pthread.h | 66 ++++++++++++++++++++++++++++++++++--------- include/semaphore.h | 2 ++ sysdeps/generic/bits/rwlock.h | 2 ++ 5 files changed, 95 insertions(+), 17 deletions(-) (limited to 'include/pthread/pthread.h') diff --git a/ChangeLog b/ChangeLog index 1337286..94cfb57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,41 @@ +2007-06-24 Samuel Thibault + + * include/semaphore.h (sem_timedwait): Declare only if __USE_XOPEN2K + is defined. + * include/pthread/pthread.h (pthread_attr_getstack) + (pthread_attr_setstack, pthread_mutex_timedlock) + (pthread_condattr_getclock, pthread_condattr_setclock) + (pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock) + (pthread_barrierattr_t, pthread_barrierattr_init) + (pthread_barrierattr_destroy, pthread_barrierattr_getpshared) + (pthread_barrierattr_setpshared, pthread_barrier_t) + (PTHREAD_BARRIER_SERIAL_THREAD, pthread_barrier_init) + (pthread_barrier_destroy, pthread_barrier_wait) + (pthread_getcpuclockid): Declare only if __USE_XOPEN2K is defined. + (pthread_mutexattr_getprioceiling, pthread_mutexattr_setprioceiling) + (pthread_mutexattr_getprotocol, pthread_mutexattr_setprotocol) + (pthread_mutexattr_gettype, pthread_mutexattr_settype) + (pthread_mutex_getprioceiling, pthread_mutex_setprioceiling) + (pthread_setconcurrency, pthread_getconcurrency): Declare only if + __USE_UNIX98 is defined. + (pthread_rwlockattr_t, pthread_rwlockattr_init) + (pthread_rwlockattr_destroy, pthread_rwlockattr_getpshared) + (pthread_rwlockattr_setpshared, pthread_rwlock_t, pthread_rwlock_init) + (pthread_rwlock_destroy, pthread_rwlock_rdlock) + (pthread_rwlock_tryrdlock, pthread_rwlock_wrlock) + (pthread_rwlock_trywrlock, pthread_rwlock_unlock): Declare only if + __USE_UNIX98 or __USE_XOPEN2K are defined. + (PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, PTHREAD_PRIO_PROTECT) + (PTHREAD_MUTEX_NORMAL, PTHREAD_MUTEX_ERRORCHECK) + (PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_DEFAULT): + Define only if __USE_UNIX98 is defined. + (PTHREAD_MUTEX_FAST_NP): Define for compatibility when __USE_GNU is + defined. + * sysdeps/generic/bits/rwlock.h (pthread_rwlock_init) + (pthread_rwlock_destroy): Declare only if __USE_UNIX98 or + __USE_XOPEN2K are defined. + * TODO: Drop that TODO item. + 2006-03-04 Samuel Thibault * sysdeps/i386/machine-sp.h (thread_stack_pointer): diff --git a/TODO b/TODO index 30ca19c..45b4cdc 100644 --- a/TODO +++ b/TODO @@ -13,10 +13,6 @@ platforms. * Implementation details -** Feature test macros - This is most likely wrong. We need a standards expert to really - look over this or someone who can outline what I need to do. - ** pthread_atfork This cannot be implemented without either changing glibc to export some hooks (c.f. libc/sysdeps/mach/hurd/fork.c) or by providing a diff --git a/include/pthread/pthread.h b/include/pthread/pthread.h index 21a9b51..9875c47 100644 --- a/include/pthread/pthread.h +++ b/include/pthread/pthread.h @@ -144,6 +144,7 @@ extern int pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr); +#ifdef __USE_XOPEN2K /* Return the value of the stackaddr and stacksize attributes in *ATTR in *STACKADDR and *STACKSIZE respectively. */ extern int pthread_attr_getstack (const pthread_attr_t *__restrict attr, @@ -155,6 +156,7 @@ extern int pthread_attr_getstack (const pthread_attr_t *__restrict attr, extern int pthread_attr_setstack (pthread_attr_t *attr, void *stackaddr, size_t stacksize); +#endif /* Return the value of the detachstate attribute in *ATTR in @@ -219,23 +221,33 @@ extern pthread_t pthread_self (void); enum __pthread_mutex_protocol { - PTHREAD_PRIO_NONE = 0, -#define PTHREAD_PRIO_NONE 0 - PTHREAD_PRIO_INHERIT, -#define PTHREAD_PRIO_INHERIT 1 - PTHREAD_PRIO_PROTECT -#define PTHREAD_PRIO_PROTECT 2 + PTHREAD_PRIO_NONE_NP = 0, + PTHREAD_PRIO_INHERIT_NP, + PTHREAD_PRIO_PROTECT_NP +#ifdef __USE_UNIX98 + , + PTHREAD_PRIO_NONE = PTHREAD_PRIO_NONE_NP, + PTHREAD_PRIO_INHERIT = PTHREAD_PRIO_INHERIT_NP, + PTHREAD_PRIO_PROTECT = PTHREAD_PRIO_PROTECT_NP +#endif }; enum __pthread_mutex_type { - PTHREAD_MUTEX_NORMAL = 0, -#define PTHREAD_MUTEX_NORMAL 0 -#define PTHREAD_MUTEX_DEFAULT 0 - PTHREAD_MUTEX_ERRORCHECK, -#define PTHREAD_MUTEX_ERRORCHECK 1 - PTHREAD_MUTEX_RECURSIVE, -#define PTHREAD_MUTEX_RECURSIVE 2 + PTHREAD_MUTEX_TIMED_NP = 0, + PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_RECURSIVE_NP +#ifdef __USE_UNIX98 + , + PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP, + PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, + PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, + PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL +#endif +#ifdef __USE_GNU + /* For compatibility. */ + , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_TIMED_NP +#endif }; #include @@ -250,6 +262,7 @@ extern int pthread_mutexattr_init(pthread_mutexattr_t *attr); extern int pthread_mutexattr_destroy(pthread_mutexattr_t *attr); +#ifdef __USE_UNIX98 /* Return the value of the prioceiling attribute in *ATTR in *PRIOCEILING. */ extern int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *__restrict attr, @@ -269,6 +282,7 @@ extern int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *__restrict a /* Set the value of the protocol attribute in *ATTR to PROTOCOL. */ extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t *attr, int protocol); +#endif /* Return the value of the process shared attribute in *ATTR in @@ -282,6 +296,7 @@ extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared); +#ifdef __USE_UNIX98 /* Return the value of the type attribute in *ATTR in *TYPE. */ extern int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict attr, int *__restrict type); @@ -289,6 +304,7 @@ extern int pthread_mutexattr_gettype(const pthread_mutexattr_t *__restrict attr, /* Set the value of the type attribute in *ATTR to TYPE. */ extern int pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type); +#endif /* Mutexes. */ @@ -313,14 +329,17 @@ extern int pthread_mutex_lock (pthread_mutex_t *__mutex); /* Try to lock MUTEX. */ extern int pthread_mutex_trylock (pthread_mutex_t *__mutex); +#ifdef __USE_XOPEN2K /* Try to lock MUTEX, block until *ABSTIME if it is already held. */ extern int pthread_mutex_timedlock (struct __pthread_mutex *__restrict mutex, const struct timespec *__restrict abstime); +#endif /* Unlock MUTEX. */ extern int pthread_mutex_unlock (pthread_mutex_t *__mutex); +#ifdef __USE_UNIX98 /* Return the priority ceiling of mutex *MUTEX in *PRIOCEILING. */ extern int pthread_mutex_getprioceiling (const pthread_mutex_t *__restrict mutex, int *__restrict prioceiling); @@ -330,6 +349,7 @@ extern int pthread_mutex_getprioceiling (const pthread_mutex_t *__restrict mutex release the mutex. */ extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict mutex, int prio, int *__restrict oldprio); +#endif @@ -347,6 +367,7 @@ extern int pthread_condattr_init (pthread_condattr_t *attr); extern int pthread_condattr_destroy (pthread_condattr_t *attr); +#ifdef __USE_XOPEN2K /* Return the value of the clock attribute in *ATTR in *CLOCK_ID. */ extern int pthread_condattr_getclock (const pthread_condattr_t *__restrict attr, clockid_t *__restrict clock_id); @@ -354,6 +375,7 @@ extern int pthread_condattr_getclock (const pthread_condattr_t *__restrict attr, /* Set the value of the clock attribute in *ATTR to CLOCK_ID. */ extern int pthread_condattr_setclock (pthread_condattr_t *attr, clockid_t clock_id); +#endif /* Return the value of the process shared attribute in *ATTR in @@ -469,6 +491,8 @@ pthread_spin_unlock (pthread_spinlock_t *__lock) /* rwlock attributes. */ +#if defined __USE_UNIX98 || defined __USE_XOPEN2K + #include typedef struct __pthread_rwlockattr pthread_rwlockattr_t; @@ -512,10 +536,12 @@ extern int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock); /* Acquire the rwlock *RWLOCK for reading. */ extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock); +# ifdef __USE_XOPEN2K /* Acquire the rwlock *RWLOCK for reading blocking until *ABSTIME if it is already held. */ extern int pthread_rwlock_timedrdlock (struct __pthread_rwlock *__restrict rwlock, const struct timespec *__restrict abstime); +# endif /* Acquire the rwlock *RWLOCK for writing. */ extern int pthread_rwlock_wrlock (pthread_rwlock_t *rwlock); @@ -523,13 +549,18 @@ extern int pthread_rwlock_wrlock (pthread_rwlock_t *rwlock); /* Try to acquire the rwlock *RWLOCK for writing. */ extern int pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock); +# ifdef __USE_XOPEN2K /* Acquire the rwlock *RWLOCK for writing blocking until *ABSTIME if it is already held. */ extern int pthread_rwlock_timedwrlock (struct __pthread_rwlock *__restrict rwlock, const struct timespec *__restrict abstime); +# endif /* Release the lock held by the current thread on *RWLOCK. */ extern int pthread_rwlock_unlock (pthread_rwlock_t *rwlock); + +#endif /* __USE_UNIX98 || __USE_XOPEN2K */ + /* Cancelation. */ @@ -569,6 +600,8 @@ extern void pthread_testcancel (void); /* Barriers attributes. */ +#ifdef __USE_XOPEN2K + #include typedef struct __pthread_barrierattr pthread_barrierattr_t; @@ -612,6 +645,9 @@ extern int pthread_barrier_destroy (pthread_barrier_t *barrier); /* Wait on barrier BARRIER. */ extern int pthread_barrier_wait (pthread_barrier_t *barrier); + +#endif /* __USE_XOPEN2K */ + /* Thread specific data. */ @@ -653,11 +689,13 @@ extern int pthread_once (pthread_once_t *once_control, /* Concurrency. */ +#ifdef __USE_UNIX98 /* Set the desired concurrency level to NEW_LEVEL. */ extern int pthread_setconcurrency (int new_level); /* Get the current concurrency level. */ extern int pthread_getconcurrency (void); +#endif /* Forking. */ @@ -681,8 +719,10 @@ extern int pthread_kill (pthread_t thread, int signo); /* Time. */ +#ifdef __USE_XOPEN2K /* Return the thread cpu clock. */ extern int pthread_getcpuclockid (pthread_t thread, clockid_t *clock); +#endif /* Scheduling. */ diff --git a/include/semaphore.h b/include/semaphore.h index 8acb768..06c9e73 100644 --- a/include/semaphore.h +++ b/include/semaphore.h @@ -45,10 +45,12 @@ extern int sem_wait (sem_t *sem); without blocking. */ extern int sem_trywait (sem_t *sem); +#ifdef __USE_XOPEN2K /* Perform a down operation on semaphore *SEM but don't wait longer than TIMEOUT. */ extern int sem_timedwait (sem_t *__restrict sem, const struct timespec *__restrict timeout); +#endif /* Perform an up operation on semaphore *SEM. */ extern int sem_post (sem_t *sem); diff --git a/sysdeps/generic/bits/rwlock.h b/sysdeps/generic/bits/rwlock.h index fc429b4..5afc4a3 100644 --- a/sysdeps/generic/bits/rwlock.h +++ b/sysdeps/generic/bits/rwlock.h @@ -43,6 +43,7 @@ struct __pthread_rwlock { __SPIN_LOCK_INITIALIZER, __SPIN_LOCK_INITIALIZER, 0, 0, 0, 0, 0 } +#if defined __USE_UNIX98 || defined __USE_XOPEN2K _EXTERN_INLINE int pthread_rwlock_init (struct __pthread_rwlock *__restrict __rwlock, const struct __pthread_rwlockattr *__restrict __attr) @@ -69,5 +70,6 @@ pthread_rwlock_destroy (struct __pthread_rwlock *__rwlock) return 0; } +#endif #endif /* bits/rwlock.h */ -- cgit v1.2.3