xref: /freebsd/usr.sbin/bhyve/mevent.h (revision 4dfa329f48618d30e0c32529f874c1d0cc7beb00)
1366f6083SPeter Grehan /*-
24d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
31de7b4b8SPedro F. Giffuni  *
4366f6083SPeter Grehan  * Copyright (c) 2011 NetApp, Inc.
5366f6083SPeter Grehan  * All rights reserved.
6366f6083SPeter Grehan  *
7366f6083SPeter Grehan  * Redistribution and use in source and binary forms, with or without
8366f6083SPeter Grehan  * modification, are permitted provided that the following conditions
9366f6083SPeter Grehan  * are met:
10366f6083SPeter Grehan  * 1. Redistributions of source code must retain the above copyright
11366f6083SPeter Grehan  *    notice, this list of conditions and the following disclaimer.
12366f6083SPeter Grehan  * 2. Redistributions in binary form must reproduce the above copyright
13366f6083SPeter Grehan  *    notice, this list of conditions and the following disclaimer in the
14366f6083SPeter Grehan  *    documentation and/or other materials provided with the distribution.
15366f6083SPeter Grehan  *
16366f6083SPeter Grehan  * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND
17366f6083SPeter Grehan  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18366f6083SPeter Grehan  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19366f6083SPeter Grehan  * ARE DISCLAIMED.  IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE
20366f6083SPeter Grehan  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21366f6083SPeter Grehan  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22366f6083SPeter Grehan  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23366f6083SPeter Grehan  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24366f6083SPeter Grehan  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25366f6083SPeter Grehan  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26366f6083SPeter Grehan  * SUCH DAMAGE.
27366f6083SPeter Grehan  */
28366f6083SPeter Grehan 
29366f6083SPeter Grehan #ifndef	_MEVENT_H_
30366f6083SPeter Grehan #define	_MEVENT_H_
31366f6083SPeter Grehan 
32366f6083SPeter Grehan enum ev_type {
33366f6083SPeter Grehan 	EVF_READ,
34151dba4aSPeter Grehan 	EVF_WRITE,
35058e24d3SJohn Baldwin 	EVF_TIMER,
3667d60dccSJohn Baldwin 	EVF_SIGNAL,
3767d60dccSJohn Baldwin 	EVF_VNODE,
38366f6083SPeter Grehan };
39366f6083SPeter Grehan 
4067d60dccSJohn Baldwin /* Filter flags for EVF_VNODE */
4167d60dccSJohn Baldwin #define	EVFF_ATTRIB	0x0001
4267d60dccSJohn Baldwin 
43366f6083SPeter Grehan struct mevent;
44366f6083SPeter Grehan 
45366f6083SPeter Grehan struct mevent *mevent_add(int fd, enum ev_type type,
46366f6083SPeter Grehan 			  void (*func)(int, enum ev_type, void *),
47366f6083SPeter Grehan 			  void *param);
4867d60dccSJohn Baldwin struct mevent *mevent_add_flags(int fd, enum ev_type type, int fflags,
4967d60dccSJohn Baldwin 			  void (*func)(int, enum ev_type, void *),
5067d60dccSJohn Baldwin 			  void *param);
513e11768eSVincenzo Maffione struct mevent *mevent_add_disabled(int fd, enum ev_type type,
523e11768eSVincenzo Maffione 			  void (*func)(int, enum ev_type, void *),
533e11768eSVincenzo Maffione 			  void *param);
54366f6083SPeter Grehan int	mevent_enable(struct mevent *evp);
55366f6083SPeter Grehan int	mevent_disable(struct mevent *evp);
56366f6083SPeter Grehan int	mevent_delete(struct mevent *evp);
57366f6083SPeter Grehan int	mevent_delete_close(struct mevent *evp);
58*4dfa329fSJessica Clarke int	mevent_timer_update(struct mevent *evp, int msecs);
59366f6083SPeter Grehan 
60366f6083SPeter Grehan void	mevent_dispatch(void);
61366f6083SPeter Grehan 
62366f6083SPeter Grehan #endif	/* _MEVENT_H_ */
63