/* Includes */
-#include <bits/libc-lock.h> /* for _LIBC_TSD_KEY_N */
+#include <bits/libc-tsd.h> /* for _LIBC_TSD_KEY_N */
+#include <limits.h>
#include <setjmp.h>
#include <signal.h>
#include <unistd.h>
#include "pt-machine.h"
+#ifndef THREAD_GETMEM
+# define THREAD_GETMEM(descr, member) descr->member
+#endif
+#ifndef THREAD_GETMEM_NC
+# define THREAD_GETMEM_NC(descr, member) descr->member
+#endif
+#ifndef THREAD_SETMEM
+# define THREAD_SETMEM(descr, member, value) descr->member = (value)
+#endif
+#ifndef THREAD_SETMEM_NC
+# define THREAD_SETMEM_NC(descr, member, value) descr->member = (value)
+#endif
+
/* Arguments passed to thread creation routine */
struct pthread_start_args {
pthread_t p_tid; /* Thread identifier */
int p_pid; /* PID of Unix process */
int p_priority; /* Thread priority (== 0 if not realtime) */
- int * p_spinlock; /* Spinlock for synchronized accesses */
+ 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 */
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 thread */
+ 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 */
};
/* The type of thread handles. */
typedef struct pthread_handle_struct * pthread_handle;
struct pthread_handle_struct {
- int h_spinlock; /* Spinlock for sychronized access */
+ struct _pthread_fastlock h_lock; /* Fast lock for sychronized access */
pthread_descr h_descr; /* Thread descriptor or NULL if invalid */
char * h_bottom; /* Lowest address in the stack thread */
};
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_CREATE, REQ_FREE, REQ_PROCESS_EXIT, REQ_MAIN_THREAD_EXIT,
+ REQ_POST, REQ_DEBUG
} req_kind;
union { /* Arguments for request */
struct { /* For REQ_CREATE: */
sigset_t mask; /* signal mask */
} create;
struct { /* For REQ_FREE: */
- pthread_descr thread; /* descriptor of thread to free */
+ pthread_t thread_id; /* identifier of thread to free */
} free;
struct { /* For REQ_PROCESS_EXIT: */
int code; /* exit status */
} exit;
+ void * post; /* For REQ_POST: the semaphore */
} req_args;
};
/* Signals used for suspend/restart and for cancellation notification. */
-#ifdef SIGRTMIN
-/* The have real-time signals. */
extern int __pthread_sig_restart;
extern int __pthread_sig_cancel;
-# define PTHREAD_SIG_RESTART __pthread_sig_restart
-# define PTHREAD_SIG_CANCEL __pthread_sig_cancel
-#else
-# define PTHREAD_SIG_RESTART SIGUSR1
-# define PTHREAD_SIG_CANCEL SIGUSR2
-#endif
+
+/* Default signals used if we don't have realtime signals */
+
+#define DEFAULT_SIG_RESTART SIGUSR1
+#define DEFAULT_SIG_CANCEL SIGUSR2
/* Global array of thread handles, used for validating a thread id
and retrieving the corresponding thread descriptor. Also used for
extern int __pthread_nonstandard_stacks;
/* File descriptor for sending requests to the thread manager.
- Initially -1, meaning that pthread_initialize must be called. */
+ Initially -1, meaning that __pthread_initialize_manager must be called. */
extern int __pthread_manager_request;
extern int __pthread_exit_requested, __pthread_exit_code;
+/* Set to 1 by gdb if we're debugging */
+
+extern volatile int __pthread_threads_debug;
+
/* Return the handle corresponding to a thread id */
static inline pthread_handle thread_handle(pthread_t id)
void __pthread_destroy_specifics(void);
void __pthread_perform_cleanup(void);
-void __pthread_sighandler(int sig);
-void __pthread_message(char * fmt, long arg, ...);
+int __pthread_initialize_manager(void);
+void __pthread_message(char * fmt, ...);
int __pthread_manager(void *reqfd);
void __pthread_manager_sighandler(int sig);
void __pthread_reset_main_thread(void);