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 | * |
… | |
… | |
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 1 |
197 | |
197 | |
198 | /* eventmask, revents, events... */ |
198 | /* eventmask, revents, events... */ |
199 | enum { |
199 | enum { |
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 */ |
496 | enum { |
499 | enum { |
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 |
507 | int ev_version_major (void); |
511 | int ev_version_major (void); |
508 | int ev_version_minor (void); |
512 | int 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 */ |
552 | struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0)); |
556 | struct ev_loop *ev_loop_new (unsigned int flags EV_CPP (= 0)); |
553 | /* destroy event loops, also works for the default loop */ |
|
|
554 | void ev_loop_destroy (EV_P); |
|
|
555 | |
557 | |
556 | ev_tstamp ev_now (EV_P); /* time w.r.t. timers and the eventloop, updated after each poll */ |
558 | ev_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 */ |
|
|
582 | void 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 */ |
717 | void ev_feed_event (EV_P_ void *w, int revents); |
722 | void ev_feed_event (EV_P_ void *w, int revents); |
718 | void ev_feed_fd_event (EV_P_ int fd, int revents); |
723 | void ev_feed_fd_event (EV_P_ int fd, int revents); |
719 | #if EV_SIGNAL_ENABLE |
724 | #if EV_SIGNAL_ENABLE |
|
|
725 | void ev_feed_signal (int signum); |
720 | void ev_feed_signal_event (EV_P_ int signum); |
726 | void ev_feed_signal_event (EV_P_ int signum); |
721 | #endif |
727 | #endif |
722 | void ev_invoke (EV_P_ void *w, int revents); |
728 | void ev_invoke (EV_P_ void *w, int revents); |
723 | int ev_clear_pending (EV_P_ void *w); |
729 | int 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 |