… | |
… | |
124 | * our syscalls return < 0, not == -1, on error. which is good |
124 | * our syscalls return < 0, not == -1, on error. which is good |
125 | * enough for linux aio. |
125 | * enough for linux aio. |
126 | * TODO: arm is also common nowadays, maybe even mips and x86 |
126 | * TODO: arm is also common nowadays, maybe even mips and x86 |
127 | * TODO: after implementing this, it suddenly looks like overkill, but its hard to remove... |
127 | * TODO: after implementing this, it suddenly looks like overkill, but its hard to remove... |
128 | */ |
128 | */ |
129 | #if __GNUC__ && __linux && ECB_AMD64 |
129 | #if __GNUC__ && __linux && ECB_AMD64 && !defined __OPTIMIZE_SIZE__ |
|
|
130 | /* the costly errno access probably kills this for size optimisation */ |
130 | |
131 | |
131 | #define ev_syscall(nr,narg,arg1,arg2,arg3,arg4,arg5) \ |
132 | #define ev_syscall(nr,narg,arg1,arg2,arg3,arg4,arg5) \ |
132 | ({ \ |
133 | ({ \ |
133 | long res; \ |
134 | long res; \ |
134 | register unsigned long r5 __asm__ ("r8" ); \ |
135 | register unsigned long r5 __asm__ ("r8" ); \ |
… | |
… | |
424 | /* ignored */; |
425 | /* ignored */; |
425 | else |
426 | else |
426 | ev_syserr ("(libev) linuxaio io_getevents"); |
427 | ev_syserr ("(libev) linuxaio io_getevents"); |
427 | else if (res) |
428 | else if (res) |
428 | { |
429 | { |
429 | /* at least one event received, handle it and any remaining ones in the ring buffer */ |
430 | /* at least one event available, handle it and any remaining ones in the ring buffer */ |
430 | linuxaio_parse_events (EV_A_ ioev, res); |
431 | linuxaio_parse_events (EV_A_ ioev, res); |
431 | linuxaio_get_events_from_ring (EV_A); |
432 | linuxaio_get_events_from_ring (EV_A); |
432 | } |
433 | } |
433 | } |
434 | } |
434 | |
435 | |
435 | static int |
436 | inline_size |
|
|
437 | int |
436 | linuxaio_io_setup (EV_P) |
438 | linuxaio_io_setup (EV_P) |
437 | { |
439 | { |
438 | linuxaio_ctx = 0; |
440 | linuxaio_ctx = 0; |
439 | return evsys_io_setup (linuxaio_nr_events (EV_A), &linuxaio_ctx); |
441 | return evsys_io_setup (linuxaio_nr_events (EV_A), &linuxaio_ctx); |
440 | } |
442 | } |
… | |
… | |
568 | void |
570 | void |
569 | linuxaio_destroy (EV_P) |
571 | linuxaio_destroy (EV_P) |
570 | { |
572 | { |
571 | epoll_destroy (EV_A); |
573 | epoll_destroy (EV_A); |
572 | linuxaio_free_iocbp (EV_A); |
574 | linuxaio_free_iocbp (EV_A); |
573 | evsys_io_destroy (linuxaio_ctx); |
575 | evsys_io_destroy (linuxaio_ctx); /* fails in child, aio context is destroyed */ |
574 | } |
576 | } |
575 | |
577 | |
576 | inline_size |
578 | inline_size |
577 | void |
579 | void |
578 | linuxaio_fork (EV_P) |
580 | linuxaio_fork (EV_P) |
… | |
… | |
584 | linuxaio_iteration = 0; /* we start over in the child */ |
586 | linuxaio_iteration = 0; /* we start over in the child */ |
585 | |
587 | |
586 | while (linuxaio_io_setup (EV_A) < 0) |
588 | while (linuxaio_io_setup (EV_A) < 0) |
587 | ev_syserr ("(libev) linuxaio io_setup"); |
589 | ev_syserr ("(libev) linuxaio io_setup"); |
588 | |
590 | |
|
|
591 | /* forking epoll should also effectively unregister all fds from the backend */ |
589 | epoll_fork (EV_A); |
592 | epoll_fork (EV_A); |
590 | |
593 | |
591 | ev_io_stop (EV_A_ &linuxaio_epoll_w); |
594 | ev_io_stop (EV_A_ &linuxaio_epoll_w); |
592 | ev_io_set (EV_A_ &linuxaio_epoll_w, backend_fd, EV_READ); |
595 | ev_io_set (EV_A_ &linuxaio_epoll_w, backend_fd, EV_READ); |
593 | ev_io_start (EV_A_ &linuxaio_epoll_w); |
596 | ev_io_start (EV_A_ &linuxaio_epoll_w); |