summaryrefslogtreecommitdiff
path: root/lib/libpthread
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/arch/amd64/amd64/context.S9
-rw-r--r--lib/libpthread/arch/i386/i386/pthread_md.c1
-rw-r--r--lib/libpthread/test/guard_b.c8
-rw-r--r--lib/libpthread/test/mutex_d.c27
-rw-r--r--lib/libpthread/test/sigsuspend_d.c2
-rw-r--r--lib/libpthread/thread/thr_cond.c10
-rw-r--r--lib/libpthread/thread/thr_init.c4
-rw-r--r--lib/libpthread/thread/thr_kern.c58
-rw-r--r--lib/libpthread/thread/thr_mutex.c46
-rw-r--r--lib/libpthread/thread/thr_nanosleep.c4
-rw-r--r--lib/libpthread/thread/thr_private.h1
-rw-r--r--lib/libpthread/thread/thr_pspinlock.c7
-rw-r--r--lib/libpthread/thread/thr_rtld.c12
-rw-r--r--lib/libpthread/thread/thr_sem.c1
-rw-r--r--lib/libpthread/thread/thr_sig.c41
-rw-r--r--lib/libpthread/thread/thr_sigsuspend.c7
-rw-r--r--lib/libpthread/thread/thr_symbols.c1
17 files changed, 134 insertions, 105 deletions
diff --git a/lib/libpthread/arch/amd64/amd64/context.S b/lib/libpthread/arch/amd64/amd64/context.S
index 9e6ed74df710..6a6b55810950 100644
--- a/lib/libpthread/arch/amd64/amd64/context.S
+++ b/lib/libpthread/arch/amd64/amd64/context.S
@@ -162,11 +162,11 @@ ENTRY(_amd64_restore_context)
cmpq $0, %rdi /* check for null pointer */
jne 1f
movq $-1, %rax
- jmp 7f
+ jmp 2f
1: cmpq $MC_SIZE, MC_LEN_OFFSET(%rdi) /* is context valid? */
je 2f
movq $-1, %rax /* bzzzt, invalid context */
- jmp 7f
+ ret
2: movq MC_RCX(%rdi), %rcx
movq MC_R8(%rdi), %r8
movq MC_R9(%rdi), %r9
@@ -213,6 +213,5 @@ ENTRY(_amd64_restore_context)
popq %rsi /* restore rsi, rdx, and rdi */
popq %rdx
popq %rdi
- leaq (8 + REDZONE)(%rsp), %rsp
- jmp *-(8 + REDZONE)(%rsp) /* jump to return address */
-7: ret
+ ret $REDZONE
+
diff --git a/lib/libpthread/arch/i386/i386/pthread_md.c b/lib/libpthread/arch/i386/i386/pthread_md.c
index 5c85fe0fcd14..cbea6d4f6af1 100644
--- a/lib/libpthread/arch/i386/i386/pthread_md.c
+++ b/lib/libpthread/arch/i386/i386/pthread_md.c
@@ -75,7 +75,6 @@ _tcb_dtor(struct tcb *tcb)
struct kcb *
_kcb_ctor(struct kse *kse)
{
- void *base;
struct kcb *kcb;
kcb = malloc(sizeof(struct kcb));
diff --git a/lib/libpthread/test/guard_b.c b/lib/libpthread/test/guard_b.c
index 42bf4edd3bbb..2e2703165dd6 100644
--- a/lib/libpthread/test/guard_b.c
+++ b/lib/libpthread/test/guard_b.c
@@ -34,6 +34,7 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <errno.h>
#include <limits.h>
#include <pthread.h>
@@ -69,9 +70,10 @@ recurse(void *args)
* hand tweaking, so just print a warning rather than aborting.
*/
if (parms->top - (void *)&top != FRAME_SIZE * parms->cur) {
- fprintf(stderr, "Stack size (%d) != expected (%d), frame %d\n",
- parms->top - (void *)&top, FRAME_SIZE * parms->cur,
- parms->cur);
+ fprintf(stderr,
+ "Stack size (%ld) != expected (%ld), frame %ld\n",
+ (long)parms->top - (long)&top,
+ (long)(FRAME_SIZE * parms->cur), (long)parms->cur);
}
parms->cur++;
diff --git a/lib/libpthread/test/mutex_d.c b/lib/libpthread/test/mutex_d.c
index 801d7791e2dd..2aa3b1df661d 100644
--- a/lib/libpthread/test/mutex_d.c
+++ b/lib/libpthread/test/mutex_d.c
@@ -31,19 +31,20 @@
*
* $FreeBSD$
*/
-#include <stdlib.h>
-#include <unistd.h>
+#include <sys/time.h>
#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <assert.h>
#include <errno.h>
-#include "pthread.h"
#include <sched.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <sysexits.h>
+#include "pthread.h"
#if defined(_LIBC_R_)
#include <pthread_np.h>
@@ -179,17 +180,17 @@ extern char *strtok_r(char *str, const char *sep, char **last);
* Functions
*----------------------------------------------------------*/
-#ifdef DEBUG
+#if defined(_LIBC_R_) && defined(DEBUG)
static void
kern_switch (pthread_t pthread_out, pthread_t pthread_in)
{
if (pthread_out != NULL)
- printf ("Swapping out thread 0x%x, ", (int) pthread_out);
+ printf ("Swapping out thread 0x%lx, ", (long) pthread_out);
else
printf ("Swapping out kernel thread, ");
if (pthread_in != NULL)
- printf ("swapping in thread 0x%x\n", (int) pthread_in);
+ printf ("swapping in thread 0x%lx\n", (long) pthread_in);
else
printf ("swapping in kernel thread.\n");
}
@@ -465,8 +466,8 @@ waiter (void *arg)
pthread_mutex_unlock (&waiter_mutex);
}
- log_trace ("Thread %d: Exiting thread 0x%x\n", (int) statep->id,
- (int) pthread_self());
+ log_trace ("Thread %ld: Exiting thread 0x%lx\n", (long) statep->id,
+ (long) pthread_self());
pthread_exit (arg);
return (NULL);
}
@@ -512,8 +513,8 @@ lock_twice (void *arg)
if (statep->ret == 0)
pthread_mutex_unlock (statep->cmd.mutex);
- log_trace ("Thread %d: Exiting thread 0x%x\n", (int) statep->id,
- (int) pthread_self());
+ log_trace ("Thread %ld: Exiting thread 0x%lx\n", (long) statep->id,
+ (long) pthread_self());
pthread_exit (arg);
return (NULL);
}
@@ -522,8 +523,8 @@ lock_twice (void *arg)
static void
sighandler (int signo)
{
- log ("Signal handler caught signal %d, thread id 0x%x\n",
- signo, (int) pthread_self());
+ log ("Signal handler caught signal %d, thread id 0x%lx\n",
+ signo, (long) pthread_self());
if (signo == SIGINT)
done = 1;
@@ -1481,7 +1482,7 @@ int main (int argc, char *argv[])
/* Create a pipe to catch the results of thread wakeups. */
assert (pipe (pipefd) == 0);
-#ifdef DEBUG
+#if defined(_LIBC_R_) && defined(DEBUG)
assert (pthread_switch_add_np (kern_switch) == 0);
#endif
diff --git a/lib/libpthread/test/sigsuspend_d.c b/lib/libpthread/test/sigsuspend_d.c
index aa80a073e4e1..d405e3dbb01a 100644
--- a/lib/libpthread/test/sigsuspend_d.c
+++ b/lib/libpthread/test/sigsuspend_d.c
@@ -221,7 +221,7 @@ int main (int argc, char *argv[])
fprintf (stderr, "Unable to create thread, errno %d.\n", errno);
exit (1);
}
-#if defined(_LIBC_R)
+#if defined(_LIBC_R_)
pthread_set_name_np (suspender_tid, "sigsuspender");
#endif
diff --git a/lib/libpthread/thread/thr_cond.c b/lib/libpthread/thread/thr_cond.c
index cd719d424140..a50a690b182e 100644
--- a/lib/libpthread/thread/thr_cond.c
+++ b/lib/libpthread/thread/thr_cond.c
@@ -421,11 +421,6 @@ _pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
/* Return invalid argument error: */
rval = EINVAL;
} else {
- /* Set the wakeup time: */
- curthread->wakeup_time.tv_sec = abstime->tv_sec;
- curthread->wakeup_time.tv_nsec =
- abstime->tv_nsec;
-
/* Reset the timeout and interrupted flags: */
curthread->timeout = 0;
curthread->interrupted = 0;
@@ -464,6 +459,11 @@ _pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * mutex,
* set the state.
*/
THR_SCHED_LOCK(curthread, curthread);
+ /* Set the wakeup time: */
+ curthread->wakeup_time.tv_sec =
+ abstime->tv_sec;
+ curthread->wakeup_time.tv_nsec =
+ abstime->tv_nsec;
THR_SET_STATE(curthread, PS_COND_WAIT);
/* Remember the CV: */
diff --git a/lib/libpthread/thread/thr_init.c b/lib/libpthread/thread/thr_init.c
index c14362732b03..9fe1ee7225f6 100644
--- a/lib/libpthread/thread/thr_init.c
+++ b/lib/libpthread/thread/thr_init.c
@@ -437,6 +437,7 @@ init_private(void)
}
_pthread_attr_default.guardsize_attr = _thr_guard_default;
_pthread_attr_default.stacksize_attr = _thr_stack_default;
+ TAILQ_INIT(&_thr_atfork_list);
init_once = 1; /* Don't do this again. */
} else {
/*
@@ -453,7 +454,6 @@ init_private(void)
/* Initialize everything else. */
TAILQ_INIT(&_thread_list);
TAILQ_INIT(&_thread_gc_list);
- TAILQ_INIT(&_thr_atfork_list);
_pthread_mutex_init(&_thr_atfork_mutex, NULL);
/*
@@ -487,6 +487,8 @@ init_private(void)
else if (getenv("LIBPTHREAD_PROCESS_SCOPE") != NULL)
_thread_scope_system = -1;
#endif
+ if (getenv("LIBPTHREAD_DEBUG") != NULL)
+ _thr_debug_flags |= DBG_INFO_DUMP;
/*
* _thread_list_lock and _kse_count are initialized
diff --git a/lib/libpthread/thread/thr_kern.c b/lib/libpthread/thread/thr_kern.c
index aec254122a50..f1b28c0e38ca 100644
--- a/lib/libpthread/thread/thr_kern.c
+++ b/lib/libpthread/thread/thr_kern.c
@@ -55,6 +55,9 @@ __FBSDID("$FreeBSD$");
#include "atomic_ops.h"
#include "thr_private.h"
#include "libc_private.h"
+#ifdef NOTYET
+#include "spinlock.h"
+#endif
/* #define DEBUG_THREAD_KERN */
#ifdef DEBUG_THREAD_KERN
@@ -210,9 +213,9 @@ _kse_single_thread(struct pthread *curthread)
struct kse *kse;
struct kse_group *kseg;
struct pthread *thread;
- kse_critical_t crit;
- int i;
+ _thr_spinlock_init();
+ *__malloc_lock = (spinlock_t)_SPINLOCK_INITIALIZER;
if (__isthreaded) {
_thr_rtld_fini();
_thr_signal_deinit();
@@ -222,7 +225,7 @@ _kse_single_thread(struct pthread *curthread)
* Restore signal mask early, so any memory problems could
* dump core.
*/
- sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL);
+ __sys_sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL);
_thread_active_threads = 1;
/*
@@ -250,11 +253,8 @@ _kse_single_thread(struct pthread *curthread)
curthread->joiner = NULL; /* no joining threads yet */
curthread->refcount = 0;
SIGEMPTYSET(curthread->sigpend); /* clear pending signals */
- if (curthread->specific != NULL) {
- free(curthread->specific);
- curthread->specific = NULL;
- curthread->specific_data_count = 0;
- }
+
+ /* Don't free thread-specific data as the caller may require it */
/* Free the free KSEs: */
while ((kse = TAILQ_FIRST(&free_kseq)) != NULL) {
@@ -317,6 +317,9 @@ _kse_single_thread(struct pthread *curthread)
curthread->attr.flags &= ~PTHREAD_SCOPE_SYSTEM;
curthread->attr.flags |= PTHREAD_SCOPE_PROCESS;
+ /* We're no longer part of any lists */
+ curthread->tlflags = 0;
+
/*
* After a fork, we are still operating on the thread's original
* stack. Don't clear the THR_FLAGS_USER from the thread's
@@ -1334,6 +1337,7 @@ kseg_gc(struct pthread *curthread)
if (free_kseg_count <= MAX_CACHED_KSEGS)
return;
+ TAILQ_INIT(&worklist);
crit = _kse_critical_enter();
KSE_LOCK_ACQUIRE(curthread->kse, &kse_lock);
while (free_kseg_count > MAX_CACHED_KSEGS) {
@@ -2365,6 +2369,11 @@ _thr_alloc(struct pthread *curthread)
if ((thread == NULL) &&
((thread = malloc(sizeof(struct pthread))) != NULL)) {
bzero(thread, sizeof(struct pthread));
+ thread->siginfo = calloc(_SIG_MAXSIG, sizeof(siginfo_t));
+ if (thread->siginfo == NULL) {
+ free(thread);
+ return (NULL);
+ }
if (curthread) {
_pthread_mutex_lock(&_tcb_mutex);
thread->tcb = _tcb_ctor(thread, 0 /* not initial tls */);
@@ -2373,25 +2382,22 @@ _thr_alloc(struct pthread *curthread)
thread->tcb = _tcb_ctor(thread, 1 /* initial tls */);
}
if (thread->tcb == NULL) {
+ free(thread->siginfo);
free(thread);
- thread = NULL;
- } else {
- thread->siginfo = calloc(_SIG_MAXSIG,
- sizeof(siginfo_t));
- /*
- * Initialize thread locking.
- * Lock initializing needs malloc, so don't
- * enter critical region before doing this!
- */
- if (_lock_init(&thread->lock, LCK_ADAPTIVE,
- _thr_lock_wait, _thr_lock_wakeup) != 0)
- PANIC("Cannot initialize thread lock");
- for (i = 0; i < MAX_THR_LOCKLEVEL; i++) {
- _lockuser_init(&thread->lockusers[i],
- (void *)thread);
- _LCK_SET_PRIVATE2(&thread->lockusers[i],
- (void *)thread);
- }
+ return (NULL);
+ }
+ /*
+ * Initialize thread locking.
+ * Lock initializing needs malloc, so don't
+ * enter critical region before doing this!
+ */
+ if (_lock_init(&thread->lock, LCK_ADAPTIVE,
+ _thr_lock_wait, _thr_lock_wakeup) != 0)
+ PANIC("Cannot initialize thread lock");
+ for (i = 0; i < MAX_THR_LOCKLEVEL; i++) {
+ _lockuser_init(&thread->lockusers[i], (void *)thread);
+ _LCK_SET_PRIVATE2(&thread->lockusers[i],
+ (void *)thread);
}
}
return (thread);
diff --git a/lib/libpthread/thread/thr_mutex.c b/lib/libpthread/thread/thr_mutex.c
index b502c15af818..99599f120366 100644
--- a/lib/libpthread/thread/thr_mutex.c
+++ b/lib/libpthread/thread/thr_mutex.c
@@ -551,14 +551,6 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *m,
/* Unlock the mutex structure: */
THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
} else {
- /* Set the wakeup time: */
- if (abstime) {
- curthread->wakeup_time.tv_sec =
- abstime->tv_sec;
- curthread->wakeup_time.tv_nsec =
- abstime->tv_nsec;
- }
-
/*
* Join the queue of threads waiting to lock
* the mutex and save a pointer to the mutex.
@@ -572,6 +564,14 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *m,
* be able to safely set the state.
*/
THR_SCHED_LOCK(curthread, curthread);
+ /* Set the wakeup time: */
+ if (abstime) {
+ curthread->wakeup_time.tv_sec =
+ abstime->tv_sec;
+ curthread->wakeup_time.tv_nsec =
+ abstime->tv_nsec;
+ }
+
THR_SET_STATE(curthread, PS_MUTEX_WAIT);
THR_SCHED_UNLOCK(curthread, curthread);
@@ -633,14 +633,6 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *m,
/* Unlock the mutex structure: */
THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
} else {
- /* Set the wakeup time: */
- if (abstime) {
- curthread->wakeup_time.tv_sec =
- abstime->tv_sec;
- curthread->wakeup_time.tv_nsec =
- abstime->tv_nsec;
- }
-
/*
* Join the queue of threads waiting to lock
* the mutex and save a pointer to the mutex.
@@ -659,6 +651,13 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *m,
mutex_priority_adjust(curthread, *m);
THR_SCHED_LOCK(curthread, curthread);
+ /* Set the wakeup time: */
+ if (abstime) {
+ curthread->wakeup_time.tv_sec =
+ abstime->tv_sec;
+ curthread->wakeup_time.tv_nsec =
+ abstime->tv_nsec;
+ }
THR_SET_STATE(curthread, PS_MUTEX_WAIT);
THR_SCHED_UNLOCK(curthread, curthread);
@@ -730,14 +729,6 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *m,
/* Unlock the mutex structure: */
THR_LOCK_RELEASE(curthread, &(*m)->m_lock);
} else {
- /* Set the wakeup time: */
- if (abstime) {
- curthread->wakeup_time.tv_sec =
- abstime->tv_sec;
- curthread->wakeup_time.tv_nsec =
- abstime->tv_nsec;
- }
-
/*
* Join the queue of threads waiting to lock
* the mutex and save a pointer to the mutex.
@@ -756,6 +747,13 @@ mutex_lock_common(struct pthread *curthread, pthread_mutex_t *m,
*/
THR_SCHED_LOCK(curthread, curthread);
+ /* Set the wakeup time: */
+ if (abstime) {
+ curthread->wakeup_time.tv_sec =
+ abstime->tv_sec;
+ curthread->wakeup_time.tv_nsec =
+ abstime->tv_nsec;
+ }
THR_SET_STATE(curthread, PS_MUTEX_WAIT);
THR_SCHED_UNLOCK(curthread, curthread);
diff --git a/lib/libpthread/thread/thr_nanosleep.c b/lib/libpthread/thread/thr_nanosleep.c
index e8baa844a1d0..5eba37db98bf 100644
--- a/lib/libpthread/thread/thr_nanosleep.c
+++ b/lib/libpthread/thread/thr_nanosleep.c
@@ -46,6 +46,7 @@ _nanosleep(const struct timespec *time_to_sleep,
int ret = 0;
struct timespec ts, ts1;
struct timespec remaining_time;
+ struct timespec wakeup_time;
/* Check if the time to sleep is legal: */
if ((time_to_sleep == NULL) || (time_to_sleep->tv_sec < 0) ||
@@ -61,10 +62,11 @@ _nanosleep(const struct timespec *time_to_sleep,
KSE_GET_TOD(curthread->kse, &ts);
/* Calculate the time for the current thread to wake up: */
- TIMESPEC_ADD(&curthread->wakeup_time, &ts, time_to_sleep);
+ TIMESPEC_ADD(&wakeup_time, &ts, time_to_sleep);
THR_LOCK_SWITCH(curthread);
curthread->interrupted = 0;
+ curthread->wakeup_time = wakeup_time;
THR_SET_STATE(curthread, PS_SLEEP_WAIT);
/* Reschedule the current thread to sleep: */
diff --git a/lib/libpthread/thread/thr_private.h b/lib/libpthread/thread/thr_private.h
index e2055bc1da64..9d8ee632fd00 100644
--- a/lib/libpthread/thread/thr_private.h
+++ b/lib/libpthread/thread/thr_private.h
@@ -82,6 +82,7 @@
#define DBG_MUTEX 0x0001
#define DBG_SIG 0x0002
+#define DBG_INFO_DUMP 0x0004
#ifdef _PTHREADS_INVARIANTS
#define THR_ASSERT(cond, msg) do { \
diff --git a/lib/libpthread/thread/thr_pspinlock.c b/lib/libpthread/thread/thr_pspinlock.c
index b58d7120d4ea..de555bfc796d 100644
--- a/lib/libpthread/thread/thr_pspinlock.c
+++ b/lib/libpthread/thread/thr_pspinlock.c
@@ -26,10 +26,13 @@
* $FreeBSD$
*/
+#include <sys/types.h>
#include <errno.h>
-#include <stdlib.h>
#include <pthread.h>
-#include <atomic_ops.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "atomic_ops.h"
#include "thr_private.h"
#define SPIN_COUNT 10000
diff --git a/lib/libpthread/thread/thr_rtld.c b/lib/libpthread/thread/thr_rtld.c
index 9528593fbde4..e8130735fb4d 100644
--- a/lib/libpthread/thread/thr_rtld.c
+++ b/lib/libpthread/thread/thr_rtld.c
@@ -160,11 +160,13 @@ _thr_rtld_lock_create(void)
{
struct rtld_kse_lock *l;
- l = malloc(sizeof(struct rtld_kse_lock));
- _lock_init(&l->lck, LCK_ADAPTIVE, _kse_lock_wait, _kse_lock_wakeup);
- l->owner = NULL;
- l->count = 0;
- l->write = 0;
+ if ((l = malloc(sizeof(struct rtld_kse_lock))) != NULL) {
+ _lock_init(&l->lck, LCK_ADAPTIVE, _kse_lock_wait,
+ _kse_lock_wakeup);
+ l->owner = NULL;
+ l->count = 0;
+ l->write = 0;
+ }
return (l);
}
diff --git a/lib/libpthread/thread/thr_sem.c b/lib/libpthread/thread/thr_sem.c
index 027960e0c859..8312a870a870 100644
--- a/lib/libpthread/thread/thr_sem.c
+++ b/lib/libpthread/thread/thr_sem.c
@@ -30,6 +30,7 @@
*/
#include "namespace.h"
+#include <sys/types.h>
#include <sys/queue.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/lib/libpthread/thread/thr_sig.c b/lib/libpthread/thread/thr_sig.c
index ec6ebd51eadd..f53b87f08b17 100644
--- a/lib/libpthread/thread/thr_sig.c
+++ b/lib/libpthread/thread/thr_sig.c
@@ -98,6 +98,12 @@ static int sigproptbl[NSIG] = {
#define DBG_MSG(x...)
#endif
+static __inline int
+_thr_dump_enabled(void)
+{
+ return ((_thr_debug_flags & DBG_INFO_DUMP) != 0);
+}
+
/*
* Signal setup and delivery.
*
@@ -253,7 +259,7 @@ _thr_sig_dispatch(struct kse *curkse, int sig, siginfo_t *info)
DBG_MSG(">>> _thr_sig_dispatch(%d)\n", sig);
/* Check if the signal requires a dump of thread information: */
- if (sig == SIGINFO) {
+ if (_thr_dump_enabled() && (sig == SIGINFO)) {
/* Dump thread information to file: */
_thread_dump_info();
}
@@ -347,7 +353,7 @@ _thr_sig_handler(int sig, siginfo_t *info, ucontext_t *ucp)
}
/* Check if the signal requires a dump of thread information: */
- if (sig == SIGINFO) {
+ if (_thr_dump_enabled() && (sig == SIGINFO)) {
/* Dump thread information to file: */
_thread_dump_info();
}
@@ -521,7 +527,7 @@ handle_signal(struct pthread *curthread, struct sighandle_info *shi)
_kse_critical_leave(&curthread->tcb->tcb_tmbx);
/* Check if the signal requires a dump of thread information: */
- if (shi->sig == SIGINFO) {
+ if (_thr_dump_enabled() && (shi->sig == SIGINFO)) {
/* Dump thread information to file: */
_thread_dump_info();
}
@@ -1200,21 +1206,24 @@ _thr_signal_init(void)
__sys_sigaction(i, &act, NULL);
}
}
- /*
- * Install the signal handler for SIGINFO. It isn't
- * really needed, but it is nice to have for debugging
- * purposes.
- */
- _thread_sigact[SIGINFO - 1].sa_flags = SA_SIGINFO | SA_RESTART;
- SIGEMPTYSET(act.sa_mask);
- act.sa_flags = SA_SIGINFO | SA_RESTART;
- act.sa_sigaction = (__siginfohandler_t *)&_thr_sig_handler;
- if (__sys_sigaction(SIGINFO, &act, NULL) != 0) {
- __sys_sigprocmask(SIG_SETMASK, &_thr_initial->sigmask, NULL);
+ if (_thr_dump_enabled()) {
/*
- * Abort this process if signal initialisation fails:
+ * Install the signal handler for SIGINFO. It isn't
+ * really needed, but it is nice to have for debugging
+ * purposes.
*/
- PANIC("Cannot initialize signal handler");
+ _thread_sigact[SIGINFO - 1].sa_flags = SA_SIGINFO | SA_RESTART;
+ SIGEMPTYSET(act.sa_mask);
+ act.sa_flags = SA_SIGINFO | SA_RESTART;
+ act.sa_sigaction = (__siginfohandler_t *)&_thr_sig_handler;
+ if (__sys_sigaction(SIGINFO, &act, NULL) != 0) {
+ __sys_sigprocmask(SIG_SETMASK, &_thr_initial->sigmask,
+ NULL);
+ /*
+ * Abort this process if signal initialisation fails:
+ */
+ PANIC("Cannot initialize signal handler");
+ }
}
__sys_sigprocmask(SIG_SETMASK, &_thr_initial->sigmask, NULL);
__sys_sigaltstack(NULL, &_thr_initial->sigstk);
diff --git a/lib/libpthread/thread/thr_sigsuspend.c b/lib/libpthread/thread/thr_sigsuspend.c
index b8e14e354fea..6452af150d43 100644
--- a/lib/libpthread/thread/thr_sigsuspend.c
+++ b/lib/libpthread/thread/thr_sigsuspend.c
@@ -31,11 +31,14 @@
*
* $FreeBSD$
*/
-#include <signal.h>
+
+#include <sys/types.h>
+#include <sys/signalvar.h>
#include <errno.h>
#include <pthread.h>
+#include <signal.h>
#include <string.h>
-#include <sys/signalvar.h>
+
#include "thr_private.h"
__weak_reference(__sigsuspend, sigsuspend);
diff --git a/lib/libpthread/thread/thr_symbols.c b/lib/libpthread/thread/thr_symbols.c
index 5091a9517c66..10e9402a6032 100644
--- a/lib/libpthread/thread/thr_symbols.c
+++ b/lib/libpthread/thread/thr_symbols.c
@@ -32,6 +32,7 @@
* $FreeBSD$
*/
+#include <sys/types.h>
#include <stddef.h>
#include <pthread.h>
#include <rtld.h>