1156136Sdavidxu/* 2156136Sdavidxu * Copyright (c) 2005 David Xu <davidxu@freebsd.org> 3156136Sdavidxu * All rights reserved. 4156136Sdavidxu * 5156136Sdavidxu * Redistribution and use in source and binary forms, with or without 6156136Sdavidxu * modification, are permitted provided that the following conditions 7156136Sdavidxu * are met: 8156136Sdavidxu * 1. Redistributions of source code must retain the above copyright 9156136Sdavidxu * notice unmodified, this list of conditions, and the following 10156136Sdavidxu * disclaimer. 11156136Sdavidxu * 2. Redistributions in binary form must reproduce the above copyright 12156136Sdavidxu * notice, this list of conditions and the following disclaimer in the 13156136Sdavidxu * documentation and/or other materials provided with the distribution. 14156136Sdavidxu * 15156136Sdavidxu * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16156136Sdavidxu * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17156136Sdavidxu * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18156136Sdavidxu * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19156136Sdavidxu * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20156136Sdavidxu * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21156136Sdavidxu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22156136Sdavidxu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23156136Sdavidxu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24156136Sdavidxu * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25156136Sdavidxu * 26156136Sdavidxu * $FreeBSD$ 27156136Sdavidxu * 28156136Sdavidxu */ 29156136Sdavidxu 30156136Sdavidxu#ifndef _SIGEV_THREAD_H_ 31156136Sdavidxu#define _SIGEV_THREAD_H_ 32156136Sdavidxu 33156136Sdavidxu#include <sys/types.h> 34156136Sdavidxu#include <sys/queue.h> 35156136Sdavidxu 36156383Sdavidxustruct sigev_thread; 37156136Sdavidxustruct sigev_node; 38156136Sdavidxu 39156136Sdavidxutypedef uintptr_t sigev_id_t; 40156267Sdavidxutypedef void (*sigev_dispatch_t)(struct sigev_node *); 41156136Sdavidxu 42156136Sdavidxustruct sigev_node { 43156136Sdavidxu LIST_ENTRY(sigev_node) sn_link; 44156136Sdavidxu int sn_type; 45156136Sdavidxu sigev_id_t sn_id; 46156136Sdavidxu sigev_dispatch_t sn_dispatch; 47156136Sdavidxu union sigval sn_value; 48156136Sdavidxu void *sn_func; 49156136Sdavidxu int sn_flags; 50156136Sdavidxu int sn_gen; 51156267Sdavidxu siginfo_t sn_info; 52156383Sdavidxu pthread_attr_t sn_attr; 53156383Sdavidxu struct sigev_thread *sn_tn; 54156136Sdavidxu}; 55156136Sdavidxu 56156136Sdavidxu 57156383Sdavidxustruct sigev_thread { 58156383Sdavidxu LIST_ENTRY(sigev_thread) tn_link; 59156136Sdavidxu pthread_t tn_thread; 60156136Sdavidxu struct sigev_node *tn_cur; 61156267Sdavidxu int tn_refcount; 62156136Sdavidxu long tn_lwpid; 63156383Sdavidxu pthread_cond_t tn_cv; 64156136Sdavidxu}; 65156136Sdavidxu 66156136Sdavidxu#define SNF_WORKING 0x01 67156136Sdavidxu#define SNF_REMOVED 0x02 68156383Sdavidxu#define SNF_SYNC 0x04 69156136Sdavidxu 70156136Sdavidxuint __sigev_check_init(); 71156267Sdavidxustruct sigev_node *__sigev_alloc(int, const struct sigevent *, 72156383Sdavidxu struct sigev_node *, int); 73156136Sdavidxustruct sigev_node *__sigev_find(int, sigev_id_t); 74156136Sdavidxuvoid __sigev_get_sigevent(struct sigev_node *, struct sigevent *, 75156136Sdavidxu sigev_id_t); 76156136Sdavidxuint __sigev_register(struct sigev_node *); 77156136Sdavidxuint __sigev_delete(int, sigev_id_t); 78156136Sdavidxuint __sigev_delete_node(struct sigev_node *); 79156383Sdavidxuvoid __sigev_list_lock(void); 80156383Sdavidxuvoid __sigev_list_unlock(void); 81156136Sdavidxuvoid __sigev_free(struct sigev_node *); 82156136Sdavidxu 83156136Sdavidxu#endif 84