sigev_thread.h revision 256281
1193323Sed/* 2193323Sed * Copyright (c) 2005 David Xu <davidxu@freebsd.org> 3193323Sed * All rights reserved. 4193323Sed * 5193323Sed * Redistribution and use in source and binary forms, with or without 6193323Sed * modification, are permitted provided that the following conditions 7193323Sed * are met: 8193323Sed * 1. Redistributions of source code must retain the above copyright 9193323Sed * notice unmodified, this list of conditions, and the following 10193323Sed * disclaimer. 11193323Sed * 2. Redistributions in binary form must reproduce the above copyright 12193323Sed * notice, this list of conditions and the following disclaimer in the 13193323Sed * documentation and/or other materials provided with the distribution. 14193323Sed * 15193323Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16193323Sed * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17193323Sed * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18218893Sdim * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19193323Sed * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20193323Sed * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21193323Sed * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22224145Sdim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23193323Sed * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24198090Srdivacky * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25193323Sed * 26193323Sed * $FreeBSD: stable/10/lib/librt/sigev_thread.h 233519 2012-03-26 19:12:09Z rmh $ 27193323Sed * 28224145Sdim */ 29226633Sdim 30224145Sdim#ifndef _SIGEV_THREAD_H_ 31224145Sdim#define _SIGEV_THREAD_H_ 32224145Sdim 33224145Sdim#include <sys/types.h> 34193323Sed#include <sys/queue.h> 35193323Sed 36193323Sedstruct sigev_thread; 37193323Sedstruct sigev_node; 38193323Sed 39193323Sedtypedef uintptr_t sigev_id_t; 40224145Sdimtypedef void (*sigev_dispatch_t)(struct sigev_node *); 41224145Sdim 42224145Sdimstruct sigev_node { 43193323Sed LIST_ENTRY(sigev_node) sn_link; 44193323Sed int sn_type; 45193323Sed sigev_id_t sn_id; 46193323Sed sigev_dispatch_t sn_dispatch; 47218893Sdim union sigval sn_value; 48224145Sdim void *sn_func; 49218893Sdim int sn_flags; 50218893Sdim int sn_gen; 51218893Sdim siginfo_t sn_info; 52218893Sdim pthread_attr_t sn_attr; 53193323Sed struct sigev_thread *sn_tn; 54193323Sed}; 55193323Sed 56193323Sed 57193323Sedstruct sigev_thread { 58193323Sed LIST_ENTRY(sigev_thread) tn_link; 59202375Srdivacky pthread_t tn_thread; 60193323Sed struct sigev_node *tn_cur; 61193323Sed int tn_refcount; 62193323Sed long tn_lwpid; 63193323Sed pthread_cond_t tn_cv; 64193323Sed}; 65193323Sed 66193323Sed#define SNF_WORKING 0x01 67193323Sed#define SNF_REMOVED 0x02 68193323Sed#define SNF_SYNC 0x04 69193323Sed 70193323Sedint __sigev_check_init(); 71193323Sedstruct sigev_node *__sigev_alloc(int, const struct sigevent *, 72193323Sed struct sigev_node *, int); 73193323Sedstruct sigev_node *__sigev_find(int, sigev_id_t); 74193323Sedvoid __sigev_get_sigevent(struct sigev_node *, struct sigevent *, 75193323Sed sigev_id_t); 76193323Sedint __sigev_register(struct sigev_node *); 77193323Sedint __sigev_delete(int, sigev_id_t); 78198090Srdivackyint __sigev_delete_node(struct sigev_node *); 79202375Srdivackyvoid __sigev_list_lock(void); 80198090Srdivackyvoid __sigev_list_unlock(void); 81202375Srdivackyvoid __sigev_free(struct sigev_node *); 82198090Srdivacky 83193323Sed#endif 84193323Sed