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/librt/sigev_thread.c 156529 2006-03-10 08:01:23Z davidxu $
27 *
28 */
29
30#include <sys/types.h>
31#include <machine/atomic.h>
32
33#include "namespace.h"
34#include <err.h>
--- 265 unchanged lines hidden (view full) ---
300 }
301 return (-1);
302}
303
304static struct sigev_thread *
305sigev_thread_create(int usedefault)
306{
307 struct sigev_thread *tn;
308 sigset_t set, oset;
309 int ret;
310
311 if (usedefault && sigev_default_thread) {
312 __sigev_list_lock();
313 sigev_default_thread->tn_refcount++;
314 __sigev_list_unlock();
315 return (sigev_default_thread);
316 }
--- 4 unchanged lines hidden (view full) ---
321 tn->tn_refcount = 1;
322 _pthread_cond_init(&tn->tn_cv, NULL);
323
324 /* for debug */
325 __sigev_list_lock();
326 LIST_INSERT_HEAD(&sigev_threads, tn, tn_link);
327 __sigev_list_unlock();
328
329 sigfillset(&set); /* SIGSERVICE is masked. */
330 sigdelset(&set, SIGBUS);
331 sigdelset(&set, SIGILL);
332 sigdelset(&set, SIGFPE);
333 sigdelset(&set, SIGSEGV);
334 sigdelset(&set, SIGTRAP);
335 _sigprocmask(SIG_SETMASK, &set, &oset);
336 ret = pthread_create(&tn->tn_thread, &sigev_default_attr,
337 sigev_service_loop, tn);
338 _sigprocmask(SIG_SETMASK, &oset, NULL);
339
340 if (ret != 0) {
341 __sigev_list_lock();
342 LIST_REMOVE(tn, tn_link);
343 __sigev_list_unlock();
344 free(tn);
345 tn = NULL;
346 } else {
--- 119 unchanged lines hidden ---
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/librt/sigev_thread.c 156529 2006-03-10 08:01:23Z davidxu $
27 *
28 */
29
30#include <sys/types.h>
31#include <machine/atomic.h>
32
33#include "namespace.h"
34#include <err.h>
--- 265 unchanged lines hidden (view full) ---
300 }
301 return (-1);
302}
303
304static struct sigev_thread *
305sigev_thread_create(int usedefault)
306{
307 struct sigev_thread *tn;
308 sigset_t set, oset;
309 int ret;
310
311 if (usedefault && sigev_default_thread) {
312 __sigev_list_lock();
313 sigev_default_thread->tn_refcount++;
314 __sigev_list_unlock();
315 return (sigev_default_thread);
316 }
--- 4 unchanged lines hidden (view full) ---
321 tn->tn_refcount = 1;
322 _pthread_cond_init(&tn->tn_cv, NULL);
323
324 /* for debug */
325 __sigev_list_lock();
326 LIST_INSERT_HEAD(&sigev_threads, tn, tn_link);
327 __sigev_list_unlock();
328
329 sigfillset(&set); /* SIGSERVICE is masked. */
330 sigdelset(&set, SIGBUS);
331 sigdelset(&set, SIGILL);
332 sigdelset(&set, SIGFPE);
333 sigdelset(&set, SIGSEGV);
334 sigdelset(&set, SIGTRAP);
335 _sigprocmask(SIG_SETMASK, &set, &oset);
336 ret = pthread_create(&tn->tn_thread, &sigev_default_attr,
337 sigev_service_loop, tn);
338 _sigprocmask(SIG_SETMASK, &oset, NULL);
339
340 if (ret != 0) {
341 __sigev_list_lock();
342 LIST_REMOVE(tn, tn_link);
343 __sigev_list_unlock();
344 free(tn);
345 tn = NULL;
346 } else {
--- 119 unchanged lines hidden ---