… | |
… | |
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; |
… | |
… | |
2394 | { |
2394 | { |
2395 | int i; |
2395 | int i; |
2396 | |
2396 | |
2397 | /* most backends do not modify the fdchanges list in backend_modfiy. |
2397 | /* most backends do not modify the fdchanges list in backend_modfiy. |
2398 | * except io_uring, which has fixed-size buffers which might force us |
2398 | * except io_uring, which has fixed-size buffers which might force us |
2399 | * to handle events in backend_modify, causing fdchangesd to be amended, |
2399 | * to handle events in backend_modify, causing fdchanges to be amended, |
2400 | * which could result in an endless loop. |
2400 | * which could result in an endless loop. |
2401 | * to avoid this, we do not dynamically handle fds that were added |
2401 | * to avoid this, we do not dynamically handle fds that were added |
2402 | * during fd_reify. that menas thast for those backends, fdchangecnt |
2402 | * during fd_reify. that means that for those backends, fdchangecnt |
2403 | * might be non-zero during poll, which must cause them to not block. |
2403 | * might be non-zero during poll, which must cause them to not block. |
2404 | * to not put too much of a burden on other backends, this detail |
2404 | * to not put too much of a burden on other backends, this detail |
2405 | * needs to be handled in the backend. |
2405 | * needs to be handled in the backend. |
2406 | */ |
2406 | */ |
2407 | int changecnt = fdchangecnt; |
2407 | int changecnt = fdchangecnt; |
… | |
… | |
2471 | inline_size |
2471 | inline_size |
2472 | void |
2472 | void |
2473 | fd_change (EV_P_ int fd, int flags) |
2473 | fd_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 | |
3051 | ecb_noinline ecb_cold |
3053 | ecb_noinline ecb_cold |
3052 | static void |
3054 | static void |
3053 | evtimerfd_init (EV_P) |
3055 | evtimerfd_init (EV_P) |
… | |
… | |
4095 | #if EV_USE_TIMERFD |
4097 | #if EV_USE_TIMERFD |
4096 | /* sleep a lot longer when we can reliably detect timejumps */ |
4098 | /* sleep a lot longer when we can reliably detect timejumps */ |
4097 | if (ecb_expect_true (timerfd >= 0)) |
4099 | if (ecb_expect_true (timerfd >= 0)) |
4098 | waittime = EV_TS_CONST (MAX_BLOCKTIME2); |
4100 | waittime = EV_TS_CONST (MAX_BLOCKTIME2); |
4099 | #endif |
4101 | #endif |
|
|
4102 | #if !EV_PERIODIC_ENABLE |
|
|
4103 | /* without periodics but with monotonic clock there is no need */ |
|
|
4104 | /* for any time jump detection, so sleep longer */ |
|
|
4105 | if (ecb_expect_true (have_monotonic)) |
|
|
4106 | waittime = EV_TS_CONST (MAX_BLOCKTIME2); |
|
|
4107 | #endif |
4100 | |
4108 | |
4101 | if (timercnt) |
4109 | if (timercnt) |
4102 | { |
4110 | { |
4103 | ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now; |
4111 | ev_tstamp to = ANHE_at (timers [HEAP0]) - mn_now; |
4104 | if (waittime > to) waittime = to; |
4112 | if (waittime > to) waittime = to; |