summaryrefslogtreecommitdiff
path: root/pthread/pt-internal.h
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@gnu.org>2007-11-20 16:23:24 +0000
committerThomas Schwinge <tschwinge@gnu.org>2009-04-07 23:05:35 +0200
commite16179334211cd7e2877197140b06b83e2f03733 (patch)
tree25ffab176418a96477e2e95cfc5540f839bfec22 /pthread/pt-internal.h
parent426e7e7edf67380ec5afc9791a9541b0f8e2c452 (diff)
parent0697fd051821d7b44b3c9ab2face57438e1a764a (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-internal.h')
-rw-r--r--pthread/pt-internal.h60
1 files changed, 35 insertions, 25 deletions
diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h
index 436f870..0dd4e9a 100644
--- a/pthread/pt-internal.h
+++ b/pthread/pt-internal.h
@@ -1,5 +1,5 @@
/* Internal defenitions for pthreads library.
- Copyright (C) 2000, 2004 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
@@ -21,12 +21,11 @@
#define _PT_INTERNAL_H 1
#include <pthread.h>
-#if 0
#include <stddef.h>
#include <sched.h>
#include <signal.h>
#include <assert.h>
-#endif
+
#include <atomic.h>
#include <pt-key.h>
@@ -126,7 +125,7 @@ __pthread_dequeue (struct __pthread *thread)
element = element->next)
/* The total number of threads currently active. */
-extern uatomic32_t __pthread_total;
+extern atomic_fast32_t __pthread_total;
/* The total number of thread IDs currently in use, or on the list of
available thread IDs. */
@@ -135,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
@@ -163,11 +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,
- void *provided_thread,
+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). */
@@ -188,33 +189,41 @@ 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 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);
-/* Initialize provided kernel thread. */
-extern int __pthread_init_provided_thread (struct __pthread *thread,
- void *p);
/* Block 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);
@@ -242,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);