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

Comparing libev/ev.c (file contents):
Revision 1.85 by root, Sat Nov 10 03:13:50 2007 UTC vs.
Revision 1.90 by root, Sun Nov 11 00:05:59 2007 UTC

26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
31#ifndef EV_STANDALONE 36#ifndef EV_STANDALONE
32# include "config.h" 37# include "config.h"
33 38
34# if HAVE_CLOCK_GETTIME 39# if HAVE_CLOCK_GETTIME
35# define EV_USE_MONOTONIC 1 40# define EV_USE_MONOTONIC 1
46 51
47# if HAVE_EPOLL && HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H 52# if HAVE_EPOLL && HAVE_EPOLL_CTL && HAVE_SYS_EPOLL_H
48# define EV_USE_EPOLL 1 53# define EV_USE_EPOLL 1
49# endif 54# endif
50 55
51# if HAVE_KQUEUE && HAVE_WORKING_KQUEUE && HAVE_SYS_EVENT_H && HAVE_SYS_QUEUE_H 56# if HAVE_KQUEUE && HAVE_SYS_EVENT_H && HAVE_SYS_QUEUE_H
52# define EV_USE_KQUEUE 1 57# define EV_USE_KQUEUE 1
53# endif 58# endif
54 59
55#endif 60#endif
56 61
221 226
222#if EV_MULTIPLICITY 227#if EV_MULTIPLICITY
223 228
224 struct ev_loop 229 struct ev_loop
225 { 230 {
231 ev_tstamp ev_rt_now;
226 #define VAR(name,decl) decl; 232 #define VAR(name,decl) decl;
227 #include "ev_vars.h" 233 #include "ev_vars.h"
228 #undef VAR 234 #undef VAR
229 }; 235 };
230 #include "ev_wrap.h" 236 #include "ev_wrap.h"
232 struct ev_loop default_loop_struct; 238 struct ev_loop default_loop_struct;
233 static struct ev_loop *default_loop; 239 static struct ev_loop *default_loop;
234 240
235#else 241#else
236 242
243 ev_tstamp ev_rt_now;
237 #define VAR(name,decl) static decl; 244 #define VAR(name,decl) static decl;
238 #include "ev_vars.h" 245 #include "ev_vars.h"
239 #undef VAR 246 #undef VAR
240 247
241 static int default_loop; 248 static int default_loop;
980 987
981 /* first reschedule or stop timer */ 988 /* first reschedule or stop timer */
982 if (w->repeat) 989 if (w->repeat)
983 { 990 {
984 assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.)); 991 assert (("negative ev_timer repeat value found while processing timers", w->repeat > 0.));
992
985 ((WT)w)->at = mn_now + w->repeat; 993 ((WT)w)->at += w->repeat;
994 if (((WT)w)->at < mn_now)
995 ((WT)w)->at = mn_now;
996
986 downheap ((WT *)timers, timercnt, 0); 997 downheap ((WT *)timers, timercnt, 0);
987 } 998 }
988 else 999 else
989 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */ 1000 ev_timer_stop (EV_A_ w); /* nonrepeating: stop timer */
990 1001
1285{ 1296{
1286 ev_clear_pending (EV_A_ (W)w); 1297 ev_clear_pending (EV_A_ (W)w);
1287 if (!ev_is_active (w)) 1298 if (!ev_is_active (w))
1288 return; 1299 return;
1289 1300
1301 assert (("ev_io_start called with illegal fd (must stay constant after start!)", w->fd >= 0 && w->fd < anfdmax));
1302
1290 wlist_del ((WL *)&anfds[w->fd].head, (WL)w); 1303 wlist_del ((WL *)&anfds[w->fd].head, (WL)w);
1291 ev_stop (EV_A_ (W)w); 1304 ev_stop (EV_A_ (W)w);
1292 1305
1293 fd_change (EV_A_ w->fd); 1306 fd_change (EV_A_ w->fd);
1294} 1307}
1592 ev_timer_start (EV_A_ &once->to); 1605 ev_timer_start (EV_A_ &once->to);
1593 } 1606 }
1594 } 1607 }
1595} 1608}
1596 1609
1610#ifdef __cplusplus
1611}
1612#endif
1613

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines