… | |
… | |
145 | typedef struct ev_watcher_list *WL; |
145 | typedef struct ev_watcher_list *WL; |
146 | typedef struct ev_watcher_time *WT; |
146 | typedef struct ev_watcher_time *WT; |
147 | |
147 | |
148 | static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ |
148 | static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ |
149 | |
149 | |
|
|
150 | #if WIN32 |
|
|
151 | /* note: the comment below could not be substantiated, but what would I care */ |
|
|
152 | /* MSDN says this is required to handle SIGFPE */ |
|
|
153 | volatile double SIGFPE_REQ = 0.0f; |
|
|
154 | #endif |
|
|
155 | |
150 | /*****************************************************************************/ |
156 | /*****************************************************************************/ |
151 | |
157 | |
152 | typedef struct |
158 | typedef struct |
153 | { |
159 | { |
154 | struct ev_watcher_list *head; |
160 | struct ev_watcher_list *head; |
… | |
… | |
232 | base = realloc (base, sizeof (*base) * (newcnt)); \ |
238 | base = realloc (base, sizeof (*base) * (newcnt)); \ |
233 | init (base + cur, newcnt - cur); \ |
239 | init (base + cur, newcnt - cur); \ |
234 | cur = newcnt; \ |
240 | cur = newcnt; \ |
235 | } |
241 | } |
236 | |
242 | |
|
|
243 | #define array_slim(stem) \ |
|
|
244 | if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ |
|
|
245 | { \ |
|
|
246 | stem ## max = array_roundsize (stem ## cnt >> 1); \ |
|
|
247 | base = realloc (base, sizeof (*base) * (stem ## max)); \ |
|
|
248 | fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ |
|
|
249 | } |
|
|
250 | |
237 | #define array_free(stem, idx) \ |
251 | #define array_free(stem, idx) \ |
238 | free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; |
252 | free (stem ## s idx); stem ## cnt idx = stem ## max idx = 0; |
239 | |
253 | |
240 | /*****************************************************************************/ |
254 | /*****************************************************************************/ |
241 | |
255 | |
… | |
… | |
456 | } |
470 | } |
457 | |
471 | |
458 | static void |
472 | static void |
459 | sighandler (int signum) |
473 | sighandler (int signum) |
460 | { |
474 | { |
|
|
475 | #if WIN32 |
|
|
476 | signal (signum, sighandler); |
|
|
477 | #endif |
|
|
478 | |
461 | signals [signum - 1].gotsig = 1; |
479 | signals [signum - 1].gotsig = 1; |
462 | |
480 | |
463 | if (!gotsig) |
481 | if (!gotsig) |
464 | { |
482 | { |
465 | int old_errno = errno; |
483 | int old_errno = errno; |
… | |
… | |
1310 | array_needsize (signals, signalmax, w->signum, signals_init); |
1328 | array_needsize (signals, signalmax, w->signum, signals_init); |
1311 | wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); |
1329 | wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); |
1312 | |
1330 | |
1313 | if (!((WL)w)->next) |
1331 | if (!((WL)w)->next) |
1314 | { |
1332 | { |
|
|
1333 | #if WIN32 |
|
|
1334 | signal (w->signum, sighandler); |
|
|
1335 | #else |
1315 | struct sigaction sa; |
1336 | struct sigaction sa; |
1316 | sa.sa_handler = sighandler; |
1337 | sa.sa_handler = sighandler; |
1317 | sigfillset (&sa.sa_mask); |
1338 | sigfillset (&sa.sa_mask); |
1318 | sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */ |
1339 | sa.sa_flags = SA_RESTART; /* if restarting works we save one iteration */ |
1319 | sigaction (w->signum, &sa, 0); |
1340 | sigaction (w->signum, &sa, 0); |
|
|
1341 | #endif |
1320 | } |
1342 | } |
1321 | } |
1343 | } |
1322 | |
1344 | |
1323 | void |
1345 | void |
1324 | ev_signal_stop (EV_P_ struct ev_signal *w) |
1346 | ev_signal_stop (EV_P_ struct ev_signal *w) |