Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:12

0001 /*
0002  * Copyright (c) 2000-2007 Niels Provos <provos@citi.umich.edu>
0003  * Copyright (c) 2007-2012 Niels Provos and Nick Mathewson
0004  *
0005  * Redistribution and use in source and binary forms, with or without
0006  * modification, are permitted provided that the following conditions
0007  * are met:
0008  * 1. Redistributions of source code must retain the above copyright
0009  *    notice, this list of conditions and the following disclaimer.
0010  * 2. Redistributions in binary form must reproduce the above copyright
0011  *    notice, this list of conditions and the following disclaimer in the
0012  *    documentation and/or other materials provided with the distribution.
0013  * 3. The name of the author may not be used to endorse or promote products
0014  *    derived from this software without specific prior written permission.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
0017  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
0018  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
0019  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
0020  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
0021  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0022  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0023  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0024  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
0025  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0026  */
0027 #ifndef EVENT2_EVENT_COMPAT_H_INCLUDED_
0028 #define EVENT2_EVENT_COMPAT_H_INCLUDED_
0029 
0030 /** @file event2/event_compat.h
0031 
0032   Potentially non-threadsafe versions of the functions in event.h: provided
0033   only for backwards compatibility.
0034 
0035   In the oldest versions of Libevent, event_base was not a first-class
0036   structure.  Instead, there was a single event base that every function
0037   manipulated.  Later, when separate event bases were added, the old functions
0038   that didn't take an event_base argument needed to work by manipulating the
0039   "current" event base.  This could lead to thread-safety issues, and obscure,
0040   hard-to-diagnose bugs.
0041 
0042   @deprecated All functions in this file are by definition deprecated.
0043  */
0044 #include <event2/visibility.h>
0045 
0046 #ifdef __cplusplus
0047 extern "C" {
0048 #endif
0049 
0050 #include <event2/event-config.h>
0051 #ifdef EVENT__HAVE_SYS_TYPES_H
0052 #include <sys/types.h>
0053 #endif
0054 #ifdef EVENT__HAVE_SYS_TIME_H
0055 #include <sys/time.h>
0056 #endif
0057 
0058 /* For int types. */
0059 #include <event2/util.h>
0060 
0061 /**
0062   Initialize the event API.
0063 
0064   The event API needs to be initialized with event_init() before it can be
0065   used.  Sets the global current base that gets used for events that have no
0066   base associated with them.
0067 
0068   @deprecated This function is deprecated because it replaces the "current"
0069     event_base, and is totally unsafe for multithreaded use.  The replacement
0070     is event_base_new().
0071 
0072   @see event_base_set(), event_base_new()
0073  */
0074 EVENT2_EXPORT_SYMBOL
0075 struct event_base *event_init(void);
0076 
0077 /**
0078   Loop to process events.
0079 
0080   Like event_base_dispatch(), but uses the "current" base.
0081 
0082   @deprecated This function is deprecated because it is easily confused by
0083     multiple calls to event_init(), and because it is not safe for
0084     multithreaded use.  The replacement is event_base_dispatch().
0085 
0086   @see event_base_dispatch(), event_init()
0087  */
0088 EVENT2_EXPORT_SYMBOL
0089 int event_dispatch(void);
0090 
0091 /**
0092   Handle events.
0093 
0094   This function behaves like event_base_loop(), but uses the "current" base
0095 
0096   @deprecated This function is deprecated because it uses the event base from
0097     the last call to event_init, and is therefore not safe for multithreaded
0098     use.  The replacement is event_base_loop().
0099 
0100   @see event_base_loop(), event_init()
0101 */
0102 EVENT2_EXPORT_SYMBOL
0103 int event_loop(int);
0104 
0105 
0106 /**
0107   Exit the event loop after the specified time.
0108 
0109   This function behaves like event_base_loopexit(), except that it uses the
0110   "current" base.
0111 
0112   @deprecated This function is deprecated because it uses the event base from
0113     the last call to event_init, and is therefore not safe for multithreaded
0114     use.  The replacement is event_base_loopexit().
0115 
0116   @see event_init, event_base_loopexit()
0117   */
0118 EVENT2_EXPORT_SYMBOL
0119 int event_loopexit(const struct timeval *);
0120 
0121 
0122 /**
0123   Abort the active event_loop() immediately.
0124 
0125   This function behaves like event_base_loopbreakt(), except that it uses the
0126   "current" base.
0127 
0128   @deprecated This function is deprecated because it uses the event base from
0129     the last call to event_init, and is therefore not safe for multithreaded
0130     use.  The replacement is event_base_loopbreak().
0131 
0132   @see event_base_loopbreak(), event_init()
0133  */
0134 EVENT2_EXPORT_SYMBOL
0135 int event_loopbreak(void);
0136 
0137 /**
0138   Schedule a one-time event to occur.
0139 
0140   @deprecated This function is obsolete, and has been replaced by
0141     event_base_once(). Its use is deprecated because it relies on the
0142     "current" base configured by event_init().
0143 
0144   @see event_base_once()
0145  */
0146 EVENT2_EXPORT_SYMBOL
0147 int event_once(evutil_socket_t , short,
0148     void (*)(evutil_socket_t, short, void *), void *, const struct timeval *);
0149 
0150 
0151 /**
0152   Get the kernel event notification mechanism used by Libevent.
0153 
0154   @deprecated This function is obsolete, and has been replaced by
0155     event_base_get_method(). Its use is deprecated because it relies on the
0156     "current" base configured by event_init().
0157 
0158   @see event_base_get_method()
0159  */
0160 EVENT2_EXPORT_SYMBOL
0161 const char *event_get_method(void);
0162 
0163 
0164 /**
0165   Set the number of different event priorities.
0166 
0167   @deprecated This function is deprecated because it is easily confused by
0168     multiple calls to event_init(), and because it is not safe for
0169     multithreaded use.  The replacement is event_base_priority_init().
0170 
0171   @see event_base_priority_init()
0172  */
0173 EVENT2_EXPORT_SYMBOL
0174 int event_priority_init(int);
0175 
0176 /**
0177   Prepare an event structure to be added.
0178 
0179   @deprecated event_set() is not recommended for new code, because it requires
0180      a subsequent call to event_base_set() to be safe under most circumstances.
0181      Use event_assign() or event_new() instead.
0182  */
0183 EVENT2_EXPORT_SYMBOL
0184 void event_set(struct event *, evutil_socket_t, short, void (*)(evutil_socket_t, short, void *), void *);
0185 
0186 #define evtimer_set(ev, cb, arg)    event_set((ev), -1, 0, (cb), (arg))
0187 #define evsignal_set(ev, x, cb, arg)    \
0188     event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
0189 
0190 
0191 /**
0192    @name timeout_* macros
0193 
0194    @deprecated These macros are deprecated because their naming is inconsistent
0195      with the rest of Libevent.  Use the evtimer_* macros instead.
0196    @{
0197  */
0198 #define timeout_add(ev, tv)     event_add((ev), (tv))
0199 #define timeout_set(ev, cb, arg)    event_set((ev), -1, 0, (cb), (arg))
0200 #define timeout_del(ev)         event_del(ev)
0201 #define timeout_pending(ev, tv)     event_pending((ev), EV_TIMEOUT, (tv))
0202 #define timeout_initialized(ev)     event_initialized(ev)
0203 /**@}*/
0204 
0205 /**
0206    @name signal_* macros
0207 
0208    @deprecated These macros are deprecated because their naming is inconsistent
0209      with the rest of Libevent.  Use the evsignal_* macros instead.
0210    @{
0211  */
0212 #define signal_add(ev, tv)      event_add((ev), (tv))
0213 #define signal_set(ev, x, cb, arg)              \
0214     event_set((ev), (x), EV_SIGNAL|EV_PERSIST, (cb), (arg))
0215 #define signal_del(ev)          event_del(ev)
0216 #define signal_pending(ev, tv)      event_pending((ev), EV_SIGNAL, (tv))
0217 #define signal_initialized(ev)      event_initialized(ev)
0218 /**@}*/
0219 
0220 #ifndef EVENT_FD
0221 /* These macros are obsolete; use event_get_fd and event_get_signal instead. */
0222 #define EVENT_FD(ev)        ((int)event_get_fd(ev))
0223 #define EVENT_SIGNAL(ev)    event_get_signal(ev)
0224 #endif
0225 
0226 #ifdef __cplusplus
0227 }
0228 #endif
0229 
0230 #endif /* EVENT2_EVENT_COMPAT_H_INCLUDED_ */