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

Comparing libev/ev.h (file contents):
Revision 1.150 by root, Sun Oct 24 18:05:53 2010 UTC vs.
Revision 1.159 by root, Wed Feb 16 08:02:50 2011 UTC

1/* 1/*
2 * libev native API header 2 * libev native API header
3 * 3 *
4 * Copyright (c) 2007,2008,2009,2010 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007,2008,2009,2010,2011 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright notice, 10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer. 11 * this list of conditions and the following disclaimer.
12 * 12 *
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution. 15 * documentation and/or other materials provided with the distribution.
16 * 16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- 18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
19 * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- 20 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
21 * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
98#ifndef EV_IDLE_ENABLE 98#ifndef EV_IDLE_ENABLE
99# define EV_IDLE_ENABLE EV_FEATURE_WATCHERS 99# define EV_IDLE_ENABLE EV_FEATURE_WATCHERS
100#endif 100#endif
101 101
102#ifndef EV_FORK_ENABLE 102#ifndef EV_FORK_ENABLE
103# define EV_FORK_ENABLE 0 /* not implemented */ 103# define EV_FORK_ENABLE EV_FEATURE_WATCHERS
104#endif 104#endif
105 105
106#ifndef EV_CLEANUP_ENABLE 106#ifndef EV_CLEANUP_ENABLE
107# define EV_CLEANUP_ENABLE EV_FEATURE_WATCHERS 107# define EV_CLEANUP_ENABLE EV_FEATURE_WATCHERS
108#endif 108#endif
191#endif 191#endif
192 192
193/*****************************************************************************/ 193/*****************************************************************************/
194 194
195#define EV_VERSION_MAJOR 4 195#define EV_VERSION_MAJOR 4
196#define EV_VERSION_MINOR 0 196#define EV_VERSION_MINOR 3
197 197
198/* eventmask, revents, events... */ 198/* eventmask, revents, events... */
199enum { 199enum {
200 EV_UNDEF = -1, /* guaranteed to be invalid */ 200 EV_UNDEF = 0xFFFFFFFF, /* guaranteed to be invalid */
201 EV_NONE = 0x00, /* no events */ 201 EV_NONE = 0x00, /* no events */
202 EV_READ = 0x01, /* ev_io detected read will not block */ 202 EV_READ = 0x01, /* ev_io detected read will not block */
203 EV_WRITE = 0x02, /* ev_io detected write will not block */ 203 EV_WRITE = 0x02, /* ev_io detected write will not block */
204 EV__IOFDSET = 0x80, /* internal use only */ 204 EV__IOFDSET = 0x80, /* internal use only */
205 EV_IO = EV_READ, /* alias for type-detection */ 205 EV_IO = EV_READ, /* alias for type-detection */
425 ev_check check; /* unused */ 425 ev_check check; /* unused */
426 ev_timer timer; /* unused */ 426 ev_timer timer; /* unused */
427 ev_periodic periodic; /* unused */ 427 ev_periodic periodic; /* unused */
428 ev_idle idle; /* unused */ 428 ev_idle idle; /* unused */
429 ev_fork fork; /* private */ 429 ev_fork fork; /* private */
430#if EV_CLEANUP_ENABLE
430 ev_cleanup cleanup; /* unused */ 431 ev_cleanup cleanup; /* unused */
432#endif
431} ev_embed; 433} ev_embed;
432#endif 434#endif
433 435
434#if EV_ASYNC_ENABLE 436#if EV_ASYNC_ENABLE
435/* invoked when somebody calls ev_async_send on the watcher */ 437/* invoked when somebody calls ev_async_send on the watcher */
487 /* debugging/feature disable */ 489 /* debugging/feature disable */
488 EVFLAG_NOINOTIFY = 0x00100000U, /* do not attempt to use inotify */ 490 EVFLAG_NOINOTIFY = 0x00100000U, /* do not attempt to use inotify */
489#if EV_COMPAT3 491#if EV_COMPAT3
490 EVFLAG_NOSIGFD = 0, /* compatibility to pre-3.9 */ 492 EVFLAG_NOSIGFD = 0, /* compatibility to pre-3.9 */
491#endif 493#endif
492 EVFLAG_SIGNALFD = 0x00200000U /* attempt to use signalfd */ 494 EVFLAG_SIGNALFD = 0x00200000U, /* attempt to use signalfd */
495 EVFLAG_NOSIGMASK = 0x00400000U /* avoid modifying the signal mask */
493}; 496};
494 497
495/* method bits to be ored together */ 498/* method bits to be ored together */
496enum { 499enum {
497 EVBACKEND_SELECT = 0x00000001U, /* about anywhere */ 500 EVBACKEND_SELECT = 0x00000001U, /* about anywhere */
498 EVBACKEND_POLL = 0x00000002U, /* !win */ 501 EVBACKEND_POLL = 0x00000002U, /* !win */
499 EVBACKEND_EPOLL = 0x00000004U, /* linux */ 502 EVBACKEND_EPOLL = 0x00000004U, /* linux */
500 EVBACKEND_KQUEUE = 0x00000008U, /* bsd */ 503 EVBACKEND_KQUEUE = 0x00000008U, /* bsd */
501 EVBACKEND_DEVPOLL = 0x00000010U, /* solaris 8 */ /* NYI */ 504 EVBACKEND_DEVPOLL = 0x00000010U, /* solaris 8 */ /* NYI */
502 EVBACKEND_PORT = 0x00000020U, /* solaris 10 */ 505 EVBACKEND_PORT = 0x00000020U, /* solaris 10 */
503 EVBACKEND_ALL = 0x0000003FU 506 EVBACKEND_ALL = 0x0000003FU, /* all known backends */
507 EVBACKEND_MASK = 0x0000FFFFU /* all future backends */
504}; 508};
505 509
506#if EV_PROTOTYPES 510#if EV_PROTOTYPES
507int ev_version_major (void); 511int ev_version_major (void);
508int ev_version_minor (void); 512int ev_version_minor (void);
548 return EV_A == EV_DEFAULT_UC; 552 return EV_A == EV_DEFAULT_UC;
549} 553}
550 554
551/* create and destroy alternative loops that don't handle signals */ 555/* create and destroy alternative loops that don't handle signals */
552struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0)); 556struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0));
553/* destroy event loops, also works for the default loop */
554void ev_loop_destroy (EV_P);
555 557
556ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */ 558ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */
557 559
558#else 560#else
559 561
573{ 575{
574 return 1; 576 return 1;
575} 577}
576 578
577#endif /* multiplicity */ 579#endif /* multiplicity */
580
581/* destroy event loops, also works for the default loop */
582void ev_loop_destroy (EV_P);
578 583
579/* this needs to be called after fork, to duplicate the loop */ 584/* this needs to be called after fork, to duplicate the loop */
580/* when you want to re-use it in the child */ 585/* when you want to re-use it in the child */
581/* you can call it in either the parent or the child */ 586/* you can call it in either the parent or the child */
582/* you can actually call it at any time, anywhere :) */ 587/* you can actually call it at any time, anywhere :) */
715/* feeds an event into a watcher as if the event actually occured */ 720/* feeds an event into a watcher as if the event actually occured */
716/* accepts any ev_watcher type */ 721/* accepts any ev_watcher type */
717void ev_feed_event (EV_P_ void *w, int revents); 722void ev_feed_event (EV_P_ void *w, int revents);
718void ev_feed_fd_event (EV_P_ int fd, int revents); 723void ev_feed_fd_event (EV_P_ int fd, int revents);
719#if EV_SIGNAL_ENABLE 724#if EV_SIGNAL_ENABLE
725void ev_feed_signal (int signum);
720void ev_feed_signal_event (EV_P_ int signum); 726void ev_feed_signal_event (EV_P_ int signum);
721#endif 727#endif
722void ev_invoke (EV_P_ void *w, int revents); 728void ev_invoke (EV_P_ void *w, int revents);
723int ev_clear_pending (EV_P_ void *w); 729int ev_clear_pending (EV_P_ void *w);
724 730
804 EV_INLINE void ev_loop (EV_P_ int flags) { ev_run (EV_A_ flags); } 810 EV_INLINE void ev_loop (EV_P_ int flags) { ev_run (EV_A_ flags); }
805 EV_INLINE void ev_unloop (EV_P_ int how ) { ev_break (EV_A_ how ); } 811 EV_INLINE void ev_unloop (EV_P_ int how ) { ev_break (EV_A_ how ); }
806 EV_INLINE void ev_default_destroy (void) { ev_loop_destroy (EV_DEFAULT); } 812 EV_INLINE void ev_default_destroy (void) { ev_loop_destroy (EV_DEFAULT); }
807 EV_INLINE void ev_default_fork (void) { ev_loop_fork (EV_DEFAULT); } 813 EV_INLINE void ev_default_fork (void) { ev_loop_fork (EV_DEFAULT); }
808 #if EV_FEATURE_API 814 #if EV_FEATURE_API
809 EV_INLINE void ev_loop_count (EV_P) { ev_iteration (EV_A); } 815 EV_INLINE unsigned int ev_loop_count (EV_P) { return ev_iteration (EV_A); }
810 EV_INLINE void ev_loop_depth (EV_P) { ev_depth (EV_A); } 816 EV_INLINE unsigned int ev_loop_depth (EV_P) { return ev_depth (EV_A); }
811 EV_INLINE void ev_loop_verify (EV_P) { ev_verify (EV_A); } 817 EV_INLINE void ev_loop_verify (EV_P) { ev_verify (EV_A); }
812 #endif 818 #endif
813 #endif 819 #endif
814#else 820#else
815 typedef struct ev_loop ev_loop; 821 typedef struct ev_loop ev_loop;
816#endif 822#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines