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

Comparing libev/ev.c (file contents):
Revision 1.345 by sf-exg, Sat Jul 31 22:33:26 2010 UTC vs.
Revision 1.347 by root, Fri Oct 15 22:44:41 2010 UTC

448# ifdef __cplusplus 448# ifdef __cplusplus
449} 449}
450# endif 450# endif
451#endif 451#endif
452 452
453
454/**/ 453/**/
455 454
456#if EV_VERIFY >= 3 455#if EV_VERIFY >= 3
457# define EV_FREQUENT_CHECK ev_verify (EV_A) 456# define EV_FREQUENT_CHECK ev_verify (EV_A)
458#else 457#else
470#define TIME_EPSILON 0.0001220703125 /* 1/8192 */ 469#define TIME_EPSILON 0.0001220703125 /* 1/8192 */
471 470
472#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */ 471#define MIN_TIMEJUMP 1. /* minimum timejump that gets detected (if monotonic clock available) */
473#define MAX_BLOCKTIME 59.743 /* never wait longer than this time (to detect time jumps) */ 472#define MAX_BLOCKTIME 59.743 /* never wait longer than this time (to detect time jumps) */
474 473
474#define EV_TV_SET(tv,t) do { tv.tv_sec = (long)t; tv.tv_usec = (long)((t - tv.tv_sec) * 1e6); } while (0)
475#define EV_TS_SET(ts,t) do { ts.tv_sec = (long)t; tv.tv_nsec = (long)((t - tv.tv_sec) * 1e9); } while (0)
476
475#if __GNUC__ >= 4 477#if __GNUC__ >= 4
476# define expect(expr,value) __builtin_expect ((expr),(value)) 478# define expect(expr,value) __builtin_expect ((expr),(value))
477# define noinline __attribute__ ((noinline)) 479# define noinline __attribute__ ((noinline))
478#else 480#else
479# define expect(expr,value) (expr) 481# define expect(expr,value) (expr)
769 if (delay > 0.) 771 if (delay > 0.)
770 { 772 {
771#if EV_USE_NANOSLEEP 773#if EV_USE_NANOSLEEP
772 struct timespec ts; 774 struct timespec ts;
773 775
774 ts.tv_sec = (time_t)delay; 776 EV_SET_TS (ts, delay);
775 ts.tv_nsec = (long)((delay - (ev_tstamp)(ts.tv_sec)) * 1e9);
776
777 nanosleep (&ts, 0); 777 nanosleep (&ts, 0);
778#elif defined(_WIN32) 778#elif defined(_WIN32)
779 Sleep ((unsigned long)(delay * 1e3)); 779 Sleep ((unsigned long)(delay * 1e3));
780#else 780#else
781 struct timeval tv; 781 struct timeval tv;
782 782
783 tv.tv_sec = (time_t)delay;
784 tv.tv_usec = (long)((delay - (ev_tstamp)(tv.tv_sec)) * 1e6);
785
786 /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */ 783 /* here we rely on sys/time.h + sys/types.h + unistd.h providing select */
787 /* something not guaranteed by newer posix versions, but guaranteed */ 784 /* something not guaranteed by newer posix versions, but guaranteed */
788 /* by older ones */ 785 /* by older ones */
786 EV_SET_TV (tv, delay);
789 select (0, 0, 0, 0, &tv); 787 select (0, 0, 0, 0, &tv);
790#endif 788#endif
791 } 789 }
792} 790}
793 791
1281 uint64_t counter = 1; 1279 uint64_t counter = 1;
1282 write (evfd, &counter, sizeof (uint64_t)); 1280 write (evfd, &counter, sizeof (uint64_t));
1283 } 1281 }
1284 else 1282 else
1285#endif 1283#endif
1284 /* win32 people keep sending patches that change this write() to send() */
1285 /* and then run away. but send() is wrong, it wants a socket handle on win32 */
1286 /* so when you think this write should be a send instead, please find out */
1287 /* where your send() is from - it's definitely not the microsoft send, and */
1288 /* tell me. thank you. */
1286 write (evpipe [1], &dummy, 1); 1289 write (evpipe [1], &dummy, 1);
1287 1290
1288 errno = old_errno; 1291 errno = old_errno;
1289 } 1292 }
1290} 1293}
1304 } 1307 }
1305 else 1308 else
1306#endif 1309#endif
1307 { 1310 {
1308 char dummy; 1311 char dummy;
1312 /* see discussion in evpipe_write when you think this read should be recv in win32 */
1309 read (evpipe [0], &dummy, 1); 1313 read (evpipe [0], &dummy, 1);
1310 } 1314 }
1311 1315
1312 if (sig_pending) 1316 if (sig_pending)
1313 { 1317 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines