1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #include "libaio.h"
- #include <errno.h>
- #include <stdlib.h>
- #include <time.h>
- #include "syscall.h"
- io_syscall5(int, __io_getevents_0_4, io_getevents, io_context_t, ctx, long, min_nr, long, nr, struct io_event *, events, struct timespec *, timeout)
- #define AIO_RING_MAGIC 0xa10a10a1
- struct aio_ring {
- unsigned id;
- unsigned nr;
- unsigned head;
- unsigned tail;
- unsigned magic;
- unsigned compat_features;
- unsigned incompat_features;
- unsigned header_length;
- };
-
- int io_getevents(io_context_t ctx, long min_nr, long nr, struct io_event * events, struct timespec * timeout)
- {
- struct aio_ring *ring;
- ring = (struct aio_ring*)ctx;
- if (ring==NULL || ring->magic != AIO_RING_MAGIC)
- goto do_syscall;
- if (timeout!=NULL && timeout->tv_sec == 0 && timeout->tv_nsec == 0) {
- if (ring->head == ring->tail)
- return 0;
- }
- do_syscall:
- return __io_getevents_0_4(ctx, min_nr, nr, events, timeout);
- }
|