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

Comparing libev/ev.c (file contents):
Revision 1.500 by root, Mon Jul 1 20:47:37 2019 UTC vs.
Revision 1.501 by root, Mon Jul 1 21:47:42 2019 UTC

332# else 332# else
333# define EV_USE_LINUXAIO 0 333# define EV_USE_LINUXAIO 0
334# endif 334# endif
335#endif 335#endif
336 336
337#ifndef EV_USE_IOURING
338# if __linux
339# define EV_USE_IOURING 0
340# else
341# define EV_USE_IOURING 0
342# endif
343#endif
344
337#ifndef EV_USE_INOTIFY 345#ifndef EV_USE_INOTIFY
338# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4)) 346# if __linux && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 4))
339# define EV_USE_INOTIFY EV_FEATURE_OS 347# define EV_USE_INOTIFY EV_FEATURE_OS
340# else 348# else
341# define EV_USE_INOTIFY 0 349# define EV_USE_INOTIFY 0
406# include <sys/syscall.h> 414# include <sys/syscall.h>
407# ifdef SYS_clock_gettime 415# ifdef SYS_clock_gettime
408# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts)) 416# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts))
409# undef EV_USE_MONOTONIC 417# undef EV_USE_MONOTONIC
410# define EV_USE_MONOTONIC 1 418# define EV_USE_MONOTONIC 1
419# define EV_NEED_SYSCALL 1
411# else 420# else
412# undef EV_USE_CLOCK_SYSCALL 421# undef EV_USE_CLOCK_SYSCALL
413# define EV_USE_CLOCK_SYSCALL 0 422# define EV_USE_CLOCK_SYSCALL 0
414# endif 423# endif
415#endif 424#endif
441#if EV_USE_LINUXAIO 450#if EV_USE_LINUXAIO
442# include <sys/syscall.h> 451# include <sys/syscall.h>
443# if !SYS_io_getevents || !EV_USE_EPOLL /* ev_linxaio uses ev_poll.c:ev_epoll_create */ 452# if !SYS_io_getevents || !EV_USE_EPOLL /* ev_linxaio uses ev_poll.c:ev_epoll_create */
444# undef EV_USE_LINUXAIO 453# undef EV_USE_LINUXAIO
445# define EV_USE_LINUXAIO 0 454# define EV_USE_LINUXAIO 0
455# else
456# define EV_NEED_SYSCALL 1
457# endif
458#endif
459
460#if EV_USE_IOURING
461# include <sys/syscall.h>
462# if !__alpha && !SYS_io_uring_setup
463# define SYS_io_uring_setup 425
464# define SYS_io_uring_enter 426
465# define SYS_io_uring_wregister 427
466# endif
467# if SYS_io_uring_setup
468# define EV_NEED_SYSCALL 1
469# else
470# undef EV_USE_IOURING
471# define EV_USE_IOURING 0
446# endif 472# endif
447#endif 473#endif
448 474
449#if EV_USE_INOTIFY 475#if EV_USE_INOTIFY
450# include <sys/statfs.h> 476# include <sys/statfs.h>
492 uint32_t ssi_signo; 518 uint32_t ssi_signo;
493 char pad[128 - sizeof (uint32_t)]; 519 char pad[128 - sizeof (uint32_t)];
494}; 520};
495#endif 521#endif
496 522
497/**/ 523/*****************************************************************************/
524
525#if EV_NEED_SYSCALL
526
527#include <sys/syscall.h>
528
529/*
530 * define some syscall wrappers for common architectures
531 * this is mostly for nice looks during debugging, not performance.
532 * our syscalls return < 0, not == -1, on error. which is good
533 * enough for linux aio.
534 * TODO: arm is also common nowadays, maybe even mips and x86
535 * TODO: after implementing this, it suddenly looks like overkill, but its hard to remove...
536 */
537#if __GNUC__ && __linux && ECB_AMD64 && !defined __OPTIMIZE_SIZE__
538 /* the costly errno access probably kills this for size optimisation */
539
540 #define ev_syscall(nr,narg,arg1,arg2,arg3,arg4,arg5) \
541 ({ \
542 long res; \
543 register unsigned long r5 __asm__ ("r8" ); \
544 register unsigned long r4 __asm__ ("r10"); \
545 register unsigned long r3 __asm__ ("rdx"); \
546 register unsigned long r2 __asm__ ("rsi"); \
547 register unsigned long r1 __asm__ ("rdi"); \
548 if (narg >= 5) r5 = (unsigned long)(arg5); \
549 if (narg >= 4) r4 = (unsigned long)(arg4); \
550 if (narg >= 3) r3 = (unsigned long)(arg3); \
551 if (narg >= 2) r2 = (unsigned long)(arg2); \
552 if (narg >= 1) r1 = (unsigned long)(arg1); \
553 __asm__ __volatile__ ( \
554 "syscall\n\t" \
555 : "=a" (res) \
556 : "0" (nr), "r" (r1), "r" (r2), "r" (r3), "r" (r4), "r" (r5) \
557 : "cc", "r11", "cx", "memory"); \
558 errno = -res; \
559 res; \
560 })
561
562#endif
563
564#ifdef ev_syscall
565 #define ev_syscall0(nr) ev_syscall (nr, 0, 0, 0, 0, 0, 0
566 #define ev_syscall1(nr,arg1) ev_syscall (nr, 1, arg1, 0, 0, 0, 0)
567 #define ev_syscall2(nr,arg1,arg2) ev_syscall (nr, 2, arg1, arg2, 0, 0, 0)
568 #define ev_syscall3(nr,arg1,arg2,arg3) ev_syscall (nr, 3, arg1, arg2, arg3, 0, 0)
569 #define ev_syscall4(nr,arg1,arg2,arg3,arg4) ev_syscall (nr, 3, arg1, arg2, arg3, arg4, 0)
570 #define ev_syscall5(nr,arg1,arg2,arg3,arg4,arg5) ev_syscall (nr, 5, arg1, arg2, arg3, arg4, arg5)
571#else
572 #define ev_syscall0(nr) syscall (nr)
573 #define ev_syscall1(nr,arg1) syscall (nr, arg1)
574 #define ev_syscall2(nr,arg1,arg2) syscall (nr, arg1, arg2)
575 #define ev_syscall3(nr,arg1,arg2,arg3) syscall (nr, arg1, arg2, arg3)
576 #define ev_syscall4(nr,arg1,arg2,arg3,arg4) syscall (nr, arg1, arg2, arg3, arg4)
577 #define ev_syscall5(nr,arg1,arg2,arg3,arg4,arg5) syscall (nr, arg1, arg2, arg3, arg4, arg5)
578#endif
579
580#endif
581
582/*****************************************************************************/
498 583
499#if EV_VERIFY >= 3 584#if EV_VERIFY >= 3
500# define EV_FREQUENT_CHECK ev_verify (EV_A) 585# define EV_FREQUENT_CHECK ev_verify (EV_A)
501#else 586#else
502# define EV_FREQUENT_CHECK do { } while (0) 587# define EV_FREQUENT_CHECK do { } while (0)
2737# include "ev_epoll.c" 2822# include "ev_epoll.c"
2738#endif 2823#endif
2739#if EV_USE_LINUXAIO 2824#if EV_USE_LINUXAIO
2740# include "ev_linuxaio.c" 2825# include "ev_linuxaio.c"
2741#endif 2826#endif
2827#if EV_USE_IOURING
2828# include "ev_iouring.c"
2829#endif
2742#if EV_USE_POLL 2830#if EV_USE_POLL
2743# include "ev_poll.c" 2831# include "ev_poll.c"
2744#endif 2832#endif
2745#if EV_USE_SELECT 2833#if EV_USE_SELECT
2746# include "ev_select.c" 2834# include "ev_select.c"
2778 2866
2779 if (EV_USE_PORT ) flags |= EVBACKEND_PORT; 2867 if (EV_USE_PORT ) flags |= EVBACKEND_PORT;
2780 if (EV_USE_KQUEUE ) flags |= EVBACKEND_KQUEUE; 2868 if (EV_USE_KQUEUE ) flags |= EVBACKEND_KQUEUE;
2781 if (EV_USE_EPOLL ) flags |= EVBACKEND_EPOLL; 2869 if (EV_USE_EPOLL ) flags |= EVBACKEND_EPOLL;
2782 if (EV_USE_LINUXAIO) flags |= EVBACKEND_LINUXAIO; 2870 if (EV_USE_LINUXAIO) flags |= EVBACKEND_LINUXAIO;
2871 if (EV_USE_IOURING ) flags |= EVBACKEND_IOURING;
2783 if (EV_USE_POLL ) flags |= EVBACKEND_POLL; 2872 if (EV_USE_POLL ) flags |= EVBACKEND_POLL;
2784 if (EV_USE_SELECT ) flags |= EVBACKEND_SELECT; 2873 if (EV_USE_SELECT ) flags |= EVBACKEND_SELECT;
2785 2874
2786 return flags; 2875 return flags;
2787} 2876}
2807#endif 2896#endif
2808 2897
2809 /* TODO: linuxaio is very experimental */ 2898 /* TODO: linuxaio is very experimental */
2810#if !EV_RECOMMEND_LINUXAIO 2899#if !EV_RECOMMEND_LINUXAIO
2811 flags &= ~EVBACKEND_LINUXAIO; 2900 flags &= ~EVBACKEND_LINUXAIO;
2901#endif
2902 /* TODO: linuxaio is super experimental */
2903#if !EV_RECOMMEND_IOURING
2904 flags &= ~EVBACKEND_IOURING;
2812#endif 2905#endif
2813 2906
2814 return flags; 2907 return flags;
2815} 2908}
2816 2909
2961 if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags); 3054 if (!backend && (flags & EVBACKEND_PORT )) backend = port_init (EV_A_ flags);
2962#endif 3055#endif
2963#if EV_USE_KQUEUE 3056#if EV_USE_KQUEUE
2964 if (!backend && (flags & EVBACKEND_KQUEUE )) backend = kqueue_init (EV_A_ flags); 3057 if (!backend && (flags & EVBACKEND_KQUEUE )) backend = kqueue_init (EV_A_ flags);
2965#endif 3058#endif
3059#if EV_USE_IOURING
3060 if (!backend && (flags & EVBACKEND_IOURING )) backend = iouring_init (EV_A_ flags);
3061#endif
2966#if EV_USE_LINUXAIO 3062#if EV_USE_LINUXAIO
2967 if (!backend && (flags & EVBACKEND_LINUXAIO)) backend = linuxaio_init (EV_A_ flags); 3063 if (!backend && (flags & EVBACKEND_LINUXAIO)) backend = linuxaio_init (EV_A_ flags);
2968#endif 3064#endif
2969#if EV_USE_EPOLL 3065#if EV_USE_EPOLL
2970 if (!backend && (flags & EVBACKEND_EPOLL )) backend = epoll_init (EV_A_ flags); 3066 if (!backend && (flags & EVBACKEND_EPOLL )) backend = epoll_init (EV_A_ flags);
3043#if EV_USE_PORT 3139#if EV_USE_PORT
3044 if (backend == EVBACKEND_PORT ) port_destroy (EV_A); 3140 if (backend == EVBACKEND_PORT ) port_destroy (EV_A);
3045#endif 3141#endif
3046#if EV_USE_KQUEUE 3142#if EV_USE_KQUEUE
3047 if (backend == EVBACKEND_KQUEUE ) kqueue_destroy (EV_A); 3143 if (backend == EVBACKEND_KQUEUE ) kqueue_destroy (EV_A);
3144#endif
3145#if EV_USE_IOURING
3146 if (backend == EVBACKEND_IOURING ) iouring_destroy (EV_A);
3048#endif 3147#endif
3049#if EV_USE_LINUXAIO 3148#if EV_USE_LINUXAIO
3050 if (backend == EVBACKEND_LINUXAIO) linuxaio_destroy (EV_A); 3149 if (backend == EVBACKEND_LINUXAIO) linuxaio_destroy (EV_A);
3051#endif 3150#endif
3052#if EV_USE_EPOLL 3151#if EV_USE_EPOLL
3110#if EV_USE_PORT 3209#if EV_USE_PORT
3111 if (backend == EVBACKEND_PORT ) port_fork (EV_A); 3210 if (backend == EVBACKEND_PORT ) port_fork (EV_A);
3112#endif 3211#endif
3113#if EV_USE_KQUEUE 3212#if EV_USE_KQUEUE
3114 if (backend == EVBACKEND_KQUEUE ) kqueue_fork (EV_A); 3213 if (backend == EVBACKEND_KQUEUE ) kqueue_fork (EV_A);
3214#endif
3215#if EV_USE_IOURING
3216 if (backend == EVBACKEND_IOURING ) iouring_fork (EV_A);
3115#endif 3217#endif
3116#if EV_USE_LINUXAIO 3218#if EV_USE_LINUXAIO
3117 if (backend == EVBACKEND_LINUXAIO) linuxaio_fork (EV_A); 3219 if (backend == EVBACKEND_LINUXAIO) linuxaio_fork (EV_A);
3118#endif 3220#endif
3119#if EV_USE_EPOLL 3221#if EV_USE_EPOLL

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines