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

Comparing libev/ev.c (file contents):
Revision 1.254 by root, Wed Jun 4 20:26:55 2008 UTC vs.
Revision 1.262 by root, Wed Oct 1 04:25:25 2008 UTC

154#ifndef _WIN32 154#ifndef _WIN32
155# include <sys/time.h> 155# include <sys/time.h>
156# include <sys/wait.h> 156# include <sys/wait.h>
157# include <unistd.h> 157# include <unistd.h>
158#else 158#else
159# include <io.h>
159# define WIN32_LEAN_AND_MEAN 160# define WIN32_LEAN_AND_MEAN
160# include <windows.h> 161# include <windows.h>
161# ifndef EV_SELECT_IS_WINSOCKET 162# ifndef EV_SELECT_IS_WINSOCKET
162# define EV_SELECT_IS_WINSOCKET 1 163# define EV_SELECT_IS_WINSOCKET 1
163# endif 164# endif
564 struct timeval tv; 565 struct timeval tv;
565 566
566 tv.tv_sec = (time_t)delay; 567 tv.tv_sec = (time_t)delay;
567 tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6); 568 tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6);
568 569
570 /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */
571 /* somehting nto guaranteed by newer posix versions, but guaranteed */
572 /* by older ones */
569 select (0, 0, 0, 0, &tv); 573 select (0, 0, 0, 0, &tv);
570#endif 574#endif
571 } 575 }
572} 576}
573 577
1507{ 1511{
1508 postfork = 1; /* must be in line with ev_default_fork */ 1512 postfork = 1; /* must be in line with ev_default_fork */
1509} 1513}
1510 1514
1511#if EV_VERIFY 1515#if EV_VERIFY
1512void noinline 1516static void noinline
1513verify_watcher (EV_P_ W w) 1517verify_watcher (EV_P_ W w)
1514{ 1518{
1515 assert (("watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI)); 1519 assert (("watcher has invalid priority", ABSPRI (w) >= 0 && ABSPRI (w) < NUMPRI));
1516 1520
1517 if (w->pending) 1521 if (w->pending)
1905ev_unref (EV_P) 1909ev_unref (EV_P)
1906{ 1910{
1907 --activecnt; 1911 --activecnt;
1908} 1912}
1909 1913
1914void
1915ev_now_update (EV_P)
1916{
1917 time_update (EV_A_ 1e100);
1918}
1919
1910static int loop_done; 1920static int loop_done;
1911 1921
1912void 1922void
1913ev_loop (EV_P_ int flags) 1923ev_loop (EV_P_ int flags)
1914{ 1924{
2567 } 2577 }
2568 2578
2569 } 2579 }
2570} 2580}
2571 2581
2582#endif
2583
2584#ifdef _WIN32
2585# define EV_LSTAT(p,b) _stati64 (p, b)
2586#else
2587# define EV_LSTAT(p,b) lstat (p, b)
2572#endif 2588#endif
2573 2589
2574void 2590void
2575ev_stat_stat (EV_P_ ev_stat *w) 2591ev_stat_stat (EV_P_ ev_stat *w)
2576{ 2592{
2817 ev_loop (EV_A_ EVLOOP_NONBLOCK); 2833 ev_loop (EV_A_ EVLOOP_NONBLOCK);
2818 } 2834 }
2819 } 2835 }
2820} 2836}
2821 2837
2838static void
2839embed_fork_cb (EV_P_ ev_fork *fork_w, int revents)
2840{
2841 ev_embed *w = (ev_embed *)(((char *)fork_w) - offsetof (ev_embed, fork));
2842
2843 {
2844 struct ev_loop *loop = w->other;
2845
2846 ev_loop_fork (EV_A);
2847 }
2848}
2849
2822#if 0 2850#if 0
2823static void 2851static void
2824embed_idle_cb (EV_P_ ev_idle *idle, int revents) 2852embed_idle_cb (EV_P_ ev_idle *idle, int revents)
2825{ 2853{
2826 ev_idle_stop (EV_A_ idle); 2854 ev_idle_stop (EV_A_ idle);
2846 2874
2847 ev_prepare_init (&w->prepare, embed_prepare_cb); 2875 ev_prepare_init (&w->prepare, embed_prepare_cb);
2848 ev_set_priority (&w->prepare, EV_MINPRI); 2876 ev_set_priority (&w->prepare, EV_MINPRI);
2849 ev_prepare_start (EV_A_ &w->prepare); 2877 ev_prepare_start (EV_A_ &w->prepare);
2850 2878
2879 ev_fork_init (&w->fork, embed_fork_cb);
2880 ev_fork_start (EV_A_ &w->fork);
2881
2851 /*ev_idle_init (&w->idle, e,bed_idle_cb);*/ 2882 /*ev_idle_init (&w->idle, e,bed_idle_cb);*/
2852 2883
2853 ev_start (EV_A_ (W)w, 1); 2884 ev_start (EV_A_ (W)w, 1);
2854 2885
2855 EV_FREQUENT_CHECK; 2886 EV_FREQUENT_CHECK;
2862 if (expect_false (!ev_is_active (w))) 2893 if (expect_false (!ev_is_active (w)))
2863 return; 2894 return;
2864 2895
2865 EV_FREQUENT_CHECK; 2896 EV_FREQUENT_CHECK;
2866 2897
2867 ev_io_stop (EV_A_ &w->io); 2898 ev_io_stop (EV_A_ &w->io);
2868 ev_prepare_stop (EV_A_ &w->prepare); 2899 ev_prepare_stop (EV_A_ &w->prepare);
2869 2900 ev_fork_stop (EV_A_ &w->fork);
2870 ev_stop (EV_A_ (W)w);
2871 2901
2872 EV_FREQUENT_CHECK; 2902 EV_FREQUENT_CHECK;
2873} 2903}
2874#endif 2904#endif
2875 2905
2972once_cb (EV_P_ struct ev_once *once, int revents) 3002once_cb (EV_P_ struct ev_once *once, int revents)
2973{ 3003{
2974 void (*cb)(int revents, void *arg) = once->cb; 3004 void (*cb)(int revents, void *arg) = once->cb;
2975 void *arg = once->arg; 3005 void *arg = once->arg;
2976 3006
2977 ev_io_stop (EV_A_ &once->io); 3007 ev_io_stop (EV_A_ &once->io);
2978 ev_timer_stop (EV_A_ &once->to); 3008 ev_timer_stop (EV_A_ &once->to);
2979 ev_free (once); 3009 ev_free (once);
2980 3010
2981 cb (revents, arg); 3011 cb (revents, arg);
2982} 3012}
2983 3013
2984static void 3014static void
2985once_cb_io (EV_P_ ev_io *w, int revents) 3015once_cb_io (EV_P_ ev_io *w, int revents)
2986{ 3016{
2987 once_cb (EV_A_ (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io)), revents); 3017 struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, io));
3018
3019 once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->to));
2988} 3020}
2989 3021
2990static void 3022static void
2991once_cb_to (EV_P_ ev_timer *w, int revents) 3023once_cb_to (EV_P_ ev_timer *w, int revents)
2992{ 3024{
2993 once_cb (EV_A_ (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to)), revents); 3025 struct ev_once *once = (struct ev_once *)(((char *)w) - offsetof (struct ev_once, to));
3026
3027 once_cb (EV_A_ once, revents | ev_clear_pending (EV_A_ &once->io));
2994} 3028}
2995 3029
2996void 3030void
2997ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg) 3031ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg)
2998{ 3032{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines