summaryrefslogtreecommitdiff
path: root/libpthread/linuxthreads/internals.h
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2015-02-14 23:00:19 -0600
committerWaldemar Brodkorb <wbx@openadk.org>2015-02-14 23:00:19 -0600
commit6b6ede3d15f04fe825cfa9f697507457e3640344 (patch)
treeefe9bf75eaf2200f89087ed0ef2ef350549ccd6d /libpthread/linuxthreads/internals.h
parentf972c2262fd4efc2bbf9789dce145bb705acec24 (diff)
resolve merge
Diffstat (limited to 'libpthread/linuxthreads/internals.h')
-rw-r--r--libpthread/linuxthreads/internals.h636
1 files changed, 308 insertions, 328 deletions
diff --git a/libpthread/linuxthreads/internals.h b/libpthread/linuxthreads/internals.h
index 68a8b6a75..ea274d824 100644
--- a/libpthread/linuxthreads/internals.h
+++ b/libpthread/linuxthreads/internals.h
@@ -13,30 +13,30 @@
/* GNU Library General Public License for more details. */
#ifndef _INTERNALS_H
-#define _INTERNALS_H 1
-
-#include "uClibc-glue.h"
+#define _INTERNALS_H 1
/* Internal data structures */
/* Includes */
+#include <bits/libc-tsd.h> /* for _LIBC_TSD_KEY_N */
#include <limits.h>
+#include <setjmp.h>
#include <signal.h>
-#include <stdbool.h>
#include <unistd.h>
-#include <sys/ucontext.h>
#include <bits/stackinfo.h>
-#include <bits/sigcontextinfo.h>
-#include <bits/pthreadtypes.h>
-
-#ifdef __UCLIBC_HAS_TLS__
-#include <tls.h>
-#endif
-#include "descr.h"
-
+#include <sys/types.h>
+#include <sys/wait.h>
+#include "pt-machine.h"
#include "semaphore.h"
-#include <pthread-functions.h>
+#include "../linuxthreads.old_db/thread_dbP.h"
+#ifdef __UCLIBC_HAS_XLOCALE__
+#include <bits/uClibc_locale.h>
+#endif /* __UCLIBC_HAS_XLOCALE__ */
+
+/* Use a funky version in a probably vein attempt at preventing gdb
+ * from dlopen()'ing glibc's libthread_db library... */
+#define VERSION __stringify(__UCLIBC_MAJOR__) "." __stringify(__UCLIBC_MINOR__) "." __stringify(__UCLIBC_SUBLEVEL__)
#ifndef THREAD_GETMEM
# define THREAD_GETMEM(descr, member) descr->member
@@ -51,14 +51,30 @@
# define THREAD_SETMEM_NC(descr, member, value) descr->member = (value)
#endif
-#if !defined NOT_IN_libc && defined FLOATING_STACKS
-# define LIBC_THREAD_GETMEM(descr, member) THREAD_GETMEM (descr, member)
-# define LIBC_THREAD_SETMEM(descr, member, value) \
- THREAD_SETMEM (descr, member, value)
-#else
-# define LIBC_THREAD_GETMEM(descr, member) descr->member
-# define LIBC_THREAD_SETMEM(descr, member, value) descr->member = (value)
-#endif
+/* Arguments passed to thread creation routine */
+
+struct pthread_start_args {
+ void * (*start_routine)(void *); /* function to run */
+ void * arg; /* its argument */
+ sigset_t mask; /* initial signal mask for thread */
+ int schedpolicy; /* initial scheduling policy (if any) */
+ struct sched_param schedparam; /* initial scheduling parameters (if any) */
+};
+
+
+/* We keep thread specific data in a special data structure, a two-level
+ array. The top-level array contains pointers to dynamically allocated
+ arrays of a certain number of data pointers. So we can implement a
+ sparse array. Each dynamic second-level array has
+ PTHREAD_KEY_2NDLEVEL_SIZE
+ entries. This value shouldn't be too large. */
+#define PTHREAD_KEY_2NDLEVEL_SIZE 32
+
+/* We need to address PTHREAD_KEYS_MAX key with PTHREAD_KEY_2NDLEVEL_SIZE
+ keys in each subarray. */
+#define PTHREAD_KEY_1STLEVEL_SIZE \
+ ((PTHREAD_KEYS_MAX + PTHREAD_KEY_2NDLEVEL_SIZE - 1) \
+ / PTHREAD_KEY_2NDLEVEL_SIZE)
typedef void (*destr_function)(void *);
@@ -68,9 +84,105 @@ struct pthread_key_struct {
};
-#define PTHREAD_START_ARGS_INITIALIZER(fct) \
- { (void *(*) (void *)) fct, NULL, {{0, }}, 0, { 0 } }
+#define PTHREAD_START_ARGS_INITIALIZER { NULL, NULL, {{0, }}, 0, { 0 } }
+
+/* The type of thread descriptors */
+
+typedef struct _pthread_descr_struct * pthread_descr;
+
+/* Callback interface for removing the thread from waiting on an
+ object if it is cancelled while waiting or about to wait.
+ This hold a pointer to the object, and a pointer to a function
+ which ``extricates'' the thread from its enqueued state.
+ The function takes two arguments: pointer to the wait object,
+ and a pointer to the thread. It returns 1 if an extrication
+ actually occured, and hence the thread must also be signalled.
+ It returns 0 if the thread had already been extricated. */
+
+typedef struct _pthread_extricate_struct {
+ void *pu_object;
+ int (*pu_extricate_func)(void *, pthread_descr);
+} pthread_extricate_if;
+/* Atomic counter made possible by compare_and_swap */
+
+struct pthread_atomic {
+ long p_count;
+ int p_spinlock;
+};
+
+/* Context info for read write locks. The pthread_rwlock_info structure
+ is information about a lock that has been read-locked by the thread
+ in whose list this structure appears. The pthread_rwlock_context
+ is embedded in the thread context and contains a pointer to the
+ head of the list of lock info structures, as well as a count of
+ read locks that are untracked, because no info structure could be
+ allocated for them. */
+
+struct _pthread_rwlock_t;
+
+typedef struct _pthread_rwlock_info {
+ struct _pthread_rwlock_info *pr_next;
+ struct _pthread_rwlock_t *pr_lock;
+ int pr_lock_count;
+} pthread_readlock_info;
+
+struct _pthread_descr_struct {
+ pthread_descr p_nextlive, p_prevlive;
+ /* Double chaining of active threads */
+ pthread_descr p_nextwaiting; /* Next element in the queue holding the thr */
+ pthread_descr p_nextlock; /* can be on a queue and waiting on a lock */
+ pthread_t p_tid; /* Thread identifier */
+ int p_pid; /* PID of Unix process */
+ int p_priority; /* Thread priority (== 0 if not realtime) */
+ struct _pthread_fastlock * p_lock; /* Spinlock for synchronized accesses */
+ int p_signal; /* last signal received */
+ sigjmp_buf * p_signal_jmp; /* where to siglongjmp on a signal or NULL */
+ sigjmp_buf * p_cancel_jmp; /* where to siglongjmp on a cancel or NULL */
+ char p_terminated; /* true if terminated e.g. by pthread_exit */
+ char p_detached; /* true if detached */
+ char p_exited; /* true if the assoc. process terminated */
+ void * p_retval; /* placeholder for return value */
+ int p_retcode; /* placeholder for return code */
+ pthread_descr p_joining; /* thread joining on that thread or NULL */
+ struct _pthread_cleanup_buffer * p_cleanup; /* cleanup functions */
+ char p_cancelstate; /* cancellation state */
+ char p_canceltype; /* cancellation type (deferred/async) */
+ char p_canceled; /* cancellation request pending */
+ int * p_errnop; /* pointer to used errno variable */
+ int p_errno; /* error returned by last system call */
+ int * p_h_errnop; /* pointer to used h_errno variable */
+ int p_h_errno; /* error returned by last netdb function */
+ char * p_in_sighandler; /* stack address of sighandler, or NULL */
+ char p_sigwaiting; /* true if a sigwait() is in progress */
+ struct pthread_start_args p_start_args; /* arguments for thread creation */
+ void ** p_specific[PTHREAD_KEY_1STLEVEL_SIZE]; /* thread-specific data */
+ void * p_libc_specific[_LIBC_TSD_KEY_N]; /* thread-specific data for libc */
+ int p_userstack; /* nonzero if the user provided the stack */
+ void *p_guardaddr; /* address of guard area or NULL */
+ size_t p_guardsize; /* size of guard area */
+ pthread_descr p_self; /* Pointer to this structure */
+ int p_nr; /* Index of descriptor in __pthread_handles */
+ int p_report_events; /* Nonzero if events must be reported. */
+ td_eventbuf_t p_eventbuf; /* Data for event. */
+ struct pthread_atomic p_resume_count; /* number of times restart() was
+ called on thread */
+ char p_woken_by_cancel; /* cancellation performed wakeup */
+ char p_condvar_avail; /* flag if conditional variable became avail */
+ char p_sem_avail; /* flag if semaphore became available */
+ pthread_extricate_if *p_extricate; /* See above */
+ pthread_readlock_info *p_readlock_list; /* List of readlock info structs */
+ pthread_readlock_info *p_readlock_free; /* Free list of structs */
+ int p_untracked_readlock_count; /* Readlocks not tracked by list */
+ /* New elements must be added at the end. */
+#ifdef __UCLIBC_HAS_XLOCALE__
+ __locale_t locale; /* thread-specific locale from uselocale() only! */
+#endif /* __UCLIBC_HAS_XLOCALE__ */
+} __attribute__ ((aligned(32))); /* We need to align the structure so that
+ doubles are aligned properly. This is 8
+ bytes on MIPS and 16 bytes on MIPS64.
+ 32 bytes might give better cache
+ utilization. */
/* The type of thread handles. */
@@ -88,7 +200,7 @@ struct pthread_request {
pthread_descr req_thread; /* Thread doing the request */
enum { /* Request kind */
REQ_CREATE, REQ_FREE, REQ_PROCESS_EXIT, REQ_MAIN_THREAD_EXIT,
- REQ_POST, REQ_DEBUG, REQ_KICK, REQ_FOR_EACH_THREAD
+ REQ_POST, REQ_DEBUG, REQ_KICK
} req_kind;
union { /* Arguments for request */
struct { /* For REQ_CREATE: */
@@ -104,24 +216,10 @@ struct pthread_request {
int code; /* exit status */
} exit;
void * post; /* For REQ_POST: the semaphore */
- struct { /* For REQ_FOR_EACH_THREAD: callback */
- void (*fn)(void *, pthread_descr);
- void *arg;
- } for_each;
} req_args;
};
-
-typedef void (*arch_sighandler_t) (int, SIGCONTEXT);
-union sighandler
-{
- arch_sighandler_t old;
- void (*rt) (int, struct siginfo *, struct ucontext *);
-};
-extern union sighandler __sighandler[NSIG];
-
-
/* Signals used for suspend/restart and for cancellation notification. */
extern int __pthread_sig_restart;
@@ -137,10 +235,52 @@ extern int __pthread_sig_debug;
extern struct pthread_handle_struct __pthread_handles[PTHREAD_THREADS_MAX];
+/* Descriptor of the initial thread */
+
+extern struct _pthread_descr_struct __pthread_initial_thread;
+
+/* Descriptor of the manager thread */
+
+extern struct _pthread_descr_struct __pthread_manager_thread;
+
/* Descriptor of the main thread */
extern pthread_descr __pthread_main_thread;
+/* Limit between the stack of the initial thread (above) and the
+ stacks of other threads (below). Aligned on a STACK_SIZE boundary.
+ Initially 0, meaning that the current thread is (by definition)
+ the initial thread. */
+
+extern char *__pthread_initial_thread_bos;
+#ifndef __ARCH_USE_MMU__
+/* For non-MMU systems, we have no idea the bounds of the initial thread
+ * stack, so we have to track it on the fly relative to other stacks. Do
+ * so by scaling back our assumptions on the limits of the bos/tos relative
+ * to the known mid point. See also the comments in pthread_initialize(). */
+extern char *__pthread_initial_thread_tos, *__pthread_initial_thread_mid;
+#define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) \
+ do { \
+ char *__tos = (tos); \
+ char *__bos = (bos); \
+ if (__tos >= __pthread_initial_thread_bos && \
+ __bos < __pthread_initial_thread_tos) { \
+ if (__bos < __pthread_initial_thread_mid) \
+ __pthread_initial_thread_bos = __tos; \
+ else \
+ __pthread_initial_thread_tos = __bos; \
+ } \
+ } while (0)
+#else
+#define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) /* empty */
+#endif /* __ARCH_USE_MMU__ */
+
+
+/* Indicate whether at least one thread has a user-defined stack (if 1),
+ or all threads have stacks supplied by LinuxThreads (if 0). */
+
+extern int __pthread_nonstandard_stacks;
+
/* File descriptor for sending requests to the thread manager.
Initially -1, meaning that __pthread_initialize_manager must be called. */
@@ -150,10 +290,10 @@ extern int __pthread_manager_request;
extern int __pthread_manager_reader;
-#ifdef FLOATING_STACKS
-/* Maximum stack size. */
-extern size_t __pthread_max_stacksize;
-#endif
+/* Limits of the thread manager stack. */
+
+extern char *__pthread_manager_thread_bos;
+extern char *__pthread_manager_thread_tos;
/* Pending request for a process-wide exit */
@@ -161,16 +301,13 @@ extern int __pthread_exit_requested, __pthread_exit_code;
/* Set to 1 by gdb if we're debugging */
-extern __volatile__ int __pthread_threads_debug;
+extern volatile int __pthread_threads_debug;
/* Globally enabled events. */
-extern __volatile__ td_thr_events_t __pthread_threads_events;
+extern volatile td_thr_events_t __pthread_threads_events;
/* Pointer to descriptor of thread with last event. */
-extern __volatile__ pthread_descr __pthread_last_event;
-
-/* Flag which tells whether we are executing on SMP kernel. */
-extern int __pthread_smp_kernel;
+extern volatile pthread_descr __pthread_last_event;
/* Return the handle corresponding to a thread id */
@@ -183,25 +320,26 @@ static __inline__ pthread_handle thread_handle(pthread_t id)
static __inline__ int invalid_handle(pthread_handle h, pthread_t id)
{
- return h->h_descr == NULL || h->h_descr->p_tid != id || h->h_descr->p_terminated;
-}
-
-static __inline__ int nonexisting_handle(pthread_handle h, pthread_t id)
-{
return h->h_descr == NULL || h->h_descr->p_tid != id;
}
/* Fill in defaults left unspecified by pt-machine.h. */
-/* We round up a value with page size. */
-#ifndef page_roundup
-#define page_roundup(v,p) ((((size_t) (v)) + (p) - 1) & ~((p) - 1))
-#endif
-
/* The page size we can get from the system. This should likely not be
changed by the machine file but, you never know. */
#define __PAGE_SIZE (sysconf (_SC_PAGESIZE))
+/* The max size of the thread stack segments. If the default
+ THREAD_SELF implementation is used, this must be a power of two and
+ a multiple of __PAGE_SIZE. */
+#ifndef STACK_SIZE
+#ifdef __ARCH_USE_MMU__
+#define STACK_SIZE (2 * 1024 * 1024)
+#else
+#define STACK_SIZE (4 * __PAGE_SIZE)
+#endif
+#endif
+
/* The initial size of the thread stack. Must be a multiple of __PAGE_SIZE. */
#ifndef INITIAL_STACK_SIZE
#define INITIAL_STACK_SIZE (4 * __PAGE_SIZE)
@@ -220,12 +358,17 @@ static __inline__ int nonexisting_handle(pthread_handle h, pthread_t id)
#define THREAD_STACK_START_ADDRESS __pthread_initial_thread_bos
#endif
+/* Get some notion of the current stack. Need not be exactly the top
+ of the stack, just something somewhere in the current frame. */
+#ifndef CURRENT_STACK_FRAME
+#define CURRENT_STACK_FRAME ({ char __csf; &__csf; })
+#endif
+
/* If MEMORY_BARRIER isn't defined in pt-machine.h, assume the
architecture doesn't need a memory barrier instruction (e.g. Intel
x86). Still we need the compiler to respect the barrier and emit
all outstanding operations which modify memory. Some architectures
distinguish between full, read and write barriers. */
-
#ifndef MEMORY_BARRIER
#define MEMORY_BARRIER() __asm__ ("" : : : "memory")
#endif
@@ -236,6 +379,54 @@ static __inline__ int nonexisting_handle(pthread_handle h, pthread_t id)
#define WRITE_MEMORY_BARRIER() MEMORY_BARRIER()
#endif
+/* Recover thread descriptor for the current thread */
+
+extern pthread_descr __pthread_find_self (void) __attribute__ ((const)) attribute_hidden;
+
+static __inline__ pthread_descr thread_self (void) __attribute__ ((const));
+static __inline__ pthread_descr thread_self (void)
+{
+#ifdef THREAD_SELF
+ return THREAD_SELF;
+#else
+ char *sp = CURRENT_STACK_FRAME;
+#ifdef __ARCH_USE_MMU__
+ if (sp >= __pthread_initial_thread_bos)
+ return &__pthread_initial_thread;
+ else if (sp >= __pthread_manager_thread_bos
+ && sp < __pthread_manager_thread_tos)
+ return &__pthread_manager_thread;
+ else if (__pthread_nonstandard_stacks)
+ return __pthread_find_self();
+ else
+ return (pthread_descr)(((unsigned long)sp | (STACK_SIZE-1))+1) - 1;
+#else
+ /* For non-MMU we need to be more careful about the initial thread stack.
+ * We refine the initial thread stack bounds dynamically as we allocate
+ * the other stack frame such that it doesn't overlap with them. Then
+ * we can be sure to pick the right thread according to the current SP */
+
+ /* Since we allow other stack frames to be above or below, we need to
+ * treat this case special. When pthread_initialize() wasn't called yet,
+ * only the initial thread is there. */
+ if (__pthread_initial_thread_bos == NULL) {
+ return &__pthread_initial_thread;
+ }
+ else if (sp >= __pthread_initial_thread_bos
+ && sp < __pthread_initial_thread_tos) {
+ return &__pthread_initial_thread;
+ }
+ else if (sp >= __pthread_manager_thread_bos
+ && sp < __pthread_manager_thread_tos) {
+ return &__pthread_manager_thread;
+ }
+ else {
+ return __pthread_find_self();
+ }
+#endif /* __ARCH_USE_MMU__ */
+#endif
+}
+
/* Max number of times we must spin on a spinlock calling sched_yield().
After MAX_SPIN_COUNT iterations, we put the calling thread to sleep. */
@@ -243,13 +434,6 @@ static __inline__ int nonexisting_handle(pthread_handle h, pthread_t id)
#define MAX_SPIN_COUNT 50
#endif
-/* Max number of times the spinlock in the adaptive mutex implementation
- spins actively on SMP systems. */
-
-#ifndef MAX_ADAPTIVE_SPIN_COUNT
-#define MAX_ADAPTIVE_SPIN_COUNT 100
-#endif
-
/* Duration of sleep (in nanoseconds) when we can't acquire a spinlock
after MAX_SPIN_COUNT iterations of sched_yield().
With the 2.0 and 2.1 kernels, this MUST BE > 2ms.
@@ -264,286 +448,82 @@ static __inline__ int nonexisting_handle(pthread_handle h, pthread_t id)
extern int __libc_multiple_threads attribute_hidden;
extern int __librt_multiple_threads;
-/* Debugging */
-
-#ifdef DEBUG
-#include <assert.h>
-#define ASSERT assert
-#define MSG __pthread_message
-#else
-#define ASSERT(x)
-#define MSG(msg,arg...)
-#endif
-
/* Internal global functions */
-extern void __pthread_do_exit (void *retval, char *currentframe)
- __attribute__ ((__noreturn__));
-extern void __pthread_destroy_specifics (void);
-extern void __pthread_perform_cleanup (char *currentframe);
-extern void __pthread_init_max_stacksize (void);
-extern int __pthread_initialize_manager (void);
-extern void __pthread_message (const char * fmt, ...) attribute_hidden;
-extern int __pthread_manager (void *reqfd);
-extern int __pthread_manager_event (void *reqfd);
-extern void __pthread_manager_sighandler (int sig);
-extern void __pthread_reset_main_thread (void);
-extern void __pthread_once_fork_prepare (void);
-extern void __pthread_once_fork_parent (void);
-extern void __pthread_once_fork_child (void);
-extern void __flockfilelist (void);
-extern void __funlockfilelist (void);
-extern void __fresetlockfiles (void);
-extern void __pthread_manager_adjust_prio (int thread_prio);
-extern void __pthread_initialize_minimal (void);
-
-extern int __pthread_attr_setguardsize (pthread_attr_t *__attr,
- size_t __guardsize);
-extern int __pthread_attr_getguardsize (const pthread_attr_t *__attr,
- size_t *__guardsize);
-#if 0 /* uClibc: deprecated stuff disabled */
-extern int __pthread_attr_setstackaddr (pthread_attr_t *__attr,
- void *__stackaddr);
-extern int __pthread_attr_getstackaddr (const pthread_attr_t *__attr,
- void **__stackaddr);
-#endif
-extern int __pthread_attr_setstacksize (pthread_attr_t *__attr,
- size_t __stacksize);
-extern int __pthread_attr_getstacksize (const pthread_attr_t *__attr,
- size_t *__stacksize);
-extern int __pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
- size_t __stacksize);
-extern int __pthread_attr_getstack (const pthread_attr_t *__attr, void **__stackaddr,
- size_t *__stacksize);
-extern int __pthread_attr_destroy (pthread_attr_t *attr);
-extern int __pthread_attr_setdetachstate (pthread_attr_t *attr,
- int detachstate);
-extern int __pthread_attr_getdetachstate (const pthread_attr_t *attr,
- int *detachstate);
-extern int __pthread_attr_setschedparam (pthread_attr_t *attr,
- const struct sched_param *param);
-extern int __pthread_attr_getschedparam (const pthread_attr_t *attr,
- struct sched_param *param);
-extern int __pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy);
-extern int __pthread_attr_getschedpolicy (const pthread_attr_t *attr,
- int *policy);
-extern int __pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit);
-extern int __pthread_attr_getinheritsched (const pthread_attr_t *attr,
- int *inherit);
-extern int __pthread_attr_setscope (pthread_attr_t *attr, int scope);
-extern int __pthread_attr_getscope (const pthread_attr_t *attr, int *scope);
-
-extern int __pthread_getconcurrency (void);
-extern int __pthread_setconcurrency (int __level);
-extern int __pthread_mutex_timedlock (pthread_mutex_t *__mutex,
- const struct timespec *__abstime);
-extern int __pthread_mutexattr_getpshared (const pthread_mutexattr_t *__attr,
- int *__pshared);
-extern int __pthread_mutexattr_setpshared (pthread_mutexattr_t *__attr,
- int __pshared);
-extern int __pthread_mutexattr_gettype (const pthread_mutexattr_t *__attr,
- int *__kind);
-extern void __pthread_kill_other_threads_np (void);
-extern int __pthread_mutex_init (pthread_mutex_t *__mutex,
- const pthread_mutexattr_t *__mutex_attr);
-extern int __pthread_mutex_destroy (pthread_mutex_t *__mutex);
-extern int __pthread_mutex_lock (pthread_mutex_t *__mutex);
-extern int __pthread_mutex_trylock (pthread_mutex_t *__mutex);
-extern int __pthread_mutex_unlock (pthread_mutex_t *__mutex);
-
-extern int __pthread_cond_init (pthread_cond_t *cond,
- const pthread_condattr_t *cond_attr);
-extern int __pthread_cond_destroy (pthread_cond_t *cond);
-extern int __pthread_cond_wait (pthread_cond_t *cond, pthread_mutex_t *mutex);
-extern int __pthread_cond_timedwait (pthread_cond_t *cond,
- pthread_mutex_t *mutex,
- const struct timespec *abstime);
-extern int __pthread_cond_signal (pthread_cond_t *cond);
-extern int __pthread_cond_broadcast (pthread_cond_t *cond);
-extern int __pthread_condattr_init (pthread_condattr_t *attr);
-extern int __pthread_condattr_destroy (pthread_condattr_t *attr);
-extern pthread_t __pthread_self (void);
-extern pthread_descr __pthread_thread_self (void);
-extern pthread_descr __pthread_self_stack (void) attribute_hidden;
-extern int __pthread_equal (pthread_t thread1, pthread_t thread2);
+void __pthread_do_exit (void *retval, char *currentframe)
+ __attribute__ ((__noreturn__)) attribute_hidden;
+void __pthread_destroy_specifics(void) attribute_hidden;
+void __pthread_perform_cleanup(char *currentframe) attribute_hidden;
+int __pthread_initialize_manager(void) attribute_hidden;
+void __pthread_message(char * fmt, ...)
+ __attribute__ ((__format__ (printf, 1, 2))) attribute_hidden;
+int __pthread_manager(void *reqfd) attribute_hidden;
+int __pthread_manager_event(void *reqfd) attribute_hidden;
+void __pthread_manager_sighandler(int sig) attribute_hidden;
+void __pthread_reset_main_thread(void) attribute_hidden;
+void __fresetlockfiles(void) attribute_hidden;
+void __pthread_manager_adjust_prio(int thread_prio) attribute_hidden;
+void __pthread_initialize_minimal (void);
+
extern void __pthread_exit (void *retval)
#if defined NOT_IN_libc && defined IS_IN_libpthread
attribute_noreturn
#endif
;
-extern int __pthread_getschedparam (pthread_t thread, int *policy,
- struct sched_param *param);
-extern int __pthread_setschedparam (pthread_t thread, int policy,
- const struct sched_param *param);
-extern int __pthread_setcancelstate (int state, int * oldstate);
-extern int __pthread_setcanceltype (int type, int * oldtype);
-
-extern void __pthread_restart_old(pthread_descr th);
-extern void __pthread_suspend_old(pthread_descr self);
-extern int __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime);
-
-extern void __pthread_restart_new(pthread_descr th);
-extern void __pthread_suspend_new(pthread_descr self);
-extern int __pthread_timedsuspend_new(pthread_descr self, const struct timespec *abstime);
-
-extern void __pthread_wait_for_restart_signal(pthread_descr self);
-
-extern void __pthread_sigsuspend (const sigset_t *mask) attribute_hidden;
-
-extern int __pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
- const struct timespec *__restrict
- __abstime);
-extern int __pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
- const struct timespec *__restrict
- __abstime);
-extern int __pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr);
-
-extern int __pthread_barrierattr_getpshared (const pthread_barrierattr_t *
- __restrict __attr,
- int *__restrict __pshared);
-
-extern int __pthread_spin_lock (pthread_spinlock_t *__lock);
-extern int __pthread_spin_trylock (pthread_spinlock_t *__lock);
-extern int __pthread_spin_unlock (pthread_spinlock_t *__lock);
-extern int __pthread_spin_init (pthread_spinlock_t *__lock, int __pshared);
-extern int __pthread_spin_destroy (pthread_spinlock_t *__lock);
-/* Global pointers to old or new suspend functions */
+extern int __pthread_attr_setguardsize(pthread_attr_t *__attr,
+ size_t __guardsize) attribute_hidden;
+extern int __pthread_attr_getguardsize(const pthread_attr_t *__attr,
+ size_t *__guardsize) attribute_hidden;
+extern int __pthread_attr_setstackaddr(pthread_attr_t *__attr,
+ void *__stackaddr) attribute_hidden;
+extern int __pthread_attr_getstackaddr(const pthread_attr_t *__attr,
+ void **__stackaddr) attribute_hidden;
+extern int __pthread_attr_setstacksize(pthread_attr_t *__attr,
+ size_t __stacksize) attribute_hidden;
+extern int __pthread_attr_getstacksize(const pthread_attr_t *__attr,
+ size_t *__stacksize) attribute_hidden;
+extern int __pthread_getconcurrency(void) attribute_hidden;
+extern int __pthread_setconcurrency(int __level) attribute_hidden;
+extern void __pthread_kill_other_threads_np(void) attribute_hidden;
+
+extern void __pthread_restart_old(pthread_descr th) attribute_hidden;
+extern void __pthread_suspend_old(pthread_descr self) attribute_hidden;
+extern int __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime) attribute_hidden;
+
+extern void __pthread_restart_new(pthread_descr th) attribute_hidden;
+extern void __pthread_suspend_new(pthread_descr self) attribute_hidden;
+extern int __pthread_timedsuspend_new(pthread_descr self, const struct timespec *abstime) attribute_hidden;
+
+extern void __pthread_wait_for_restart_signal(pthread_descr self) attribute_hidden;
-extern void (*__pthread_restart)(pthread_descr);
-extern void (*__pthread_suspend)(pthread_descr);
-extern int (*__pthread_timedsuspend)(pthread_descr, const struct timespec *);
+/* Global pointers to old or new suspend functions */
-/* Prototypes for some of the new semaphore functions. */
-extern int sem_post (sem_t * sem);
-extern int sem_init (sem_t *__sem, int __pshared, unsigned int __value);
-extern int sem_wait (sem_t *__sem);
-extern int sem_trywait (sem_t *__sem);
-extern int sem_getvalue (sem_t *__restrict __sem, int *__restrict __sval);
-extern int sem_destroy (sem_t *__sem);
-
-/* Prototypes for compatibility functions. */
-extern int __pthread_attr_init (pthread_attr_t *__attr);
-extern int __pthread_create (pthread_t *__restrict __threadp,
- const pthread_attr_t *__attr,
- void *(*__start_routine) (void *),
- void *__restrict __arg);
+extern void (*__pthread_restart)(pthread_descr) attribute_hidden;
+extern void (*__pthread_suspend)(pthread_descr) attribute_hidden;
-/* The functions called the signal events. */
-extern void __linuxthreads_create_event (void);
-extern void __linuxthreads_death_event (void);
-extern void __linuxthreads_reap_event (void);
+#if defined NOT_IN_libc && defined IS_IN_libpthread
+extern __typeof(pthread_mutex_init) __pthread_mutex_init attribute_hidden;
+extern __typeof(pthread_mutex_destroy) __pthread_mutex_destroy attribute_hidden;
+extern __typeof(pthread_mutex_lock) __pthread_mutex_lock attribute_hidden;
+extern __typeof(pthread_mutex_trylock) __pthread_mutex_trylock attribute_hidden;
+extern __typeof(pthread_mutex_unlock) __pthread_mutex_unlock attribute_hidden;
+#endif
-/* This function is called to initialize the pthread library. */
-extern void __pthread_initialize (void);
+/* Prototypes for some of the new semaphore functions. */
+/*extern int __new_sem_post (sem_t * sem);*/
/* TSD. */
-#if !defined __UCLIBC_HAS_TLS__ && defined __UCLIBC_HAS_RPC__
extern int __pthread_internal_tsd_set (int key, const void * pointer);
extern void * __pthread_internal_tsd_get (int key);
extern void ** __attribute__ ((__const__))
__pthread_internal_tsd_address (int key);
-#endif
-/* Sighandler wrappers. */
-extern void __pthread_sighandler(int signo, SIGCONTEXT ctx);
-extern void __pthread_sighandler_rt(int signo, struct siginfo *si,
- struct ucontext *uc);
-extern void __pthread_null_sighandler(int sig);
-extern int __pthread_sigaction (int sig, const struct sigaction *act,
- struct sigaction *oact);
-extern int __pthread_sigwait (const sigset_t *set, int *sig);
-extern int __pthread_raise (int sig);
-
-/* Cancellation. */
-extern int __pthread_enable_asynccancel (void) attribute_hidden;
-extern void __pthread_disable_asynccancel (int oldtype)
- internal_function attribute_hidden;
-
-/* The two functions are in libc.so and not exported. */
-extern int __libc_enable_asynccancel (void) attribute_hidden;
-extern void __libc_disable_asynccancel (int oldtype)
- internal_function attribute_hidden;
-
-/* The two functions are in libc.so and are exported. */
-extern int __librt_enable_asynccancel (void);
-extern void __librt_disable_asynccancel (int oldtype) internal_function;
-
-extern void __pthread_cleanup_upto (__jmp_buf target,
- char *targetframe) attribute_hidden;
-extern pid_t __pthread_fork (struct fork_block *b) attribute_hidden;
-
-#define asm_handle(name) _asm_handle(name)
-#define _asm_handle(name) #name
-#define ASM_GLOBAL asm_handle(ASM_GLOBAL_DIRECTIVE)
-#define ASM_CANCEL(name) asm_handle(C_SYMBOL_NAME(name))
-
-#if !defined NOT_IN_libc
-# define LIBC_CANCEL_ASYNC() \
- __libc_enable_asynccancel ()
-# define LIBC_CANCEL_RESET(oldtype) \
- __libc_disable_asynccancel (oldtype)
-# define LIBC_CANCEL_HANDLED() \
- __asm__ (ASM_GLOBAL " " ASM_CANCEL(__libc_enable_asynccancel)); \
- __asm__ (ASM_GLOBAL " " ASM_CANCEL(__libc_disable_asynccancel))
-#elif defined IS_IN_libpthread
-# define LIBC_CANCEL_ASYNC() \
- __pthread_enable_asynccancel ()
-# define LIBC_CANCEL_RESET(oldtype) \
- __pthread_disable_asynccancel (oldtype)
-# define LIBC_CANCEL_HANDLED() \
- __asm__ (ASM_GLOBAL " " ASM_CANCEL(__pthread_enable_asynccancel)); \
- __asm__ (ASM_GLOBAL " " ASM_CANCEL(__pthread_disable_asynccancel))
-#elif defined IS_IN_librt
-# define LIBC_CANCEL_ASYNC() \
- __librt_enable_asynccancel ()
-# define LIBC_CANCEL_RESET(oldtype) \
- __librt_disable_asynccancel (oldtype)
-# define LIBC_CANCEL_HANDLED() \
- __asm__ (ASM_GLOBAL " " ASM_CANCEL(__librt_enable_asynccancel)); \
- __asm__ (ASM_GLOBAL " " ASM_CANCEL(__librt_disable_asynccancel))
-#else
-# define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */
-# define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */
-# define LIBC_CANCEL_HANDLED() /* Nothing. */
-#endif
-
-#if !defined NOT_IN_libc && !defined FLOATING_STACKS
-# ifdef SHARED
-# define thread_self() \
- (*__libc_pthread_functions.ptr_pthread_thread_self) ()
-# else
-weak_extern (__pthread_thread_self)
-# define thread_self() __pthread_thread_self ()
-# endif
-#endif
-
-#ifndef __UCLIBC_HAS_TLS__
-# define __manager_thread (&__pthread_manager_thread)
-#else
-# define __manager_thread __pthread_manager_threadp
-#endif
+/* The functions called the signal events. */
+extern void __linuxthreads_create_event (void) attribute_hidden;
+extern void __linuxthreads_death_event (void) attribute_hidden;
+extern void __linuxthreads_reap_event (void) attribute_hidden;
-static __always_inline pthread_descr
-check_thread_self (void);
-static __always_inline pthread_descr
-check_thread_self (void)
-{
- pthread_descr self = thread_self ();
-#if defined THREAD_SELF && defined INIT_THREAD_SELF
- if (self == __manager_thread)
- {
- /* A new thread might get a cancel signal before it is fully
- initialized, so that the thread register might still point to the
- manager thread. Double check that this is really the manager
- thread. */
- self = __pthread_self_stack();
- if (self != __manager_thread)
- /* Oops, thread_self() isn't working yet.. */
- INIT_THREAD_SELF(self, self->p_nr);
- }
-#endif
- return self;
-}
+#include <pthread-functions.h>
#endif /* internals.h */