diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2009-10-09 18:17:02 +0000 |
---|---|---|
committer | <> | 2013-09-20 15:53:04 +0000 |
commit | e6a27c468cae77ce26f6aa924b22bd39055892fe (patch) | |
tree | 5799c05ec62d99e582db411ed0fe5ffd2ba519db /libaio-0.3.109/src/io_getevents.c | |
download | libaio-tarball-e6a27c468cae77ce26f6aa924b22bd39055892fe.tar.gz |
Imported from /home/lorry/working-area/delta_libaio-tarball/libaio_0.3.109.orig.tar.gz.HEADlibaio_0.3.109.origmaster
Diffstat (limited to 'libaio-0.3.109/src/io_getevents.c')
-rw-r--r-- | libaio-0.3.109/src/io_getevents.c | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/libaio-0.3.109/src/io_getevents.c b/libaio-0.3.109/src/io_getevents.c new file mode 100644 index 0000000..5a05174 --- /dev/null +++ b/libaio-0.3.109/src/io_getevents.c @@ -0,0 +1,57 @@ +/* io_getevents.c + libaio Linux async I/O interface + Copyright 2002 Red Hat, Inc. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#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 + +/* Ben will hate me for this */ +struct aio_ring { + unsigned id; /* kernel internal index number */ + unsigned nr; /* number of io_events */ + unsigned head; + unsigned tail; + + unsigned magic; + unsigned compat_features; + unsigned incompat_features; + unsigned header_length; /* size of aio_ring */ +}; + +int io_getevents_0_4(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); +} + +DEFSYMVER(io_getevents_0_4, io_getevents, 0.4) |