debuggers.hg

view tools/blktap2/drivers/libaio-compat.h @ 22848:6341fe0f4e5a

Added tag 4.1.0-rc2 for changeset 9dca60d88c63
author Keir Fraser <keir@xen.org>
date Tue Jan 25 14:06:55 2011 +0000 (2011-01-25)
parents b0ffb4912c46
children
line source
1 /*
2 * Copyright (c) 2010, XenSource Inc.
3 * All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful, but
11 * 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.
14 *
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
18 * USA
19 */
21 /*
22 * kernel 2.6.21 added eventfd(2) support, kernel 2.6.22 eventfds for
23 * aio. libaio 0.3.107 updated the header file, but few systems have
24 * it. define a custom iocb_common struct instead, and work around a
25 * potentially missing sys/eventfd.h. this header should vanish over
26 * time.
27 */
29 #ifndef __LIBAIO_COMPAT
30 #define __LIBAIO_COMPAT
32 #include <libaio.h>
33 #include <unistd.h>
34 #include <sys/syscall.h>
36 struct __compat_io_iocb_common {
37 char __pad_buf[8];
38 char __pad_nbytes[8];
39 long long offset;
40 long long __pad3;
41 unsigned flags;
42 unsigned resfd;
43 };
45 static inline void __io_set_eventfd(struct iocb *iocb, int eventfd)
46 {
47 struct __compat_io_iocb_common *c;
48 c = (struct __compat_io_iocb_common*)&iocb->u.c;
49 c->flags |= (1 << 0);
50 c->resfd = eventfd;
51 }
53 #ifndef SYS_eventfd
54 #ifndef __NR_eventfd
55 # if defined(__alpha__)
56 # define __NR_eventfd 478
57 # elif defined(__arm__)
58 # define __NR_eventfd (__NR_SYSCALL_BASE+351)
59 # elif defined(__ia64__)
60 # define __NR_eventfd 1309
61 # elif defined(__i386__)
62 # define __NR_eventfd 323
63 # elif defined(__m68k__)
64 # define __NR_eventfd 319
65 # elif 0 && defined(__mips__)
66 # error __NR_eventfd?
67 # define __NR_eventfd (__NR_Linux + 319)
68 # define __NR_eventfd (__NR_Linux + 278)
69 # define __NR_eventfd (__NR_Linux + 282)
70 # elif defined(__hppa__)
71 # define __NR_eventfd (__NR_Linux + 304)
72 # elif defined(__PPC__) || defined(__powerpc64__)
73 # define __NR_eventfd 307
74 # elif defined(__s390__) || defined(__s390x__)
75 # define __NR_eventfd 318
76 # elif defined(__sparc__)
77 # define __NR_eventfd 313
78 # elif defined(__x86_64__)
79 # define __NR_eventfd 284
80 # endif
81 #else
82 # error __NR_eventfd?
83 #endif
84 #define SYS_eventfd __NR_eventfd
85 #endif
87 static inline int tapdisk_sys_eventfd(int initval)
88 {
89 return syscall(SYS_eventfd, initval, 0);
90 }
92 #endif /* __LIBAIO_COMPAT */