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

Comparing libev/ev.c (file contents):
Revision 1.524 by root, Wed Jan 22 02:20:47 2020 UTC vs.
Revision 1.534 by root, Thu Jul 30 00:59:36 2020 UTC

1/* 1/*
2 * libev event processing core, watcher management 2 * libev event processing core, watcher management
3 * 3 *
4 * Copyright (c) 2007-2019 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007-2020 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
491# endif 491# endif
492#endif 492#endif
493 493
494#if EV_USE_IOURING 494#if EV_USE_IOURING
495# include <sys/syscall.h> 495# include <sys/syscall.h>
496# if !SYS_io_uring_setup && __linux && !__alpha 496# if !SYS_io_uring_register && __linux && !__alpha
497# define SYS_io_uring_setup 425 497# define SYS_io_uring_setup 425
498# define SYS_io_uring_enter 426 498# define SYS_io_uring_enter 426
499# define SYS_io_uring_wregister 427 499# define SYS_io_uring_register 427
500# endif 500# endif
501# if SYS_io_uring_setup && EV_USE_EPOLL /* iouring backend requires epoll backend */ 501# if SYS_io_uring_setup && EV_USE_EPOLL /* iouring backend requires epoll backend */
502# define EV_NEED_SYSCALL 1 502# define EV_NEED_SYSCALL 1
503# else 503# else
504# undef EV_USE_IOURING 504# undef EV_USE_IOURING
604/* the following is ecb.h embedded into libev - use update_ev_c to update from an external copy */ 604/* the following is ecb.h embedded into libev - use update_ev_c to update from an external copy */
605/* ECB.H BEGIN */ 605/* ECB.H BEGIN */
606/* 606/*
607 * libecb - http://software.schmorp.de/pkg/libecb 607 * libecb - http://software.schmorp.de/pkg/libecb
608 * 608 *
609 * Copyright (©) 2009-2015 Marc Alexander Lehmann <libecb@schmorp.de> 609 * Copyright (©) 2009-2015,2018-2020 Marc Alexander Lehmann <libecb@schmorp.de>
610 * Copyright (©) 2011 Emanuele Giaquinta 610 * Copyright (©) 2011 Emanuele Giaquinta
611 * All rights reserved. 611 * All rights reserved.
612 * 612 *
613 * Redistribution and use in source and binary forms, with or without modifica- 613 * Redistribution and use in source and binary forms, with or without modifica-
614 * tion, are permitted provided that the following conditions are met: 614 * tion, are permitted provided that the following conditions are met:
649/* 16 bits major, 16 bits minor */ 649/* 16 bits major, 16 bits minor */
650#define ECB_VERSION 0x00010008 650#define ECB_VERSION 0x00010008
651 651
652#include <string.h> /* for memcpy */ 652#include <string.h> /* for memcpy */
653 653
654#ifdef _WIN32 654#if defined (_WIN32) && !defined (__MINGW32__)
655 typedef signed char int8_t; 655 typedef signed char int8_t;
656 typedef unsigned char uint8_t; 656 typedef unsigned char uint8_t;
657 typedef signed char int_fast8_t; 657 typedef signed char int_fast8_t;
658 typedef unsigned char uint_fast8_t; 658 typedef unsigned char uint_fast8_t;
659 typedef signed short int16_t; 659 typedef signed short int16_t;
2471inline_size 2471inline_size
2472void 2472void
2473fd_change (EV_P_ int fd, int flags) 2473fd_change (EV_P_ int fd, int flags)
2474{ 2474{
2475 unsigned char reify = anfds [fd].reify; 2475 unsigned char reify = anfds [fd].reify;
2476 anfds [fd].reify |= flags; 2476 anfds [fd].reify = reify | flags;
2477 2477
2478 if (ecb_expect_true (!reify)) 2478 if (ecb_expect_true (!reify))
2479 { 2479 {
2480 ++fdchangecnt; 2480 ++fdchangecnt;
2481 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, array_needsize_noinit); 2481 array_needsize (int, fdchanges, fdchangemax, fdchangecnt, array_needsize_noinit);
3043 /* but maybe in the future we want the full treatment. */ 3043 /* but maybe in the future we want the full treatment. */
3044 /* 3044 /*
3045 now_floor = EV_TS_CONST (0.); 3045 now_floor = EV_TS_CONST (0.);
3046 time_update (EV_A_ EV_TSTAMP_HUGE); 3046 time_update (EV_A_ EV_TSTAMP_HUGE);
3047 */ 3047 */
3048#if EV_PERIODIC_ENABLE
3048 periodics_reschedule (EV_A); 3049 periodics_reschedule (EV_A);
3050#endif
3049} 3051}
3050 3052
3051ecb_noinline ecb_cold 3053ecb_noinline ecb_cold
3052static void 3054static void
3053evtimerfd_init (EV_P) 3055evtimerfd_init (EV_P)
3163 3165
3164 /* TODO: linuxaio is very experimental */ 3166 /* TODO: linuxaio is very experimental */
3165#if !EV_RECOMMEND_LINUXAIO 3167#if !EV_RECOMMEND_LINUXAIO
3166 flags &= ~EVBACKEND_LINUXAIO; 3168 flags &= ~EVBACKEND_LINUXAIO;
3167#endif 3169#endif
3168 /* TODO: linuxaio is super experimental */ 3170 /* TODO: iouring is super experimental */
3169#if !EV_RECOMMEND_IOURING 3171#if !EV_RECOMMEND_IOURING
3170 flags &= ~EVBACKEND_IOURING; 3172 flags &= ~EVBACKEND_IOURING;
3171#endif 3173#endif
3172 3174
3173 return flags; 3175 return flags;
4090 4092
4091 if (ecb_expect_true (!(flags & EVRUN_NOWAIT || idleall || !activecnt || pipe_write_skipped))) 4093 if (ecb_expect_true (!(flags & EVRUN_NOWAIT || idleall || !activecnt || pipe_write_skipped)))
4092 { 4094 {
4093 waittime = EV_TS_CONST (MAX_BLOCKTIME); 4095 waittime = EV_TS_CONST (MAX_BLOCKTIME);
4094 4096
4097 if (ecb_expect_true (have_monotonic))
4098 {
4095#if EV_USE_TIMERFD 4099#if EV_USE_TIMERFD
4096 /* sleep a lot longer when we can reliably detect timejumps */ 4100 /* sleep a lot longer when we can reliably detect timejumps */
4097 if (ecb_expect_true (timerfd >= 0)) 4101 if (ecb_expect_true (timerfd != -1))
4102 waittime = EV_TS_CONST (MAX_BLOCKTIME2);
4103#endif
4104#if !EV_PERIODIC_ENABLE
4105 /* without periodics but with monotonic clock there is no need */
4106 /* for any time jump detection, so sleep longer */
4098 waittime = EV_TS_CONST (MAX_BLOCKTIME2); 4107 waittime = EV_TS_CONST (MAX_BLOCKTIME2);
4099#endif 4108#endif
4109 }
4100 4110
4101 if (timercnt) 4111 if (timercnt)
4102 { 4112 {
4103 ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now; 4113 ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now;
4104 if (waittime > to) waittime = to; 4114 if (waittime > to) waittime = to;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines