ia64/xen-unstable

view tools/libaio/src/io_getevents.c @ 10736:2937703f0ed0

Added blktap support. Includes kernel driver (enabled as CONFIG_XEN_BLKDEV_TAP=y) and userspace tools. The userspace deamon (blktapctrl) is enabled by default when xend is activated. For further information on using and configuring blktap see tools/blktap/README.
author jchesterfield@dhcp92.uk.xensource.com
date Thu Jul 13 10:13:26 2006 +0100 (2006-07-13)
parents
children
line source
1 /* io_getevents.c
2 libaio Linux async I/O interface
3 Copyright 2002 Red Hat, Inc.
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 #include <libaio.h>
20 #include <errno.h>
21 #include <stdlib.h>
22 #include <time.h>
23 #include "syscall.h"
25 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)
27 #define AIO_RING_MAGIC 0xa10a10a1
29 /* Ben will hate me for this */
30 struct aio_ring {
31 unsigned id; /* kernel internal index number */
32 unsigned nr; /* number of io_events */
33 unsigned head;
34 unsigned tail;
36 unsigned magic;
37 unsigned compat_features;
38 unsigned incompat_features;
39 unsigned header_length; /* size of aio_ring */
40 };
42 int io_getevents_0_4(io_context_t ctx, long min_nr, long nr, struct io_event * events, struct timespec * timeout)
43 {
44 struct aio_ring *ring;
45 ring = (struct aio_ring*)ctx;
46 if (ring==NULL || ring->magic != AIO_RING_MAGIC)
47 goto do_syscall;
48 if (timeout!=NULL && timeout->tv_sec == 0 && timeout->tv_nsec == 0) {
49 if (ring->head == ring->tail)
50 return 0;
51 }
53 do_syscall:
54 return __io_getevents_0_4(ctx, min_nr, nr, events, timeout);
55 }
57 DEFSYMVER(io_getevents_0_4, io_getevents, 0.4)