Remove building with NOCRYPTO option
[minix.git] / external / bsd / libevent / dist / include / event2 / event_compat.h
blobcf0b6bd1f1885fe5a745a21f3b78760a9ea8bfe6
1 /* $NetBSD: event_compat.h,v 1.1.1.2 2015/01/29 06:38:27 spz Exp $ */
2 /* $NetBSD: event_compat.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
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.
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.
29 #ifndef _EVENT2_EVENT_COMPAT_H_
30 #define _EVENT2_EVENT_COMPAT_H_
32 /** @file event2/event_compat.h
34 Potentially non-threadsafe versions of the functions in event.h: provided
35 only for backwards compatibility.
37 In the oldest versions of Libevent, event_base was not a first-class
38 structure. Instead, there was a single event base that every function
39 manipulated. Later, when separate event bases were added, the old functions
40 that didn't take an event_base argument needed to work by manipulating the
41 "current" event base. This could lead to thread-safety issues, and obscure,
42 hard-to-diagnose bugs.
44 @deprecated All functions in this file are by definition deprecated.
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
51 #include <event2/event-config.h>
52 #ifdef _EVENT_HAVE_SYS_TYPES_H
53 #include <sys/types.h>
54 #endif
55 #ifdef _EVENT_HAVE_SYS_TIME_H
56 #include <sys/time.h>
57 #endif
59 /* For int types. */
60 #include <event2/util.h>
62 /**
63 Initialize the event API.
65 The event API needs to be initialized with event_init() before it can be
66 used. Sets the global current base that gets used for events that have no
67 base associated with them.
69 @deprecated This function is deprecated because it replaces the "current"
70 event_base, and is totally unsafe for multithreaded use. The replacement
71 is event_base_new().
73 @see event_base_set(), event_base_new()
75 struct event_base *event_init(void);
77 /**
78 Loop to process events.
80 Like event_base_dispatch(), but uses the "current" base.
82 @deprecated This function is deprecated because it is easily confused by
83 multiple calls to event_init(), and because it is not safe for
84 multithreaded use. The replacement is event_base_dispatch().
86 @see event_base_dispatch(), event_init()
88 int event_dispatch(void);
90 /**
91 Handle events.
93 This function behaves like event_base_loop(), but uses the "current" base
95 @deprecated This function is deprecated because it uses the event base from
96 the last call to event_init, and is therefore not safe for multithreaded
97 use. The replacement is event_base_loop().
99 @see event_base_loop(), event_init()
101 int event_loop(int);
105 Exit the event loop after the specified time.
107 This function behaves like event_base_loopexit(), except that it uses the
108 "current" base.
110 @deprecated This function is deprecated because it uses the event base from
111 the last call to event_init, and is therefore not safe for multithreaded
112 use. The replacement is event_base_loopexit().
114 @see event_init, event_base_loopexit()
116 int event_loopexit(const struct timeval *);
120 Abort the active event_loop() immediately.
122 This function behaves like event_base_loopbreakt(), except that it uses the
123 "current" base.
125 @deprecated This function is deprecated because it uses the event base from
126 the last call to event_init, and is therefore not safe for multithreaded
127 use. The replacement is event_base_loopbreak().
129 @see event_base_loopbreak(), event_init()
131 int event_loopbreak(void);
134 Schedule a one-time event to occur.
136 @deprecated This function is obsolete, and has been replaced by
137 event_base_once(). Its use is deprecated because it relies on the
138 "current" base configured by event_init().
140 @see event_base_once()
142 int event_once(evutil_socket_t , short,
143 void (*)(evutil_socket_t, short, void *), void *, const struct timeval *);
147 Get the kernel event notification mechanism used by Libevent.
149 @deprecated This function is obsolete, and has been replaced by
150 event_base_get_method(). Its use is deprecated because it relies on the
151 "current" base configured by event_init().
153 @see event_base_get_method()
155 const char *event_get_method(void);
159 Set the number of different event priorities.
161 @deprecated This function is deprecated because it is easily confused by
162 multiple calls to event_init(), and because it is not safe for
163 multithreaded use. The replacement is event_base_priority_init().
165 @see event_base_priority_init()
167 int event_priority_init(int);
170 Prepare an event structure to be added.
172 @deprecated event_set() is not recommended for new code, because it requires
173 a subsequent call to event_base_set() to be safe under most circumstances.
174 Use event_assign() or event_new() instead.
176 void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *);
178 #define evtimer_set(ev, cb, arg) event_set((ev), -1, 0, (cb), (arg))
179 #define evsignal_set(ev, x, cb, arg) \
180 event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
184 @name timeout_* macros
186 @deprecated These macros are deprecated because their naming is inconsistent
187 with the rest of Libevent. Use the evtimer_* macros instead.
190 #define timeout_add(ev, tv) event_add((ev), (tv))
191 #define timeout_set(ev, cb, arg) event_set((ev), -1, 0, (cb), (arg))
192 #define timeout_del(ev) event_del(ev)
193 #define timeout_pending(ev, tv) event_pending((ev), EV_TIMEOUT, (tv))
194 #define timeout_initialized(ev) event_initialized(ev)
195 /**@}*/
198 @name signal_* macros
200 @deprecated These macros are deprecated because their naming is inconsistent
201 with the rest of Libevent. Use the evsignal_* macros instead.
204 #define signal_add(ev, tv) event_add((ev), (tv))
205 #define signal_set(ev, x, cb, arg) \
206 event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
207 #define signal_del(ev) event_del(ev)
208 #define signal_pending(ev, tv) event_pending((ev), EV_SIGNAL, (tv))
209 #define signal_initialized(ev) event_initialized(ev)
210 /**@}*/
212 #ifndef EVENT_FD
213 /* These macros are obsolete; use event_get_fd and event_get_signal instead. */
214 #define EVENT_FD(ev) ((int)event_get_fd(ev))
215 #define EVENT_SIGNAL(ev) event_get_signal(ev)
216 #endif
218 #ifdef __cplusplus
220 #endif
222 #endif /* _EVENT2_EVENT_COMPAT_H_ */