Home | History | Annotate | Line # | Download | only in sys
      1  1.10   thorpej /*	$NetBSD: eventvar.h,v 1.10 2021/10/10 18:07:51 thorpej Exp $	*/
      2   1.8        ad 
      3   1.1     lukem /*-
      4   1.1     lukem  * Copyright (c) 1999,2000 Jonathan Lemon <jlemon (at) FreeBSD.org>
      5   1.1     lukem  * All rights reserved.
      6   1.1     lukem  *
      7   1.1     lukem  * Redistribution and use in source and binary forms, with or without
      8   1.1     lukem  * modification, are permitted provided that the following conditions
      9   1.1     lukem  * are met:
     10   1.1     lukem  * 1. Redistributions of source code must retain the above copyright
     11   1.1     lukem  *    notice, this list of conditions and the following disclaimer.
     12   1.1     lukem  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1     lukem  *    notice, this list of conditions and the following disclaimer in the
     14   1.1     lukem  *    documentation and/or other materials provided with the distribution.
     15   1.1     lukem  *
     16   1.1     lukem  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     17   1.1     lukem  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18   1.1     lukem  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19   1.1     lukem  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     20   1.1     lukem  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21   1.1     lukem  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22   1.1     lukem  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23   1.1     lukem  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24   1.1     lukem  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25   1.1     lukem  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26   1.1     lukem  * SUCH DAMAGE.
     27   1.1     lukem  *
     28   1.8        ad  * FreeBSD: src/sys/sys/eventvar.h,v 1.4 2000/07/18 19:31:48 jlemon Exp
     29   1.8        ad  */
     30   1.8        ad 
     31   1.8        ad /*
     32   1.8        ad  * This header is provided for the kqueue implementation and kmem
     33   1.8        ad  * grovellers, and is not expected to be used elsewhere.
     34   1.1     lukem  */
     35   1.1     lukem 
     36   1.1     lukem #ifndef _SYS_EVENTVAR_H_
     37   1.3  jdolecek #define	_SYS_EVENTVAR_H_
     38   1.1     lukem 
     39   1.8        ad #include <sys/mutex.h>
     40   1.8        ad #include <sys/selinfo.h>
     41   1.8        ad #include <sys/filedesc.h>
     42   1.7        ad 
     43   1.3  jdolecek #define	KQ_NEVENTS	8		/* minimize copy{in,out} calls */
     44   1.3  jdolecek #define	KQ_EXTENT	256		/* linear growth by this amount */
     45   1.3  jdolecek #define	KFILTER_MAXNAME	256		/* maximum size of a filter name */
     46   1.3  jdolecek #define	KFILTER_EXTENT	8		/* grow user_kfilters by this amt */
     47   1.1     lukem 
     48   1.1     lukem struct kqueue {
     49   1.1     lukem 	TAILQ_HEAD(kqlist, knote) kq_head;	/* list of pending event */
     50   1.8        ad 	kmutex_t	kq_lock;		/* mutex for queue access */
     51   1.8        ad 	filedesc_t	*kq_fdp;
     52   1.8        ad 	struct selinfo	kq_sel;
     53   1.8        ad 	kcondvar_t	kq_cv;
     54  1.10   thorpej 	uint32_t	kq_count;		/* number of pending events */
     55   1.1     lukem };
     56   1.1     lukem 
     57  1.10   thorpej #define	KQ_RESTART	__BIT(31)		/* force ERESTART */
     58  1.10   thorpej #define	KQ_CLOSING	__BIT(30)		/* kqueue is closing for good */
     59  1.10   thorpej #define	KQ_MAXCOUNT	__BITS(0,29)
     60  1.10   thorpej #define	KQ_COUNT(kq)	((unsigned int)((kq)->kq_count & KQ_MAXCOUNT))
     61  1.10   thorpej 
     62  1.10   thorpej #ifdef _KERNEL
     63  1.10   thorpej 
     64  1.10   thorpej #if defined(DDB)
     65  1.10   thorpej void	kqueue_printit(struct kqueue *, bool,
     66  1.10   thorpej 	    void (*)(const char *, ...));
     67  1.10   thorpej #endif /* DDB */
     68  1.10   thorpej 
     69  1.10   thorpej #endif /* _KERNEL */
     70  1.10   thorpej 
     71   1.1     lukem #endif /* !_SYS_EVENTVAR_H_ */
     72