1 /* Test for notification mechanism in lio_listio.
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, see
17 <http://www.gnu.org/licenses/>. */
26 static pthread_barrier_t b;
32 int e = pthread_barrier_wait (&b);
33 if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
35 puts ("child: barrier_wait failed");
42 do_test (int argc, char *argv[])
44 char name[] = "/tmp/aio3.XXXXXX";
48 static const char buf[] = "Hello World\n";
53 printf ("cannot open temp name: %m\n");
59 if (pthread_barrier_init (&b, NULL, 2) != 0)
61 puts ("barrier_init failed");
68 cb.aio_lio_opcode = LIO_WRITE;
70 cb.aio_buf = (void *) buf;
71 cb.aio_nbytes = sizeof (buf) - 1;
73 cb.aio_sigevent.sigev_notify = SIGEV_THREAD;
74 cb.aio_sigevent.sigev_notify_function = thrfct;
75 cb.aio_sigevent.sigev_notify_attributes = NULL;
76 cb.aio_sigevent.sigev_value.sival_ptr = NULL;
78 if (lio_listio (LIO_NOWAIT, arr, 1, NULL) < 0)
82 puts ("no aio support in this configuration");
85 printf ("lio_listio failed: %m\n");
89 if (aio_suspend ((const struct aiocb *const *) arr, 1, NULL) < 0)
91 printf ("aio_suspend failed: %m\n");
95 int e = pthread_barrier_wait (&b);
96 if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
98 puts ("parent: barrier_wait failed");
107 #include "../test-skeleton.c"