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

Comparing libev/ev.c (file contents):
Revision 1.353 by root, Thu Oct 21 12:32:47 2010 UTC vs.
Revision 1.355 by root, Fri Oct 22 10:09:12 2010 UTC

35 * and other provisions required by the GPL. If you do not delete the 35 * and other provisions required by the GPL. If you do not delete the
36 * provisions above, a recipient may use your version of this file under 36 * provisions above, a recipient may use your version of this file under
37 * either the BSD or the GPL. 37 * either the BSD or the GPL.
38 */ 38 */
39 39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/* this big block deduces configuration from config.h */ 40/* this big block deduces configuration from config.h */
45#ifndef EV_STANDALONE 41#ifndef EV_STANDALONE
46# ifdef EV_CONFIG_H 42# ifdef EV_CONFIG_H
47# include EV_CONFIG_H 43# include EV_CONFIG_H
48# else 44# else
182# include EV_H 178# include EV_H
183#else 179#else
184# include "ev.h" 180# include "ev.h"
185#endif 181#endif
186 182
183EV_CPP(extern "C" {)
184
187#ifndef _WIN32 185#ifndef _WIN32
188# include <sys/time.h> 186# include <sys/time.h>
189# include <sys/wait.h> 187# include <sys/wait.h>
190# include <unistd.h> 188# include <unistd.h>
191#else 189#else
411# define EFD_CLOEXEC O_CLOEXEC 409# define EFD_CLOEXEC O_CLOEXEC
412# else 410# else
413# define EFD_CLOEXEC 02000000 411# define EFD_CLOEXEC 02000000
414# endif 412# endif
415# endif 413# endif
416# ifdef __cplusplus
417extern "C" {
418# endif
419int (eventfd) (unsigned int initval, int flags); 414EV_CPP(extern "C") int (eventfd) (unsigned int initval, int flags);
420# ifdef __cplusplus
421}
422# endif
423#endif 415#endif
424 416
425#if EV_USE_SIGNALFD 417#if EV_USE_SIGNALFD
426/* our minimum requirement is glibc 2.7 which has the stub, but not the header */ 418/* our minimum requirement is glibc 2.7 which has the stub, but not the header */
427# include <stdint.h> 419# include <stdint.h>
433# define SFD_CLOEXEC O_CLOEXEC 425# define SFD_CLOEXEC O_CLOEXEC
434# else 426# else
435# define SFD_CLOEXEC 02000000 427# define SFD_CLOEXEC 02000000
436# endif 428# endif
437# endif 429# endif
438# ifdef __cplusplus
439extern "C" {
440# endif
441int signalfd (int fd, const sigset_t *mask, int flags); 430EV_CPP (extern "C") int signalfd (int fd, const sigset_t *mask, int flags);
442 431
443struct signalfd_siginfo 432struct signalfd_siginfo
444{ 433{
445 uint32_t ssi_signo; 434 uint32_t ssi_signo;
446 char pad[128 - sizeof (uint32_t)]; 435 char pad[128 - sizeof (uint32_t)];
447}; 436};
448# ifdef __cplusplus
449}
450# endif
451#endif 437#endif
452 438
453/**/ 439/**/
454 440
455#if EV_VERIFY >= 3 441#if EV_VERIFY >= 3
534#endif 520#endif
535 521
536#ifdef _WIN32 522#ifdef _WIN32
537# include "ev_win32.c" 523# include "ev_win32.c"
538#endif 524#endif
525
526/*****************************************************************************/
527
528static unsigned int noinline
529ev_linux_version (void)
530{
531#ifdef __linux
532 struct utsname buf;
533 unsigned int v;
534 int i;
535 char *p = buf.release;
536
537 if (uname (&buf))
538 return 0;
539
540 for (i = 3+1; --i; )
541 {
542 unsigned int c = 0;
543
544 for (;;)
545 {
546 if (*p >= '0' && *p <= '9')
547 c = c * 10 + *p++ - '0';
548 else
549 {
550 p += *p == '.';
551 break;
552 }
553 }
554
555 v = (v << 8) | c;
556 }
557
558 return v;
559#else
560 return 0;
561#endif
562}
539 563
540/*****************************************************************************/ 564/*****************************************************************************/
541 565
542#if EV_AVOID_STDIO 566#if EV_AVOID_STDIO
543static void noinline 567static void noinline
1544ev_embeddable_backends (void) 1568ev_embeddable_backends (void)
1545{ 1569{
1546 int flags = EVBACKEND_EPOLL | EVBACKEND_KQUEUE | EVBACKEND_PORT; 1570 int flags = EVBACKEND_EPOLL | EVBACKEND_KQUEUE | EVBACKEND_PORT;
1547 1571
1548 /* epoll embeddability broken on all linux versions up to at least 2.6.23 */ 1572 /* epoll embeddability broken on all linux versions up to at least 2.6.23 */
1549 /* please fix it and tell me how to detect the fix */ 1573 if (ev_linux_version () < 0x020620) /* disable it on linux < 2.6.32 */
1550 flags &= ~EVBACKEND_EPOLL; 1574 flags &= ~EVBACKEND_EPOLL;
1551 1575
1552 return flags; 1576 return flags;
1553} 1577}
1554 1578
1555unsigned int 1579unsigned int
3062 { 3086 {
3063 struct inotify_event *ev = (struct inotify_event *)(buf + ofs); 3087 struct inotify_event *ev = (struct inotify_event *)(buf + ofs);
3064 infy_wd (EV_A_ ev->wd, ev->wd, ev); 3088 infy_wd (EV_A_ ev->wd, ev->wd, ev);
3065 ofs += sizeof (struct inotify_event) + ev->len; 3089 ofs += sizeof (struct inotify_event) + ev->len;
3066 } 3090 }
3067}
3068
3069inline_size unsigned int
3070ev_linux_version (void)
3071{
3072 struct utsname buf;
3073 unsigned int v;
3074 int i;
3075 char *p = buf.release;
3076
3077 if (uname (&buf))
3078 return 0;
3079
3080 for (i = 3+1; --i; )
3081 {
3082 unsigned int c = 0;
3083
3084 for (;;)
3085 {
3086 if (*p >= '0' && *p <= '9')
3087 c = c * 10 + *p++ - '0';
3088 else
3089 {
3090 p += *p == '.';
3091 break;
3092 }
3093 }
3094
3095 v = (v << 8) | c;
3096 }
3097
3098 return v;
3099} 3091}
3100 3092
3101inline_size void 3093inline_size void
3102ev_check_2625 (EV_P) 3094ev_check_2625 (EV_P)
3103{ 3095{
3807 3799
3808#if EV_MULTIPLICITY 3800#if EV_MULTIPLICITY
3809 #include "ev_wrap.h" 3801 #include "ev_wrap.h"
3810#endif 3802#endif
3811 3803
3812#ifdef __cplusplus 3804EV_CPP(})
3813}
3814#endif
3815 3805

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines