… | |
… | |
19 | |
19 | |
20 | #include <cstdio> |
20 | #include <cstdio> |
21 | #include <cstdlib> |
21 | #include <cstdlib> |
22 | #include <cerrno> |
22 | #include <cerrno> |
23 | |
23 | |
|
|
24 | #include <sys/time.h> |
|
|
25 | |
|
|
26 | #if 1 // older unices need these includes for select(2) |
|
|
27 | # include <unistd.h> |
|
|
28 | # include <sys/types.h> |
|
|
29 | #endif |
|
|
30 | |
|
|
31 | // if the BSDs would at least be marginally POSIX-compatible.. *sigh* |
|
|
32 | // until that happens, sys/select.h must come last |
24 | #include <sys/select.h> |
33 | #include <sys/select.h> |
25 | #include <sys/time.h> |
|
|
26 | |
34 | |
27 | #include "iom.h" |
35 | #include "iom.h" |
28 | |
36 | |
29 | // TSTAMP_MAX must still fit into a positive struct timeval |
37 | // TSTAMP_MAX must still fit into a positive struct timeval |
30 | #define TSTAMP_MAX (double)(1UL<<31) |
38 | #define TSTAMP_MAX (double)(1UL<<31) |
|
|
39 | |
|
|
40 | // this is a dummy time watcher to ensure that the first |
|
|
41 | // time watcher is _always_ valid, this gets rid of a lot |
|
|
42 | // of null-pointer-checks |
|
|
43 | // (must come _before_ iom is being defined) |
|
|
44 | static struct tw0 : time_watcher { |
|
|
45 | void cb (time_watcher &w) |
|
|
46 | { |
|
|
47 | // should never get called |
|
|
48 | // reached end-of-time, or tstamp has a bogus definition, |
|
|
49 | // or compiler initilization order broken, or somethine else :) |
|
|
50 | abort (); |
|
|
51 | } |
|
|
52 | |
|
|
53 | tw0() |
|
|
54 | : time_watcher (this, &tw0::cb) |
|
|
55 | { } |
|
|
56 | } tw0; |
31 | |
57 | |
32 | tstamp NOW; |
58 | tstamp NOW; |
33 | static bool iom_valid; |
59 | static bool iom_valid; |
34 | io_manager iom; |
60 | io_manager iom; |
35 | |
61 | |
… | |
… | |
222 | break; |
248 | break; |
223 | #endif |
249 | #endif |
224 | } |
250 | } |
225 | } |
251 | } |
226 | |
252 | |
227 | // this is a dummy time watcher to ensure that the first |
|
|
228 | // time watcher is _always_ valid, this gets rid of a lot |
|
|
229 | // of null-pointer-checks |
|
|
230 | static struct tw0 : time_watcher { |
|
|
231 | void cb (time_watcher &w) |
|
|
232 | { |
|
|
233 | // should never get called |
|
|
234 | // reached end-of-time, or tstamp has a bogus definition :) |
|
|
235 | abort (); |
|
|
236 | } |
|
|
237 | |
|
|
238 | tw0() |
|
|
239 | : time_watcher (this, &tw0::cb) |
|
|
240 | { } |
|
|
241 | } tw0; |
|
|
242 | |
|
|
243 | io_manager::io_manager () |
253 | io_manager::io_manager () |
244 | { |
254 | { |
245 | iom_valid = true; |
255 | iom_valid = true; |
246 | |
256 | |
247 | #if IOM_TIME |
257 | #if IOM_TIME |