Deleted Added
sdiff udiff text old ( 209933 ) new ( 211524 )
full compact
1/*
2 * Copyright (c) 2005, David Xu <davidxu@freebsd.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

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.
25 *
26 * $FreeBSD: head/lib/libthr/thread/thr_sig.c 209933 2010-07-12 10:15:33Z kib $
27 */
28
29#include "namespace.h"
30#include <sys/param.h>
31#include <sys/types.h>
32#include <sys/signalvar.h>
33#include <signal.h>
34#include <errno.h>

--- 27 unchanged lines hidden (view full) ---

62
63
64static void
65sigcancel_handler(int sig __unused,
66 siginfo_t *info __unused, ucontext_t *ucp __unused)
67{
68 struct pthread *curthread = _get_curthread();
69
70 if (curthread->cancel_defer && curthread->cancel_pending)
71 thr_wake(curthread->tid);
72 curthread->in_sigcancel_handler++;
73 _thr_ast(curthread);
74 curthread->in_sigcancel_handler--;
75}
76
77void
78_thr_ast(struct pthread *curthread)
79{
80 if (!THR_IN_CRITICAL(curthread)) {
81 _thr_testcancel(curthread);
82 if (__predict_false((curthread->flags &
83 (THR_FLAGS_NEED_SUSPEND | THR_FLAGS_SUSPENDED))
84 == THR_FLAGS_NEED_SUSPEND))
85 _thr_suspend_check(curthread);
86 }
87}
88
89void
90_thr_suspend_check(struct pthread *curthread)
91{
92 uint32_t cycle;
93 int err;
94

--- 196 unchanged lines hidden (view full) ---

291 SIGDELSET(newset, SIGCANCEL);
292 pset = &newset;
293 } else
294 pset = set;
295 ret = __sys_sigtimedwait(pset, info, timeout);
296 return (ret);
297}
298
299int
300__sigtimedwait(const sigset_t *set, siginfo_t *info,
301 const struct timespec * timeout)
302{
303 struct pthread *curthread = _get_curthread();
304 sigset_t newset;
305 const sigset_t *pset;
306 int ret;
307
308 if (SIGISMEMBER(*set, SIGCANCEL)) {
309 newset = *set;
310 SIGDELSET(newset, SIGCANCEL);
311 pset = &newset;
312 } else
313 pset = set;
314 _thr_cancel_enter(curthread);
315 ret = __sys_sigtimedwait(pset, info, timeout);
316 _thr_cancel_leave(curthread);
317 return (ret);
318}
319
320int
321_sigwaitinfo(const sigset_t *set, siginfo_t *info)
322{
323 sigset_t newset;
324 const sigset_t *pset;

--- 5 unchanged lines hidden (view full) ---

330 pset = &newset;
331 } else
332 pset = set;
333
334 ret = __sys_sigwaitinfo(pset, info);
335 return (ret);
336}
337
338int
339__sigwaitinfo(const sigset_t *set, siginfo_t *info)
340{
341 struct pthread *curthread = _get_curthread();
342 sigset_t newset;
343 const sigset_t *pset;
344 int ret;
345
346 if (SIGISMEMBER(*set, SIGCANCEL)) {
347 newset = *set;
348 SIGDELSET(newset, SIGCANCEL);
349 pset = &newset;
350 } else
351 pset = set;
352
353 _thr_cancel_enter(curthread);
354 ret = __sys_sigwaitinfo(pset, info);
355 _thr_cancel_leave(curthread);
356 return (ret);
357}
358
359int
360_sigwait(const sigset_t *set, int *sig)
361{
362 sigset_t newset;
363 const sigset_t *pset;

--- 5 unchanged lines hidden (view full) ---

369 pset = &newset;
370 } else
371 pset = set;
372
373 ret = __sys_sigwait(pset, sig);
374 return (ret);
375}
376
377int
378__sigwait(const sigset_t *set, int *sig)
379{
380 struct pthread *curthread = _get_curthread();
381 sigset_t newset;
382 const sigset_t *pset;
383 int ret;
384
385 if (SIGISMEMBER(*set, SIGCANCEL)) {
386 newset = *set;
387 SIGDELSET(newset, SIGCANCEL);
388 pset = &newset;
389 } else
390 pset = set;
391
392 _thr_cancel_enter(curthread);
393 ret = __sys_sigwait(pset, sig);
394 _thr_cancel_leave(curthread);
395 return (ret);
396}