1 /* Test for notification mechanism in lio_listio.
2 Copyright (C) 2000-2015 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/>. */
27 static pthread_barrier_t b;
33 int e = pthread_barrier_wait (&b);
34 if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
36 puts ("child: barrier_wait failed");
43 do_test (int argc, char *argv[])
45 char name[] = "/tmp/aio3.XXXXXX";
49 static const char buf[] = "Hello World\n";
54 printf ("cannot open temp name: %m\n");
60 if (pthread_barrier_init (&b, NULL, 2) != 0)
62 puts ("barrier_init failed");
69 cb.aio_lio_opcode = LIO_WRITE;
71 cb.aio_buf = (void *) buf;
72 cb.aio_nbytes = sizeof (buf) - 1;
74 cb.aio_sigevent.sigev_notify = SIGEV_THREAD;
75 cb.aio_sigevent.sigev_notify_function = thrfct;
76 cb.aio_sigevent.sigev_notify_attributes = NULL;
77 cb.aio_sigevent.sigev_value.sival_ptr = NULL;
79 if (lio_listio (LIO_NOWAIT, arr, 1, NULL) < 0)
83 puts ("no aio support in this configuration");
86 printf ("lio_listio failed: %m\n");
90 if (aio_suspend ((const struct aiocb *const *) arr, 1, NULL) < 0)
92 printf ("aio_suspend failed: %m\n");
96 int e = pthread_barrier_wait (&b);
97 if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
99 puts ("parent: barrier_wait failed");
108 #include "../test-skeleton.c"