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

Comparing libev/ev.h (file contents):
Revision 1.151 by root, Sun Oct 24 18:09:58 2010 UTC vs.
Revision 1.161 by root, Sat Oct 15 09:05:03 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,
102#ifndef EV_FORK_ENABLE 102#ifndef EV_FORK_ENABLE
103# define EV_FORK_ENABLE EV_FEATURE_WATCHERS 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 0 /* not implemented */ 107# define EV_CLEANUP_ENABLE EV_FEATURE_WATCHERS
108#endif 108#endif
109 109
110#ifndef EV_SIGNAL_ENABLE 110#ifndef EV_SIGNAL_ENABLE
111# define EV_SIGNAL_ENABLE EV_FEATURE_WATCHERS 111# define EV_SIGNAL_ENABLE EV_FEATURE_WATCHERS
112#endif 112#endif
183# define EV_INLINE static inline 183# define EV_INLINE static inline
184#else 184#else
185# define EV_INLINE static 185# define EV_INLINE static
186#endif 186#endif
187 187
188/* EV_PROTOTYPES can be sued to switch of prototype declarations */ 188/* EV_PROTOTYPES can be used to switch of prototype declarations */
189#ifndef EV_PROTOTYPES 189#ifndef EV_PROTOTYPES
190# define EV_PROTOTYPES 1 190# define EV_PROTOTYPES 1
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 4
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 */
489 /* debugging/feature disable */ 489 /* debugging/feature disable */
490 EVFLAG_NOINOTIFY = 0x00100000U, /* do not attempt to use inotify */ 490 EVFLAG_NOINOTIFY = 0x00100000U, /* do not attempt to use inotify */
491#if EV_COMPAT3 491#if EV_COMPAT3
492 EVFLAG_NOSIGFD = 0, /* compatibility to pre-3.9 */ 492 EVFLAG_NOSIGFD = 0, /* compatibility to pre-3.9 */
493#endif 493#endif
494 EVFLAG_SIGNALFD = 0x00200000U /* attempt to use signalfd */ 494 EVFLAG_SIGNALFD = 0x00200000U, /* attempt to use signalfd */
495 EVFLAG_NOSIGMASK = 0x00400000U /* avoid modifying the signal mask */
495}; 496};
496 497
497/* method bits to be ored together */ 498/* method bits to be ored together */
498enum { 499enum {
499 EVBACKEND_SELECT = 0x00000001U, /* about anywhere */ 500 EVBACKEND_SELECT = 0x00000001U, /* about anywhere */
500 EVBACKEND_POLL = 0x00000002U, /* !win */ 501 EVBACKEND_POLL = 0x00000002U, /* !win */
501 EVBACKEND_EPOLL = 0x00000004U, /* linux */ 502 EVBACKEND_EPOLL = 0x00000004U, /* linux */
502 EVBACKEND_KQUEUE = 0x00000008U, /* bsd */ 503 EVBACKEND_KQUEUE = 0x00000008U, /* bsd */
503 EVBACKEND_DEVPOLL = 0x00000010U, /* solaris 8 */ /* NYI */ 504 EVBACKEND_DEVPOLL = 0x00000010U, /* solaris 8 */ /* NYI */
504 EVBACKEND_PORT = 0x00000020U, /* solaris 10 */ 505 EVBACKEND_PORT = 0x00000020U, /* solaris 10 */
505 EVBACKEND_ALL = 0x0000003FU 506 EVBACKEND_ALL = 0x0000003FU, /* all known backends */
507 EVBACKEND_MASK = 0x0000FFFFU /* all future backends */
506}; 508};
507 509
508#if EV_PROTOTYPES 510#if EV_PROTOTYPES
509int ev_version_major (void); 511int ev_version_major (void);
510int ev_version_minor (void); 512int ev_version_minor (void);
550 return EV_A == EV_DEFAULT_UC; 552 return EV_A == EV_DEFAULT_UC;
551} 553}
552 554
553/* create and destroy alternative loops that don't handle signals */ 555/* create and destroy alternative loops that don't handle signals */
554struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0)); 556struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0));
555/* destroy event loops, also works for the default loop */
556void ev_loop_destroy (EV_P);
557 557
558ev_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 */
559 559
560#else 560#else
561 561
575{ 575{
576 return 1; 576 return 1;
577} 577}
578 578
579#endif /* multiplicity */ 579#endif /* multiplicity */
580
581/* destroy event loops, also works for the default loop */
582void ev_loop_destroy (EV_P);
580 583
581/* this needs to be called after fork, to duplicate the loop */ 584/* this needs to be called after fork, to duplicate the loop */
582/* when you want to re-use it in the child */ 585/* when you want to re-use it in the child */
583/* you can call it in either the parent or the child */ 586/* you can call it in either the parent or the child */
584/* you can actually call it at any time, anywhere :) */ 587/* you can actually call it at any time, anywhere :) */
712 715
713/* stopping (enabling, adding) a watcher does nothing if it is already running */ 716/* stopping (enabling, adding) a watcher does nothing if it is already running */
714/* stopping (disabling, deleting) a watcher does nothing unless its already running */ 717/* stopping (disabling, deleting) a watcher does nothing unless its already running */
715#if EV_PROTOTYPES 718#if EV_PROTOTYPES
716 719
717/* feeds an event into a watcher as if the event actually occured */ 720/* feeds an event into a watcher as if the event actually occurred */
718/* accepts any ev_watcher type */ 721/* accepts any ev_watcher type */
719void ev_feed_event (EV_P_ void *w, int revents); 722void ev_feed_event (EV_P_ void *w, int revents);
720void ev_feed_fd_event (EV_P_ int fd, int revents); 723void ev_feed_fd_event (EV_P_ int fd, int revents);
721#if EV_SIGNAL_ENABLE 724#if EV_SIGNAL_ENABLE
725void ev_feed_signal (int signum);
722void ev_feed_signal_event (EV_P_ int signum); 726void ev_feed_signal_event (EV_P_ int signum);
723#endif 727#endif
724void ev_invoke (EV_P_ void *w, int revents); 728void ev_invoke (EV_P_ void *w, int revents);
725int ev_clear_pending (EV_P_ void *w); 729int ev_clear_pending (EV_P_ void *w);
726 730
806 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); }
807 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 ); }
808 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); }
809 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); }
810 #if EV_FEATURE_API 814 #if EV_FEATURE_API
811 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); }
812 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); }
813 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); }
814 #endif 818 #endif
815 #endif 819 #endif
816#else 820#else
817 typedef struct ev_loop ev_loop; 821 typedef struct ev_loop ev_loop;
818#endif 822#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines