Fix struct timespec normalization (as used in many other places).
[platform/upstream/glibc.git] / rt / tst-aio3.c
index 766771c..4d1fe8e 100644 (file)
@@ -1,35 +1,40 @@
 /* Test for notification mechanism in lio_listio.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2002, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
    The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <aio.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <errno.h>
 
-int flag;
+static pthread_barrier_t b;
 
 
 static void
 thrfct (sigval_t arg)
 {
-  flag = 1;
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
+    {
+      puts ("child: barrier_wait failed");
+      exit (1);
+    }
 }
 
 
@@ -51,6 +56,12 @@ do_test (int argc, char *argv[])
 
   unlink (name);
 
+  if (pthread_barrier_init (&b, NULL, 2) != 0)
+    {
+      puts ("barrier_init failed");
+      return 1;
+    }
+
   arr[0] = &cb;
 
   cb.aio_fildes = fd;
@@ -66,6 +77,11 @@ do_test (int argc, char *argv[])
 
   if (lio_listio (LIO_NOWAIT, arr, 1, NULL) < 0)
     {
+      if (errno == ENOSYS)
+       {
+         puts ("no aio support in this configuration");
+         return 0;
+       }
       printf ("lio_listio failed: %m\n");
       return 1;
     }
@@ -76,9 +92,10 @@ do_test (int argc, char *argv[])
       return 1;
     }
 
-  if (flag != 0)
+  int e = pthread_barrier_wait (&b);
+  if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
     {
-      puts ("thread created, should not have happened");
+      puts ("parent: barrier_wait failed");
       return 1;
     }