summaryrefslogtreecommitdiff
path: root/pthread/pt-alloc.c
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@gnu.org>2008-08-12 15:07:50 +0000
committerThomas Schwinge <tschwinge@gnu.org>2009-04-07 23:52:49 +0200
commit61585a1da2ce36b0db1cbc9673456205d5111e78 (patch)
tree3539b1cc2c6f95c6fc453c14fdc0c8c6468c2376 /pthread/pt-alloc.c
parent38648cd5741e671ef977879150be16546b71d84b (diff)
2008-08-12 Neal H. Walfield <neal@gnu.org>
Merge changes from hurd-l4 fork. * Makefile (SRCS): Add pt-startup.c and pt-mutex-transfer-np.c. (sysdeps_headers): Add pthread-np.h. 2008-08-12 Neal H. Walfield <neal@gnu.org> * sysdeps/generic/bits/pthread-np.h: New file. 2008-08-12 Neal H. Walfield <neal@gnu.org> * sysdeps/generic/pt-startup.c: New file. 2008-08-12 Neal H. Walfield <neal@gnu.org> * sysdeps/generic/bits/mutex.h (__PTHREAD_RECURSIVE_MUTEX_INITIALIZER): Define. (__PTHREAD_MUTEX_RECURSIVE_INITIALIZER): Don't define. * include/pthread/pthread.h (PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) [__USE_GNU]: Define. (PTHREAD_MUTEX_RECURSIVE_INITIALIZER_NP): Don't define. 2008-08-12 Neal H. Walfield <neal@gnu.org> * include/pthread/pthread.h: Include <sys/cdefs.h>. (__extern_inline): If not defined, define appropriately. 2008-06-01 Neal H. Walfield <neal@gnu.org> * include/pthread/pthread.h (PTHREAD_MUTEX_RECURSIVE_INITIALIZER_NP): New definition. * sysdeps/generic/bits/mutex.h (__PTHREAD_MUTEX_RECURSIVE_INITIALIZER): New definition. * sysdeps/generic/bits/mutex-attr.h (__pthread_recursive_mutexattr): New definition. * sysdeps/generic/pt-mutexattr.c (__pthread_recursive_mutexattr): New declaration. * sysdeps/generic/pt-mutex-init.c (_pthread_mutex_init): If ATTR is &__PTHREAD_RECURSIVE_MUTEXATTR, don't allocate a copy, just save in MUTEX->ATTR. * sysdeps/generic/pt-mutex-destroy.c (_pthread_mutex_destroy): If MUTEX->ATTR is &__PTHREAD_RECURSIVE_MUTEXATTR, don't free it. 2008-05-29 Thomas Schwinge <tschwinge@gnu.org> * sysdeps/generic/sem-timedwait.c: Don't include <error.h>. 2008-05-21 Neal H. Walfield <neal@gnu.org> * include/pthread/pthread.h: Include <bits/pthread-np.h>. 2008-03-01 Neal H. Walfield <neal@gnu.org> * sysdeps/generic/pt-mutex-transfer-np.c: New file. * pthread/pt-self.c (pthread_self): Assert that SELF is not NULL. 2007-12-23 Neal H. Walfield <neal@gnu.org> * pthread/pt-join.c (pthread_join): Cast argument to pthread_cleanup_push to avoid warning. 2007-11-23 Neal H. Walfield <neal@gnu.org> * pthread/pt-internal.h (__pthread_startup): Add declaration. * pthread/pt-create.c (entry_point): Call __pthread_startup.
Diffstat (limited to 'pthread/pt-alloc.c')
-rw-r--r--pthread/pt-alloc.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/pthread/pt-alloc.c b/pthread/pt-alloc.c
index 6cf9106..30dcede 100644
--- a/pthread/pt-alloc.c
+++ b/pthread/pt-alloc.c
@@ -1,5 +1,5 @@
/* Allocate a new thread structure.
- Copyright (C) 2000, 2002, 2005, 2007 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
@@ -25,7 +25,7 @@
#include <pt-internal.h>
-#include <atomic.h>
+#include <bits/atomic.h>
/* This braindamage is necessary because the standard says that some
of the threads functions "shall fail" if "No thread could be found
@@ -46,7 +46,7 @@ pthread_rwlock_t __pthread_threads_lock;
/* List of thread structures corresponding to free thread IDs. */
-atomicptr_t __pthread_free_threads;
+__atomicptr_t __pthread_free_threads;
static inline error_t
initialize_pthread (struct __pthread *new, int recycling)
@@ -97,10 +97,8 @@ __pthread_alloc (struct __pthread **pthread)
/* Try to re-use a thread structure before creating a new one. */
while ((new = (struct __pthread *)__pthread_free_threads))
{
- if (atomic_compare_and_exchange_val_acq (&__pthread_free_threads,
- (uintptr_t) new->next,
- (uintptr_t) new)
- == (uintptr_t) new)
+ if (__atomicptr_compare_and_swap (&__pthread_free_threads,
+ new, new->next))
{
/* Yes, we managed to get one. The thread number in the
thread structure still refers to the correct slot. */
@@ -112,10 +110,8 @@ __pthread_alloc (struct __pthread **pthread)
while (1)
{
new->next = (struct __pthread *)__pthread_free_threads;
- if (atomic_compare_and_exchange_val_acq
- (&__pthread_free_threads,
- (uintptr_t) new, (uintptr_t) new->next)
- == (uintptr_t) new->next)
+ if (__atomicptr_compare_and_swap (&__pthread_free_threads,
+ new->next, new))
break;
}