2 * Copyright (c) 2005 David Xu <davidxu@freebsd.org>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice unmodified, this list of conditions, and the following
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * $DragonFly: src/lib/libthread_xu/thread/thr_kern.c,v 1.1 2005/02/01 12:38:27 davidxu Exp $
29 #include <sys/cdefs.h>
30 #include <sys/types.h>
31 #include <sys/signalvar.h>
33 #include "thr_private.h"
35 /*#define DEBUG_THREAD_KERN */
36 #ifdef DEBUG_THREAD_KERN
37 #define DBG_MSG stdout_debug
43 * This is called when the first thread (other than the initial
47 _thr_setthreaded(int threaded)
49 if (((threaded == 0) ^ (__isthreaded == 0)) == 0)
52 __isthreaded = threaded;
64 _thr_signal_block(struct pthread *curthread)
68 if (curthread->sigblock > 0) {
69 curthread->sigblock++;
73 SIGDELSET(set, SIGBUS);
74 SIGDELSET(set, SIGILL);
75 SIGDELSET(set, SIGFPE);
76 SIGDELSET(set, SIGSEGV);
77 SIGDELSET(set, SIGTRAP);
78 __sys_sigprocmask(SIG_BLOCK, &set, &curthread->sigmask);
79 curthread->sigblock++;
83 _thr_signal_unblock(struct pthread *curthread)
85 if (--curthread->sigblock == 0)
86 __sys_sigprocmask(SIG_SETMASK, &curthread->sigmask, NULL);
90 _thr_assert_lock_level()
92 PANIC("locklevel <= 0");
96 _thr_send_sig(struct pthread *thread, int sig)
98 return (kill(thread->tid, sig));