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, |
… | |
… | |
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... */ |
199 | enum { |
199 | enum { |
200 | EV_UNDEF = 0xFFFFFFFF, /* guaranteed to be invalid */ |
200 | EV_UNDEF = 0xFFFFFFFF, /* guaranteed to be invalid */ |
201 | EV_NONE = 0x00, /* no events */ |
201 | EV_NONE = 0x00, /* no events */ |
… | |
… | |
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 */ |
498 | enum { |
499 | enum { |
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 |
509 | int ev_version_major (void); |
511 | int ev_version_major (void); |
510 | int ev_version_minor (void); |
512 | int ev_version_minor (void); |
… | |
… | |
718 | /* 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 */ |
719 | /* accepts any ev_watcher type */ |
721 | /* accepts any ev_watcher type */ |
720 | void ev_feed_event (EV_P_ void *w, int revents); |
722 | void ev_feed_event (EV_P_ void *w, int revents); |
721 | void ev_feed_fd_event (EV_P_ int fd, int revents); |
723 | void ev_feed_fd_event (EV_P_ int fd, int revents); |
722 | #if EV_SIGNAL_ENABLE |
724 | #if EV_SIGNAL_ENABLE |
|
|
725 | void ev_feed_signal (int signum); |
723 | void ev_feed_signal_event (EV_P_ int signum); |
726 | void ev_feed_signal_event (EV_P_ int signum); |
724 | #endif |
727 | #endif |
725 | void ev_invoke (EV_P_ void *w, int revents); |
728 | void ev_invoke (EV_P_ void *w, int revents); |
726 | int ev_clear_pending (EV_P_ void *w); |
729 | int ev_clear_pending (EV_P_ void *w); |
727 | |
730 | |
… | |
… | |
807 | 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); } |
808 | 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 ); } |
809 | 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); } |
810 | 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); } |
811 | #if EV_FEATURE_API |
814 | #if EV_FEATURE_API |
812 | 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); } |
813 | 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); } |
814 | 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); } |
815 | #endif |
818 | #endif |
816 | #endif |
819 | #endif |
817 | #else |
820 | #else |
818 | typedef struct ev_loop ev_loop; |
821 | typedef struct ev_loop ev_loop; |
819 | #endif |
822 | #endif |