1 | /* |
1 | /* |
2 | * libev native API header |
2 | * libev native API header |
3 | * |
3 | * |
4 | * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de> |
4 | * Copyright (c) 2007,2008,2009,2010 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 | * |
… | |
… | |
42 | |
42 | |
43 | #ifdef __cplusplus |
43 | #ifdef __cplusplus |
44 | extern "C" { |
44 | extern "C" { |
45 | #endif |
45 | #endif |
46 | |
46 | |
47 | typedef double ev_tstamp; |
47 | /*****************************************************************************/ |
|
|
48 | |
|
|
49 | #ifndef EV_FEATURES |
|
|
50 | # define EV_FEATURES 0x3f |
|
|
51 | #endif |
|
|
52 | |
|
|
53 | #define EV_FEATURE_CODE ((EV_FEATURES) & 1) |
|
|
54 | #define EV_FEATURE_DATA ((EV_FEATURES) & 2) |
|
|
55 | #define EV_FEATURE_API ((EV_FEATURES) & 4) |
|
|
56 | #define EV_FEATURE_WATCHERS ((EV_FEATURES) & 8) |
|
|
57 | #define EV_FEATURE_BACKENDS ((EV_FEATURES) & 16) |
|
|
58 | #define EV_FEATURE_OS ((EV_FEATURES) & 32) |
48 | |
59 | |
49 | /* these priorities are inclusive, higher priorities will be called earlier */ |
60 | /* these priorities are inclusive, higher priorities will be called earlier */ |
50 | #ifndef EV_MINPRI |
61 | #ifndef EV_MINPRI |
51 | # define EV_MINPRI -2 |
62 | # define EV_MINPRI (EV_FEATURE_API ? -2 : 0) |
52 | #endif |
63 | #endif |
53 | #ifndef EV_MAXPRI |
64 | #ifndef EV_MAXPRI |
54 | # define EV_MAXPRI +2 |
65 | # define EV_MAXPRI (EV_FEATURE_API ? +2 : 0) |
55 | #endif |
66 | #endif |
56 | |
67 | |
57 | #ifndef EV_MULTIPLICITY |
68 | #ifndef EV_MULTIPLICITY |
58 | # define EV_MULTIPLICITY 1 |
69 | # define EV_MULTIPLICITY EV_FEATURE_API |
59 | #endif |
70 | #endif |
60 | |
71 | |
61 | #ifndef EV_PERIODIC_ENABLE |
72 | #ifndef EV_PERIODIC_ENABLE |
62 | # define EV_PERIODIC_ENABLE 1 |
73 | # define EV_PERIODIC_ENABLE EV_FEATURE_WATCHERS |
63 | #endif |
74 | #endif |
64 | |
75 | |
65 | #ifndef EV_STAT_ENABLE |
76 | #ifndef EV_STAT_ENABLE |
66 | # define EV_STAT_ENABLE 1 |
77 | # define EV_STAT_ENABLE EV_FEATURE_WATCHERS |
|
|
78 | #endif |
|
|
79 | |
|
|
80 | #ifndef EV_PREPARE_ENABLE |
|
|
81 | # define EV_PREPARE_ENABLE EV_FEATURE_WATCHERS |
|
|
82 | #endif |
|
|
83 | |
|
|
84 | #ifndef EV_CHECK_ENABLE |
|
|
85 | # define EV_CHECK_ENABLE EV_FEATURE_WATCHERS |
67 | #endif |
86 | #endif |
68 | |
87 | |
69 | #ifndef EV_IDLE_ENABLE |
88 | #ifndef EV_IDLE_ENABLE |
70 | # define EV_IDLE_ENABLE 1 |
89 | # define EV_IDLE_ENABLE EV_FEATURE_WATCHERS |
71 | #endif |
90 | #endif |
72 | |
91 | |
73 | #ifndef EV_FORK_ENABLE |
92 | #ifndef EV_FORK_ENABLE |
74 | # define EV_FORK_ENABLE 1 |
93 | # define EV_FORK_ENABLE EV_FEATURE_WATCHERS |
75 | #endif |
94 | #endif |
76 | |
95 | |
77 | #ifndef EV_SIGNAL_ENABLE |
96 | #ifndef EV_SIGNAL_ENABLE |
78 | # define EV_SIGNAL_ENABLE 1 |
97 | # define EV_SIGNAL_ENABLE EV_FEATURE_WATCHERS |
79 | #endif |
98 | #endif |
80 | |
99 | |
81 | #ifndef EV_CHILD_ENABLE |
100 | #ifndef EV_CHILD_ENABLE |
82 | # ifdef _WIN32 |
101 | # ifdef _WIN32 |
83 | # define EV_CHILD_ENABLE 0 |
102 | # define EV_CHILD_ENABLE 0 |
84 | # else |
103 | # else |
85 | # define EV_CHILD_ENABLE 1 |
104 | # define EV_CHILD_ENABLE EV_FEATURE_WATCHERS |
86 | #endif |
105 | #endif |
87 | #endif |
106 | #endif |
88 | |
107 | |
89 | #ifndef EV_ASYNC_ENABLE |
108 | #ifndef EV_ASYNC_ENABLE |
90 | # define EV_ASYNC_ENABLE 1 |
109 | # define EV_ASYNC_ENABLE EV_FEATURE_WATCHERS |
91 | #endif |
110 | #endif |
92 | |
111 | |
93 | #ifndef EV_EMBED_ENABLE |
112 | #ifndef EV_EMBED_ENABLE |
94 | # define EV_EMBED_ENABLE 1 |
113 | # define EV_EMBED_ENABLE EV_FEATURE_WATCHERS |
95 | #endif |
114 | #endif |
96 | |
115 | |
97 | #ifndef EV_WALK_ENABLE |
116 | #ifndef EV_WALK_ENABLE |
98 | # define EV_WALK_ENABLE 0 /* not yet */ |
117 | # define EV_WALK_ENABLE 0 /* not yet */ |
99 | #endif |
118 | #endif |
|
|
119 | |
|
|
120 | /*****************************************************************************/ |
|
|
121 | |
|
|
122 | #if EV_CHILD_ENABLE && !EV_SIGNAL_ENABLE |
|
|
123 | # undef EV_SIGNAL_ENABLE |
|
|
124 | # define EV_SIGNAL_ENABLE 1 |
|
|
125 | #endif |
|
|
126 | |
|
|
127 | /*****************************************************************************/ |
|
|
128 | |
|
|
129 | typedef double ev_tstamp; |
100 | |
130 | |
101 | #ifndef EV_ATOMIC_T |
131 | #ifndef EV_ATOMIC_T |
102 | # include <signal.h> |
132 | # include <signal.h> |
103 | # define EV_ATOMIC_T sig_atomic_t volatile |
133 | # define EV_ATOMIC_T sig_atomic_t volatile |
104 | #endif |
|
|
105 | |
|
|
106 | /*****************************************************************************/ |
|
|
107 | |
|
|
108 | #if EV_CHILD_ENABLE && !EV_SIGNAL_ENABLE |
|
|
109 | # undef EV_SIGNAL_ENABLE |
|
|
110 | # define EV_SIGNAL_ENABLE 1 |
|
|
111 | #endif |
134 | #endif |
112 | |
135 | |
113 | #if EV_STAT_ENABLE |
136 | #if EV_STAT_ENABLE |
114 | # ifdef _WIN32 |
137 | # ifdef _WIN32 |
115 | # include <time.h> |
138 | # include <time.h> |
… | |
… | |
559 | * convenience function, wait for a single event, without registering an event watcher |
582 | * convenience function, wait for a single event, without registering an event watcher |
560 | * if timeout is < 0, do wait indefinitely |
583 | * if timeout is < 0, do wait indefinitely |
561 | */ |
584 | */ |
562 | void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg); |
585 | void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg); |
563 | |
586 | |
564 | # if EV_MINIMAL < 2 |
587 | # if EV_FEATURE_API |
565 | unsigned int ev_loop_count (EV_P); /* number of loop iterations */ |
588 | unsigned int ev_loop_count (EV_P); /* number of loop iterations */ |
566 | unsigned int ev_loop_depth (EV_P); /* #ev_loop enters - #ev_loop leaves */ |
589 | unsigned int ev_loop_depth (EV_P); /* #ev_loop enters - #ev_loop leaves */ |
567 | void ev_loop_verify (EV_P); /* abort if loop data corrupted */ |
590 | void ev_loop_verify (EV_P); /* abort if loop data corrupted */ |
568 | |
591 | |
569 | void ev_set_io_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */ |
592 | void ev_set_io_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */ |
… | |
… | |
692 | # if EV_IDLE_ENABLE |
715 | # if EV_IDLE_ENABLE |
693 | void ev_idle_start (EV_P_ ev_idle *w); |
716 | void ev_idle_start (EV_P_ ev_idle *w); |
694 | void ev_idle_stop (EV_P_ ev_idle *w); |
717 | void ev_idle_stop (EV_P_ ev_idle *w); |
695 | # endif |
718 | # endif |
696 | |
719 | |
|
|
720 | #if EV_PREPARE_ENABLE |
697 | void ev_prepare_start (EV_P_ ev_prepare *w); |
721 | void ev_prepare_start (EV_P_ ev_prepare *w); |
698 | void ev_prepare_stop (EV_P_ ev_prepare *w); |
722 | void ev_prepare_stop (EV_P_ ev_prepare *w); |
|
|
723 | #endif |
699 | |
724 | |
|
|
725 | #if EV_CHECK_ENABLE |
700 | void ev_check_start (EV_P_ ev_check *w); |
726 | void ev_check_start (EV_P_ ev_check *w); |
701 | void ev_check_stop (EV_P_ ev_check *w); |
727 | void ev_check_stop (EV_P_ ev_check *w); |
|
|
728 | #endif |
702 | |
729 | |
703 | # if EV_FORK_ENABLE |
730 | # if EV_FORK_ENABLE |
704 | void ev_fork_start (EV_P_ ev_fork *w); |
731 | void ev_fork_start (EV_P_ ev_fork *w); |
705 | void ev_fork_stop (EV_P_ ev_fork *w); |
732 | void ev_fork_stop (EV_P_ ev_fork *w); |
706 | # endif |
733 | # endif |