other-licenses/android/eventlib.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* $NetBSD: eventlib.h,v 1.1.1.3 2005/12/21 23:15:22 christos Exp $ */
michael@0 2
michael@0 3 /*
michael@0 4 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
michael@0 5 * Copyright (c) 1995-1999 by Internet Software Consortium
michael@0 6 *
michael@0 7 * Permission to use, copy, modify, and distribute this software for any
michael@0 8 * purpose with or without fee is hereby granted, provided that the above
michael@0 9 * copyright notice and this permission notice appear in all copies.
michael@0 10 *
michael@0 11 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
michael@0 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
michael@0 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
michael@0 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
michael@0 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
michael@0 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
michael@0 17 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
michael@0 18 */
michael@0 19
michael@0 20 /* eventlib.h - exported interfaces for eventlib
michael@0 21 * vix 09sep95 [initial]
michael@0 22 *
michael@0 23 * Id: eventlib.h,v 1.1.2.1.4.2 2005/07/28 07:43:18 marka Exp
michael@0 24 */
michael@0 25
michael@0 26 /*
michael@0 27 * This version of this file is derived from Android 2.3 "Gingerbread",
michael@0 28 * which contains uncredited changes by Android/Google developers. It has
michael@0 29 * been modified in 2011 for use in the Android build of Mozilla Firefox by
michael@0 30 * Mozilla contributors (including Michael Edwards <m.k.edwards@gmail.com>,
michael@0 31 * and Steve Workman <sjhworkman@gmail.com>).
michael@0 32 * These changes are offered under the same license as the original NetBSD
michael@0 33 * file, whose copyright and license are unchanged above.
michael@0 34 */
michael@0 35
michael@0 36 #ifndef _EVENTLIB_H
michael@0 37 #define _EVENTLIB_H
michael@0 38
michael@0 39 #include <sys/types.h>
michael@0 40 #include <sys/uio.h>
michael@0 41 #include <sys/time.h>
michael@0 42 #include <stdio.h>
michael@0 43
michael@0 44 #ifndef __P
michael@0 45 # define __EVENTLIB_P_DEFINED
michael@0 46 # ifdef __STDC__
michael@0 47 # define __P(x) x
michael@0 48 # else
michael@0 49 # define __P(x) ()
michael@0 50 # endif
michael@0 51 #endif
michael@0 52
michael@0 53 /* In the absence of branded types... */
michael@0 54 typedef struct { void *opaque; } evConnID;
michael@0 55 typedef struct { void *opaque; } evFileID;
michael@0 56 typedef struct { void *opaque; } evStreamID;
michael@0 57 typedef struct { void *opaque; } evTimerID;
michael@0 58 typedef struct { void *opaque; } evWaitID;
michael@0 59 typedef struct { void *opaque; } evContext;
michael@0 60 typedef struct { void *opaque; } evEvent;
michael@0 61
michael@0 62 #define evInitID(id) ((id)->opaque = NULL)
michael@0 63 #define evTestID(id) ((id).opaque != NULL)
michael@0 64
michael@0 65 typedef void (*evConnFunc)__P((evContext, void *, int, const void *, int,
michael@0 66 const void *, int));
michael@0 67 typedef void (*evFileFunc)__P((evContext, void *, int, int));
michael@0 68 typedef void (*evStreamFunc)__P((evContext, void *, int, int));
michael@0 69 typedef void (*evTimerFunc)__P((evContext, void *,
michael@0 70 struct timespec, struct timespec));
michael@0 71 typedef void (*evWaitFunc)__P((evContext, void *, const void *));
michael@0 72
michael@0 73 typedef struct { unsigned char mask[256/8]; } evByteMask;
michael@0 74 #define EV_BYTEMASK_BYTE(b) ((b) / 8)
michael@0 75 #define EV_BYTEMASK_MASK(b) (1 << ((b) % 8))
michael@0 76 #define EV_BYTEMASK_SET(bm, b) \
michael@0 77 ((bm).mask[EV_BYTEMASK_BYTE(b)] |= EV_BYTEMASK_MASK(b))
michael@0 78 #define EV_BYTEMASK_CLR(bm, b) \
michael@0 79 ((bm).mask[EV_BYTEMASK_BYTE(b)] &= ~EV_BYTEMASK_MASK(b))
michael@0 80 #define EV_BYTEMASK_TST(bm, b) \
michael@0 81 ((bm).mask[EV_BYTEMASK_BYTE(b)] & EV_BYTEMASK_MASK(b))
michael@0 82
michael@0 83 #define EV_POLL 1
michael@0 84 #define EV_WAIT 2
michael@0 85 #define EV_NULL 4
michael@0 86
michael@0 87 #define EV_READ 1
michael@0 88 #define EV_WRITE 2
michael@0 89 #define EV_EXCEPT 4
michael@0 90
michael@0 91 #define EV_WASNONBLOCKING 8 /* Internal library use. */
michael@0 92
michael@0 93 /* eventlib.c */
michael@0 94 #define evCreate __evCreate
michael@0 95 #define evSetDebug __evSetDebug
michael@0 96 #define evDestroy __evDestroy
michael@0 97 #define evGetNext __evGetNext
michael@0 98 #define evDispatch __evDispatch
michael@0 99 #define evDrop __evDrop
michael@0 100 #define evMainLoop __evMainLoop
michael@0 101 #define evHighestFD __evHighestFD
michael@0 102 #define evGetOption __evGetOption
michael@0 103 #define evSetOption __evSetOption
michael@0 104
michael@0 105 int evCreate __P((evContext *));
michael@0 106 void evSetDebug __P((evContext, int, FILE *));
michael@0 107 int evDestroy __P((evContext));
michael@0 108 int evGetNext __P((evContext, evEvent *, int));
michael@0 109 int evDispatch __P((evContext, evEvent));
michael@0 110 void evDrop __P((evContext, evEvent));
michael@0 111 int evMainLoop __P((evContext));
michael@0 112 int evHighestFD __P((evContext));
michael@0 113 int evGetOption __P((evContext *, const char *, int *));
michael@0 114 int evSetOption __P((evContext *, const char *, int));
michael@0 115
michael@0 116 /* ev_connects.c */
michael@0 117 #define evListen __evListen
michael@0 118 #define evConnect __evConnect
michael@0 119 #define evCancelConn __evCancelConn
michael@0 120 #define evHold __evHold
michael@0 121 #define evUnhold __evUnhold
michael@0 122 #define evTryAccept __evTryAccept
michael@0 123
michael@0 124 int evListen __P((evContext, int, int, evConnFunc, void *, evConnID *));
michael@0 125 int evConnect __P((evContext, int, const void *, int,
michael@0 126 evConnFunc, void *, evConnID *));
michael@0 127 int evCancelConn __P((evContext, evConnID));
michael@0 128 int evHold __P((evContext, evConnID));
michael@0 129 int evUnhold __P((evContext, evConnID));
michael@0 130 int evTryAccept __P((evContext, evConnID, int *));
michael@0 131
michael@0 132 /* ev_files.c */
michael@0 133 #define evSelectFD __evSelectFD
michael@0 134 #define evDeselectFD __evDeselectFD
michael@0 135
michael@0 136 int evSelectFD __P((evContext, int, int, evFileFunc, void *, evFileID *));
michael@0 137 int evDeselectFD __P((evContext, evFileID));
michael@0 138
michael@0 139 /* ev_streams.c */
michael@0 140 #define evConsIovec __evConsIovec
michael@0 141 #define evWrite __evWrite
michael@0 142 #define evRead __evRead
michael@0 143 #define evTimeRW __evTimeRW
michael@0 144 #define evUntimeRW __evUntimeRW
michael@0 145 #define evCancelRW __evCancelRW
michael@0 146
michael@0 147 struct iovec evConsIovec __P((void *, size_t));
michael@0 148 int evWrite __P((evContext, int, const struct iovec *, int,
michael@0 149 evStreamFunc func, void *, evStreamID *));
michael@0 150 int evRead __P((evContext, int, const struct iovec *, int,
michael@0 151 evStreamFunc func, void *, evStreamID *));
michael@0 152 int evTimeRW __P((evContext, evStreamID, evTimerID timer));
michael@0 153 int evUntimeRW __P((evContext, evStreamID));
michael@0 154 int evCancelRW __P((evContext, evStreamID));
michael@0 155
michael@0 156 /* ev_timers.c */
michael@0 157 #define evConsTime __evConsTime
michael@0 158 #define evAddTime __evAddTime
michael@0 159 #define evSubTime __evSubTime
michael@0 160 #define evCmpTime __evCmpTime
michael@0 161 #define evTimeSpec __evTimeSpec
michael@0 162 #define evTimeVal __evTimeVal
michael@0 163
michael@0 164 #define evNowTime __evNowTime
michael@0 165 #define evUTCTime __evUTCTime
michael@0 166 #define evLastEventTime __evLastEventTime
michael@0 167 #define evSetTimer __evSetTimer
michael@0 168 #define evClearTimer __evClearTimer
michael@0 169 #define evConfigTimer __evConfigTimer
michael@0 170 #define evResetTimer __evResetTimer
michael@0 171 #define evSetIdleTimer __evSetIdleTimer
michael@0 172 #define evClearIdleTimer __evClearIdleTimer
michael@0 173 #define evResetIdleTimer __evResetIdleTimer
michael@0 174 #define evTouchIdleTimer __evTouchIdleTimer
michael@0 175
michael@0 176 struct timespec evConsTime __P((time_t sec, long nsec));
michael@0 177 struct timespec evAddTime __P((struct timespec, struct timespec));
michael@0 178 struct timespec evSubTime __P((struct timespec, struct timespec));
michael@0 179 struct timespec evNowTime __P((void));
michael@0 180 struct timespec evUTCTime __P((void));
michael@0 181 struct timespec evLastEventTime __P((evContext));
michael@0 182 struct timespec evTimeSpec __P((struct timeval));
michael@0 183 struct timeval evTimeVal __P((struct timespec));
michael@0 184 int evCmpTime __P((struct timespec, struct timespec));
michael@0 185 int evSetTimer __P((evContext, evTimerFunc, void *, struct timespec,
michael@0 186 struct timespec, evTimerID *));
michael@0 187 int evClearTimer __P((evContext, evTimerID));
michael@0 188 int evConfigTimer __P((evContext, evTimerID, const char *param,
michael@0 189 int value));
michael@0 190 int evResetTimer __P((evContext, evTimerID, evTimerFunc, void *,
michael@0 191 struct timespec, struct timespec));
michael@0 192 int evSetIdleTimer __P((evContext, evTimerFunc, void *, struct timespec,
michael@0 193 evTimerID *));
michael@0 194 int evClearIdleTimer __P((evContext, evTimerID));
michael@0 195 int evResetIdleTimer __P((evContext, evTimerID, evTimerFunc, void *,
michael@0 196 struct timespec));
michael@0 197 int evTouchIdleTimer __P((evContext, evTimerID));
michael@0 198
michael@0 199 /* ev_waits.c */
michael@0 200 #define evWaitFor __evWaitFor
michael@0 201 #define evDo __evDo
michael@0 202 #define evUnwait __evUnwait
michael@0 203 #define evDefer __evDefer
michael@0 204
michael@0 205 int evWaitFor __P((evContext, const void *, evWaitFunc, void *, evWaitID *));
michael@0 206 int evDo __P((evContext, const void *));
michael@0 207 int evUnwait __P((evContext, evWaitID));
michael@0 208 int evDefer __P((evContext, evWaitFunc, void *));
michael@0 209
michael@0 210 #ifdef __EVENTLIB_P_DEFINED
michael@0 211 # undef __P
michael@0 212 #endif
michael@0 213
michael@0 214 #endif /*_EVENTLIB_H*/

mercurial