… | |
… | |
148 | typedef struct ev_watcher_list *WL; |
148 | typedef struct ev_watcher_list *WL; |
149 | typedef struct ev_watcher_time *WT; |
149 | typedef struct ev_watcher_time *WT; |
150 | |
150 | |
151 | static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ |
151 | static int have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */ |
152 | |
152 | |
153 | #if WIN32 |
153 | #include "ev_win32.c" |
154 | /* note: the comment below could not be substantiated, but what would I care */ |
|
|
155 | /* MSDN says this is required to handle SIGFPE */ |
|
|
156 | volatile double SIGFPE_REQ = 0.0f; |
|
|
157 | |
|
|
158 | static int |
|
|
159 | ev_socketpair_tcp (int filedes [2]) |
|
|
160 | { |
|
|
161 | struct sockaddr_in addr = { 0 }; |
|
|
162 | int addr_size = sizeof (addr); |
|
|
163 | SOCKET listener; |
|
|
164 | SOCKET sock [2] = { -1, -1 }; |
|
|
165 | |
|
|
166 | if ((listener = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) |
|
|
167 | return -1; |
|
|
168 | |
|
|
169 | addr.sin_family = AF_INET; |
|
|
170 | addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); |
|
|
171 | addr.sin_port = 0; |
|
|
172 | |
|
|
173 | if (bind (listener, (struct sockaddr *)&addr, addr_size)) |
|
|
174 | goto fail; |
|
|
175 | |
|
|
176 | if (getsockname(listener, (struct sockaddr *)&addr, &addr_size)) |
|
|
177 | goto fail; |
|
|
178 | |
|
|
179 | if (listen (listener, 1)) |
|
|
180 | goto fail; |
|
|
181 | |
|
|
182 | if ((sock [0] = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) |
|
|
183 | goto fail; |
|
|
184 | |
|
|
185 | if (connect (sock[0], (struct sockaddr *)&addr, addr_size)) |
|
|
186 | goto fail; |
|
|
187 | |
|
|
188 | if ((sock[1] = accept (listener, 0, 0)) < 0) |
|
|
189 | goto fail; |
|
|
190 | |
|
|
191 | closesocket (listener); |
|
|
192 | |
|
|
193 | filedes [0] = sock [0]; |
|
|
194 | filedes [1] = sock [1]; |
|
|
195 | |
|
|
196 | return 0; |
|
|
197 | |
|
|
198 | fail: |
|
|
199 | closesocket (listener); |
|
|
200 | |
|
|
201 | if (sock [0] != INVALID_SOCKET) closesocket (sock [0]); |
|
|
202 | if (sock [1] != INVALID_SOCKET) closesocket (sock [1]); |
|
|
203 | |
|
|
204 | return -1; |
|
|
205 | } |
|
|
206 | |
|
|
207 | # define ev_pipe(filedes) ev_socketpair_tcp (filedes) |
|
|
208 | #else |
|
|
209 | # define ev_pipe(filedes) pipe (filedes) |
|
|
210 | #endif |
|
|
211 | |
154 | |
212 | /*****************************************************************************/ |
155 | /*****************************************************************************/ |
213 | |
156 | |
214 | static void (*syserr_cb)(const char *msg); |
157 | static void (*syserr_cb)(const char *msg); |
215 | |
158 | |
… | |
… | |
325 | ev_now (EV_P) |
268 | ev_now (EV_P) |
326 | { |
269 | { |
327 | return rt_now; |
270 | return rt_now; |
328 | } |
271 | } |
329 | |
272 | |
330 | #define array_roundsize(base,n) ((n) | 4 & ~3) |
273 | #define array_roundsize(type,n) ((n) | 4 & ~3) |
331 | |
274 | |
332 | #define array_needsize(base,cur,cnt,init) \ |
275 | #define array_needsize(type,base,cur,cnt,init) \ |
333 | if (expect_false ((cnt) > cur)) \ |
276 | if (expect_false ((cnt) > cur)) \ |
334 | { \ |
277 | { \ |
335 | int newcnt = cur; \ |
278 | int newcnt = cur; \ |
336 | do \ |
279 | do \ |
337 | { \ |
280 | { \ |
338 | newcnt = array_roundsize (base, newcnt << 1); \ |
281 | newcnt = array_roundsize (type, newcnt << 1); \ |
339 | } \ |
282 | } \ |
340 | while ((cnt) > newcnt); \ |
283 | while ((cnt) > newcnt); \ |
341 | \ |
284 | \ |
342 | base = ev_realloc (base, sizeof (*base) * (newcnt)); \ |
285 | base = (type *)ev_realloc (base, sizeof (type) * (newcnt));\ |
343 | init (base + cur, newcnt - cur); \ |
286 | init (base + cur, newcnt - cur); \ |
344 | cur = newcnt; \ |
287 | cur = newcnt; \ |
345 | } |
288 | } |
346 | |
289 | |
347 | #define array_slim(stem) \ |
290 | #define array_slim(type,stem) \ |
348 | if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ |
291 | if (stem ## max < array_roundsize (stem ## cnt >> 2)) \ |
349 | { \ |
292 | { \ |
350 | stem ## max = array_roundsize (stem ## cnt >> 1); \ |
293 | stem ## max = array_roundsize (stem ## cnt >> 1); \ |
351 | base = ev_realloc (base, sizeof (*base) * (stem ## max)); \ |
294 | base = (type *)ev_realloc (base, sizeof (type) * (stem ## max));\ |
352 | fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ |
295 | fprintf (stderr, "slimmed down " # stem " to %d\n", stem ## max);/*D*/\ |
353 | } |
296 | } |
354 | |
297 | |
355 | /* microsoft's pseudo-c is quite far from C as the rest of the world and the standard knows it */ |
298 | /* microsoft's pseudo-c is quite far from C as the rest of the world and the standard knows it */ |
356 | /* bringing us everlasting joy in form of stupid extra macros that are not required in C */ |
299 | /* bringing us everlasting joy in form of stupid extra macros that are not required in C */ |
… | |
… | |
383 | pendings [ABSPRI (w)][w->pending - 1].events |= events; |
326 | pendings [ABSPRI (w)][w->pending - 1].events |= events; |
384 | return; |
327 | return; |
385 | } |
328 | } |
386 | |
329 | |
387 | w->pending = ++pendingcnt [ABSPRI (w)]; |
330 | w->pending = ++pendingcnt [ABSPRI (w)]; |
388 | array_needsize (pendings [ABSPRI (w)], pendingmax [ABSPRI (w)], pendingcnt [ABSPRI (w)], (void)); |
331 | array_needsize (ANPENDING, pendings [ABSPRI (w)], pendingmax [ABSPRI (w)], pendingcnt [ABSPRI (w)], (void)); |
389 | pendings [ABSPRI (w)][w->pending - 1].w = w; |
332 | pendings [ABSPRI (w)][w->pending - 1].w = w; |
390 | pendings [ABSPRI (w)][w->pending - 1].events = events; |
333 | pendings [ABSPRI (w)][w->pending - 1].events = events; |
391 | } |
334 | } |
392 | |
335 | |
393 | static void |
336 | static void |
… | |
… | |
448 | return; |
391 | return; |
449 | |
392 | |
450 | anfds [fd].reify = 1; |
393 | anfds [fd].reify = 1; |
451 | |
394 | |
452 | ++fdchangecnt; |
395 | ++fdchangecnt; |
453 | array_needsize (fdchanges, fdchangemax, fdchangecnt, (void)); |
396 | array_needsize (int, fdchanges, fdchangemax, fdchangecnt, (void)); |
454 | fdchanges [fdchangecnt - 1] = fd; |
397 | fdchanges [fdchangecnt - 1] = fd; |
455 | } |
398 | } |
456 | |
399 | |
457 | static void |
400 | static void |
458 | fd_kill (EV_P_ int fd) |
401 | fd_kill (EV_P_ int fd) |
… | |
… | |
598 | |
541 | |
599 | if (!gotsig) |
542 | if (!gotsig) |
600 | { |
543 | { |
601 | int old_errno = errno; |
544 | int old_errno = errno; |
602 | gotsig = 1; |
545 | gotsig = 1; |
|
|
546 | #ifdef WIN32 |
|
|
547 | send (sigpipe [1], &signum, 1, MSG_DONTWAIT); |
|
|
548 | #else |
603 | write (sigpipe [1], &signum, 1); |
549 | write (sigpipe [1], &signum, 1); |
|
|
550 | #endif |
604 | errno = old_errno; |
551 | errno = old_errno; |
605 | } |
552 | } |
606 | } |
553 | } |
607 | |
554 | |
608 | static void |
555 | static void |
609 | sigcb (EV_P_ struct ev_io *iow, int revents) |
556 | sigcb (EV_P_ struct ev_io *iow, int revents) |
610 | { |
557 | { |
611 | WL w; |
558 | WL w; |
612 | int signum; |
559 | int signum; |
613 | |
560 | |
|
|
561 | #ifdef WIN32 |
|
|
562 | recv (sigpipe [0], &revents, 1, MSG_DONTWAIT); |
|
|
563 | #else |
614 | read (sigpipe [0], &revents, 1); |
564 | read (sigpipe [0], &revents, 1); |
|
|
565 | #endif |
615 | gotsig = 0; |
566 | gotsig = 0; |
616 | |
567 | |
617 | for (signum = signalmax; signum--; ) |
568 | for (signum = signalmax; signum--; ) |
618 | if (signals [signum].gotsig) |
569 | if (signals [signum].gotsig) |
619 | { |
570 | { |
… | |
… | |
828 | ev_ref (EV_A); |
779 | ev_ref (EV_A); |
829 | ev_io_stop (EV_A_ &sigev); |
780 | ev_io_stop (EV_A_ &sigev); |
830 | close (sigpipe [0]); |
781 | close (sigpipe [0]); |
831 | close (sigpipe [1]); |
782 | close (sigpipe [1]); |
832 | |
783 | |
833 | while (ev_pipe (sigpipe)) |
784 | while (pipe (sigpipe)) |
834 | syserr ("(libev) error creating pipe"); |
785 | syserr ("(libev) error creating pipe"); |
835 | |
786 | |
836 | siginit (EV_A); |
787 | siginit (EV_A); |
837 | } |
788 | } |
838 | |
789 | |
… | |
… | |
881 | int |
832 | int |
882 | #endif |
833 | #endif |
883 | ev_default_loop (int methods) |
834 | ev_default_loop (int methods) |
884 | { |
835 | { |
885 | if (sigpipe [0] == sigpipe [1]) |
836 | if (sigpipe [0] == sigpipe [1]) |
886 | if (ev_pipe (sigpipe)) |
837 | if (pipe (sigpipe)) |
887 | return 0; |
838 | return 0; |
888 | |
839 | |
889 | if (!default_loop) |
840 | if (!default_loop) |
890 | { |
841 | { |
891 | #if EV_MULTIPLICITY |
842 | #if EV_MULTIPLICITY |
… | |
… | |
945 | if (method) |
896 | if (method) |
946 | postfork = 1; |
897 | postfork = 1; |
947 | } |
898 | } |
948 | |
899 | |
949 | /*****************************************************************************/ |
900 | /*****************************************************************************/ |
|
|
901 | |
|
|
902 | static int |
|
|
903 | any_pending (EV_P) |
|
|
904 | { |
|
|
905 | int pri; |
|
|
906 | |
|
|
907 | for (pri = NUMPRI; pri--; ) |
|
|
908 | if (pendingcnt [pri]) |
|
|
909 | return 1; |
|
|
910 | |
|
|
911 | return 0; |
|
|
912 | } |
950 | |
913 | |
951 | static void |
914 | static void |
952 | call_pending (EV_P) |
915 | call_pending (EV_P) |
953 | { |
916 | { |
954 | int pri; |
917 | int pri; |
… | |
… | |
997 | struct ev_periodic *w = periodics [0]; |
960 | struct ev_periodic *w = periodics [0]; |
998 | |
961 | |
999 | assert (("inactive timer on periodic heap detected", ev_is_active (w))); |
962 | assert (("inactive timer on periodic heap detected", ev_is_active (w))); |
1000 | |
963 | |
1001 | /* first reschedule or stop timer */ |
964 | /* first reschedule or stop timer */ |
|
|
965 | if (w->reschedule_cb) |
|
|
966 | { |
|
|
967 | ev_tstamp at = ((WT)w)->at = w->reschedule_cb (w, rt_now + 0.0001); |
|
|
968 | |
|
|
969 | assert (("ev_periodic reschedule callback returned time in the past", ((WT)w)->at > rt_now)); |
|
|
970 | downheap ((WT *)periodics, periodiccnt, 0); |
|
|
971 | } |
1002 | if (w->interval) |
972 | else if (w->interval) |
1003 | { |
973 | { |
1004 | ((WT)w)->at += floor ((rt_now - ((WT)w)->at) / w->interval + 1.) * w->interval; |
974 | ((WT)w)->at += floor ((rt_now - ((WT)w)->at) / w->interval + 1.) * w->interval; |
1005 | assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > rt_now)); |
975 | assert (("ev_periodic timeout in the past detected while processing timers, negative interval?", ((WT)w)->at > rt_now)); |
1006 | downheap ((WT *)periodics, periodiccnt, 0); |
976 | downheap ((WT *)periodics, periodiccnt, 0); |
1007 | } |
977 | } |
… | |
… | |
1020 | /* adjust periodics after time jump */ |
990 | /* adjust periodics after time jump */ |
1021 | for (i = 0; i < periodiccnt; ++i) |
991 | for (i = 0; i < periodiccnt; ++i) |
1022 | { |
992 | { |
1023 | struct ev_periodic *w = periodics [i]; |
993 | struct ev_periodic *w = periodics [i]; |
1024 | |
994 | |
|
|
995 | if (w->reschedule_cb) |
|
|
996 | ((WT)w)->at = w->reschedule_cb (w, rt_now); |
1025 | if (w->interval) |
997 | else if (w->interval) |
1026 | { |
|
|
1027 | ev_tstamp diff = ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval; |
998 | ((WT)w)->at += ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval; |
1028 | |
|
|
1029 | if (fabs (diff) >= 1e-4) |
|
|
1030 | { |
|
|
1031 | ev_periodic_stop (EV_A_ w); |
|
|
1032 | ev_periodic_start (EV_A_ w); |
|
|
1033 | |
|
|
1034 | i = 0; /* restart loop, inefficient, but time jumps should be rare */ |
|
|
1035 | } |
|
|
1036 | } |
|
|
1037 | } |
999 | } |
|
|
1000 | |
|
|
1001 | /* now rebuild the heap */ |
|
|
1002 | for (i = periodiccnt >> 1; i--; ) |
|
|
1003 | downheap ((WT *)periodics, periodiccnt, i); |
1038 | } |
1004 | } |
1039 | |
1005 | |
1040 | inline int |
1006 | inline int |
1041 | time_update_monotonic (EV_P) |
1007 | time_update_monotonic (EV_P) |
1042 | { |
1008 | { |
… | |
… | |
1138 | /* update fd-related kernel structures */ |
1104 | /* update fd-related kernel structures */ |
1139 | fd_reify (EV_A); |
1105 | fd_reify (EV_A); |
1140 | |
1106 | |
1141 | /* calculate blocking time */ |
1107 | /* calculate blocking time */ |
1142 | |
1108 | |
1143 | /* we only need this for !monotonic clockor timers, but as we basically |
1109 | /* we only need this for !monotonic clock or timers, but as we basically |
1144 | always have timers, we just calculate it always */ |
1110 | always have timers, we just calculate it always */ |
1145 | #if EV_USE_MONOTONIC |
1111 | #if EV_USE_MONOTONIC |
1146 | if (expect_true (have_monotonic)) |
1112 | if (expect_true (have_monotonic)) |
1147 | time_update_monotonic (EV_A); |
1113 | time_update_monotonic (EV_A); |
1148 | else |
1114 | else |
… | |
… | |
1181 | /* queue pending timers and reschedule them */ |
1147 | /* queue pending timers and reschedule them */ |
1182 | timers_reify (EV_A); /* relative timers called last */ |
1148 | timers_reify (EV_A); /* relative timers called last */ |
1183 | periodics_reify (EV_A); /* absolute timers called first */ |
1149 | periodics_reify (EV_A); /* absolute timers called first */ |
1184 | |
1150 | |
1185 | /* queue idle watchers unless io or timers are pending */ |
1151 | /* queue idle watchers unless io or timers are pending */ |
1186 | if (!pendingcnt) |
1152 | if (idlecnt && !any_pending (EV_A)) |
1187 | queue_events (EV_A_ (W *)idles, idlecnt, EV_IDLE); |
1153 | queue_events (EV_A_ (W *)idles, idlecnt, EV_IDLE); |
1188 | |
1154 | |
1189 | /* queue check watchers, to be executed first */ |
1155 | /* queue check watchers, to be executed first */ |
1190 | if (checkcnt) |
1156 | if (checkcnt) |
1191 | queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); |
1157 | queue_events (EV_A_ (W *)checks, checkcnt, EV_CHECK); |
… | |
… | |
1266 | return; |
1232 | return; |
1267 | |
1233 | |
1268 | assert (("ev_io_start called with negative fd", fd >= 0)); |
1234 | assert (("ev_io_start called with negative fd", fd >= 0)); |
1269 | |
1235 | |
1270 | ev_start (EV_A_ (W)w, 1); |
1236 | ev_start (EV_A_ (W)w, 1); |
1271 | array_needsize (anfds, anfdmax, fd + 1, anfds_init); |
1237 | array_needsize (ANFD, anfds, anfdmax, fd + 1, anfds_init); |
1272 | wlist_add ((WL *)&anfds[fd].head, (WL)w); |
1238 | wlist_add ((WL *)&anfds[fd].head, (WL)w); |
1273 | |
1239 | |
1274 | fd_change (EV_A_ fd); |
1240 | fd_change (EV_A_ fd); |
1275 | } |
1241 | } |
1276 | |
1242 | |
… | |
… | |
1296 | ((WT)w)->at += mn_now; |
1262 | ((WT)w)->at += mn_now; |
1297 | |
1263 | |
1298 | assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); |
1264 | assert (("ev_timer_start called with negative timer repeat value", w->repeat >= 0.)); |
1299 | |
1265 | |
1300 | ev_start (EV_A_ (W)w, ++timercnt); |
1266 | ev_start (EV_A_ (W)w, ++timercnt); |
1301 | array_needsize (timers, timermax, timercnt, (void)); |
1267 | array_needsize (struct ev_timer *, timers, timermax, timercnt, (void)); |
1302 | timers [timercnt - 1] = w; |
1268 | timers [timercnt - 1] = w; |
1303 | upheap ((WT *)timers, timercnt - 1); |
1269 | upheap ((WT *)timers, timercnt - 1); |
1304 | |
1270 | |
1305 | assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); |
1271 | assert (("internal timer heap corruption", timers [((W)w)->active - 1] == w)); |
1306 | } |
1272 | } |
… | |
… | |
1346 | ev_periodic_start (EV_P_ struct ev_periodic *w) |
1312 | ev_periodic_start (EV_P_ struct ev_periodic *w) |
1347 | { |
1313 | { |
1348 | if (ev_is_active (w)) |
1314 | if (ev_is_active (w)) |
1349 | return; |
1315 | return; |
1350 | |
1316 | |
|
|
1317 | if (w->reschedule_cb) |
|
|
1318 | ((WT)w)->at = w->reschedule_cb (w, rt_now); |
|
|
1319 | else if (w->interval) |
|
|
1320 | { |
1351 | assert (("ev_periodic_start called with negative interval value", w->interval >= 0.)); |
1321 | assert (("ev_periodic_start called with negative interval value", w->interval >= 0.)); |
1352 | |
|
|
1353 | /* this formula differs from the one in periodic_reify because we do not always round up */ |
1322 | /* this formula differs from the one in periodic_reify because we do not always round up */ |
1354 | if (w->interval) |
|
|
1355 | ((WT)w)->at += ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval; |
1323 | ((WT)w)->at += ceil ((rt_now - ((WT)w)->at) / w->interval) * w->interval; |
|
|
1324 | } |
1356 | |
1325 | |
1357 | ev_start (EV_A_ (W)w, ++periodiccnt); |
1326 | ev_start (EV_A_ (W)w, ++periodiccnt); |
1358 | array_needsize (periodics, periodicmax, periodiccnt, (void)); |
1327 | array_needsize (struct ev_periodic *, periodics, periodicmax, periodiccnt, (void)); |
1359 | periodics [periodiccnt - 1] = w; |
1328 | periodics [periodiccnt - 1] = w; |
1360 | upheap ((WT *)periodics, periodiccnt - 1); |
1329 | upheap ((WT *)periodics, periodiccnt - 1); |
1361 | |
1330 | |
1362 | assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); |
1331 | assert (("internal periodic heap corruption", periodics [((W)w)->active - 1] == w)); |
1363 | } |
1332 | } |
… | |
… | |
1379 | |
1348 | |
1380 | ev_stop (EV_A_ (W)w); |
1349 | ev_stop (EV_A_ (W)w); |
1381 | } |
1350 | } |
1382 | |
1351 | |
1383 | void |
1352 | void |
|
|
1353 | ev_periodic_again (EV_P_ struct ev_periodic *w) |
|
|
1354 | { |
|
|
1355 | ev_periodic_stop (EV_A_ w); |
|
|
1356 | ev_periodic_start (EV_A_ w); |
|
|
1357 | } |
|
|
1358 | |
|
|
1359 | void |
1384 | ev_idle_start (EV_P_ struct ev_idle *w) |
1360 | ev_idle_start (EV_P_ struct ev_idle *w) |
1385 | { |
1361 | { |
1386 | if (ev_is_active (w)) |
1362 | if (ev_is_active (w)) |
1387 | return; |
1363 | return; |
1388 | |
1364 | |
1389 | ev_start (EV_A_ (W)w, ++idlecnt); |
1365 | ev_start (EV_A_ (W)w, ++idlecnt); |
1390 | array_needsize (idles, idlemax, idlecnt, (void)); |
1366 | array_needsize (struct ev_idle *, idles, idlemax, idlecnt, (void)); |
1391 | idles [idlecnt - 1] = w; |
1367 | idles [idlecnt - 1] = w; |
1392 | } |
1368 | } |
1393 | |
1369 | |
1394 | void |
1370 | void |
1395 | ev_idle_stop (EV_P_ struct ev_idle *w) |
1371 | ev_idle_stop (EV_P_ struct ev_idle *w) |
… | |
… | |
1407 | { |
1383 | { |
1408 | if (ev_is_active (w)) |
1384 | if (ev_is_active (w)) |
1409 | return; |
1385 | return; |
1410 | |
1386 | |
1411 | ev_start (EV_A_ (W)w, ++preparecnt); |
1387 | ev_start (EV_A_ (W)w, ++preparecnt); |
1412 | array_needsize (prepares, preparemax, preparecnt, (void)); |
1388 | array_needsize (struct ev_prepare *, prepares, preparemax, preparecnt, (void)); |
1413 | prepares [preparecnt - 1] = w; |
1389 | prepares [preparecnt - 1] = w; |
1414 | } |
1390 | } |
1415 | |
1391 | |
1416 | void |
1392 | void |
1417 | ev_prepare_stop (EV_P_ struct ev_prepare *w) |
1393 | ev_prepare_stop (EV_P_ struct ev_prepare *w) |
… | |
… | |
1429 | { |
1405 | { |
1430 | if (ev_is_active (w)) |
1406 | if (ev_is_active (w)) |
1431 | return; |
1407 | return; |
1432 | |
1408 | |
1433 | ev_start (EV_A_ (W)w, ++checkcnt); |
1409 | ev_start (EV_A_ (W)w, ++checkcnt); |
1434 | array_needsize (checks, checkmax, checkcnt, (void)); |
1410 | array_needsize (struct ev_check *, checks, checkmax, checkcnt, (void)); |
1435 | checks [checkcnt - 1] = w; |
1411 | checks [checkcnt - 1] = w; |
1436 | } |
1412 | } |
1437 | |
1413 | |
1438 | void |
1414 | void |
1439 | ev_check_stop (EV_P_ struct ev_check *w) |
1415 | ev_check_stop (EV_P_ struct ev_check *w) |
… | |
… | |
1460 | return; |
1436 | return; |
1461 | |
1437 | |
1462 | assert (("ev_signal_start called with illegal signal number", w->signum > 0)); |
1438 | assert (("ev_signal_start called with illegal signal number", w->signum > 0)); |
1463 | |
1439 | |
1464 | ev_start (EV_A_ (W)w, 1); |
1440 | ev_start (EV_A_ (W)w, 1); |
1465 | array_needsize (signals, signalmax, w->signum, signals_init); |
1441 | array_needsize (ANSIG, signals, signalmax, w->signum, signals_init); |
1466 | wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); |
1442 | wlist_add ((WL *)&signals [w->signum - 1].head, (WL)w); |
1467 | |
1443 | |
1468 | if (!((WL)w)->next) |
1444 | if (!((WL)w)->next) |
1469 | { |
1445 | { |
1470 | #if WIN32 |
1446 | #if WIN32 |
… | |
… | |
1553 | } |
1529 | } |
1554 | |
1530 | |
1555 | void |
1531 | void |
1556 | ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) |
1532 | ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) |
1557 | { |
1533 | { |
1558 | struct ev_once *once = ev_malloc (sizeof (struct ev_once)); |
1534 | struct ev_once *once = (struct ev_once *)ev_malloc (sizeof (struct ev_once)); |
1559 | |
1535 | |
1560 | if (!once) |
1536 | if (!once) |
1561 | cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg); |
1537 | cb (EV_ERROR | EV_READ | EV_WRITE | EV_TIMEOUT, arg); |
1562 | else |
1538 | else |
1563 | { |
1539 | { |