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

Comparing libev/ev.c (file contents):
Revision 1.505 by root, Wed Jul 10 14:25:35 2019 UTC vs.
Revision 1.506 by root, Thu Jul 11 05:41:39 2019 UTC

544#define EV_TSTAMP_HUGE \ 544#define EV_TSTAMP_HUGE \
545 (sizeof (time_t) >= 8 ? 10000000000000. \ 545 (sizeof (time_t) >= 8 ? 10000000000000. \
546 : 0 < (time_t)4294967295 ? 4294967295. \ 546 : 0 < (time_t)4294967295 ? 4294967295. \
547 : 2147483647.) \ 547 : 2147483647.) \
548 548
549#define EV_TS_TO_MS(a) a * 1e3 + 0.9999
550#define EV_TS_FROM_US(us) us * 1e-6
549#define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0) 551#define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0)
550#define EV_TS_SET(ts,t) do { ts.tv_sec = (long)t; ts.tv_nsec = (long)((t - ts.tv_sec) * 1e9); } while (0) 552#define EV_TS_SET(ts,t) do { ts.tv_sec = (long)t; ts.tv_nsec = (long)((t - ts.tv_sec) * 1e9); } while (0)
551#define EV_TV_GET(tv) ((tv).tv_sec + (tv).tv_usec * 1e6) 553#define EV_TV_GET(tv) ((tv).tv_sec + (tv).tv_usec * 1e-6)
552#define EV_TS_GET(ts) ((ts).tv_sec + (ts).tv_nsec * 1e9) 554#define EV_TS_GET(ts) ((ts).tv_sec + (ts).tv_nsec * 1e-9)
553 555
554/* the following is ecb.h embedded into libev - use update_ev_c to update from an external copy */ 556/* the following is ecb.h embedded into libev - use update_ev_c to update from an external copy */
555/* ECB.H BEGIN */ 557/* ECB.H BEGIN */
556/* 558/*
557 * libecb - http://software.schmorp.de/pkg/libecb 559 * libecb - http://software.schmorp.de/pkg/libecb
2041 EV_TS_SET (ts, delay); 2043 EV_TS_SET (ts, delay);
2042 nanosleep (&ts, 0); 2044 nanosleep (&ts, 0);
2043#elif defined _WIN32 2045#elif defined _WIN32
2044 /* maybe this should round up, as ms is very low resolution */ 2046 /* maybe this should round up, as ms is very low resolution */
2045 /* compared to select (µs) or nanosleep (ns) */ 2047 /* compared to select (µs) or nanosleep (ns) */
2046 Sleep ((unsigned long)(delay * 1e3)); 2048 Sleep ((unsigned long)(EV_TS_TO_MS (delay)));
2047#else 2049#else
2048 struct timeval tv; 2050 struct timeval tv;
2049 2051
2050 /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */ 2052 /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */
2051 /* something not guaranteed by newer posix versions, but guaranteed */ 2053 /* something not guaranteed by newer posix versions, but guaranteed */
2401 2403
2402 /* find minimum child */ 2404 /* find minimum child */
2403 if (ecb_expect_true (pos + DHEAP - 1 < E)) 2405 if (ecb_expect_true (pos + DHEAP - 1 < E))
2404 { 2406 {
2405 /* fast path */ (minpos = pos + 0), (minat = ANHE_at (*minpos)); 2407 /* fast path */ (minpos = pos + 0), (minat = ANHE_at (*minpos));
2406 if ( ANHE_at (pos [1]) < minat) (minpos = pos + 1), (minat = ANHE_at (*minpos)); 2408 if ( minat > ANHE_at (pos [1])) (minpos = pos + 1), (minat = ANHE_at (*minpos));
2407 if ( ANHE_at (pos [2]) < minat) (minpos = pos + 2), (minat = ANHE_at (*minpos)); 2409 if ( minat > ANHE_at (pos [2])) (minpos = pos + 2), (minat = ANHE_at (*minpos));
2408 if ( ANHE_at (pos [3]) < minat) (minpos = pos + 3), (minat = ANHE_at (*minpos)); 2410 if ( minat > ANHE_at (pos [3])) (minpos = pos + 3), (minat = ANHE_at (*minpos));
2409 } 2411 }
2410 else if (pos < E) 2412 else if (pos < E)
2411 { 2413 {
2412 /* slow path */ (minpos = pos + 0), (minat = ANHE_at (*minpos)); 2414 /* slow path */ (minpos = pos + 0), (minat = ANHE_at (*minpos));
2413 if (pos + 1 < E && ANHE_at (pos [1]) < minat) (minpos = pos + 1), (minat = ANHE_at (*minpos)); 2415 if (pos + 1 < E && minat > ANHE_at (pos [1])) (minpos = pos + 1), (minat = ANHE_at (*minpos));
2414 if (pos + 2 < E && ANHE_at (pos [2]) < minat) (minpos = pos + 2), (minat = ANHE_at (*minpos)); 2416 if (pos + 2 < E && minat > ANHE_at (pos [2])) (minpos = pos + 2), (minat = ANHE_at (*minpos));
2415 if (pos + 3 < E && ANHE_at (pos [3]) < minat) (minpos = pos + 3), (minat = ANHE_at (*minpos)); 2417 if (pos + 3 < E && minat > ANHE_at (pos [3])) (minpos = pos + 3), (minat = ANHE_at (*minpos));
2416 } 2418 }
2417 else 2419 else
2418 break; 2420 break;
2419 2421
2420 if (ANHE_at (he) <= minat) 2422 if (ANHE_at (he) <= minat)
2428 2430
2429 heap [k] = he; 2431 heap [k] = he;
2430 ev_active (ANHE_w (he)) = k; 2432 ev_active (ANHE_w (he)) = k;
2431} 2433}
2432 2434
2433#else /* 4HEAP */ 2435#else /* not 4HEAP */
2434 2436
2435#define HEAP0 1 2437#define HEAP0 1
2436#define HPARENT(k) ((k) >> 1) 2438#define HPARENT(k) ((k) >> 1)
2437#define UPHEAP_DONE(p,k) (!(p)) 2439#define UPHEAP_DONE(p,k) (!(p))
2438 2440

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines