ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev.c
(Generate patch)

Comparing libev/ev.c (file contents):
Revision 1.427 by root, Sun May 6 19:29:59 2012 UTC vs.
Revision 1.434 by root, Fri May 18 00:04:52 2012 UTC

201# include <sys/wait.h> 201# include <sys/wait.h>
202# include <unistd.h> 202# include <unistd.h>
203#else 203#else
204# include <io.h> 204# include <io.h>
205# define WIN32_LEAN_AND_MEAN 205# define WIN32_LEAN_AND_MEAN
206# include <winsock2.h>
206# include <windows.h> 207# include <windows.h>
207# ifndef EV_SELECT_IS_WINSOCKET 208# ifndef EV_SELECT_IS_WINSOCKET
208# define EV_SELECT_IS_WINSOCKET 1 209# define EV_SELECT_IS_WINSOCKET 1
209# endif 210# endif
210# undef EV_AVOID_STDIO 211# undef EV_AVOID_STDIO
408/* some very old inotify.h headers don't have IN_DONT_FOLLOW */ 409/* some very old inotify.h headers don't have IN_DONT_FOLLOW */
409# ifndef IN_DONT_FOLLOW 410# ifndef IN_DONT_FOLLOW
410# undef EV_USE_INOTIFY 411# undef EV_USE_INOTIFY
411# define EV_USE_INOTIFY 0 412# define EV_USE_INOTIFY 0
412# endif 413# endif
413#endif
414
415#if EV_SELECT_IS_WINSOCKET
416# include <winsock.h>
417#endif 414#endif
418 415
419#if EV_USE_EVENTFD 416#if EV_USE_EVENTFD
420/* our minimum requirement is glibc 2.7 which has the stub, but not the header */ 417/* our minimum requirement is glibc 2.7 which has the stub, but not the header */
421# include <stdint.h> 418# include <stdint.h>
1108#endif 1105#endif
1109 1106
1110static void (*syserr_cb)(const char *msg) EV_THROW; 1107static void (*syserr_cb)(const char *msg) EV_THROW;
1111 1108
1112void ecb_cold 1109void ecb_cold
1113ev_set_syserr_cb (void (*cb)(const char *msg)) EV_THROW 1110ev_set_syserr_cb (void (*cb)(const char *msg) EV_THROW) EV_THROW
1114{ 1111{
1115 syserr_cb = cb; 1112 syserr_cb = cb;
1116} 1113}
1117 1114
1118static void noinline ecb_cold 1115static void noinline ecb_cold
1136 abort (); 1133 abort ();
1137 } 1134 }
1138} 1135}
1139 1136
1140static void * 1137static void *
1141ev_realloc_emul (void *ptr, long size) 1138ev_realloc_emul (void *ptr, long size) EV_THROW
1142{ 1139{
1143#if __GLIBC__ 1140#if __GLIBC__
1144 return realloc (ptr, size); 1141 return realloc (ptr, size);
1145#else 1142#else
1146 /* some systems, notably openbsd and darwin, fail to properly 1143 /* some systems, notably openbsd and darwin, fail to properly
1157} 1154}
1158 1155
1159static void *(*alloc)(void *ptr, long size) EV_THROW = ev_realloc_emul; 1156static void *(*alloc)(void *ptr, long size) EV_THROW = ev_realloc_emul;
1160 1157
1161void ecb_cold 1158void ecb_cold
1162ev_set_allocator (void *(*cb)(void *ptr, long size)) EV_THROW 1159ev_set_allocator (void *(*cb)(void *ptr, long size) EV_THROW) EV_THROW
1163{ 1160{
1164 alloc = cb; 1161 alloc = cb;
1165} 1162}
1166 1163
1167inline_speed void * 1164inline_speed void *
1913 { 1910 {
1914 char dummy[4]; 1911 char dummy[4];
1915#ifdef _WIN32 1912#ifdef _WIN32
1916 WSABUF buf; 1913 WSABUF buf;
1917 DWORD recvd; 1914 DWORD recvd;
1915 DWORD flags = 0;
1918 buf.buf = dummy; 1916 buf.buf = dummy;
1919 buf.len = sizeof (dummy); 1917 buf.len = sizeof (dummy);
1920 WSARecv (EV_FD_TO_WIN32_HANDLE (evpipe [0]), &buf, 1, &recvd, 0, 0, 0); 1918 WSARecv (EV_FD_TO_WIN32_HANDLE (evpipe [0]), &buf, 1, &recvd, &flags, 0, 0);
1921#else 1919#else
1922 read (evpipe [0], &dummy, sizeof (dummy)); 1920 read (evpipe [0], &dummy, sizeof (dummy));
1923#endif 1921#endif
1924 } 1922 }
1925 } 1923 }
2357 EV_INVOKE_PENDING; 2355 EV_INVOKE_PENDING;
2358 } 2356 }
2359#endif 2357#endif
2360 2358
2361#if EV_CHILD_ENABLE 2359#if EV_CHILD_ENABLE
2362 if (ev_is_active (&childev)) 2360 if (ev_is_default_loop (EV_A) && ev_is_active (&childev))
2363 { 2361 {
2364 ev_ref (EV_A); /* child watcher */ 2362 ev_ref (EV_A); /* child watcher */
2365 ev_signal_stop (EV_A_ &childev); 2363 ev_signal_stop (EV_A_ &childev);
2366 } 2364 }
2367#endif 2365#endif
2562#if EV_FEATURE_API 2560#if EV_FEATURE_API
2563void ecb_cold 2561void ecb_cold
2564ev_verify (EV_P) EV_THROW 2562ev_verify (EV_P) EV_THROW
2565{ 2563{
2566#if EV_VERIFY 2564#if EV_VERIFY
2567 int i, j; 2565 int i;
2568 WL w, w2; 2566 WL w, w2;
2569 2567
2570 assert (activecnt >= -1); 2568 assert (activecnt >= -1);
2571 2569
2572 assert (fdchangemax >= fdchangecnt); 2570 assert (fdchangemax >= fdchangecnt);
2573 for (i = 0; i < fdchangecnt; ++i) 2571 for (i = 0; i < fdchangecnt; ++i)
2574 assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0)); 2572 assert (("libev: negative fd in fdchanges", fdchanges [i] >= 0));
2575 2573
2576 assert (anfdmax >= 0); 2574 assert (anfdmax >= 0);
2577 for (i = j = 0; i < anfdmax; ++i) 2575 for (i = 0; i < anfdmax; ++i)
2576 {
2577 int j = 0;
2578
2578 for (w = w2 = anfds [i].head; w; w = w->next) 2579 for (w = w2 = anfds [i].head; w; w = w->next)
2579 { 2580 {
2580 verify_watcher (EV_A_ (W)w); 2581 verify_watcher (EV_A_ (W)w);
2581 2582
2582 if (++j & 1) 2583 if (j++ & 1)
2583 w2 = w2->next; 2584 {
2584
2585 assert (("libev: io watcher list contains a loop", w != w2)); 2585 assert (("libev: io watcher list contains a loop", w != w2));
2586 w2 = w2->next;
2587 }
2588
2586 assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1)); 2589 assert (("libev: inactive fd watcher on anfd list", ev_active (w) == 1));
2587 assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i)); 2590 assert (("libev: fd mismatch between watcher and anfd", ((ev_io *)w)->fd == i));
2588 } 2591 }
2592 }
2589 2593
2590 assert (timermax >= timercnt); 2594 assert (timermax >= timercnt);
2591 verify_heap (EV_A_ timers, timercnt); 2595 verify_heap (EV_A_ timers, timercnt);
2592 2596
2593#if EV_PERIODIC_ENABLE 2597#if EV_PERIODIC_ENABLE

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines