root / lab4 / .minix-src / include / event2 / event_struct.h @ 13
History | View | Annotate | Download (4.09 KB)
1 | 13 | up20180614 | /* $NetBSD: event_struct.h,v 1.1.1.2 2015/01/29 06:38:27 spz Exp $ */
|
---|---|---|---|
2 | /* $NetBSD: event_struct.h,v 1.1.1.2 2015/01/29 06:38:27 spz Exp $ */
|
||
3 | /*
|
||
4 | * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
|
||
5 | * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
|
||
6 | *
|
||
7 | * Redistribution and use in source and binary forms, with or without
|
||
8 | * modification, are permitted provided that the following conditions
|
||
9 | * are met:
|
||
10 | * 1. Redistributions of source code must retain the above copyright
|
||
11 | * notice, this list of conditions and the following disclaimer.
|
||
12 | * 2. Redistributions in binary form must reproduce the above copyright
|
||
13 | * notice, this list of conditions and the following disclaimer in the
|
||
14 | * documentation and/or other materials provided with the distribution.
|
||
15 | * 3. The name of the author may not be used to endorse or promote products
|
||
16 | * derived from this software without specific prior written permission.
|
||
17 | *
|
||
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
28 | */
|
||
29 | #ifndef _EVENT2_EVENT_STRUCT_H_
|
||
30 | #define _EVENT2_EVENT_STRUCT_H_
|
||
31 | |||
32 | /** @file event2/event_struct.h
|
||
33 | |||
34 | Structures used by event.h. Using these structures directly WILL harm
|
||
35 | forward compatibility: be careful.
|
||
36 | |||
37 | No field declared in this file should be used directly in user code. Except
|
||
38 | for historical reasons, these fields would not be exposed at all.
|
||
39 | */
|
||
40 | |||
41 | #ifdef __cplusplus
|
||
42 | extern "C" { |
||
43 | #endif
|
||
44 | |||
45 | #include <event2/event-config.h> |
||
46 | #ifdef _EVENT_HAVE_SYS_TYPES_H
|
||
47 | #include <sys/types.h> |
||
48 | #endif
|
||
49 | #ifdef _EVENT_HAVE_SYS_TIME_H
|
||
50 | #include <sys/time.h> |
||
51 | #endif
|
||
52 | |||
53 | /* For int types. */
|
||
54 | #include <event2/util.h> |
||
55 | |||
56 | /* For evkeyvalq */
|
||
57 | #include <event2/keyvalq_struct.h> |
||
58 | |||
59 | #define EVLIST_TIMEOUT 0x01 |
||
60 | #define EVLIST_INSERTED 0x02 |
||
61 | #define EVLIST_SIGNAL 0x04 |
||
62 | #define EVLIST_ACTIVE 0x08 |
||
63 | #define EVLIST_INTERNAL 0x10 |
||
64 | #define EVLIST_INIT 0x80 |
||
65 | |||
66 | /* EVLIST_X_ Private space: 0x1000-0xf000 */
|
||
67 | #define EVLIST_ALL (0xf000 | 0x9f) |
||
68 | |||
69 | /* Fix so that people don't have to run with <sys/queue.h> */
|
||
70 | #ifndef TAILQ_ENTRY
|
||
71 | #define _EVENT_DEFINED_TQENTRY
|
||
72 | #define TAILQ_ENTRY(type) \
|
||
73 | struct { \
|
||
74 | struct type *tqe_next; /* next element */ \ |
||
75 | struct type **tqe_prev; /* address of previous next element */ \ |
||
76 | } |
||
77 | #endif /* !TAILQ_ENTRY */ |
||
78 | |||
79 | #ifndef TAILQ_HEAD
|
||
80 | #define _EVENT_DEFINED_TQHEAD
|
||
81 | #define TAILQ_HEAD(name, type) \
|
||
82 | struct name { \
|
||
83 | struct type *tqh_first; \
|
||
84 | struct type **tqh_last; \
|
||
85 | } |
||
86 | #endif
|
||
87 | |||
88 | struct event_base;
|
||
89 | struct event {
|
||
90 | TAILQ_ENTRY(event) ev_active_next; |
||
91 | TAILQ_ENTRY(event) ev_next; |
||
92 | /* for managing timeouts */
|
||
93 | union {
|
||
94 | TAILQ_ENTRY(event) ev_next_with_common_timeout; |
||
95 | int min_heap_idx;
|
||
96 | } ev_timeout_pos; |
||
97 | evutil_socket_t ev_fd; |
||
98 | |||
99 | struct event_base *ev_base;
|
||
100 | |||
101 | union {
|
||
102 | /* used for io events */
|
||
103 | struct {
|
||
104 | TAILQ_ENTRY(event) ev_io_next; |
||
105 | struct timeval ev_timeout;
|
||
106 | } ev_io; |
||
107 | |||
108 | /* used by signal events */
|
||
109 | struct {
|
||
110 | TAILQ_ENTRY(event) ev_signal_next; |
||
111 | short ev_ncalls;
|
||
112 | /* Allows deletes in callback */
|
||
113 | short *ev_pncalls;
|
||
114 | } ev_signal; |
||
115 | } _ev; |
||
116 | |||
117 | short ev_events;
|
||
118 | short ev_res; /* result passed to event callback */ |
||
119 | short ev_flags;
|
||
120 | ev_uint8_t ev_pri; /* smaller numbers are higher priority */
|
||
121 | ev_uint8_t ev_closure; |
||
122 | struct timeval ev_timeout;
|
||
123 | |||
124 | /* allows us to adopt for different types of events */
|
||
125 | void (*ev_callback)(evutil_socket_t, short, void *arg); |
||
126 | void *ev_arg;
|
||
127 | }; |
||
128 | |||
129 | TAILQ_HEAD (event_list, event); |
||
130 | |||
131 | #ifdef _EVENT_DEFINED_TQENTRY
|
||
132 | #undef TAILQ_ENTRY
|
||
133 | #endif
|
||
134 | |||
135 | #ifdef _EVENT_DEFINED_TQHEAD
|
||
136 | #undef TAILQ_HEAD
|
||
137 | #endif
|
||
138 | |||
139 | #ifdef __cplusplus
|
||
140 | } |
||
141 | #endif
|
||
142 | |||
143 | #endif /* _EVENT2_EVENT_STRUCT_H_ */ |