ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.140 by root, Mon Nov 26 19:49:36 2007 UTC vs.
Revision 1.141 by root, Mon Nov 26 20:33:58 2007 UTC

225 225
226/*****************************************************************************/ 226/*****************************************************************************/
227 227
228static void (*syserr_cb)(const char *msg); 228static void (*syserr_cb)(const char *msg);
229 229
230void
230void ev_set_syserr_cb (void (*cb)(const char *msg)) 231ev_set_syserr_cb (void (*cb)(const char *msg))
231{ 232{
232 syserr_cb = cb; 233 syserr_cb = cb;
233} 234}
234 235
235static void 236static void noinline
236syserr (const char *msg) 237syserr (const char *msg)
237{ 238{
238 if (!msg) 239 if (!msg)
239 msg = "(libev) system error"; 240 msg = "(libev) system error";
240 241
247 } 248 }
248} 249}
249 250
250static void *(*alloc)(void *ptr, long size); 251static void *(*alloc)(void *ptr, long size);
251 252
253void
252void ev_set_allocator (void *(*cb)(void *ptr, long size)) 254ev_set_allocator (void *(*cb)(void *ptr, long size))
253{ 255{
254 alloc = cb; 256 alloc = cb;
255} 257}
256 258
257static void * 259static void *
315 317
316#endif 318#endif
317 319
318/*****************************************************************************/ 320/*****************************************************************************/
319 321
320ev_tstamp noinline 322ev_tstamp
321ev_time (void) 323ev_time (void)
322{ 324{
323#if EV_USE_REALTIME 325#if EV_USE_REALTIME
324 struct timespec ts; 326 struct timespec ts;
325 clock_gettime (CLOCK_REALTIME, &ts); 327 clock_gettime (CLOCK_REALTIME, &ts);
382#define array_free(stem, idx) \ 384#define array_free(stem, idx) \
383 ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; 385 ev_free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0;
384 386
385/*****************************************************************************/ 387/*****************************************************************************/
386 388
387void inline_size
388anfds_init (ANFD *base, int count)
389{
390 while (count--)
391 {
392 base->head = 0;
393 base->events = EV_NONE;
394 base->reify = 0;
395
396 ++base;
397 }
398}
399
400void noinline 389void noinline
401ev_feed_event (EV_P_ void *w, int revents) 390ev_feed_event (EV_P_ void *w, int revents)
402{ 391{
403 W w_ = (W)w; 392 W w_ = (W)w;
404 393
412 array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], EMPTY2); 401 array_needsize (ANPENDING, pendings [ABSPRI (w_)], pendingmax [ABSPRI (w_)], pendingcnt [ABSPRI (w_)], EMPTY2);
413 pendings [ABSPRI (w_)][w_->pending - 1].w = w_; 402 pendings [ABSPRI (w_)][w_->pending - 1].w = w_;
414 pendings [ABSPRI (w_)][w_->pending - 1].events = revents; 403 pendings [ABSPRI (w_)][w_->pending - 1].events = revents;
415} 404}
416 405
417static void 406void inline_size
418queue_events (EV_P_ W *events, int eventcnt, int type) 407queue_events (EV_P_ W *events, int eventcnt, int type)
419{ 408{
420 int i; 409 int i;
421 410
422 for (i = 0; i < eventcnt; ++i) 411 for (i = 0; i < eventcnt; ++i)
423 ev_feed_event (EV_A_ events [i], type); 412 ev_feed_event (EV_A_ events [i], type);
424} 413}
425 414
415/*****************************************************************************/
416
417void inline_size
418anfds_init (ANFD *base, int count)
419{
420 while (count--)
421 {
422 base->head = 0;
423 base->events = EV_NONE;
424 base->reify = 0;
425
426 ++base;
427 }
428}
429
426void inline_speed 430void inline_speed
427fd_event (EV_P_ int fd, int revents) 431fd_event (EV_P_ int fd, int revents)
428{ 432{
429 ANFD *anfd = anfds + fd; 433 ANFD *anfd = anfds + fd;
430 ev_io *w; 434 ev_io *w;
441void 445void
442ev_feed_fd_event (EV_P_ int fd, int revents) 446ev_feed_fd_event (EV_P_ int fd, int revents)
443{ 447{
444 fd_event (EV_A_ fd, revents); 448 fd_event (EV_A_ fd, revents);
445} 449}
446
447/*****************************************************************************/
448 450
449void inline_size 451void inline_size
450fd_reify (EV_P) 452fd_reify (EV_P)
451{ 453{
452 int i; 454 int i;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines