2 * Copyright (c) 2005 David Xu <davidxu@freebsd.org>
3 * Copyright (C) 2003 Daniel M. Eischen <deischen@freebsd.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice unmodified, this list of conditions, and the following
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include <sys/types.h>
31 #include <sys/signalvar.h>
34 #include "thr_private.h"
36 /*#define DEBUG_THREAD_KERN */
37 #ifdef DEBUG_THREAD_KERN
38 #define DBG_MSG stdout_debug
44 * This is called when the first thread (other than the initial
48 _thr_setthreaded(int threaded)
50 if (((threaded == 0) ^ (__isthreaded == 0)) == 0)
53 __isthreaded = threaded;
63 _thr_signal_block(struct pthread *curthread)
67 if (curthread->sigblock > 0) {
68 curthread->sigblock++;
72 SIGDELSET(set, SIGBUS);
73 SIGDELSET(set, SIGILL);
74 SIGDELSET(set, SIGFPE);
75 SIGDELSET(set, SIGSEGV);
76 SIGDELSET(set, SIGTRAP);
77 __sys_sigprocmask(SIG_BLOCK, &set, &curthread->sigmask);
78 curthread->sigblock++;
82 _thr_signal_unblock(struct pthread *curthread)
84 if (--curthread->sigblock == 0)
85 __sys_sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL);
89 _thr_send_sig(struct pthread *thread, int sig)
91 return thr_kill(thread->tid, sig);
95 _thr_assert_lock_level()
97 PANIC("locklevel <= 0");