From 81cb5487d08c59fca0190cf03a07bdf45fe90ea8 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Mon, 2 May 2005 22:00:34 +0000 Subject: libpthread/ 2005-05-02 Neal H. Walfield * pthread/pt-alloc.c (__pthread_alloc): Set the thread id to the table index plus one. * pthread/pt-internal.h (__pthread_getid): Index __pthread_threads using THREAD - 1, not THREAD. (__pthread_setid): Likewise. * pthread/pt-create.c (__pthread_create_internal): Likewise. * sysdeps/generic/pt-mutex-trylock.c (__pthread_mutex_trylock): When returning EBUSY, don't forget to first unlock MUTEX->__HELD. --- pthread/pt-internal.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'pthread/pt-internal.h') diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index a32345c..75631db 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -1,5 +1,5 @@ /* Internal defenitions for pthreads library. - 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 @@ -134,20 +134,23 @@ extern int __pthread_num_threads; /* Concurrency hint. */ extern int __pthread_concurrency; -/* Array of __pthread structures and its lock. */ +/* Array of __pthread structures and its lock. Indexed by the pthread + id minus one. (Why not just use the pthread id? Because some + brain-dead users of the pthread interface incorrectly assume that 0 + is an invalid pthread id.) */ extern struct __pthread **__pthread_threads; extern pthread_rwlock_t __pthread_threads_lock; #define __pthread_getid(thread) \ ({ struct __pthread *__t; \ pthread_rwlock_rdlock (&__pthread_threads_lock); \ - __t = __pthread_threads[thread]; \ + __t = __pthread_threads[thread - 1]; \ pthread_rwlock_unlock (&__pthread_threads_lock); \ __t; }) #define __pthread_setid(thread, pthread) \ pthread_rwlock_wrlock (&__pthread_threads_lock); \ - __pthread_threads[thread] = pthread; \ + __pthread_threads[thread - 1] = pthread; \ pthread_rwlock_unlock (&__pthread_threads_lock); /* Similar to pthread_self, but returns the thread descriptor instead -- cgit v1.2.3 From f19e83eb2a17d0e87b90a050e7550e1e6985196f Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Wed, 4 May 2005 16:04:06 +0000 Subject: libpthread/ 2005-05-04 Neal H. Walfield * Makefile (SRCS): Add pt-thread_dealloc.c. * sysdeps/mach/pt-thread-dealloc.c: New file. * pthread/pt-internal.h (__pthread_thread_dealloc): New declaration. (__pthread_thread_halt): Add parameter NEED_DEALLOC. Update callers. * sysdeps/mach/pt-thread-halt.c (__pthread_thread_halt): Respect new NEED_DEALLOC parameter. Move code which deallocates kernel resources from here ... * sysdeps/mach/pt-thread-dealloc.c (__pthread_thread_dealloc): ...to here. * pthread/pt-create.c (__pthread_create_internal): Call __pthread_thread_dealloc on failure. * pthread/pt-exit.c (pthread_exit): Call __pthread_thread_dealloc. * sysdeps/mach/pt-thread-alloc.c (create_wakeupmsg): Call __mach_port_destroy to deallocate the receive right. __mach_port_deallocate won't do it. * pthread/pt-detach.c (pthread_detach): Don't call __pthread_thread_halt a second time. * sysdeps/mach/hurd/pt-sysdep.c (_cthread_init_routine): Fix declaration. (init_routine): Update declaration and remove gratuitous cast. --- ChangeLog | 28 +++++++++++++++++++++++++++ Makefile | 3 ++- pthread/pt-create.c | 3 ++- pthread/pt-detach.c | 4 +--- pthread/pt-exit.c | 13 +++++++++---- pthread/pt-internal.h | 20 +++++++++++++++----- sysdeps/mach/hurd/pt-sysdep.c | 10 +++++----- sysdeps/mach/pt-thread-alloc.c | 9 +++++---- sysdeps/mach/pt-thread-dealloc.c | 41 ++++++++++++++++++++++++++++++++++++++++ sysdeps/mach/pt-thread-halt.c | 18 +++++++++++------- 10 files changed, 119 insertions(+), 30 deletions(-) create mode 100644 sysdeps/mach/pt-thread-dealloc.c (limited to 'pthread/pt-internal.h') diff --git a/ChangeLog b/ChangeLog index c398c1f..fd8455c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +2005-05-04 Neal H. Walfield + + * Makefile (SRCS): Add pt-thread_dealloc.c. + * sysdeps/mach/pt-thread-dealloc.c: New file. + * pthread/pt-internal.h (__pthread_thread_dealloc): New + declaration. + (__pthread_thread_halt): Add parameter NEED_DEALLOC. Update + callers. + * sysdeps/mach/pt-thread-halt.c (__pthread_thread_halt): Respect + new NEED_DEALLOC parameter. Move code which deallocates kernel + resources from here ... + * sysdeps/mach/pt-thread-dealloc.c (__pthread_thread_dealloc): + ...to here. + * pthread/pt-create.c (__pthread_create_internal): Call + __pthread_thread_dealloc on failure. + * pthread/pt-exit.c (pthread_exit): Call __pthread_thread_dealloc. + + * sysdeps/mach/pt-thread-alloc.c (create_wakeupmsg): Call + __mach_port_destroy to deallocate the receive right. + __mach_port_deallocate won't do it. + + * pthread/pt-detach.c (pthread_detach): Don't call + __pthread_thread_halt a second time. + + * sysdeps/mach/hurd/pt-sysdep.c (_cthread_init_routine): Fix + declaration. + (init_routine): Update declaration and remove gratuitous cast. + 2005-05-02 Neal H. Walfield * pthread/pt-alloc.c (__pthread_alloc): Set the thread id to the diff --git a/Makefile b/Makefile index 41ef081..041035a 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 1994,95,96,97,2000,02, 2004 Free Software Foundation, Inc. +# Copyright (C) 1994,95,96,97,2000,02, 2004, 2005 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -96,6 +96,7 @@ SRCS := pt-attr.c pt-attr-destroy.c pt-attr-getdetachstate.c \ \ pt-stack-alloc.c \ pt-thread-alloc.c \ + pt-thread-dealloc.c \ pt-thread-start.c \ pt-thread-halt.c \ \ diff --git a/pthread/pt-create.c b/pthread/pt-create.c index cf5b32d..bad5d83 100644 --- a/pthread/pt-create.c +++ b/pthread/pt-create.c @@ -192,7 +192,8 @@ __pthread_create_internal (struct __pthread **thread, failed_sigstate: __pthread_sigstate_destroy (pthread); failed_setup: - __pthread_thread_halt (pthread); + __pthread_thread_dealloc (pthread); + __pthread_thread_halt (pthread, 0); failed_thread_alloc: __pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize); pthread->stack = 0; diff --git a/pthread/pt-detach.c b/pthread/pt-detach.c index c22f6a0..42a8408 100644 --- a/pthread/pt-detach.c +++ b/pthread/pt-detach.c @@ -1,5 +1,5 @@ /* Detach a thread. - 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 @@ -58,8 +58,6 @@ pthread_detach (pthread_t thread) __pthread_mutex_unlock (&pthread->state_lock); - __pthread_thread_halt (pthread); - assert (pthread->stack); __pthread_stack_dealloc (pthread->stackaddr, pthread->stacksize); pthread->stack = 0; diff --git a/pthread/pt-exit.c b/pthread/pt-exit.c index fb9e97c..7484ffd 100644 --- a/pthread/pt-exit.c +++ b/pthread/pt-exit.c @@ -1,5 +1,5 @@ /* Thread termination. - 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 @@ -35,6 +35,7 @@ pthread_exit (void *status) struct __pthread *self = _pthread_self (); struct __pthread_cancelation_handler **handlers; int oldstate; + int need_dealloc; /* Run any cancelation handlers. According to POSIX, the cancellation cleanup handlers should be called with cancellation @@ -69,10 +70,13 @@ pthread_exit (void *status) if (self->cancel_state == PTHREAD_CANCEL_ENABLE && self->cancel_pending) status = PTHREAD_CANCELED; + __pthread_thread_dealloc (self); + switch (self->state) { default: - assert (! "This cannot happen!"); + assert (! "Consistency error: unexpected self->state"); + abort (); break; case PTHREAD_DETACHED: @@ -82,7 +86,7 @@ pthread_exit (void *status) deallocate our own stack. However, it will eventually be reused when this thread structure is recycled. */ __pthread_mutex_unlock (&self->state_lock); - __pthread_dealloc (self); + need_dealloc = 1; break; @@ -99,6 +103,7 @@ pthread_exit (void *status) waiting to join us. */ pthread_cond_broadcast (&self->state_cond); __pthread_mutex_unlock (&self->state_lock); + need_dealloc = 0; break; } @@ -108,7 +113,7 @@ pthread_exit (void *status) This means that before freeing any resources, such a thread should make sure that this thread is really halted. */ - __pthread_thread_halt (self); + __pthread_thread_halt (self, need_dealloc); /* NOTREACHED */ abort (); diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h index 75631db..e908695 100644 --- a/pthread/pt-internal.h +++ b/pthread/pt-internal.h @@ -195,16 +195,26 @@ extern int __pthread_setup (struct __pthread *thread, void *(*start_routine)(void *), void *arg); -/* Allocate a kernel thread for THREAD; it must not be placed on the - run queue. */ +/* Allocate a kernel thread (and any miscellaneous system dependent + resources) for THREAD; it must not be placed on the run queue. */ extern int __pthread_thread_alloc (struct __pthread *thread); +/* Deallocate any kernel resources associated with THREAD except don't + halt the thread itself. On return, the thread will be marked as + dead and __pthread_halt will be called. */ +extern void __pthread_thread_dealloc (struct __pthread *thread); + /* Start THREAD making it eligible to run. */ extern int __pthread_thread_start (struct __pthread *thread); -/* Stop thread thread and deallocate any kernel resources associated - with THREAD. */ -extern void __pthread_thread_halt (struct __pthread *thread); +/* Stop the kernel thread associated with THREAD. If NEED_DEALLOC is + true, the function must call __pthread_dealloc on THREAD. + + NB: The thread executing this function may be the thread which is + being halted, thus the last action should be halting the thread + itself. */ +extern void __pthread_thread_halt (struct __pthread *thread, + int need_dealloc); /* Block THREAD. */ diff --git a/sysdeps/mach/hurd/pt-sysdep.c b/sysdeps/mach/hurd/pt-sysdep.c index b42fe25..5e07006 100644 --- a/sysdeps/mach/hurd/pt-sysdep.c +++ b/sysdeps/mach/hurd/pt-sysdep.c @@ -1,5 +1,5 @@ /* System dependent pthreads code. Hurd 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 @@ -29,16 +29,16 @@ #include /* Forward. */ -static int init_routine (void); +static void *init_routine (void); /* OK, the name of this variable isn't really appropriate, but I don't want to change it yet. */ -int (*_cthread_init_routine)(void) = &init_routine; +void *(*_cthread_init_routine)(void) = &init_routine; /* This function is called from the Hurd-specific startup code. It should return a new stack pointer for the main thread. The caller will switch to this new stack before doing anything serious. */ -static int +static void * init_routine (void) { struct __pthread *thread; @@ -68,5 +68,5 @@ init_routine (void) = (__pthread_default_attr.stacksize - __hurd_threadvar_max * sizeof (uintptr_t)); - return (int) thread->mcontext.sp; + return thread->mcontext.sp; } diff --git a/sysdeps/mach/pt-thread-alloc.c b/sysdeps/mach/pt-thread-alloc.c index a191c71..1acba98 100644 --- a/sysdeps/mach/pt-thread-alloc.c +++ b/sysdeps/mach/pt-thread-alloc.c @@ -1,5 +1,5 @@ /* Start thread. 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 @@ -50,8 +50,8 @@ create_wakeupmsg (struct __pthread *thread) MACH_MSG_TYPE_MAKE_SEND); if (err) { - __mach_port_deallocate (__mach_task_self (), - thread->wakeupmsg.msgh_remote_port); + __mach_port_destroy (__mach_task_self (), + thread->wakeupmsg.msgh_remote_port); return EAGAIN; } @@ -86,7 +86,8 @@ __pthread_thread_alloc (struct __pthread *thread) { assert (__pthread_total == 0); thread->kernel_thread = __mach_thread_self (); - /* We implicitly hold a reference. */ + /* We implicitly hold a reference drop the one that we just + acquired. */ __mach_port_deallocate (__mach_task_self (), thread->kernel_thread); } else diff --git a/sysdeps/mach/pt-thread-dealloc.c b/sysdeps/mach/pt-thread-dealloc.c new file mode 100644 index 0000000..55d8c4d --- /dev/null +++ b/sysdeps/mach/pt-thread-dealloc.c @@ -0,0 +1,41 @@ +/* Deallocate the kernel thread resources. Mach version. + Copyright (C) 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 + modify it under the terms of the GNU Library General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with the GNU C Library; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include +#include +#include + +#include + +/* Deallocate any kernel resources associated with THREAD except don't + halt the thread itself. On return, the thread will be marked as + dead and __pthread_halt will be called. */ +void +__pthread_thread_dealloc (struct __pthread *thread) +{ + /* Why no assert? Easy. When Mach kills a task, it starts by + invalidating the task port and then terminating the threads one + by one. But while it is terminating them, they are still + eligible to be scheduled. Imagine we have two threads, one calls + exit, one calls pthread_exit. The second one may run this after + the mask port can been destroyed thus gratuitously triggering the + assert. */ + __mach_port_destroy (__mach_task_self (), + thread->wakeupmsg.msgh_remote_port); +} diff --git a/sysdeps/mach/pt-thread-halt.c b/sysdeps/mach/pt-thread-halt.c index 84e6ac8..9f86024 100644 --- a/sysdeps/mach/pt-thread-halt.c +++ b/sysdeps/mach/pt-thread-halt.c @@ -1,5 +1,5 @@ /* Deallocate the kernel thread resources. 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 @@ -23,17 +23,21 @@ #include +/* Stop the kernel thread associated with THREAD. If NEED_DEALLOC is + true, the function must call __pthread_dealloc on THREAD. -/* Deallocate the kernel thread resources associated with THREAD. */ + NB: The thread executing this function may be the thread which is + being halted, thus the last action should be halting the thread + itself. */ void -__pthread_thread_halt (struct __pthread *thread) +__pthread_thread_halt (struct __pthread *thread, int need_dealloc) { error_t err; + thread_t tid = thread->kernel_thread; - err = __mach_port_deallocate (__mach_task_self (), - thread->wakeupmsg.msgh_remote_port); - assert_perror (err); + if (need_dealloc) + __pthread_dealloc (thread); - err = __thread_terminate (thread->kernel_thread); + err = __thread_terminate (tid); assert_perror (err); } -- 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 'pthread/pt-internal.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