diff options
author | Neal H. Walfield <neal@gnu.org> | 2007-11-20 16:23:24 +0000 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gnu.org> | 2009-04-07 23:05:35 +0200 |
commit | e16179334211cd7e2877197140b06b83e2f03733 (patch) | |
tree | 25ffab176418a96477e2e95cfc5540f839bfec22 /pthread/pt-create.c | |
parent | 426e7e7edf67380ec5afc9791a9541b0f8e2c452 (diff) | |
parent | 0697fd051821d7b44b3c9ab2face57438e1a764a (diff) |
2007-11-20 Neal H. Walfield <neal@gnu.org>
Merge changes from mainline Hurd. Update L4 bits to compile with
those changes.
* sysdeps/l4/pt-block.c (__pthread_block): Call l4_receive, not
L4_Receive.
* sysdeps/l4/pt-create-np.c (pthread_create_from_l4_tid_np): Don't
pass TID to __pthread_create_internal. Emit a warning.
* sysdeps/l4/pt-stack-alloc.c (allocate_page): Remove function.
(__pthread_stack_alloc): Don't require that STACKSIZE is equal to
__pthread_stacksize. Call mmap.
* sysdeps/l4/pt-thread-halt.c (__pthread_thread_halt): Take
additional argument, need_dealloc. Call __pthread_dealloc. Stop
the thread.
* sysdeps/l4/hurd/pt-sysdep.c (init_routine): When calling
__pthread_create_internal, don't pass the tid.
* tests/test-1.c (main): Use pthread_mutex_init, not
PTHREAD_MUTEX_INITIALIZER.
* pthread/pt-alloc.c: Don't include <bits/atomic.h>. Include
<atomic.h>.
(__pthread_free_threads): Make it an atomicptr_t, not an
__atomicptr_t.
(__pthread_alloc): Don't use __atomicptr_compare_and_swap, use
atomic_compare_and_exchange_val_acq.
* pthread/pt-create.c: Don't include <bits/atomic.h>. Include
<atomic.h>.
(__pthread_total): Make it an atomic_fast32_t, not an __atomic_t.
(__pthread_create_internal): Use atomic_increment and
atomic_decrement, not __atomic_inc and __atomic_dec.
* pthread/pt-dealloc.c: Don't include <bits/atomic.h>. Include
<atomic.h>.
(__pthread_free_threads): Make it an atomicptr_t, not an
__atomicptr_t.
(__pthread_dealloc): Use atomic_compare_and_exchange_val_acq, not
__atomicptr_compare_and_swap.
* pthread/pt-exit.c: Don't include <bits/atomic.h>. Include
<atomic.h>.
(pthread_exit): Use atomic_decrement_and_test, not
__atomic_dec_and_test.
* pthread/pt-internal.h: Don't include <bits/atomic.h>. Include
<atomic.h>.
(__pthread_total): Make it an atomic_fast32_t, not an __atomic_t.
* sysdeps/powerpc/bits/atomic.h: Remove file.
* sysdeps/ia32/bits/atomic.h: Likewise.
Diffstat (limited to 'pthread/pt-create.c')
-rw-r--r-- | pthread/pt-create.c | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/pthread/pt-create.c b/pthread/pt-create.c index 8d348fb..4f8d043 100644 --- a/pthread/pt-create.c +++ b/pthread/pt-create.c @@ -1,5 +1,5 @@ /* Thread creation. - Copyright (C) 2000, 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2000, 2002, 2005, 2007 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 @@ -33,7 +33,7 @@ /* The total number of pthreads currently active. This is defined here since it would be really stupid to have a threads-using program that doesn't call `pthread_create'. */ -uatomic32_t __pthread_total; +atomic_fast32_t __pthread_total; /* The entry-point for new threads. */ @@ -57,7 +57,7 @@ pthread_create (pthread_t *thread, const pthread_attr_t *attr, int err; struct __pthread *pthread; - err = __pthread_create_internal (&pthread, attr, 0, start_routine, arg); + err = __pthread_create_internal (&pthread, attr, start_routine, arg); if (! err) *thread = pthread->thread; @@ -69,7 +69,6 @@ pthread_create (pthread_t *thread, const pthread_attr_t *attr, int __pthread_create_internal (struct __pthread **thread, const pthread_attr_t *attr, - void *provided_thread, void *(*start_routine)(void *), void *arg) { int err; @@ -123,20 +122,10 @@ __pthread_create_internal (struct __pthread **thread, pthread->stack = 1; } - /* Allocate the kernel thread and other required resources - if they were not provided with this call. */ - if (!provided_thread) - { - err = __pthread_thread_alloc (pthread); - if (err) - goto failed_thread_alloc; - } - else - { - err = __pthread_init_provided_thread (pthread, provided_thread); - if (err) - goto failed_thread_alloc; - } + /* Allocate the kernel thread and other required resources. */ + err = __pthread_thread_alloc (pthread); + if (err) + goto failed_thread_alloc; /* And initialize the rest of the machine context. This may include additional machine- and system-specific initializations that @@ -157,8 +146,7 @@ __pthread_create_internal (struct __pthread **thread, shall be empty." If the currnet thread is not a pthread then we just inherit the process' sigmask. */ if (__pthread_num_threads == 1) - /* FIXME no sigprocmask yet */ - err = 0; /* sigprocmask (0, 0, &sigset); */ + err = sigprocmask (0, 0, &sigset); else err = __pthread_sigstate (_pthread_self (), 0, 0, &sigset, 0); assert_perror (err); @@ -180,7 +168,7 @@ __pthread_create_internal (struct __pthread **thread, other thread should be using this entry (we also assume that the store is atomic). */ pthread_rwlock_rdlock (&__pthread_threads_lock); - __pthread_threads[pthread->thread] = pthread; + __pthread_threads[pthread->thread - 1] = pthread; pthread_rwlock_unlock (&__pthread_threads_lock); /* At this point it is possible to guess our pthread ID. We have to @@ -204,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; |