xref: /aosp_15_r20/external/strace/tests-m32/aio.c (revision cf84ac9a129d8ea9952db616b4e9b904c4bdde56)
1*cf84ac9aSAndroid Build Coastguard Worker /*
2*cf84ac9aSAndroid Build Coastguard Worker  * Copyright (c) 2015-2016 Dmitry V. Levin <[email protected]>
3*cf84ac9aSAndroid Build Coastguard Worker  * Copyright (c) 2015-2018 The strace developers.
4*cf84ac9aSAndroid Build Coastguard Worker  * All rights reserved.
5*cf84ac9aSAndroid Build Coastguard Worker  *
6*cf84ac9aSAndroid Build Coastguard Worker  * Redistribution and use in source and binary forms, with or without
7*cf84ac9aSAndroid Build Coastguard Worker  * modification, are permitted provided that the following conditions
8*cf84ac9aSAndroid Build Coastguard Worker  * are met:
9*cf84ac9aSAndroid Build Coastguard Worker  * 1. Redistributions of source code must retain the above copyright
10*cf84ac9aSAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer.
11*cf84ac9aSAndroid Build Coastguard Worker  * 2. Redistributions in binary form must reproduce the above copyright
12*cf84ac9aSAndroid Build Coastguard Worker  *    notice, this list of conditions and the following disclaimer in the
13*cf84ac9aSAndroid Build Coastguard Worker  *    documentation and/or other materials provided with the distribution.
14*cf84ac9aSAndroid Build Coastguard Worker  * 3. The name of the author may not be used to endorse or promote products
15*cf84ac9aSAndroid Build Coastguard Worker  *    derived from this software without specific prior written permission.
16*cf84ac9aSAndroid Build Coastguard Worker  *
17*cf84ac9aSAndroid Build Coastguard Worker  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18*cf84ac9aSAndroid Build Coastguard Worker  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19*cf84ac9aSAndroid Build Coastguard Worker  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20*cf84ac9aSAndroid Build Coastguard Worker  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21*cf84ac9aSAndroid Build Coastguard Worker  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22*cf84ac9aSAndroid Build Coastguard Worker  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23*cf84ac9aSAndroid Build Coastguard Worker  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24*cf84ac9aSAndroid Build Coastguard Worker  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25*cf84ac9aSAndroid Build Coastguard Worker  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26*cf84ac9aSAndroid Build Coastguard Worker  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*cf84ac9aSAndroid Build Coastguard Worker  */
28*cf84ac9aSAndroid Build Coastguard Worker 
29*cf84ac9aSAndroid Build Coastguard Worker #include "tests.h"
30*cf84ac9aSAndroid Build Coastguard Worker #include <fcntl.h>
31*cf84ac9aSAndroid Build Coastguard Worker #include <inttypes.h>
32*cf84ac9aSAndroid Build Coastguard Worker #include <stdio.h>
33*cf84ac9aSAndroid Build Coastguard Worker #include <time.h>
34*cf84ac9aSAndroid Build Coastguard Worker #include <unistd.h>
35*cf84ac9aSAndroid Build Coastguard Worker #include <asm/unistd.h>
36*cf84ac9aSAndroid Build Coastguard Worker 
37*cf84ac9aSAndroid Build Coastguard Worker #if defined __NR_io_setup \
38*cf84ac9aSAndroid Build Coastguard Worker  && defined __NR_io_submit \
39*cf84ac9aSAndroid Build Coastguard Worker  && defined __NR_io_getevents \
40*cf84ac9aSAndroid Build Coastguard Worker  && defined __NR_io_cancel \
41*cf84ac9aSAndroid Build Coastguard Worker  && defined __NR_io_destroy
42*cf84ac9aSAndroid Build Coastguard Worker # include <linux/aio_abi.h>
43*cf84ac9aSAndroid Build Coastguard Worker 
44*cf84ac9aSAndroid Build Coastguard Worker int
main(void)45*cf84ac9aSAndroid Build Coastguard Worker main(void)
46*cf84ac9aSAndroid Build Coastguard Worker {
47*cf84ac9aSAndroid Build Coastguard Worker 	static const long bogus_ctx =
48*cf84ac9aSAndroid Build Coastguard Worker 		(long) 0xface1e55deadbeefLL;
49*cf84ac9aSAndroid Build Coastguard Worker 
50*cf84ac9aSAndroid Build Coastguard Worker 	static const char data2[] =
51*cf84ac9aSAndroid Build Coastguard Worker 		"\0\1\2\3cat test test test 0123456789abcdef";
52*cf84ac9aSAndroid Build Coastguard Worker 
53*cf84ac9aSAndroid Build Coastguard Worker 	const unsigned int sizeof_data0 = 4096;
54*cf84ac9aSAndroid Build Coastguard Worker 	const unsigned int sizeof_data1 = 8192;
55*cf84ac9aSAndroid Build Coastguard Worker 	void *data0 = tail_alloc(sizeof_data0);
56*cf84ac9aSAndroid Build Coastguard Worker 	void *data1 = tail_alloc(sizeof_data1);
57*cf84ac9aSAndroid Build Coastguard Worker 
58*cf84ac9aSAndroid Build Coastguard Worker 	const struct iocb proto_cb[] = {
59*cf84ac9aSAndroid Build Coastguard Worker 		{
60*cf84ac9aSAndroid Build Coastguard Worker 			.aio_data = (unsigned long) 0xfeedface11111111ULL,
61*cf84ac9aSAndroid Build Coastguard Worker 			.aio_reqprio = 11,
62*cf84ac9aSAndroid Build Coastguard Worker 			.aio_buf = (unsigned long) data0,
63*cf84ac9aSAndroid Build Coastguard Worker 			.aio_offset = (unsigned long) 0xdeface1facefeedULL,
64*cf84ac9aSAndroid Build Coastguard Worker 			.aio_nbytes = sizeof_data0
65*cf84ac9aSAndroid Build Coastguard Worker 		},
66*cf84ac9aSAndroid Build Coastguard Worker 		{
67*cf84ac9aSAndroid Build Coastguard Worker 			.aio_data = (unsigned long) 0xfeedface22222222ULL,
68*cf84ac9aSAndroid Build Coastguard Worker 			.aio_reqprio = 22,
69*cf84ac9aSAndroid Build Coastguard Worker 			.aio_buf = (unsigned long) data1,
70*cf84ac9aSAndroid Build Coastguard Worker 			.aio_offset = (unsigned long) 0xdeface2cafef00dULL,
71*cf84ac9aSAndroid Build Coastguard Worker 			.aio_nbytes = sizeof_data1
72*cf84ac9aSAndroid Build Coastguard Worker 		}
73*cf84ac9aSAndroid Build Coastguard Worker 	};
74*cf84ac9aSAndroid Build Coastguard Worker 	const struct iocb *cb = tail_memdup(proto_cb, sizeof(proto_cb));
75*cf84ac9aSAndroid Build Coastguard Worker 
76*cf84ac9aSAndroid Build Coastguard Worker 	const struct iovec proto_iov0[] = {
77*cf84ac9aSAndroid Build Coastguard Worker 		{
78*cf84ac9aSAndroid Build Coastguard Worker 			.iov_base = data0,
79*cf84ac9aSAndroid Build Coastguard Worker 			.iov_len = sizeof_data0 / 4
80*cf84ac9aSAndroid Build Coastguard Worker 		},
81*cf84ac9aSAndroid Build Coastguard Worker 		{
82*cf84ac9aSAndroid Build Coastguard Worker 			.iov_base = data0 + sizeof_data0 / 4,
83*cf84ac9aSAndroid Build Coastguard Worker 			.iov_len = sizeof_data0 / 4 * 3
84*cf84ac9aSAndroid Build Coastguard Worker 		},
85*cf84ac9aSAndroid Build Coastguard Worker 	};
86*cf84ac9aSAndroid Build Coastguard Worker 	const struct iovec *iov0 = tail_memdup(proto_iov0, sizeof(proto_iov0));
87*cf84ac9aSAndroid Build Coastguard Worker 
88*cf84ac9aSAndroid Build Coastguard Worker 	const struct iovec proto_iov1[] = {
89*cf84ac9aSAndroid Build Coastguard Worker 		{
90*cf84ac9aSAndroid Build Coastguard Worker 			.iov_base = data1,
91*cf84ac9aSAndroid Build Coastguard Worker 			.iov_len = sizeof_data1 / 4
92*cf84ac9aSAndroid Build Coastguard Worker 		},
93*cf84ac9aSAndroid Build Coastguard Worker 		{
94*cf84ac9aSAndroid Build Coastguard Worker 			.iov_base = data1 + sizeof_data1 / 4,
95*cf84ac9aSAndroid Build Coastguard Worker 			.iov_len = sizeof_data1 / 4 * 3
96*cf84ac9aSAndroid Build Coastguard Worker 		},
97*cf84ac9aSAndroid Build Coastguard Worker 	};
98*cf84ac9aSAndroid Build Coastguard Worker 	const struct iovec *iov1 = tail_memdup(proto_iov1, sizeof(proto_iov1));
99*cf84ac9aSAndroid Build Coastguard Worker 
100*cf84ac9aSAndroid Build Coastguard Worker 	const struct iocb proto_cbv[] = {
101*cf84ac9aSAndroid Build Coastguard Worker 		{
102*cf84ac9aSAndroid Build Coastguard Worker 			.aio_data = (unsigned long) 0xfeed11111111faceULL,
103*cf84ac9aSAndroid Build Coastguard Worker 			.aio_lio_opcode = 7,
104*cf84ac9aSAndroid Build Coastguard Worker 			.aio_reqprio = 111,
105*cf84ac9aSAndroid Build Coastguard Worker 			.aio_buf = (unsigned long) iov0,
106*cf84ac9aSAndroid Build Coastguard Worker 			.aio_offset = (unsigned long) 0xdeface1facefeedULL,
107*cf84ac9aSAndroid Build Coastguard Worker 			.aio_nbytes = ARRAY_SIZE(proto_iov0)
108*cf84ac9aSAndroid Build Coastguard Worker 		},
109*cf84ac9aSAndroid Build Coastguard Worker 		{
110*cf84ac9aSAndroid Build Coastguard Worker 			.aio_data = (unsigned long) 0xfeed22222222faceULL,
111*cf84ac9aSAndroid Build Coastguard Worker 			.aio_lio_opcode = 7,
112*cf84ac9aSAndroid Build Coastguard Worker 			.aio_reqprio = 222,
113*cf84ac9aSAndroid Build Coastguard Worker 			.aio_buf = (unsigned long) iov1,
114*cf84ac9aSAndroid Build Coastguard Worker 			.aio_offset = (unsigned long) 0xdeface2cafef00dULL,
115*cf84ac9aSAndroid Build Coastguard Worker 			.aio_nbytes = ARRAY_SIZE(proto_iov1)
116*cf84ac9aSAndroid Build Coastguard Worker 		}
117*cf84ac9aSAndroid Build Coastguard Worker 	};
118*cf84ac9aSAndroid Build Coastguard Worker 	const struct iocb *cbv = tail_memdup(proto_cbv, sizeof(proto_cbv));
119*cf84ac9aSAndroid Build Coastguard Worker 
120*cf84ac9aSAndroid Build Coastguard Worker 	/* For additional decoder testing */
121*cf84ac9aSAndroid Build Coastguard Worker 	const struct iocb proto_cbv2[] = {
122*cf84ac9aSAndroid Build Coastguard Worker 		{
123*cf84ac9aSAndroid Build Coastguard Worker 			.aio_data = 0xbadfacedc0ffeeedULL,
124*cf84ac9aSAndroid Build Coastguard Worker 			.aio_key = 0xdefaced0,
125*cf84ac9aSAndroid Build Coastguard Worker 			.aio_lio_opcode = 0xf00d,
126*cf84ac9aSAndroid Build Coastguard Worker 			.aio_reqprio = 0,
127*cf84ac9aSAndroid Build Coastguard Worker 			.aio_fildes = 0xdefaced1,
128*cf84ac9aSAndroid Build Coastguard Worker 			.aio_buf = 0,
129*cf84ac9aSAndroid Build Coastguard Worker 		},
130*cf84ac9aSAndroid Build Coastguard Worker 		{
131*cf84ac9aSAndroid Build Coastguard Worker 			.aio_data = 0,
132*cf84ac9aSAndroid Build Coastguard Worker 			.aio_key = 0xdefaced0,
133*cf84ac9aSAndroid Build Coastguard Worker 			.aio_lio_opcode = 1,
134*cf84ac9aSAndroid Build Coastguard Worker 			.aio_reqprio = 0xbeef,
135*cf84ac9aSAndroid Build Coastguard Worker 			.aio_fildes = 0xdefaced1,
136*cf84ac9aSAndroid Build Coastguard Worker 			.aio_buf = 0,
137*cf84ac9aSAndroid Build Coastguard Worker 			/* In order to make record valid */
138*cf84ac9aSAndroid Build Coastguard Worker 			.aio_nbytes = (size_t) 0x1020304050607080ULL,
139*cf84ac9aSAndroid Build Coastguard Worker 			.aio_offset = 0xdeadda7abadc0dedULL,
140*cf84ac9aSAndroid Build Coastguard Worker # ifdef IOCB_FLAG_RESFD
141*cf84ac9aSAndroid Build Coastguard Worker 			.aio_flags = 0xfacef157,
142*cf84ac9aSAndroid Build Coastguard Worker 			.aio_resfd = 0xded1ca7e,
143*cf84ac9aSAndroid Build Coastguard Worker # endif
144*cf84ac9aSAndroid Build Coastguard Worker 		},
145*cf84ac9aSAndroid Build Coastguard Worker 		{
146*cf84ac9aSAndroid Build Coastguard Worker 			.aio_data = 0,
147*cf84ac9aSAndroid Build Coastguard Worker 			.aio_key = 0xdefaced0,
148*cf84ac9aSAndroid Build Coastguard Worker 			.aio_lio_opcode = 1,
149*cf84ac9aSAndroid Build Coastguard Worker 			.aio_reqprio = 0xbeef,
150*cf84ac9aSAndroid Build Coastguard Worker 			.aio_fildes = 0xdefaced1,
151*cf84ac9aSAndroid Build Coastguard Worker 			.aio_buf = 0xbadc0ffeedefacedULL,
152*cf84ac9aSAndroid Build Coastguard Worker 			.aio_nbytes = 0x8090a0b0c0d0e0f0ULL,
153*cf84ac9aSAndroid Build Coastguard Worker 			.aio_offset = 0xdeadda7abadc0dedULL,
154*cf84ac9aSAndroid Build Coastguard Worker 		},
155*cf84ac9aSAndroid Build Coastguard Worker 		{
156*cf84ac9aSAndroid Build Coastguard Worker 			.aio_data = 0,
157*cf84ac9aSAndroid Build Coastguard Worker 			.aio_key = 0xdefaced0,
158*cf84ac9aSAndroid Build Coastguard Worker 			.aio_lio_opcode = 1,
159*cf84ac9aSAndroid Build Coastguard Worker 			.aio_reqprio = 0xbeef,
160*cf84ac9aSAndroid Build Coastguard Worker 			.aio_fildes = 0xdefaced1,
161*cf84ac9aSAndroid Build Coastguard Worker 			.aio_buf = (unsigned long)data2,
162*cf84ac9aSAndroid Build Coastguard Worker 			.aio_nbytes = sizeof(data2),
163*cf84ac9aSAndroid Build Coastguard Worker 			.aio_offset = 0xdeadda7abadc0dedULL,
164*cf84ac9aSAndroid Build Coastguard Worker 		},
165*cf84ac9aSAndroid Build Coastguard Worker 		{
166*cf84ac9aSAndroid Build Coastguard Worker 			.aio_data = 0,
167*cf84ac9aSAndroid Build Coastguard Worker 			.aio_key = 0xdefaced0,
168*cf84ac9aSAndroid Build Coastguard Worker 			.aio_lio_opcode = 8,
169*cf84ac9aSAndroid Build Coastguard Worker 			.aio_reqprio = 0xbeef,
170*cf84ac9aSAndroid Build Coastguard Worker 			.aio_fildes = 0xdefaced1,
171*cf84ac9aSAndroid Build Coastguard Worker 			.aio_buf = 0,
172*cf84ac9aSAndroid Build Coastguard Worker 			.aio_nbytes = 0x8090a0b0c0d0e0f0ULL,
173*cf84ac9aSAndroid Build Coastguard Worker 			.aio_offset = 0xdeadda7abadc0dedULL,
174*cf84ac9aSAndroid Build Coastguard Worker 		},
175*cf84ac9aSAndroid Build Coastguard Worker 	};
176*cf84ac9aSAndroid Build Coastguard Worker 	const struct iocb *cbv2 = tail_memdup(proto_cbv2, sizeof(proto_cbv2));
177*cf84ac9aSAndroid Build Coastguard Worker 
178*cf84ac9aSAndroid Build Coastguard Worker 	const struct iocb proto_cbc = {
179*cf84ac9aSAndroid Build Coastguard Worker 		.aio_data = (unsigned long) 0xdeadbeefbadc0dedULL,
180*cf84ac9aSAndroid Build Coastguard Worker 		.aio_reqprio = 99,
181*cf84ac9aSAndroid Build Coastguard Worker 		.aio_fildes = -42
182*cf84ac9aSAndroid Build Coastguard Worker 	};
183*cf84ac9aSAndroid Build Coastguard Worker 	const struct iocb *cbc = tail_memdup(&proto_cbc, sizeof(proto_cbc));
184*cf84ac9aSAndroid Build Coastguard Worker 
185*cf84ac9aSAndroid Build Coastguard Worker 	const long proto_cbs[] = {
186*cf84ac9aSAndroid Build Coastguard Worker 		(long) &cb[0], (long) &cb[1]
187*cf84ac9aSAndroid Build Coastguard Worker 	};
188*cf84ac9aSAndroid Build Coastguard Worker 	const long *cbs = tail_memdup(proto_cbs, sizeof(proto_cbs));
189*cf84ac9aSAndroid Build Coastguard Worker 
190*cf84ac9aSAndroid Build Coastguard Worker 	const long proto_cbvs[] = {
191*cf84ac9aSAndroid Build Coastguard Worker 		(long) &cbv[0], (long) &cbv[1],
192*cf84ac9aSAndroid Build Coastguard Worker 	};
193*cf84ac9aSAndroid Build Coastguard Worker 	const long *cbvs = tail_memdup(proto_cbvs, sizeof(proto_cbvs));
194*cf84ac9aSAndroid Build Coastguard Worker 
195*cf84ac9aSAndroid Build Coastguard Worker 	const long proto_cbvs2[] = {
196*cf84ac9aSAndroid Build Coastguard Worker 		(long) &cbv2[0], (long) &cbv2[1], (long) &cbv2[2],
197*cf84ac9aSAndroid Build Coastguard Worker 		(long) &cbv2[3], (long) &cbv2[4],
198*cf84ac9aSAndroid Build Coastguard Worker 		(long) NULL, (long) 0xffffffffffffffffLL,
199*cf84ac9aSAndroid Build Coastguard Worker 	};
200*cf84ac9aSAndroid Build Coastguard Worker 	const long *cbvs2 = tail_memdup(proto_cbvs2, sizeof(proto_cbvs2));
201*cf84ac9aSAndroid Build Coastguard Worker 
202*cf84ac9aSAndroid Build Coastguard Worker 	TAIL_ALLOC_OBJECT_CONST_PTR(unsigned long, ctx);
203*cf84ac9aSAndroid Build Coastguard Worker 	*ctx = 0;
204*cf84ac9aSAndroid Build Coastguard Worker 
205*cf84ac9aSAndroid Build Coastguard Worker 	const unsigned int nr = ARRAY_SIZE(proto_cb);
206*cf84ac9aSAndroid Build Coastguard Worker 	const unsigned long lnr = (unsigned long) (0xdeadbeef00000000ULL | nr);
207*cf84ac9aSAndroid Build Coastguard Worker 
208*cf84ac9aSAndroid Build Coastguard Worker 	const struct io_event *ev = tail_alloc(nr * sizeof(struct io_event));
209*cf84ac9aSAndroid Build Coastguard Worker 	TAIL_ALLOC_OBJECT_CONST_PTR(struct timespec, ts);
210*cf84ac9aSAndroid Build Coastguard Worker 
211*cf84ac9aSAndroid Build Coastguard Worker 	(void) close(0);
212*cf84ac9aSAndroid Build Coastguard Worker 	if (open("/dev/zero", O_RDONLY))
213*cf84ac9aSAndroid Build Coastguard Worker 		perror_msg_and_skip("open: %s", "/dev/zero");
214*cf84ac9aSAndroid Build Coastguard Worker 
215*cf84ac9aSAndroid Build Coastguard Worker 	long rc = syscall(__NR_io_setup, 0xdeadbeef, NULL);
216*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_setup(%u, NULL) = %s\n", 0xdeadbeef, sprintrc(rc));
217*cf84ac9aSAndroid Build Coastguard Worker 
218*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_setup, lnr, ctx + 1);
219*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_setup(%u, %p) = %s\n", nr, ctx + 1, sprintrc(rc));
220*cf84ac9aSAndroid Build Coastguard Worker 
221*cf84ac9aSAndroid Build Coastguard Worker 	if (syscall(__NR_io_setup, lnr, ctx))
222*cf84ac9aSAndroid Build Coastguard Worker 		perror_msg_and_skip("io_setup");
223*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_setup(%u, [%#lx]) = 0\n", nr, *ctx);
224*cf84ac9aSAndroid Build Coastguard Worker 
225*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_submit, bogus_ctx, (long) 0xca7faceddeadf00dLL,
226*cf84ac9aSAndroid Build Coastguard Worker 		     NULL);
227*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_submit(%#lx, %ld, NULL) = %s\n",
228*cf84ac9aSAndroid Build Coastguard Worker 	       bogus_ctx, (long) 0xca7faceddeadf00dLL, sprintrc(rc));
229*cf84ac9aSAndroid Build Coastguard Worker 
230*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_submit, *ctx, nr, cbs + nr);
231*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_submit(%#lx, %ld, %p) = %s\n",
232*cf84ac9aSAndroid Build Coastguard Worker 	       *ctx, (long) nr, cbs + nr, sprintrc(rc));
233*cf84ac9aSAndroid Build Coastguard Worker 
234*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_submit, *ctx, -1L, cbs);
235*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_submit(%#lx, -1, %p) = %s\n",
236*cf84ac9aSAndroid Build Coastguard Worker 	       *ctx, cbs, sprintrc(rc));
237*cf84ac9aSAndroid Build Coastguard Worker 
238*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_submit, *ctx, nr, cbs);
239*cf84ac9aSAndroid Build Coastguard Worker 	if (rc != (long) nr)
240*cf84ac9aSAndroid Build Coastguard Worker 		perror_msg_and_skip("io_submit");
241*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_submit(%#lx, %u, ["
242*cf84ac9aSAndroid Build Coastguard Worker 	       "{aio_data=%#" PRI__x64 ", aio_lio_opcode=IOCB_CMD_PREAD"
243*cf84ac9aSAndroid Build Coastguard Worker 		", aio_reqprio=11, aio_fildes=0, aio_buf=%p, aio_nbytes=%u"
244*cf84ac9aSAndroid Build Coastguard Worker 		", aio_offset=%" PRI__d64
245*cf84ac9aSAndroid Build Coastguard Worker 	       "}, {aio_data=%#" PRI__x64 ", aio_lio_opcode=IOCB_CMD_PREAD"
246*cf84ac9aSAndroid Build Coastguard Worker 		", aio_reqprio=22, aio_fildes=0, aio_buf=%p, aio_nbytes=%u"
247*cf84ac9aSAndroid Build Coastguard Worker 		", aio_offset=%" PRI__d64 "}]) = %s\n",
248*cf84ac9aSAndroid Build Coastguard Worker 	       *ctx, nr,
249*cf84ac9aSAndroid Build Coastguard Worker 	       cb[0].aio_data, data0, sizeof_data0, cb[0].aio_offset,
250*cf84ac9aSAndroid Build Coastguard Worker 	       cb[1].aio_data, data1, sizeof_data1, cb[1].aio_offset,
251*cf84ac9aSAndroid Build Coastguard Worker 	       sprintrc(rc));
252*cf84ac9aSAndroid Build Coastguard Worker 
253*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_getevents, bogus_ctx,
254*cf84ac9aSAndroid Build Coastguard Worker 		     (long) 0xca7faceddeadf00dLL, (long) 0xba5e1e505ca571e0LL,
255*cf84ac9aSAndroid Build Coastguard Worker 		     ev + 1, NULL);
256*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_getevents(%#lx, %ld, %ld, %p, NULL) = %s\n",
257*cf84ac9aSAndroid Build Coastguard Worker 	       bogus_ctx, (long) 0xca7faceddeadf00dLL,
258*cf84ac9aSAndroid Build Coastguard Worker 	       (long) 0xba5e1e505ca571e0LL, ev + 1, sprintrc(rc));
259*cf84ac9aSAndroid Build Coastguard Worker 
260*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_getevents, bogus_ctx,
261*cf84ac9aSAndroid Build Coastguard Worker 		     (long) 0xca7faceddeadf00dLL, (long) 0xba5e1e505ca571e0LL,
262*cf84ac9aSAndroid Build Coastguard Worker 		     NULL, ts + 1);
263*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_getevents(%#lx, %ld, %ld, NULL, %p) = %s\n",
264*cf84ac9aSAndroid Build Coastguard Worker 	       bogus_ctx, (long) 0xca7faceddeadf00dLL,
265*cf84ac9aSAndroid Build Coastguard Worker 	       (long) 0xba5e1e505ca571e0LL, ts + 1, sprintrc(rc));
266*cf84ac9aSAndroid Build Coastguard Worker 
267*cf84ac9aSAndroid Build Coastguard Worker 	ts->tv_sec = 0xdeadbeefU;
268*cf84ac9aSAndroid Build Coastguard Worker 	ts->tv_nsec = 0xfacefeedU;
269*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_getevents, bogus_ctx, 0, 0, 0, ts);
270*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_getevents(%#lx, 0, 0, NULL"
271*cf84ac9aSAndroid Build Coastguard Worker 	       ", {tv_sec=%lld, tv_nsec=%llu}) = %s\n",
272*cf84ac9aSAndroid Build Coastguard Worker 	       bogus_ctx, (long long) ts->tv_sec,
273*cf84ac9aSAndroid Build Coastguard Worker 	       zero_extend_signed_to_ull(ts->tv_nsec), sprintrc(rc));
274*cf84ac9aSAndroid Build Coastguard Worker 
275*cf84ac9aSAndroid Build Coastguard Worker 	ts->tv_sec = (time_t) 0xcafef00ddeadbeefLL;
276*cf84ac9aSAndroid Build Coastguard Worker 	ts->tv_nsec = (long) 0xbadc0dedfacefeedLL;
277*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_getevents, bogus_ctx, 0, 0, 0, ts);
278*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_getevents(%#lx, 0, 0, NULL"
279*cf84ac9aSAndroid Build Coastguard Worker 	       ", {tv_sec=%lld, tv_nsec=%llu}) = %s\n",
280*cf84ac9aSAndroid Build Coastguard Worker 	       bogus_ctx, (long long) ts->tv_sec,
281*cf84ac9aSAndroid Build Coastguard Worker 	       zero_extend_signed_to_ull(ts->tv_nsec), sprintrc(rc));
282*cf84ac9aSAndroid Build Coastguard Worker 
283*cf84ac9aSAndroid Build Coastguard Worker 	ts->tv_sec = 0;
284*cf84ac9aSAndroid Build Coastguard Worker 	ts->tv_nsec = 123456789;
285*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_getevents, *ctx, nr, nr + 1, ev, ts);
286*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_getevents(%#lx, %ld, %ld, ["
287*cf84ac9aSAndroid Build Coastguard Worker 	       "{data=%#" PRI__x64 ", obj=%p, res=%u, res2=0}, "
288*cf84ac9aSAndroid Build Coastguard Worker 	       "{data=%#" PRI__x64 ", obj=%p, res=%u, res2=0}"
289*cf84ac9aSAndroid Build Coastguard Worker 	       "], {tv_sec=0, tv_nsec=123456789}) = %s\n",
290*cf84ac9aSAndroid Build Coastguard Worker 	       *ctx, (long) nr, (long) (nr + 1),
291*cf84ac9aSAndroid Build Coastguard Worker 	       cb[0].aio_data, &cb[0], sizeof_data0,
292*cf84ac9aSAndroid Build Coastguard Worker 	       cb[1].aio_data, &cb[1], sizeof_data1,
293*cf84ac9aSAndroid Build Coastguard Worker 	       sprintrc(rc));
294*cf84ac9aSAndroid Build Coastguard Worker 
295*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_cancel, bogus_ctx, NULL, NULL);
296*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_cancel(%#lx, NULL, NULL) = %s\n", bogus_ctx, sprintrc(rc));
297*cf84ac9aSAndroid Build Coastguard Worker 
298*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_cancel, *ctx, cbc + 1, ev);
299*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_cancel(%#lx, %p, %p) = %s\n", *ctx, cbc + 1, ev,
300*cf84ac9aSAndroid Build Coastguard Worker 	       sprintrc(rc));
301*cf84ac9aSAndroid Build Coastguard Worker 
302*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_cancel, *ctx, cbc, ev);
303*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_cancel(%#lx, {aio_data=%#" PRI__x64
304*cf84ac9aSAndroid Build Coastguard Worker 		", aio_lio_opcode=IOCB_CMD_PREAD, aio_reqprio=99"
305*cf84ac9aSAndroid Build Coastguard Worker 		", aio_fildes=-42}, %p) = %s\n",
306*cf84ac9aSAndroid Build Coastguard Worker 	       *ctx, cbc->aio_data, ev, sprintrc(rc));
307*cf84ac9aSAndroid Build Coastguard Worker 
308*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_submit, (unsigned long) 0xfacef157beeff00dULL,
309*cf84ac9aSAndroid Build Coastguard Worker 		     (long) 0xdeadc0defacefeedLL, NULL);
310*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_submit(%#lx, %ld, NULL) = %s\n",
311*cf84ac9aSAndroid Build Coastguard Worker 	       (long) 0xfacef157beeff00dULL,
312*cf84ac9aSAndroid Build Coastguard Worker 	       (long) 0xdeadc0defacefeedLL, sprintrc(rc));
313*cf84ac9aSAndroid Build Coastguard Worker 
314*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_submit, *ctx, -1L, cbvs + nr);
315*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_submit(%#lx, %ld, %p) = %s\n",
316*cf84ac9aSAndroid Build Coastguard Worker 	       *ctx, -1L, cbvs + nr, sprintrc(rc));
317*cf84ac9aSAndroid Build Coastguard Worker 
318*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_submit(%#lx, %ld, ["
319*cf84ac9aSAndroid Build Coastguard Worker 	       "{aio_data=%#" PRI__x64 ", aio_key=%u"
320*cf84ac9aSAndroid Build Coastguard Worker 		", aio_lio_opcode=%hu /* IOCB_CMD_??? */, aio_fildes=%d}"
321*cf84ac9aSAndroid Build Coastguard Worker 		", {aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE, aio_reqprio=%hd"
322*cf84ac9aSAndroid Build Coastguard Worker 		", aio_fildes=%d, aio_buf=NULL"
323*cf84ac9aSAndroid Build Coastguard Worker 		", aio_nbytes=%" PRI__u64 ", aio_offset=%" PRI__d64
324*cf84ac9aSAndroid Build Coastguard Worker # ifdef IOCB_FLAG_RESFD
325*cf84ac9aSAndroid Build Coastguard Worker 		", aio_resfd=%d, aio_flags=%#x"
326*cf84ac9aSAndroid Build Coastguard Worker # endif
327*cf84ac9aSAndroid Build Coastguard Worker 	       "}, {aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE"
328*cf84ac9aSAndroid Build Coastguard Worker 		", aio_reqprio=%hd, aio_fildes=%d, aio_buf=%#" PRI__x64
329*cf84ac9aSAndroid Build Coastguard Worker 		", aio_nbytes=%" PRI__u64 ", aio_offset=%" PRI__d64
330*cf84ac9aSAndroid Build Coastguard Worker 	       "}, {aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE"
331*cf84ac9aSAndroid Build Coastguard Worker 		", aio_reqprio=%hd, aio_fildes=%d"
332*cf84ac9aSAndroid Build Coastguard Worker 		", aio_buf=\"\\0\\1\\2\\3%.28s\"..."
333*cf84ac9aSAndroid Build Coastguard Worker 		", aio_nbytes=%" PRI__u64 ", aio_offset=%" PRI__d64
334*cf84ac9aSAndroid Build Coastguard Worker 	       "}, {aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITEV"
335*cf84ac9aSAndroid Build Coastguard Worker 		", aio_reqprio=%hd, aio_fildes=%d, aio_buf=%#" PRI__x64
336*cf84ac9aSAndroid Build Coastguard Worker 		", aio_nbytes=%" PRI__u64 ", aio_offset=%" PRI__d64
337*cf84ac9aSAndroid Build Coastguard Worker 	       "}, NULL, %#lx, ... /* %p */]) = ",
338*cf84ac9aSAndroid Build Coastguard Worker 	       *ctx, 1057L,
339*cf84ac9aSAndroid Build Coastguard Worker 	       cbv2[0].aio_data, cbv2[0].aio_key,
340*cf84ac9aSAndroid Build Coastguard Worker 	       cbv2[0].aio_lio_opcode, cbv2[0].aio_fildes,
341*cf84ac9aSAndroid Build Coastguard Worker 	       cbv2[1].aio_key, cbv2[1].aio_reqprio, cbv2[1].aio_fildes,
342*cf84ac9aSAndroid Build Coastguard Worker 	       cbv2[1].aio_nbytes, cbv2[1].aio_offset,
343*cf84ac9aSAndroid Build Coastguard Worker # ifdef IOCB_FLAG_RESFD
344*cf84ac9aSAndroid Build Coastguard Worker 	       cbv2[1].aio_resfd, cbv2[1].aio_flags,
345*cf84ac9aSAndroid Build Coastguard Worker # endif
346*cf84ac9aSAndroid Build Coastguard Worker 	       cbv2[2].aio_key, cbv2[2].aio_reqprio, cbv2[2].aio_fildes,
347*cf84ac9aSAndroid Build Coastguard Worker 	       cbv2[2].aio_buf, cbv2[2].aio_nbytes, cbv2[2].aio_offset,
348*cf84ac9aSAndroid Build Coastguard Worker 	       cbv2[3].aio_key, cbv2[3].aio_reqprio, cbv2[3].aio_fildes,
349*cf84ac9aSAndroid Build Coastguard Worker 	       data2 + 4, cbv2[3].aio_nbytes, cbv2[3].aio_offset,
350*cf84ac9aSAndroid Build Coastguard Worker 	       cbv2[4].aio_key, cbv2[4].aio_reqprio, cbv2[4].aio_fildes,
351*cf84ac9aSAndroid Build Coastguard Worker 	       cbv2[4].aio_buf, cbv2[4].aio_nbytes, cbv2[4].aio_offset,
352*cf84ac9aSAndroid Build Coastguard Worker 	       cbvs2[6], cbvs2 + 7);
353*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_submit, *ctx, 1057L, cbvs2);
354*cf84ac9aSAndroid Build Coastguard Worker 	puts(sprintrc(rc));
355*cf84ac9aSAndroid Build Coastguard Worker 
356*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_submit, *ctx, nr, cbvs);
357*cf84ac9aSAndroid Build Coastguard Worker 	if (rc != (long) nr)
358*cf84ac9aSAndroid Build Coastguard Worker 		perror_msg_and_skip("io_submit");
359*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_submit(%#lx, %u, ["
360*cf84ac9aSAndroid Build Coastguard Worker 	       "{aio_data=%#" PRI__x64 ", aio_lio_opcode=IOCB_CMD_PREADV"
361*cf84ac9aSAndroid Build Coastguard Worker 		", aio_reqprio=%hd, aio_fildes=0, "
362*cf84ac9aSAndroid Build Coastguard Worker 		"aio_buf=[{iov_base=%p, iov_len=%u}"
363*cf84ac9aSAndroid Build Coastguard Worker 	       ", {iov_base=%p, iov_len=%u}], aio_offset=%" PRI__d64 "}, "
364*cf84ac9aSAndroid Build Coastguard Worker 	       "{aio_data=%#" PRI__x64 ", aio_lio_opcode=IOCB_CMD_PREADV"
365*cf84ac9aSAndroid Build Coastguard Worker 		", aio_reqprio=%hd, aio_fildes=0"
366*cf84ac9aSAndroid Build Coastguard Worker 		", aio_buf=[{iov_base=%p, iov_len=%u}"
367*cf84ac9aSAndroid Build Coastguard Worker 		", {iov_base=%p, iov_len=%u}], aio_offset=%" PRI__d64 "}"
368*cf84ac9aSAndroid Build Coastguard Worker 	       "]) = %s\n",
369*cf84ac9aSAndroid Build Coastguard Worker 	       *ctx, nr,
370*cf84ac9aSAndroid Build Coastguard Worker 	       cbv[0].aio_data, cbv[0].aio_reqprio,
371*cf84ac9aSAndroid Build Coastguard Worker 	       iov0[0].iov_base, (unsigned int) iov0[0].iov_len,
372*cf84ac9aSAndroid Build Coastguard Worker 	       iov0[1].iov_base, (unsigned int) iov0[1].iov_len,
373*cf84ac9aSAndroid Build Coastguard Worker 	       cbv[0].aio_offset,
374*cf84ac9aSAndroid Build Coastguard Worker 	       cbv[1].aio_data, cbv[1].aio_reqprio,
375*cf84ac9aSAndroid Build Coastguard Worker 	       iov1[0].iov_base, (unsigned int) iov1[0].iov_len,
376*cf84ac9aSAndroid Build Coastguard Worker 	       iov1[1].iov_base, (unsigned int) iov1[1].iov_len,
377*cf84ac9aSAndroid Build Coastguard Worker 	       cbv[1].aio_offset,
378*cf84ac9aSAndroid Build Coastguard Worker 	       sprintrc(rc));
379*cf84ac9aSAndroid Build Coastguard Worker 
380*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_destroy, bogus_ctx);
381*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_destroy(%#lx) = %s\n",
382*cf84ac9aSAndroid Build Coastguard Worker 	       bogus_ctx, sprintrc(rc));
383*cf84ac9aSAndroid Build Coastguard Worker 
384*cf84ac9aSAndroid Build Coastguard Worker 	rc = syscall(__NR_io_destroy, *ctx);
385*cf84ac9aSAndroid Build Coastguard Worker 	printf("io_destroy(%#lx) = %s\n", *ctx, sprintrc(rc));
386*cf84ac9aSAndroid Build Coastguard Worker 
387*cf84ac9aSAndroid Build Coastguard Worker 	puts("+++ exited with 0 +++");
388*cf84ac9aSAndroid Build Coastguard Worker 	return 0;
389*cf84ac9aSAndroid Build Coastguard Worker }
390*cf84ac9aSAndroid Build Coastguard Worker 
391*cf84ac9aSAndroid Build Coastguard Worker #else
392*cf84ac9aSAndroid Build Coastguard Worker 
393*cf84ac9aSAndroid Build Coastguard Worker SKIP_MAIN_UNDEFINED("__NR_io_*")
394*cf84ac9aSAndroid Build Coastguard Worker 
395*cf84ac9aSAndroid Build Coastguard Worker #endif
396