1 /* Test for completion thread handling.
2 Copyright (C) 2000, 2002, 2006 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C 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.1 of the License, or (at your option) any later version.
10 The GNU C 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 the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 /* We might need a bit longer timeout. */
29 #define TIMEOUT 10 /* sec */
33 volatile sig_atomic_t flag
;
53 printf ("signal handler received wrong signal, flag is %d\n", flag
);
62 do_test (int argc
, char *argv
[])
64 char name
[] = "/tmp/aio5.XXXXXX";
68 static const char buf
[] = "Hello World\n";
74 printf ("cannot open temp name: %m\n");
83 int sz
= set_o_direct (fd
);
86 int err
= posix_memalign (&p
, sz
, sz
);
90 printf ("cannot allocate memory: %m\n");
93 memcpy (p
, buf
, sizeof (buf
) - 1);
94 memset (p
+ sizeof (buf
) - 1, ' ', sz
- sizeof (buf
) + 1);
95 printf ("Using O_DIRECT with block size %d\n", sz
);
100 sz
= sizeof (buf
) - 1;
104 cb
.aio_lio_opcode
= LIO_WRITE
;
109 cb
.aio_sigevent
.sigev_notify
= SIGEV_THREAD
;
110 cb
.aio_sigevent
.sigev_notify_function
= callback
;
111 cb
.aio_sigevent
.sigev_notify_attributes
= NULL
;
112 cb
.aio_sigevent
.sigev_value
.sival_int
= MY_SIVAL
;
114 ev
.sigev_notify
= SIGEV_THREAD
;
115 ev
.sigev_notify_function
= callback
;
116 ev
.sigev_notify_attributes
= NULL
;
117 ev
.sigev_value
.sival_int
= MY_SIVAL
;
119 /* First use aio_write. */
120 if (aio_write (arr
[0]) < 0)
124 puts ("no aio support in this configuration");
127 printf ("aio_write failed: %m\n");
134 puts ("aio_write OK");
137 /* Again with lio_listio. */
138 if (lio_listio (LIO_NOWAIT
, arr
, 1, &ev
) < 0)
140 printf ("lio_listio failed: %m\n");
152 #include "../test-skeleton.c"