public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 2/4] nptl: Using libsupport for tst-cancel4*
  2017-04-27 21:31 [PATCH 1/4] posix: Using libsupport for p{write,read}v tests Adhemerval Zanella
  2017-04-27 21:31 ` [PATCH 3/4] posix: Fix internal p{read,write} plt usage Adhemerval Zanella
  2017-04-27 21:31 ` [PATCH 4/4] posix: Implement preadv2 and pwritev2 Adhemerval Zanella
@ 2017-04-27 21:31 ` Adhemerval Zanella
  2017-05-01 15:31   ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4 Wainer dos Santos Moschetta
  2017-05-01 17:18   ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4* Florian Weimer
  2017-05-01 14:59 ` [PATCH 1/4] posix: Using libsupport for p{write,read}v tests Wainer dos Santos Moschetta
  3 siblings, 2 replies; 17+ messages in thread
From: Adhemerval Zanella @ 2017-04-27 21:31 UTC (permalink / raw)
  To: libc-alpha

Checked on x86_64-linux-gnu.

	* nptl/tst-cancel4-common.c: Use libsupport.
	* nptl/tst-cancel4-common.h: Likewise.
	* nptl/tst-cancel4.c (tf_read): Likewise.
	(tf_readv): Likewise.
	(tf_write): Likewise.
	(tf_writev): Likewise.
	(tf_sleep): Likewise.
	(tf_usleep): Likewise.
	(tf_nanosleep): Likewise.
	(tf_select): Likewise.
	(tf_pselect): Likewise.
	(tf_poll): Likewise.
	(tf_ppoll): Likewise.
	(tf_wait): Likewise.
	(tf_waitpid): Likewise.
	(tf_waitid): Likewise.
	(tf_sigpause): Likewise.
	(tf_sigsuspend): Likewise.
	(tf_sigwait): Likewise.
	(tf_sigwaitinfo): Likewise.
	(tf_sigtimedwait): Likewise.
	(tf_pause): Likewise.
	(tf_accept): Likewise.
	(tf_send): Likewise.
	(tf_recv): Likewise.
	(tf_recvfrom): Likewise.
	(tf_recvmsg): Likewise.
	(tf_open): Likewise.
	(tf_close): Likewise.
	(tf_pread): Likewise.
	(tf_pwrite): Likewise.
	(tf_preadv): Likewise.
	(tf_pwritev): Likewise.
	(tf_fsync): Likewise.
	(tf_fdatasync): Likewise.
	(tf_msync): Likewise.
	(tf_sendto): Likewise.
	(tf_sendmsg): Likewise.
	(tf_creat): Likewise.
	(tf_connect): Likewise.
	(tf_tcdrain): Likewise.
	(tf_msgrcv): Likewise.
	(tf_msgsnd): Likewise.
	* nptl/tst-cancel4_1.c (tf_sendmmsg): Likewise.
	* nptl/tst-cancel4_2.c (tf_recvmmsg): Likewise.
---
 ChangeLog                 |  46 +++
 nptl/tst-cancel4-common.c |   3 +-
 nptl/tst-cancel4-common.h |   2 +
 nptl/tst-cancel4.c        | 845 ++++++++++------------------------------------
 nptl/tst-cancel4_1.c      |  33 +-
 nptl/tst-cancel4_2.c      |  33 +-
 6 files changed, 248 insertions(+), 714 deletions(-)

diff --git a/nptl/tst-cancel4-common.c b/nptl/tst-cancel4-common.c
index 3c57c99..eb32117 100644
--- a/nptl/tst-cancel4-common.c
+++ b/nptl/tst-cancel4-common.c
@@ -259,5 +259,4 @@ do_test (void)
 }
 
 #define TIMEOUT 60
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/nptl/tst-cancel4-common.h b/nptl/tst-cancel4-common.h
index 1964564..ffec6c8 100644
--- a/nptl/tst-cancel4-common.h
+++ b/nptl/tst-cancel4-common.h
@@ -19,6 +19,8 @@
 
 #include <pthread.h>
 
+#include <support/check.h>
+
 /* Pipe descriptors.  */
 static int fds[2];
 
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index 590ce0a..693c93f 100644
--- a/nptl/tst-cancel4.c
+++ b/nptl/tst-cancel4.c
@@ -88,23 +88,17 @@ tf_read  (void *arg)
       char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
       tempfd = fd = mkstemp (fname);
       if (fd == -1)
-	printf ("%s: mkstemp failed\n", __FUNCTION__);
+	FAIL_EXIT1 ("mkstemp failed: %m");
       unlink (fname);
 
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
@@ -114,9 +108,7 @@ tf_read  (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: read returns with %zd\n", __FUNCTION__, s);
-
-  exit (1);
+  FAIL_EXIT1 ("read returns with %zd", s);
 }
 
 
@@ -133,23 +125,17 @@ tf_readv  (void *arg)
       char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
       tempfd = fd = mkstemp (fname);
       if (fd == -1)
-	printf ("%s: mkstemp failed\n", __FUNCTION__);
+	FAIL_EXIT1 ("mkstemp failed: %m");
       unlink (fname);
 
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
@@ -160,9 +146,7 @@ tf_readv  (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: readv returns with %zd\n", __FUNCTION__, s);
-
-  exit (1);
+  FAIL_EXIT1 ("readv returns with %zd", s);
 }
 
 
@@ -179,23 +163,17 @@ tf_write  (void *arg)
       char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
       tempfd = fd = mkstemp (fname);
       if (fd == -1)
-	printf ("%s: mkstemp failed\n", __FUNCTION__);
+	FAIL_EXIT1 ("mkstemp failed: %m");
       unlink (fname);
 
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
@@ -206,9 +184,7 @@ tf_write  (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: write returns with %zd\n", __FUNCTION__, s);
-
-  exit (1);
+  FAIL_EXIT1 ("write returns with %zd", s);
 }
 
 
@@ -225,23 +201,17 @@ tf_writev  (void *arg)
       char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
       tempfd = fd = mkstemp (fname);
       if (fd == -1)
-	printf ("%s: mkstemp failed\n", __FUNCTION__);
+	FAIL_EXIT1 ("mkstemp failed: %m");
       unlink (fname);
 
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
@@ -253,9 +223,7 @@ tf_writev  (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: writev returns with %zd\n", __FUNCTION__, s);
-
-  exit (1);
+  FAIL_EXIT1 ("writev returns with %zd", s);
 }
 
 
@@ -264,19 +232,13 @@ tf_sleep (void *arg)
 {
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -285,9 +247,7 @@ tf_sleep (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sleep returns\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("sleep returns");
 }
 
 
@@ -296,19 +256,13 @@ tf_usleep (void *arg)
 {
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -317,9 +271,7 @@ tf_usleep (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: usleep returns\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("usleep returns");
 }
 
 
@@ -328,19 +280,13 @@ tf_nanosleep (void *arg)
 {
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -350,9 +296,7 @@ tf_nanosleep (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: nanosleep returns\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("nanosleep returns");
 }
 
 
@@ -369,23 +313,17 @@ tf_select (void *arg)
       char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
       tempfd = fd = mkstemp (fname);
       if (fd == -1)
-	printf ("%s: mkstemp failed\n", __FUNCTION__);
+	FAIL_EXIT1 ("mkstemp");
       unlink (fname);
 
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   fd_set rfs;
   FD_ZERO (&rfs);
@@ -398,10 +336,7 @@ tf_select (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: select returns with %d (%s)\n", __FUNCTION__, s,
-	  strerror (errno));
-
-  exit (1);
+  FAIL_EXIT1 ("select returns with %d: %m", s);
 }
 
 
@@ -418,23 +353,17 @@ tf_pselect (void *arg)
       char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
       tempfd = fd = mkstemp (fname);
       if (fd == -1)
-	printf ("%s: mkstemp failed\n", __FUNCTION__);
+	FAIL_EXIT1 ("mkstemp");
       unlink (fname);
 
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   fd_set rfs;
   FD_ZERO (&rfs);
@@ -447,10 +376,7 @@ tf_pselect (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: pselect returns with %d (%s)\n", __FUNCTION__, s,
-	  strerror (errno));
-
-  exit (1);
+  FAIL_EXIT1 ("pselect returns with %d: %m", s);
 }
 
 
@@ -467,23 +393,17 @@ tf_poll (void *arg)
       char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
       tempfd = fd = mkstemp (fname);
       if (fd == -1)
-	printf ("%s: mkstemp failed\n", __FUNCTION__);
+	FAIL_EXIT1 ("mkstemp");
       unlink (fname);
 
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } };
 
@@ -494,10 +414,7 @@ tf_poll (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: poll returns with %d (%s)\n", __FUNCTION__, s,
-	  strerror (errno));
-
-  exit (1);
+  FAIL_EXIT1 ("poll returns with %d: %m", s);
 }
 
 
@@ -514,23 +431,17 @@ tf_ppoll (void *arg)
       char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
       tempfd = fd = mkstemp (fname);
       if (fd == -1)
-	printf ("%s: mkstemp failed\n", __FUNCTION__);
+	FAIL_EXIT1 ("mkstemp");
       unlink (fname);
 
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } };
 
@@ -541,10 +452,7 @@ tf_ppoll (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: ppoll returns with %d (%s)\n", __FUNCTION__, s,
-	  strerror (errno));
-
-  exit (1);
+  FAIL_EXIT1 ("ppoll returns with %d: %m", s);
 }
 
 
@@ -553,10 +461,7 @@ tf_wait (void *arg)
 {
   pid_t pid = fork ();
   if (pid == -1)
-    {
-      puts ("fork failed");
-      exit (1);
-    }
+    FAIL_EXIT1 ("fork: %m");
 
   if (pid == 0)
     {
@@ -575,18 +480,12 @@ tf_wait (void *arg)
 
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   int s;
   pthread_cleanup_push (cl, NULL);
@@ -595,23 +494,16 @@ tf_wait (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: wait returns with %d (%s)\n", __FUNCTION__, s,
-	  strerror (errno));
-
-  exit (1);
+  FAIL_EXIT1 ("wait returns with %d: %m", s);
 }
 
 
 static void *
 tf_waitpid (void *arg)
 {
-
   pid_t pid = fork ();
   if (pid == -1)
-    {
-      puts ("fork failed");
-      exit (1);
-    }
+    FAIL_EXIT1 ("fork: %m");
 
   if (pid == 0)
     {
@@ -630,30 +522,21 @@ tf_waitpid (void *arg)
 
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   int s;
- pthread_cleanup_push (cl, NULL);
+  pthread_cleanup_push (cl, NULL);
 
   s = waitpid (-1, NULL, 0);
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: waitpid returns with %d (%s)\n", __FUNCTION__, s,
-	  strerror (errno));
-
-  exit (1);
+  FAIL_EXIT1 ("waitpid returns with %d: %m", s);
 }
 
 
@@ -662,10 +545,7 @@ tf_waitid (void *arg)
 {
   pid_t pid = fork ();
   if (pid == -1)
-    {
-      puts ("fork failed");
-      exit (1);
-    }
+    FAIL_EXIT1 ("fork: %m");
 
   if (pid == 0)
     {
@@ -684,18 +564,12 @@ tf_waitid (void *arg)
 
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   int s;
   pthread_cleanup_push (cl, NULL);
@@ -708,10 +582,7 @@ tf_waitid (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: waitid returns with %d (%s)\n", __FUNCTION__, s,
-	  strerror (errno));
-
-  exit (1);
+  FAIL_EXIT1 ("waitid returns with %di: %m", s);
 }
 
 
@@ -720,19 +591,13 @@ tf_sigpause (void *arg)
 {
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -741,9 +606,7 @@ tf_sigpause (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sigpause returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("sigpause returned");
 }
 
 
@@ -752,19 +615,13 @@ tf_sigsuspend (void *arg)
 {
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -776,9 +633,7 @@ tf_sigsuspend (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sigsuspend returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("sigsuspend returned");
 }
 
 
@@ -787,19 +642,13 @@ tf_sigwait (void *arg)
 {
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   /* Block SIGUSR1.  */
@@ -807,10 +656,7 @@ tf_sigwait (void *arg)
   sigemptyset (&mask);
   sigaddset (&mask, SIGUSR1);
   if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
-    {
-      printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_sigmask");
 
   int sig;
   pthread_cleanup_push (cl, NULL);
@@ -820,9 +666,7 @@ tf_sigwait (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sigwait returned with signal %d\n", __FUNCTION__, sig);
-
-  exit (1);
+  FAIL_EXIT1 ("sigwait returned with signal %d", sig);
 }
 
 
@@ -831,19 +675,13 @@ tf_sigwaitinfo (void *arg)
 {
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   /* Block SIGUSR1.  */
@@ -851,10 +689,7 @@ tf_sigwaitinfo (void *arg)
   sigemptyset (&mask);
   sigaddset (&mask, SIGUSR1);
   if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
-    {
-      printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_sigmask");
 
   siginfo_t info;
   pthread_cleanup_push (cl, NULL);
@@ -864,10 +699,7 @@ tf_sigwaitinfo (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sigwaitinfo returned with signal %d\n", __FUNCTION__,
-	  info.si_signo);
-
-  exit (1);
+  FAIL_EXIT1 ("sigwaitinfo returned with signal %d", info.si_signo);
 }
 
 
@@ -876,19 +708,13 @@ tf_sigtimedwait (void *arg)
 {
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   /* Block SIGUSR1.  */
@@ -896,10 +722,7 @@ tf_sigtimedwait (void *arg)
   sigemptyset (&mask);
   sigaddset (&mask, SIGUSR1);
   if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
-    {
-      printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_sigmask");
 
   /* Wait for SIGUSR1.  */
   siginfo_t info;
@@ -910,10 +733,7 @@ tf_sigtimedwait (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sigtimedwait returned with signal %d\n", __FUNCTION__,
-	  info.si_signo);
-
-  exit (1);
+  FAIL_EXIT1 ("sigtimedwait returned with signal %d", info.si_signo);
 }
 
 
@@ -922,19 +742,13 @@ tf_pause (void *arg)
 {
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -943,9 +757,7 @@ tf_pause (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: pause returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("pause returned");
 }
 
 
@@ -959,25 +771,18 @@ tf_accept (void *arg)
 
   tempfd = socket (AF_UNIX, pf, 0);
   if (tempfd == -1)
-    {
-      printf ("%s: socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, %s, 0): %m", arg == NULL ? "SOCK_STREAM"
+					       : "SOCK_DGRAM");
 
   int tries = 0;
   do
     {
       if (++tries > 10)
-	{
-	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
-	}
+	FAIL_EXIT1 ("too many unsuccessful bind calls");
 
       strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-1-XXXXXX");
       if (mktemp (sun.sun_path) == NULL)
-	{
-	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("cannot generate temp file name");
 
       sun.sun_family = AF_UNIX;
     }
@@ -993,19 +798,13 @@ tf_accept (void *arg)
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -1014,9 +813,7 @@ tf_accept (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: accept returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("accept returned");
 }
 
 
@@ -1027,25 +824,17 @@ tf_send (void *arg)
 
   tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
   if (tempfd == -1)
-    {
-      printf ("%s: first socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
 
   int tries = 0;
   do
     {
       if (++tries > 10)
-	{
-	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
-	}
+	FAIL_EXIT1 ("too many unsuccessful bind calls");
 
       strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX");
       if (mktemp (sun.sun_path) == NULL)
-	{
-	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("cannot generate temp file name");
 
       sun.sun_family = AF_UNIX;
     }
@@ -1057,34 +846,22 @@ tf_send (void *arg)
 
   tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
   if (tempfd2 == -1)
-    {
-      printf ("%s: second socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
 
   if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0)
-    {
-      printf ("%s: connect failed\n", __FUNCTION__);
-      exit(1);
-    }
+    FAIL_EXIT1 ("connect: %m");
 
   unlink (sun.sun_path);
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -1096,9 +873,7 @@ tf_send (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: send returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("send returned");
 }
 
 
@@ -1109,25 +884,17 @@ tf_recv (void *arg)
 
   tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
   if (tempfd == -1)
-    {
-      printf ("%s: first socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
 
   int tries = 0;
   do
     {
       if (++tries > 10)
-	{
-	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
-	}
+	FAIL_EXIT1 ("too many unsuccessful bind calls");
 
       strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-3-XXXXXX");
       if (mktemp (sun.sun_path) == NULL)
-	{
-	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("cannot generate temp file name");
 
       sun.sun_family = AF_UNIX;
     }
@@ -1139,34 +906,22 @@ tf_recv (void *arg)
 
   tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
   if (tempfd2 == -1)
-    {
-      printf ("%s: second socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
 
   if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0)
-    {
-      printf ("%s: connect failed\n", __FUNCTION__);
-      exit(1);
-    }
+    FAIL_EXIT1 ("connect: %m");
 
   unlink (sun.sun_path);
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -1177,9 +932,7 @@ tf_recv (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: recv returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("recv returned");
 }
 
 
@@ -1190,25 +943,17 @@ tf_recvfrom (void *arg)
 
   tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
   if (tempfd == -1)
-    {
-      printf ("%s: first socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
 
   int tries = 0;
   do
     {
       if (++tries > 10)
-	{
-	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
-	}
+	FAIL_EXIT1 ("too many unsuccessful bind calls");
 
       strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-4-XXXXXX");
       if (mktemp (sun.sun_path) == NULL)
-	{
-	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("cannot generate temp file name");
 
       sun.sun_family = AF_UNIX;
     }
@@ -1220,26 +965,17 @@ tf_recvfrom (void *arg)
 
   tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
   if (tempfd2 == -1)
-    {
-      printf ("%s: second socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -1252,9 +988,7 @@ tf_recvfrom (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: recvfrom returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("recvfrom returned");
 }
 
 
@@ -1265,25 +999,17 @@ tf_recvmsg (void *arg)
 
   tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
   if (tempfd == -1)
-    {
-      printf ("%s: first socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
 
   int tries = 0;
   do
     {
       if (++tries > 10)
-	{
-	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
-	}
+	FAIL_EXIT1 ("too many unsuccessful bind calls");
 
       strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-5-XXXXXX");
       if (mktemp (sun.sun_path) == NULL)
-	{
-	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("cannot generate temp file name");
 
       sun.sun_family = AF_UNIX;
     }
@@ -1295,26 +1021,17 @@ tf_recvmsg (void *arg)
 
   tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
   if (tempfd2 == -1)
-    {
-      printf ("%s: second socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -1336,9 +1053,7 @@ tf_recvmsg (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: recvmsg returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("recvmsg returned");
 }
 
 static void *
@@ -1348,27 +1063,18 @@ tf_open (void *arg)
     {
       fifofd = mkfifo (fifoname, S_IWUSR | S_IRUSR);
       if (fifofd == -1)
-	{
-	  printf ("%s: mkfifo failed: %m\n", __func__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("mkfifo: %m");
     }
   else
     {
       int r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: barrier_wait failed: %m\n", __func__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed: %m\n", __func__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   pthread_cleanup_push (cl_fifo, NULL);
 
@@ -1376,9 +1082,7 @@ tf_open (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: open returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("open returned");
 }
 
 
@@ -1393,25 +1097,16 @@ tf_close (void *arg)
   char fname[] = "/tmp/tst-cancel-fd-XXXXXX";
   tempfd = mkstemp (fname);
   if (tempfd == -1)
-    {
-      printf ("%s: mkstemp failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("mkstemp");
   unlink (fname);
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1419,9 +1114,7 @@ tf_close (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: close returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("close returned");
 }
 
 
@@ -1435,24 +1128,15 @@ tf_pread (void *arg)
 
   tempfd = open ("Makefile", O_RDONLY);
   if (tempfd == -1)
-    {
-      printf ("%s: cannot open Makefile\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1461,9 +1145,7 @@ tf_pread (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: pread returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("pread returned");
 }
 
 
@@ -1478,25 +1160,16 @@ tf_pwrite (void *arg)
   char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
   tempfd = mkstemp (fname);
   if (tempfd == -1)
-    {
-      printf ("%s: mkstemp failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("mkstemp");
   unlink (fname);
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1505,9 +1178,7 @@ tf_pwrite (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: pwrite returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("pwrite returned");
 }
 
 static void *
@@ -1524,22 +1195,16 @@ tf_preadv (void *arg)
   char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
   tempfd = fd = mkstemp (fname);
   if (fd == -1)
-    printf ("%s: mkstemp failed\n", __FUNCTION__);
+    FAIL_EXIT1 ("mkstemp");
   unlink (fname);
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
@@ -1550,9 +1215,7 @@ tf_preadv (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: preadv returns with %zd\n", __FUNCTION__, s);
-
-  exit (1);
+  FAIL_EXIT1 ("preadv returns with %zd", s);
 }
 
 static void *
@@ -1569,22 +1232,16 @@ tf_pwritev (void *arg)
   char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
   tempfd = fd = mkstemp (fname);
   if (fd == -1)
-    printf ("%s: mkstemp failed\n", __FUNCTION__);
+    FAIL_EXIT1 ("mkstemp");
   unlink (fname);
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   ssize_t s;
   pthread_cleanup_push (cl, NULL);
@@ -1596,9 +1253,7 @@ tf_pwritev (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: pwritev returns with %zd\n", __FUNCTION__, s);
-
-  exit (1);
+  FAIL_EXIT1 ("pwritev returns with %zd", s);
 }
 
 static void *
@@ -1611,24 +1266,15 @@ tf_fsync (void *arg)
 
   tempfd = open ("Makefile", O_RDONLY);
   if (tempfd == -1)
-    {
-      printf ("%s: cannot open Makefile\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1636,9 +1282,7 @@ tf_fsync (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: fsync returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("fsync returned");
 }
 
 
@@ -1652,24 +1296,15 @@ tf_fdatasync (void *arg)
 
   tempfd = open ("Makefile", O_RDONLY);
   if (tempfd == -1)
-    {
-      printf ("%s: cannot open Makefile\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1677,9 +1312,7 @@ tf_fdatasync (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: fdatasync returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("fdatasync returned");
 }
 
 
@@ -1693,30 +1326,19 @@ tf_msync (void *arg)
 
   tempfd = open ("Makefile", O_RDONLY);
   if (tempfd == -1)
-    {
-      printf ("%s: cannot open Makefile\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
+
   void *p = mmap (NULL, 10, PROT_READ, MAP_SHARED, tempfd, 0);
   if (p == MAP_FAILED)
-    {
-      printf ("%s: mmap failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("mmap (NULL, 10, PROT_READ, MAP_SHARED, ...): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1724,9 +1346,7 @@ tf_msync (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: msync returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("msync returned");
 }
 
 
@@ -1742,25 +1362,17 @@ tf_sendto (void *arg)
 
   tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
   if (tempfd == -1)
-    {
-      printf ("%s: first socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
 
   int tries = 0;
   do
     {
       if (++tries > 10)
-	{
-	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
-	}
+	FAIL_EXIT1 ("too many unsuccessful bind calls");
 
       strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-6-XXXXXX");
       if (mktemp (sun.sun_path) == NULL)
-	{
-	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("cannot generate temp file name");
 
       sun.sun_family = AF_UNIX;
     }
@@ -1771,24 +1383,15 @@ tf_sendto (void *arg)
 
   tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
   if (tempfd2 == -1)
-    {
-      printf ("%s: second socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1800,9 +1403,7 @@ tf_sendto (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sendto returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("sendto returned");
 }
 
 
@@ -1818,25 +1419,17 @@ tf_sendmsg (void *arg)
 
   tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
   if (tempfd == -1)
-    {
-      printf ("%s: first socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
 
   int tries = 0;
   do
     {
       if (++tries > 10)
-	{
-	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
-	}
+	FAIL_EXIT1 ("too many unsuccessful bind calls");
 
       strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-7-XXXXXX");
       if (mktemp (sun.sun_path) == NULL)
-	{
-	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("cannot generate temp file name");
 
       sun.sun_family = AF_UNIX;
     }
@@ -1847,24 +1440,15 @@ tf_sendmsg (void *arg)
 
   tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
   if (tempfd2 == -1)
-    {
-      printf ("%s: second socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1886,9 +1470,7 @@ tf_sendmsg (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sendmsg returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("sendmsg returned");
 }
 
 
@@ -1902,17 +1484,11 @@ tf_creat (void *arg)
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   pthread_cleanup_push (cl, NULL);
 
@@ -1920,9 +1496,7 @@ tf_creat (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: creat returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("creat returned");
 }
 
 
@@ -1938,25 +1512,17 @@ tf_connect (void *arg)
 
   tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
   if (tempfd == -1)
-    {
-      printf ("%s: first socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
 
   int tries = 0;
   do
     {
       if (++tries > 10)
-	{
-	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
-	}
+	FAIL_EXIT1 ("too many unsuccessful bind calls");
 
       strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX");
       if (mktemp (sun.sun_path) == NULL)
-	{
-	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("cannot generate temp file name");
 
       sun.sun_family = AF_UNIX;
     }
@@ -1969,26 +1535,17 @@ tf_connect (void *arg)
 
   tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
   if (tempfd2 == -1)
-    {
-      printf ("%s: second socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -1997,9 +1554,7 @@ tf_connect (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: connect returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("connect returned");
 }
 
 
@@ -2013,19 +1568,13 @@ tf_tcdrain (void *arg)
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -2036,9 +1585,7 @@ tf_tcdrain (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: tcdrain returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("tcdrain returned");
 }
 
 
@@ -2047,26 +1594,17 @@ tf_msgrcv (void *arg)
 {
   tempmsg = msgget (IPC_PRIVATE, 0666 | IPC_CREAT);
   if (tempmsg == -1)
-    {
-      printf ("%s: msgget failed: %s\n", __FUNCTION__, strerror (errno));
-      exit (1);
-    }
+    FAIL_EXIT1 ("msgget (IPC_PRIVATE, 0666 | IPC_CREAT): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   ssize_t s;
@@ -2092,11 +1630,9 @@ tf_msgrcv (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: msgrcv returned %zd with errno = %m\n", __FUNCTION__, s);
-
   msgctl (tempmsg, IPC_RMID, NULL);
 
-  exit (1);
+  FAIL_EXIT1 ("msgrcv returned %zd", s);
 }
 
 
@@ -2110,24 +1646,15 @@ tf_msgsnd (void *arg)
 
   tempmsg = msgget (IPC_PRIVATE, 0666 | IPC_CREAT);
   if (tempmsg == -1)
-    {
-      printf ("%s: msgget failed: %s\n", __FUNCTION__, strerror (errno));
-      exit (1);
-    }
+    FAIL_EXIT1 ("msgget (IPC_PRIVATE, 0666 | IPC_CREAT): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   pthread_cleanup_push (cl, NULL);
 
@@ -2144,11 +1671,9 @@ tf_msgsnd (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: msgsnd returned\n", __FUNCTION__);
-
   msgctl (tempmsg, IPC_RMID, NULL);
 
-  exit (1);
+  FAIL_EXIT1 ("msgsnd returned");
 }
 
 
diff --git a/nptl/tst-cancel4_1.c b/nptl/tst-cancel4_1.c
index 05b5f7b..0f41965 100644
--- a/nptl/tst-cancel4_1.c
+++ b/nptl/tst-cancel4_1.c
@@ -44,25 +44,17 @@ tf_sendmmsg (void *arg)
 
   tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
   if (tempfd == -1)
-    {
-      printf ("%s: first socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
 
   int tries = 0;
   do
     {
       if (++tries > 10)
-	{
-	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
-	}
+	FAIL_EXIT1 ("too many unsuccessful bind calls");
 
       strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-7-XXXXXX");
       if (mktemp (sun.sun_path) == NULL)
-	{
-	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("cannot generate temp file name");
 
       sun.sun_family = AF_UNIX;
     }
@@ -73,24 +65,15 @@ tf_sendmmsg (void *arg)
 
   tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
   if (tempfd2 == -1)
-    {
-      printf ("%s: second socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   pthread_cleanup_push (cl, NULL);
 
@@ -114,9 +97,7 @@ tf_sendmmsg (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: sendmmsg returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("sendmmsg returned");
 }
 
 struct cancel_tests tests[] =
diff --git a/nptl/tst-cancel4_2.c b/nptl/tst-cancel4_2.c
index f7a8797..1158609 100644
--- a/nptl/tst-cancel4_2.c
+++ b/nptl/tst-cancel4_2.c
@@ -39,25 +39,17 @@ tf_recvmmsg (void *arg)
 
   tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
   if (tempfd == -1)
-    {
-      printf ("%s: first socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
 
   int tries = 0;
   do
     {
       if (++tries > 10)
-	{
-	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
-	}
+	FAIL_EXIT1 ("too many unsuccessful bind calls");
 
       strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-5-XXXXXX");
       if (mktemp (sun.sun_path) == NULL)
-	{
-	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("cannot generate temp file name");
 
       sun.sun_family = AF_UNIX;
     }
@@ -69,26 +61,17 @@ tf_recvmmsg (void *arg)
 
   tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
   if (tempfd2 == -1)
-    {
-      printf ("%s: second socket call failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
 
   int r = pthread_barrier_wait (&b2);
   if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-    {
-      printf ("%s: barrier_wait failed\n", __FUNCTION__);
-      exit (1);
-    }
+    FAIL_EXIT1 ("pthread_barrier_wait");
 
   if (arg != NULL)
     {
       r = pthread_barrier_wait (&b2);
       if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
-	{
-	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
-	  exit (1);
-	}
+	FAIL_EXIT1 ("pthread_barrier_wait");
     }
 
   pthread_cleanup_push (cl, NULL);
@@ -112,9 +95,7 @@ tf_recvmmsg (void *arg)
 
   pthread_cleanup_pop (0);
 
-  printf ("%s: recvmmsg returned\n", __FUNCTION__);
-
-  exit (1);
+  FAIL_EXIT1 ("recvmmsg returned");
 }
 
 struct cancel_tests tests[] =
-- 
2.7.4

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 3/4] posix: Fix internal p{read,write} plt usage
  2017-04-27 21:31 [PATCH 1/4] posix: Using libsupport for p{write,read}v tests Adhemerval Zanella
@ 2017-04-27 21:31 ` Adhemerval Zanella
  2017-04-27 21:31 ` [PATCH 4/4] posix: Implement preadv2 and pwritev2 Adhemerval Zanella
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: Adhemerval Zanella @ 2017-04-27 21:31 UTC (permalink / raw)
  To: libc-alpha

This patch adds internal alias for __pread, __pread64, and __pwrite
following the already in place one for __pwrite64.  This is not used
in any implementation but on microblaze on preadv/pwritev fallback
(since it does not define __ASSUME_PREADV).

In fact it was signaled by commit c35db50ff5 which update the expected
localptl.data for the architecture based on resulted value.  This patch
updates the plt for microblaze now that p{read,write}{64} are correctly
routed to use internal alias.

Checked on x86_64-linux-gnu and a build for all supported architectures
(no all variants although).

	* include/unistd.h (__pread): Add libc_hidden_proto.
	(__pread64): Likewise.
	(__pwrite): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/localplt.data [libc.so]
	(__pread64): Remove.
	* sysdeps/unix/sysv/linux/pread.c (__pread64): Add libc_hidden_weak.
	* sysdeps/unix/sysv/linux/pread64.c (__pread64): Likewise.
	* sysdeps/unix/sysv/linux/pwrite.c (__pwrite): Likewise.
---
 ChangeLog                                        | 9 +++++++++
 include/unistd.h                                 | 3 +++
 sysdeps/unix/sysv/linux/microblaze/localplt.data | 1 -
 sysdeps/unix/sysv/linux/pread.c                  | 1 +
 sysdeps/unix/sysv/linux/pread64.c                | 1 +
 sysdeps/unix/sysv/linux/pwrite.c                 | 1 +
 6 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/include/unistd.h b/include/unistd.h
index 16a8815..f36759b 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -33,14 +33,17 @@ extern __off_t __libc_lseek (int __fd, __off_t __offset, int __whence);
 extern __off64_t __libc_lseek64 (int __fd, __off64_t __offset, int __whence);
 extern ssize_t __pread (int __fd, void *__buf, size_t __nbytes,
 			__off_t __offset);
+libc_hidden_proto (__pread);
 extern ssize_t __libc_pread (int __fd, void *__buf, size_t __nbytes,
 			     __off_t __offset);
 extern ssize_t __pread64 (int __fd, void *__buf, size_t __nbytes,
 			  __off64_t __offset);
+libc_hidden_proto (__pread64);
 extern ssize_t __libc_pread64 (int __fd, void *__buf, size_t __nbytes,
 			       __off64_t __offset);
 extern ssize_t __pwrite (int __fd, const void *__buf, size_t __n,
 			 __off_t __offset);
+libc_hidden_proto (__pwrite)
 extern ssize_t __libc_pwrite (int __fd, const void *__buf, size_t __n,
 			      __off_t __offset);
 extern ssize_t __pwrite64 (int __fd, const void *__buf, size_t __n,
diff --git a/sysdeps/unix/sysv/linux/microblaze/localplt.data b/sysdeps/unix/sysv/linux/microblaze/localplt.data
index 4187832..a61b94d 100644
--- a/sysdeps/unix/sysv/linux/microblaze/localplt.data
+++ b/sysdeps/unix/sysv/linux/microblaze/localplt.data
@@ -1,5 +1,4 @@
 libc.so: __errno_location
-libc.so: __pread64
 libc.so: calloc
 libc.so: free
 libc.so: malloc
diff --git a/sysdeps/unix/sysv/linux/pread.c b/sysdeps/unix/sysv/linux/pread.c
index b4f1b87..96df997 100644
--- a/sysdeps/unix/sysv/linux/pread.c
+++ b/sysdeps/unix/sysv/linux/pread.c
@@ -32,5 +32,6 @@ __libc_pread (int fd, void *buf, size_t count, off_t offset)
 }
 
 strong_alias (__libc_pread, __pread)
+libc_hidden_weak (__pread)
 weak_alias (__libc_pread, pread)
 #endif
diff --git a/sysdeps/unix/sysv/linux/pread64.c b/sysdeps/unix/sysv/linux/pread64.c
index c7f9cb1..0c2c80e 100644
--- a/sysdeps/unix/sysv/linux/pread64.c
+++ b/sysdeps/unix/sysv/linux/pread64.c
@@ -30,6 +30,7 @@ __libc_pread64 (int fd, void *buf, size_t count, off64_t offset)
 }
 
 weak_alias (__libc_pread64, __pread64)
+libc_hidden_weak (__pread64)
 weak_alias (__libc_pread64, pread64)
 
 #ifdef __OFF_T_MATCHES_OFF64_T
diff --git a/sysdeps/unix/sysv/linux/pwrite.c b/sysdeps/unix/sysv/linux/pwrite.c
index ef1bb01..ef11d8f 100644
--- a/sysdeps/unix/sysv/linux/pwrite.c
+++ b/sysdeps/unix/sysv/linux/pwrite.c
@@ -32,5 +32,6 @@ __libc_pwrite (int fd, const void *buf, size_t count, off_t offset)
 }
 
 strong_alias (__libc_pwrite, __pwrite)
+libc_hidden_weak (__pwrite)
 weak_alias (__libc_pwrite, pwrite)
 #endif
-- 
2.7.4

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 1/4] posix: Using libsupport for p{write,read}v tests
@ 2017-04-27 21:31 Adhemerval Zanella
  2017-04-27 21:31 ` [PATCH 3/4] posix: Fix internal p{read,write} plt usage Adhemerval Zanella
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: Adhemerval Zanella @ 2017-04-27 21:31 UTC (permalink / raw)
  To: libc-alpha

Checked on x86_64-linux-gnu.

	* misc/tst-preadvwritev-common.c (do_prepare): Use libsupport
	expected arguments.
	(do_test): Adapt to use libsupport.
---
 ChangeLog                      |  6 ++++++
 misc/tst-preadvwritev-common.c | 49 +++++++++++++++++++++---------------------
 2 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/misc/tst-preadvwritev-common.c b/misc/tst-preadvwritev-common.c
index 2943312..5540dfb 100644
--- a/misc/tst-preadvwritev-common.c
+++ b/misc/tst-preadvwritev-common.c
@@ -16,31 +16,28 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
 #include <sys/uio.h>
 #include <sys/stat.h>
 
-static void do_prepare (void);
-#define PREPARE(argc, argv)     do_prepare ()
-static int do_test (void);
-#define TEST_FUNCTION           do_test ()
-#include "test-skeleton.c"
+#include <support/check.h>
+#include <support/temp_file.h>
 
 static char *temp_filename;
 static int temp_fd;
 
+static int do_test (void);
+
 static void
-do_prepare (void)
+do_prepare (int argc, char **argv)
 {
   temp_fd = create_temp_file ("tst-preadvwritev.", &temp_filename);
   if (temp_fd == -1)
-    {
-      printf ("cannot create temporary file: %m\n");
-      exit (1);
-    }
+    FAIL_EXIT1 ("cannot create temporary file");
 }
-
-#define FAIL(str) \
-  do { printf ("error: %s (line %d)\n", str, __LINE__); return 1; } while (0)
+#define PREPARE do_prepare
 
 static int
 do_test_with_offset (off_t offset)
@@ -63,15 +60,15 @@ do_test_with_offset (off_t offset)
 
   ret = pwritev (temp_fd, iov, 2, offset);
   if (ret == -1)
-    FAIL ("first pwritev returned -1");
+    FAIL_RET ("first pwritev returned -1");
   if (ret != (sizeof buf1 + sizeof buf2))
-    FAIL ("first pwritev returned an unexpected value");
+    FAIL_RET ("first pwritev returned an unexpected value");
 
   ret = pwritev (temp_fd, iov, 2, sizeof buf1 + sizeof buf2 + offset);
   if (ret == -1)
-    FAIL ("second pwritev returned -1");
+    FAIL_RET ("second pwritev returned -1");
   if (ret != (sizeof buf1 + sizeof buf2))
-    FAIL ("second pwritev returned an unexpected value");
+    FAIL_RET ("second pwritev returned an unexpected value");
 
   char buf3[32];
   char buf4[64];
@@ -87,26 +84,28 @@ do_test_with_offset (off_t offset)
   /* Now read two buffer with 32 and 64 bytes respectively.  */
   ret = preadv (temp_fd, iov, 2, offset);
   if (ret == -1)
-    FAIL ("first preadv returned -1");
+    FAIL_RET ("first preadv returned -1");
   if (ret != (sizeof buf3 + sizeof buf4))
-    FAIL ("first preadv returned an unexpected value");
+    FAIL_RET ("first preadv returned an unexpected value");
 
   if (memcmp (buf1, buf3, sizeof buf1) != 0)
-    FAIL ("first buffer from first preadv different than expected");
+    FAIL_RET ("first buffer from first preadv different than expected");
   if (memcmp (buf2, buf4, sizeof buf2) != 0)
-    FAIL ("second buffer from first preadv different than expected");
+    FAIL_RET ("second buffer from first preadv different than expected");
 
   ret = preadv (temp_fd, iov, 2, sizeof buf3 + sizeof buf4 + offset);
   if (ret == -1)
-    FAIL ("second preadv returned -1");
+    FAIL_RET ("second preadv returned -1");
   if (ret != (sizeof buf3 + sizeof buf4))
-    FAIL ("second preadv returned an unexpected value");
+    FAIL_RET ("second preadv returned an unexpected value");
 
   /* And compare the buffers read and written to check if there are equal.  */
   if (memcmp (buf1, buf3, sizeof buf1) != 0)
-    FAIL ("first buffer from second preadv different than expected");
+    FAIL_RET ("first buffer from second preadv different than expected");
   if (memcmp (buf2, buf4, sizeof buf2) != 0)
-    FAIL ("second buffer from second preadv different than expected");
+    FAIL_RET ("second buffer from second preadv different than expected");
 
   return 0;
 }
+
+#include <support/test-driver.c>
-- 
2.7.4

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH 4/4] posix: Implement preadv2 and pwritev2
  2017-04-27 21:31 [PATCH 1/4] posix: Using libsupport for p{write,read}v tests Adhemerval Zanella
  2017-04-27 21:31 ` [PATCH 3/4] posix: Fix internal p{read,write} plt usage Adhemerval Zanella
@ 2017-04-27 21:31 ` Adhemerval Zanella
  2017-04-27 22:30   ` Joseph Myers
  2017-04-28 14:14   ` Zack Weinberg
  2017-04-27 21:31 ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4* Adhemerval Zanella
  2017-05-01 14:59 ` [PATCH 1/4] posix: Using libsupport for p{write,read}v tests Wainer dos Santos Moschetta
  3 siblings, 2 replies; 17+ messages in thread
From: Adhemerval Zanella @ 2017-04-27 21:31 UTC (permalink / raw)
  To: libc-alpha

This patch adds support of preadv2 and pwritev2 which are similar to
preadv/pwritev but adds an extra flag argument.  As for preadv/pwritev
both interfaces are added a non-standard standard GNU API.

On default 'posix' implementation trying to emulate the Linux supported
flags is troublesome:

   * We can not temporary change the file state of the O_DSYNC and O_SYNC
     flags to emulate RWF_{D}SYNC (attempts to change the state of using
     fcntl are silently ignored).

   * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal
     semantic not provided by any other flag (O_NONBLOCK for instance).

So default implementation just ignore the flag argument and calls generic
preadv/pwritev.

The Linux one uses the preadv2/pwritev2 syscall if defined, otherwise it
call preadv/writev.  Instead of using the previous __ASSUME_* to
unconditionally issue the syscall (and avoid building the fallback routine),
it call pread/write if the preadv2/pwritev2 syscalls fails.  The idea
is just avoid adding another __ASSUME_* and checking each architecture
on every kernel bump and simplify code conditionals.

Checked on x86_64-linux-gnu and on i686-linux-gnu and a check with
run-built-tests=no on aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabihf,
ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu, mips{64,64n32}-linux-gnu,
nios2-linux-gnu, powerpc{64,64le}-linux-gnu, s390{x}-linux-gnu,
sparc{64,v9}-linux-gnu, tile{gx,pro}-linux-gnu, and sh4-linux-gnu (all using
gcc 6.3).

	* misc/Makefile (routines): Add preadv2, preadv64v2, pwritev2, and
	pwritev64v2.
	(tests): Add tst-preadvwritev2 and tst-preadvwritev64v2.
	* misc/Versions (GLIBC_2.26): Add preadv2, preadv64v2, pwritev2, and
	pwritev64v2.
	* misc/preadv2.c: New file.
	* misc/preadv64v2.c: Likewise.
	* misc/pwritev2.c: Likewise.
	* misc/pwritev64v2.c: Likewise.
	* misc/tst-preadvwritev2.c: Likewise.
	* misc/tst-preadvwritev64v2.c: Likewise.
	* misc/sys/uio.h [__USE_MISC && !__USE_FILE_OFFSET64] (preadv2): New
	prototype.
	[__USE_MISC && !__USE_FILE_OFFSET64] (pwritev2): Likewise.
	[__USE_MISC && __USE_FILE_OFFSET64] (preadv64v2): New
	prototype.
	[__USE_MISC && __USE_FILE_OFFSET64] (pwritev64v2): Likewise.
	* misc/tst-preadvwritev-common.c (PREADV): Define if not defined.
	(PWRITEV): Likewise.
	(do_test_with_offset): Use PREADV and PWRITEV macros and check for
	ENOSYS.
	* nptl/tst-cancel4.c (tf_pwritev2): New test.
	(tf_preadv2): Likewise.
	(tf_fsync): Add tf_pwritev2 and tf_preadv2.
	* sysdeps/posix/preadv2.c: Likewise.
	* sysdeps/posix/preadv64v2.c: Likewise.
	* sysdeps/posix/pwritev2.c: Likewise.
	* sysdeps/posix/pwritev64v2.c: Likewise.
	* sysdeps/unix/sysv/linux/preadv2.c: Likewise.
	* sysdeps/unix/sysv/linux/preadv64v2.c: Likewise.
	* sysdeps/unix/sysv/linux/pwritev2.c: Likewise.
	* sysdeps/unix/sysv/linux/pwritev64v2.c: Likewise.
	* sysdeps/unix/sysv/linux/preadv.c (preadv): Add libc_hidden_def.
	* sysdeps/unix/sysv/linux/preadv64.c (preadv64): Likewise.
	* sysdeps/unix/sysv/linux/pwritev.c (pwritev): Likewise.
	* sysdeps/unix/sysv/linux/pwritev64.c (pwritev64): Likewise.
	* sysdeps/unix/sysv/linux/bits/uio.h: Add supported preadv2/pwritev2
	support flags on Linux.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist (GLIBC_2.26): Add
	preadv2, preadv64v2, pwritev2, pwritev64v2.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
	(GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
	(GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
	(GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/sysv/linux/tile/tilegx/tilegx32/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/sysv/linux/tile/tilegx/tilegx64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist (GLIBC_2.26):
	Likewise.
---
 ChangeLog                                          | 88 ++++++++++++++++++++++
 include/sys/uio.h                                  |  6 ++
 misc/Makefile                                      |  5 +-
 misc/Versions                                      |  3 +
 misc/preadv2.c                                     | 30 ++++++++
 misc/preadv64v2.c                                  | 30 ++++++++
 misc/pwritev2.c                                    | 30 ++++++++
 misc/pwritev64v2.c                                 | 30 ++++++++
 misc/sys/uio.h                                     | 16 ++++
 misc/tst-preadvwritev-common.c                     | 19 ++++-
 misc/tst-preadvwritev2.c                           | 31 ++++++++
 misc/tst-preadvwritev64v2.c                        | 33 ++++++++
 nptl/tst-cancel4.c                                 | 81 ++++++++++++++++++++
 sysdeps/posix/preadv2.c                            | 32 ++++++++
 sysdeps/posix/preadv64v2.c                         | 31 ++++++++
 sysdeps/posix/pwritev2.c                           | 32 ++++++++
 sysdeps/posix/pwritev64v2.c                        | 32 ++++++++
 sysdeps/unix/sysv/linux/aarch64/libc.abilist       |  5 ++
 sysdeps/unix/sysv/linux/alpha/libc.abilist         |  5 ++
 sysdeps/unix/sysv/linux/arm/libc.abilist           |  5 ++
 sysdeps/unix/sysv/linux/bits/uio.h                 |  6 ++
 sysdeps/unix/sysv/linux/hppa/libc.abilist          |  5 ++
 sysdeps/unix/sysv/linux/i386/libc.abilist          |  5 ++
 sysdeps/unix/sysv/linux/ia64/libc.abilist          |  5 ++
 sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist |  5 ++
 sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist   |  5 ++
 sysdeps/unix/sysv/linux/microblaze/libc.abilist    |  5 ++
 .../unix/sysv/linux/mips/mips32/fpu/libc.abilist   |  5 ++
 .../unix/sysv/linux/mips/mips32/nofpu/libc.abilist |  5 ++
 .../unix/sysv/linux/mips/mips64/n32/libc.abilist   |  5 ++
 .../unix/sysv/linux/mips/mips64/n64/libc.abilist   |  5 ++
 sysdeps/unix/sysv/linux/nios2/libc.abilist         |  5 ++
 .../sysv/linux/powerpc/powerpc32/fpu/libc.abilist  |  5 ++
 .../linux/powerpc/powerpc32/nofpu/libc.abilist     |  5 ++
 .../sysv/linux/powerpc/powerpc64/libc-le.abilist   |  5 ++
 .../unix/sysv/linux/powerpc/powerpc64/libc.abilist |  5 ++
 sysdeps/unix/sysv/linux/preadv.c                   |  2 +
 sysdeps/unix/sysv/linux/preadv2.c                  | 51 +++++++++++++
 sysdeps/unix/sysv/linux/preadv64.c                 |  2 +
 sysdeps/unix/sysv/linux/preadv64v2.c               | 51 +++++++++++++
 sysdeps/unix/sysv/linux/pwrite64.c                 |  1 +
 sysdeps/unix/sysv/linux/pwritev.c                  |  2 +
 sysdeps/unix/sysv/linux/pwritev2.c                 | 47 ++++++++++++
 sysdeps/unix/sysv/linux/pwritev64.c                |  2 +
 sysdeps/unix/sysv/linux/pwritev64v2.c              | 51 +++++++++++++
 sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist  |  5 ++
 sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist  |  5 ++
 sysdeps/unix/sysv/linux/sh/libc.abilist            |  5 ++
 sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist |  5 ++
 sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist |  5 ++
 .../sysv/linux/tile/tilegx/tilegx32/libc.abilist   |  5 ++
 .../sysv/linux/tile/tilegx/tilegx64/libc.abilist   |  5 ++
 sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist  |  5 ++
 sysdeps/unix/sysv/linux/x86_64/64/libc.abilist     |  5 ++
 sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist    |  5 ++
 55 files changed, 879 insertions(+), 5 deletions(-)
 create mode 100644 misc/preadv2.c
 create mode 100644 misc/preadv64v2.c
 create mode 100644 misc/pwritev2.c
 create mode 100644 misc/pwritev64v2.c
 create mode 100644 misc/tst-preadvwritev2.c
 create mode 100644 misc/tst-preadvwritev64v2.c
 create mode 100644 sysdeps/posix/preadv2.c
 create mode 100644 sysdeps/posix/preadv64v2.c
 create mode 100644 sysdeps/posix/pwritev2.c
 create mode 100644 sysdeps/posix/pwritev64v2.c
 create mode 100644 sysdeps/unix/sysv/linux/preadv2.c
 create mode 100644 sysdeps/unix/sysv/linux/preadv64v2.c
 create mode 100644 sysdeps/unix/sysv/linux/pwritev2.c
 create mode 100644 sysdeps/unix/sysv/linux/pwritev64v2.c

diff --git a/include/sys/uio.h b/include/sys/uio.h
index f44ce18..20860bf 100644
--- a/include/sys/uio.h
+++ b/include/sys/uio.h
@@ -7,5 +7,11 @@ extern ssize_t __readv (int __fd, const struct iovec *__iovec,
 			int __count);
 extern ssize_t __writev (int __fd, const struct iovec *__iovec,
 			 int __count);
+
+/* Used for p{read,write}{v64}v2 implementation.  */
+libc_hidden_proto (preadv)
+libc_hidden_proto (preadv64)
+libc_hidden_proto (pwritev)
+libc_hidden_proto (pwritev64)
 #endif
 #endif
diff --git a/misc/Makefile b/misc/Makefile
index 622da67..bed46d7 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -39,6 +39,7 @@ headers	:= sys/uio.h bits/uio.h sys/ioctl.h bits/ioctls.h bits/ioctl-types.h \
 
 routines := brk sbrk sstk ioctl \
 	    readv writev preadv preadv64 pwritev pwritev64 \
+	    preadv2 preadv64v2 pwritev2 pwritev64v2 \
 	    setreuid setregid \
 	    seteuid setegid \
 	    getpagesize \
@@ -79,7 +80,9 @@ gpl2lgpl := error.c error.h
 tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \
 	 tst-error1 tst-pselect tst-insremque tst-mntent2 bug-hsearch1 \
 	 tst-mntent-blank-corrupt tst-mntent-blank-passno bug18240 \
-	 tst-preadvwritev tst-preadvwritev64 tst-makedev tst-empty \
+	 tst-preadvwritev tst-preadvwritev64 tst-preadvwritev2 \
+	 tst-preadvwritev64v2 \
+	 tst-makedev tst-empty \
 	 tst-atomic tst-atomic-long
 tests-static := tst-empty
 
diff --git a/misc/Versions b/misc/Versions
index f2c90ff..bafda78 100644
--- a/misc/Versions
+++ b/misc/Versions
@@ -155,6 +155,9 @@ libc {
   GLIBC_2.25 {
     gnu_dev_major; gnu_dev_minor; gnu_dev_makedev;
   }
+  GLIBC_2.26 {
+    preadv2; preadv64v2; pwritev2; pwritev64v2;
+  }
   GLIBC_PRIVATE {
     __madvise;
     __mktemp;
diff --git a/misc/preadv2.c b/misc/preadv2.c
new file mode 100644
index 0000000..a62dcaa
--- /dev/null
+++ b/misc/preadv2.c
@@ -0,0 +1,30 @@
+/* Default implementation of preadv2.
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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 <sys/uio.h>
+
+/* Same as preadv but with an additional flags argument.  */
+ssize_t
+preadv2 (int fd, const struct iovec *vector, int count, off_t offset,
+	 int flags)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+
+stub_warning (preadv2)
diff --git a/misc/preadv64v2.c b/misc/preadv64v2.c
new file mode 100644
index 0000000..a802c2f
--- /dev/null
+++ b/misc/preadv64v2.c
@@ -0,0 +1,30 @@
+/* Default implementation of preadv2 (LFS version).
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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 <sys/uio.h>
+
+/* Same as preadv64 but with an addional flag argument.  */
+ssize_t
+preadv64v2 (int fd, const struct iovec *vector, int count, off64_t offset,
+	    int flags)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+
+stub_warning (preadv64v2)
diff --git a/misc/pwritev2.c b/misc/pwritev2.c
new file mode 100644
index 0000000..b9e0727
--- /dev/null
+++ b/misc/pwritev2.c
@@ -0,0 +1,30 @@
+/* Default implementation of pwritev2.
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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 <sys/uio.h>
+
+/* Same as pwritev but with an additional flags argument.  */
+ssize_t
+pwritev2 (int fd, const struct iovec *vector, int count, off_t offset,
+	  int flags)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+
+stub_warning (pwritev2)
diff --git a/misc/pwritev64v2.c b/misc/pwritev64v2.c
new file mode 100644
index 0000000..1f874f0
--- /dev/null
+++ b/misc/pwritev64v2.c
@@ -0,0 +1,30 @@
+/* Default implementation of pwritev2 (LFS version).
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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 <sys/uio.h>
+
+/* Same as preadv64 but with an addional flag argument.  */
+ssize_t
+pwritev64v2 (int fd, const struct iovec *vector, int count, off64_t offset,
+	     int flags)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+
+stub_warning (pwritev64v2)
diff --git a/misc/sys/uio.h b/misc/sys/uio.h
index e80f013..530ee9c 100644
--- a/misc/sys/uio.h
+++ b/misc/sys/uio.h
@@ -65,6 +65,10 @@ extern ssize_t writev (int __fd, const struct iovec *__iovec, int __count)
 extern ssize_t preadv (int __fd, const struct iovec *__iovec, int __count,
 		       __off_t __offset) __wur;
 
+/* Same as preadv but with an additional flag argumenti defined at uio.h.  */
+extern ssize_t preadv2 (int __fp, const struct iovec *__iovec, int __count,
+			__off_t __offset, int ___flags) __wur;
+
 /* Write data pointed by the buffers described by IOVEC, which is a
    vector of COUNT 'struct iovec's, to file descriptor FD at the given
    position OFFSET without change the file pointer.  The data is
@@ -76,14 +80,26 @@ extern ssize_t preadv (int __fd, const struct iovec *__iovec, int __count,
    __THROW.  */
 extern ssize_t pwritev (int __fd, const struct iovec *__iovec, int __count,
 			__off_t __offset) __wur;
+
+/* Same as preadv but with an additional flag argument defined at uio.h.  */
+extern ssize_t pwritev2 (int __fd, const struct iovec *__iodev, int __count,
+			 __off_t __offset, int __flags) __wur;
 # else
 #  ifdef __REDIRECT
 extern ssize_t __REDIRECT (preadv, (int __fd, const struct iovec *__iovec,
 				    int __count, __off64_t __offset),
 			   preadv64) __wur;
+extern ssize_t __REDIRECT (preadv2, (int __fd, const struct iovec *__iovec,
+				     int __count, __off64_t __offset,
+				     int __flags),
+			   preadv64v2) __wur;
 extern ssize_t __REDIRECT (pwritev, (int __fd, const struct iovec *__iovec,
 				     int __count, __off64_t __offset),
 			   pwritev64) __wur;
+extern ssize_t __REDIRECT (pwritev2, (int __fd, const struct iovec *__iovec,
+				      int __count, __off64_t __offset,
+				      int __flags),
+			   pwritev64v2) __wur;
 #  else
 #   define preadv preadv64
 #   define pwritev pwritev64
diff --git a/misc/tst-preadvwritev-common.c b/misc/tst-preadvwritev-common.c
index 5540dfb..676d495 100644
--- a/misc/tst-preadvwritev-common.c
+++ b/misc/tst-preadvwritev-common.c
@@ -18,6 +18,7 @@
 
 #include <stdio.h>
 #include <stdint.h>
+#include <errno.h>
 #include <string.h>
 #include <sys/uio.h>
 #include <sys/stat.h>
@@ -39,6 +40,16 @@ do_prepare (int argc, char **argv)
 }
 #define PREPARE do_prepare
 
+#ifndef PREADV
+# define PREADV(__fd, __iov, __iovcnt, __offset) \
+  preadv (__fd, __iov, __iovcnt, __offset)
+#endif
+
+#ifndef PWRITEV
+# define PWRITEV(__fd, __iov, __iovcnt, __offset) \
+  pwritev (__fd, __iov, __iovcnt, __offset)
+#endif
+
 static int
 do_test_with_offset (off_t offset)
 {
@@ -58,13 +69,13 @@ do_test_with_offset (off_t offset)
   iov[1].iov_base = buf2;
   iov[1].iov_len = sizeof buf2;
 
-  ret = pwritev (temp_fd, iov, 2, offset);
+  ret = PWRITEV (temp_fd, iov, 2, offset);
   if (ret == -1)
     FAIL_RET ("first pwritev returned -1");
   if (ret != (sizeof buf1 + sizeof buf2))
     FAIL_RET ("first pwritev returned an unexpected value");
 
-  ret = pwritev (temp_fd, iov, 2, sizeof buf1 + sizeof buf2 + offset);
+  ret = PWRITEV (temp_fd, iov, 2, sizeof buf1 + sizeof buf2 + offset);
   if (ret == -1)
     FAIL_RET ("second pwritev returned -1");
   if (ret != (sizeof buf1 + sizeof buf2))
@@ -82,7 +93,7 @@ do_test_with_offset (off_t offset)
   iov[1].iov_len = sizeof buf4;
 
   /* Now read two buffer with 32 and 64 bytes respectively.  */
-  ret = preadv (temp_fd, iov, 2, offset);
+  ret = PREADV (temp_fd, iov, 2, offset);
   if (ret == -1)
     FAIL_RET ("first preadv returned -1");
   if (ret != (sizeof buf3 + sizeof buf4))
@@ -93,7 +104,7 @@ do_test_with_offset (off_t offset)
   if (memcmp (buf2, buf4, sizeof buf2) != 0)
     FAIL_RET ("second buffer from first preadv different than expected");
 
-  ret = preadv (temp_fd, iov, 2, sizeof buf3 + sizeof buf4 + offset);
+  ret = PREADV (temp_fd, iov, 2, sizeof buf3 + sizeof buf4 + offset);
   if (ret == -1)
     FAIL_RET ("second preadv returned -1");
   if (ret != (sizeof buf3 + sizeof buf4))
diff --git a/misc/tst-preadvwritev2.c b/misc/tst-preadvwritev2.c
new file mode 100644
index 0000000..cf36272
--- /dev/null
+++ b/misc/tst-preadvwritev2.c
@@ -0,0 +1,31 @@
+/* Tests for preadv2 and pwritev2.
+   Copyright (C) 2016-2017 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 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
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#define PREADV(__fd, __iov, __iovcnt, __offset) \
+  preadv2 (__fd, __iov, __iovcnt, __offset, 0)
+
+#define PWRITEV(__fd, __iov, __iovcnt, __offset) \
+  pwritev2 (__fd, __iov, __iovcnt, __offset, 0)
+
+#include "tst-preadvwritev-common.c"
+
+static int
+do_test (void)
+{
+  return do_test_with_offset (0);
+}
diff --git a/misc/tst-preadvwritev64v2.c b/misc/tst-preadvwritev64v2.c
new file mode 100644
index 0000000..8d0c48e
--- /dev/null
+++ b/misc/tst-preadvwritev64v2.c
@@ -0,0 +1,33 @@
+/* Tests for preadv2 and pwritev2 (LFS version).
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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/>.  */
+
+#define _FILE_OFFSET_BITS 64
+
+#define PREADV(__fd, __iov, __iovcnt, __offset) \
+  preadv2 (__fd, __iov, __iovcnt, __offset, 0)
+
+#define PWRITEV(__fd, __iov, __iovcnt, __offset) \
+  pwritev2 (__fd, __iov, __iovcnt, __offset, 0)
+
+#include "tst-preadvwritev-common.c"
+
+static int
+do_test (void)
+{
+  return do_test_with_offset (0);
+}
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index 693c93f..e70d32c 100644
--- a/nptl/tst-cancel4.c
+++ b/nptl/tst-cancel4.c
@@ -1257,6 +1257,85 @@ tf_pwritev (void *arg)
 }
 
 static void *
+tf_pwritev2 (void *arg)
+{
+  int fd;
+  int r;
+
+  if (arg == NULL)
+    /* XXX If somebody can provide a portable test case in which pwritev2
+       blocks we can enable this test to run in both rounds.  */
+    abort ();
+
+  errno = 0;
+
+  char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+  tempfd = fd = mkstemp (fname);
+  if (fd == -1)
+    FAIL_EXIT1 ("mkstemp: %m");
+  unlink (fname);
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    FAIL_EXIT1 ("pthread_barrier_wait: %m");
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    FAIL_EXIT1 ("pthread_barrier_wait: %m");
+
+  ssize_t s;
+  pthread_cleanup_push (cl, NULL);
+
+  char buf[WRITE_BUFFER_SIZE];
+  memset (buf, '\0', sizeof (buf));
+  struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
+  s = pwritev2 (fd, iov, 1, 0, 0);
+
+  pthread_cleanup_pop (0);
+
+  FAIL_EXIT1 ("pwritev returns with %zd", s);
+}
+
+static void *
+tf_preadv2 (void *arg)
+{
+  int fd;
+  int r;
+
+  if (arg == NULL)
+    /* XXX If somebody can provide a portable test case in which preadv2
+       blocks we can enable this test to run in both rounds.  */
+    abort ();
+
+  errno = 0;
+
+  char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
+  tempfd = fd = mkstemp (fname);
+  if (fd == -1)
+    FAIL_EXIT1 ("mkstemp: %m");
+  unlink (fname);
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    FAIL_EXIT1 ("pthread_barrier_wait: %m");
+
+  r = pthread_barrier_wait (&b2);
+  if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
+    FAIL_EXIT1 ("pthread_barrier_wait: %m");
+
+  ssize_t s;
+  pthread_cleanup_push (cl, NULL);
+
+  char buf[100];
+  struct iovec iov[1] = { [0] = { .iov_base = buf, .iov_len = sizeof (buf) } };
+  s = preadv2 (fd, iov, 1, 0, 0);
+
+  pthread_cleanup_pop (0);
+
+  FAIL_EXIT1 ("preadv2 returns with %zd", s);
+}
+
+static void *
 tf_fsync (void *arg)
 {
   if (arg == NULL)
@@ -1705,7 +1784,9 @@ struct cancel_tests tests[] =
   ADD_TEST (recvfrom, 2, 0),
   ADD_TEST (recvmsg, 2, 0),
   ADD_TEST (preadv, 2, 1),
+  ADD_TEST (preadv2, 2, 1),
   ADD_TEST (pwritev, 2, 1),
+  ADD_TEST (pwritev2, 2, 1),
   ADD_TEST (open, 2, 1),
   ADD_TEST (close, 2, 1),
   ADD_TEST (pread, 2, 1),
diff --git a/sysdeps/posix/preadv2.c b/sysdeps/posix/preadv2.c
new file mode 100644
index 0000000..1626bda
--- /dev/null
+++ b/sysdeps/posix/preadv2.c
@@ -0,0 +1,32 @@
+/* Generic version of preadv2.
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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 <unistd.h>
+#include <sys/uio.h>
+
+#ifndef __OFF_T_MATCHES_OFF64_T
+
+/* Since we define no flags for preadv2 just route to preadv.  */
+ssize_t
+preadv2 (int fd, const struct iovec *vector, int count, OFF_T offset,
+	 int flags)
+{
+  return preadv (fd, vector, count, offset);
+}
+
+#endif
diff --git a/sysdeps/posix/preadv64v2.c b/sysdeps/posix/preadv64v2.c
new file mode 100644
index 0000000..6e1033d
--- /dev/null
+++ b/sysdeps/posix/preadv64v2.c
@@ -0,0 +1,31 @@
+/* Generic version of preadv2.
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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 <unistd.>
+#include <sys/uio.h>
+
+ssize_t
+preadv64v2 (int fd, const struct iovec *vector, int count, OFF_T offset,
+	    int flags)
+{
+  return preadv64 (fd, vector, count, offset);
+}
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+strong_alias (preadv64v2, preadv2)
+#endif
diff --git a/sysdeps/posix/pwritev2.c b/sysdeps/posix/pwritev2.c
new file mode 100644
index 0000000..886af4d
--- /dev/null
+++ b/sysdeps/posix/pwritev2.c
@@ -0,0 +1,32 @@
+/* Generic version of pwritev2.
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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 <unistd.h>
+#include <sys/uio.h>
+
+#ifndef __OFF_T_MATCHES_OFF64_T
+
+/* Since we define no flags for pwritev2 just route to pwritev.  */
+ssize_t
+pwritev2 (int fd, const struct iovec *vector, int count, OFF_T offset,
+	 int flags)
+{
+  return pwritev (fd, vector, count, offset);
+}
+
+#endif
diff --git a/sysdeps/posix/pwritev64v2.c b/sysdeps/posix/pwritev64v2.c
new file mode 100644
index 0000000..7be00e8
--- /dev/null
+++ b/sysdeps/posix/pwritev64v2.c
@@ -0,0 +1,32 @@
+/* Generic version of pwritev2.
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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 <unistd.h>
+#include <sys/uio.h>
+
+/* Since we define no flags for pwritev2 just route to pwritev.  */ 
+ssize_t
+pwritev64v2 (int fd, const struct iovec *vector, int count, OFF_T offset,
+	     int flags)
+{
+  return pwritev64 (fd, vector, count, offset);
+}
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+strong_alias (pwritev64v2, pwritev2)
+#endif
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 58d768c..296f2a5 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2097,3 +2097,8 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 906050d..8006e72 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2008,6 +2008,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/arm/libc.abilist b/sysdeps/unix/sysv/linux/arm/libc.abilist
index 66112dd..29f9688 100644
--- a/sysdeps/unix/sysv/linux/arm/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/libc.abilist
@@ -98,6 +98,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0xa0
diff --git a/sysdeps/unix/sysv/linux/bits/uio.h b/sysdeps/unix/sysv/linux/bits/uio.h
index 1583f04..d5701f8 100644
--- a/sysdeps/unix/sysv/linux/bits/uio.h
+++ b/sysdeps/unix/sysv/linux/bits/uio.h
@@ -69,4 +69,10 @@ extern ssize_t process_vm_writev (pid_t __pid, const struct iovec *__lvec,
 __END_DECLS
 
 # endif
+
+/* Flags for preadv2/pwritev2: */
+#define RWF_HIPRI	0x00000001 /* High priority request.  */
+#define RWF_DSYNC	0x00000002 /* per-IO O_DSYNC.  */
+#define RWF_SYNC	0x00000004 /* per-IO O_SYNC.  */
+
 #endif
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index 3ddadd2..e9cfbaf 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -1862,6 +1862,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index 977ab90..c6ad3c3 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2020,6 +2020,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index c7edb9a..d0055a2 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -1884,6 +1884,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index 450be4e..3777676 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -99,6 +99,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.4 GLIBC_2.4 A
 GLIBC_2.4 _Exit F
 GLIBC_2.4 _IO_2_1_stderr_ D 0x98
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 9e016bd..8b1f80c 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -1976,6 +1976,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/microblaze/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/libc.abilist
index 1a455be..d4db9a8 100644
--- a/sysdeps/unix/sysv/linux/microblaze/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/libc.abilist
@@ -2097,3 +2097,8 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index 8eb5e66..f430bdb 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -1951,6 +1951,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index 416d9ac..a4dca19 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -1949,6 +1949,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index f4949e5..0814fa8 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -1947,6 +1947,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index c7375ae..a0bdeff 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -1942,6 +1942,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index 724a0e3..b201290 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2138,3 +2138,8 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 2dc32b6..6e7ff24 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -1980,6 +1980,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index 5658109..19c7c7d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -1985,6 +1985,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
index c761221..e94ce38 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
@@ -2185,3 +2185,8 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
index 265c769..f3daa33 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
@@ -99,6 +99,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 _Exit F
 GLIBC_2.3 _IO_2_1_stderr_ D 0xe0
diff --git a/sysdeps/unix/sysv/linux/preadv.c b/sysdeps/unix/sysv/linux/preadv.c
index ccfe763..a3c8aec 100644
--- a/sysdeps/unix/sysv/linux/preadv.c
+++ b/sysdeps/unix/sysv/linux/preadv.c
@@ -50,4 +50,6 @@ preadv (int fd, const struct iovec *vector, int count, off_t offset)
 #  define OFF_T off_t
 #  include <sysdeps/posix/preadv.c>
 # endif /* __ASSUME_PREADV  */
+
+libc_hidden_def (preadv)
 #endif
diff --git a/sysdeps/unix/sysv/linux/preadv2.c b/sysdeps/unix/sysv/linux/preadv2.c
new file mode 100644
index 0000000..0e28015
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/preadv2.c
@@ -0,0 +1,51 @@
+/* Linux implementation of preadv2.
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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 <sys/uio.h>
+#include <sysdep-cancel.h>
+
+#ifndef __OFF_T_MATCHES_OFF64_T
+
+# if !defined (__NR_preadv2) && defined (__NR_pread64v2)
+#  define __NR_preadv2 __NR_pread64v2
+# endif
+
+ssize_t
+preadv2 (int fd, const struct iovec *vector, int count, off_t offset,
+	 int flags)
+{
+# ifdef __NR_preadv2
+  ssize_t result = SYSCALL_CANCEL (preadv2, fd, vector, count,
+				   LO_HI_LONG (offset), flags);
+  if (result >= 0 || errno != ENOSYS)
+    return result;
+# endif
+  /* Trying to emulate the preadv2 syscall flags is troublesome:
+
+     * We can not temporary change the file state of the O_DSYNC and O_SYNC
+       flags to emulate RWF_{D}SYNC (attempts to change the state of using
+       fcntl silently ignored).
+
+     * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal
+       semantic not provided by any other flag (O_NONBLOCK for instance).
+
+     So for generic case just ignore the flags can call preadv directly.  */
+  return preadv (fd, vector, count, offset);
+}
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/preadv64.c b/sysdeps/unix/sysv/linux/preadv64.c
index 979db95..448dc17 100644
--- a/sysdeps/unix/sysv/linux/preadv64.c
+++ b/sysdeps/unix/sysv/linux/preadv64.c
@@ -48,7 +48,9 @@ preadv64 (int fd, const struct iovec *vector, int count, off64_t offset)
 # define OFF_T off64_t
 # include <sysdeps/posix/preadv.c>
 #endif
+libc_hidden_def (preadv64)
 
 #ifdef __OFF_T_MATCHES_OFF64_T
 strong_alias (preadv64, preadv)
+libc_hidden_def (preadv)
 #endif
diff --git a/sysdeps/unix/sysv/linux/preadv64v2.c b/sysdeps/unix/sysv/linux/preadv64v2.c
new file mode 100644
index 0000000..64afb05
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/preadv64v2.c
@@ -0,0 +1,51 @@
+/* Linux implementation of preadv2 (LFS version).
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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 <sys/uio.h>
+#include <sysdep-cancel.h>
+
+#if !defined(__NR_preadv64v2) && defined(__NR_preadv2)
+# define __NR_preadv64v2 __NR_preadv2
+#endif
+
+ssize_t
+preadv64v2 (int fd, const struct iovec *vector, int count, off64_t offset,
+	    int flags)
+{
+#ifdef __NR_preadv64v2
+  ssize_t result = SYSCALL_CANCEL (preadv64v2, fd, vector, count,
+				   LO_HI_LONG (offset), flags);
+  if (result >= 0 || errno != ENOSYS)
+    return result;
+#endif
+  /* Trying to emulate the preadv2 syscall flags is troublesome:
+
+     * We can not temporary change the file state of the O_DSYNC and O_SYNC
+       flags to emulate RWF_{D}SYNC (attempts to change the state of using
+       fcntl silently ignored).
+
+     * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal
+       semantic not provided by any other flag (O_NONBLOCK for instance).
+
+     So for generic case just ignore the flags can call preadv directly.  */
+  return preadv64 (fd, vector, count, offset);
+}
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+strong_alias (preadv64v2, preadv2)
+#endif
diff --git a/sysdeps/unix/sysv/linux/pwrite64.c b/sysdeps/unix/sysv/linux/pwrite64.c
index 57e5d20..71959c0 100644
--- a/sysdeps/unix/sysv/linux/pwrite64.c
+++ b/sysdeps/unix/sysv/linux/pwrite64.c
@@ -28,6 +28,7 @@ __libc_pwrite64 (int fd, const void *buf, size_t count, off64_t offset)
 {
   return SYSCALL_CANCEL (pwrite64, fd, buf, count, SYSCALL_LL64_PRW (offset));
 }
+
 weak_alias (__libc_pwrite64, __pwrite64)
 libc_hidden_weak (__pwrite64)
 weak_alias (__libc_pwrite64, pwrite64)
diff --git a/sysdeps/unix/sysv/linux/pwritev.c b/sysdeps/unix/sysv/linux/pwritev.c
index 2789943..c91c248 100644
--- a/sysdeps/unix/sysv/linux/pwritev.c
+++ b/sysdeps/unix/sysv/linux/pwritev.c
@@ -50,4 +50,6 @@ pwritev (int fd, const struct iovec *vector, int count, off_t offset)
 #  define OFF_T off_t
 #  include <sysdeps/posix/pwritev.c>
 # endif /* __ASSUME_PREADV  */
+
+libc_hidden_def (pwritev)
 #endif
diff --git a/sysdeps/unix/sysv/linux/pwritev2.c b/sysdeps/unix/sysv/linux/pwritev2.c
new file mode 100644
index 0000000..176c038
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/pwritev2.c
@@ -0,0 +1,47 @@
+/* Linux implementation of pwritev2.
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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 <sys/uio.h>
+#include <sysdep-cancel.h>
+
+#ifndef __OFF_T_MATCHES_OFF64_T
+
+ssize_t
+pwritev2 (int fd, const struct iovec *vector, int count, off_t offset,
+	  int flags)
+{
+# ifdef __NR_pwritev2
+  ssize_t result = SYSCALL_CANCEL (pwritev2, fd, vector, count,
+				   LO_HI_LONG (offset), flags);
+  if (result >= 0 || errno != ENOSYS)
+    return result;
+# endif
+  /* Trying to emulate the pwritev2 syscall flags is troublesome:
+
+     * We can not temporary change the file state of the O_DSYNC and O_SYNC
+       flags to emulate RWF_{D}SYNC (attempts to change the state of using
+       fcntl silently ignored).
+
+     * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal
+       semantic not provided by any other flag (O_NONBLOCK for instance).
+
+     So for generic case just ignore the flags can call pwritev directly.  */
+  return pwritev (fd, vector, count, offset);
+}
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/pwritev64.c b/sysdeps/unix/sysv/linux/pwritev64.c
index 1e3a36c..b236df3 100644
--- a/sysdeps/unix/sysv/linux/pwritev64.c
+++ b/sysdeps/unix/sysv/linux/pwritev64.c
@@ -48,7 +48,9 @@ pwritev64 (int fd, const struct iovec *vector, int count, off64_t offset)
 # define OFF_T off64_t
 # include <sysdeps/posix/pwritev.c>
 #endif
+libc_hidden_def (pwritev64)
 
 #ifdef __OFF_T_MATCHES_OFF64_T
 strong_alias (pwritev64, pwritev)
+libc_hidden_def (pwritev)
 #endif
diff --git a/sysdeps/unix/sysv/linux/pwritev64v2.c b/sysdeps/unix/sysv/linux/pwritev64v2.c
new file mode 100644
index 0000000..01d0c89
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/pwritev64v2.c
@@ -0,0 +1,51 @@
+/* Linux implementation of pwritev2 (LFS version).
+   Copyright (C) 2017 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 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
+   Lesser General Public License for more details.
+
+   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 <sys/uio.h>
+#include <sysdep-cancel.h>
+
+#if !defined(__NR_pwritev64v2) && defined(__NR_pwritev2)
+# define __NR_pwritev64v2 __NR_pwritev2
+#endif
+
+ssize_t
+pwritev64v2 (int fd, const struct iovec *vector, int count, off64_t offset,
+	     int flags)
+{
+#ifdef __NR_pwritev64v2
+  ssize_t result = SYSCALL_CANCEL (pwritev64v2, fd, vector, count,
+				   LO_HI_LONG (offset), flags);
+  if (result >= 0 || errno != ENOSYS)
+    return result;
+#endif
+  /* Trying to emulate the pwritev2 syscall flags is troublesome:
+
+     * We can not temporary change the file state of the O_DSYNC and O_SYNC
+       flags to emulate RWF_{D}SYNC (attempts to change the state of using
+       fcntl silently ignored).
+
+     * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal
+       semantic not provided by any other flag (O_NONBLOCK for instance).
+
+     So for generic case just ignore the flags can call pwritev directly.  */
+  return pwritev64 (fd, vector, count, offset);
+}
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+strong_alias (pwritev64v2, pwritev2)
+#endif
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index ed1b6bf..eb9e72f 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -1980,6 +1980,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index 2e75d29..1402959 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -1881,6 +1881,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/sh/libc.abilist b/sysdeps/unix/sysv/linux/sh/libc.abilist
index bd74c0c..e9eefcb 100644
--- a/sysdeps/unix/sysv/linux/sh/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/libc.abilist
@@ -1866,6 +1866,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index 5584838..967699e 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -1972,6 +1972,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index efedbe2..9dd938a 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -1910,6 +1910,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist
index ffd988a..68c9887 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist
@@ -2104,3 +2104,8 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
diff --git a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
index f0c13ce..97aa0f7 100644
--- a/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
@@ -2104,3 +2104,8 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
diff --git a/sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist b/sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist
index ffd988a..68c9887 100644
--- a/sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist
+++ b/sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist
@@ -2104,3 +2104,8 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index f57004c..2032659 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -1861,6 +1861,11 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
 GLIBC_2.3 GLIBC_2.3 A
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 05629e1..11a278c 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2104,3 +2104,8 @@ GLIBC_2.25 getrandom F
 GLIBC_2.25 strfromd F
 GLIBC_2.25 strfromf F
 GLIBC_2.25 strfroml F
+GLIBC_2.26 GLIBC_2.26 A
+GLIBC_2.26 preadv2 F
+GLIBC_2.26 preadv64v2 F
+GLIBC_2.26 pwritev2 F
+GLIBC_2.26 pwritev64v2 F
-- 
2.7.4

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] posix: Implement preadv2 and pwritev2
  2017-04-27 21:31 ` [PATCH 4/4] posix: Implement preadv2 and pwritev2 Adhemerval Zanella
@ 2017-04-27 22:30   ` Joseph Myers
  2017-04-28 13:58     ` Adhemerval Zanella
  2017-04-28 14:14   ` Zack Weinberg
  1 sibling, 1 reply; 17+ messages in thread
From: Joseph Myers @ 2017-04-27 22:30 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Thu, 27 Apr 2017, Adhemerval Zanella wrote:

> The Linux one uses the preadv2/pwritev2 syscall if defined, otherwise it
> call preadv/writev.  Instead of using the previous __ASSUME_* to
> unconditionally issue the syscall (and avoid building the fallback routine),
> it call pread/write if the preadv2/pwritev2 syscalls fails.  The idea
> is just avoid adding another __ASSUME_* and checking each architecture
> on every kernel bump and simplify code conditionals.

I think we should have the __ASSUME_*; it's how we track when code can be 
removed after an increase to the minimum supported kernel version (unless 
you have some other way of the community tracking code that will become 
obsolete after such a change).

What's the rationale for missing documentation for these functions?  That 
preadv and pwritev are also missing documentation?

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] posix: Implement preadv2 and pwritev2
  2017-04-27 22:30   ` Joseph Myers
@ 2017-04-28 13:58     ` Adhemerval Zanella
  2017-04-28 14:53       ` Joseph Myers
  0 siblings, 1 reply; 17+ messages in thread
From: Adhemerval Zanella @ 2017-04-28 13:58 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



On 27/04/2017 19:30, Joseph Myers wrote:
> On Thu, 27 Apr 2017, Adhemerval Zanella wrote:
> 
>> The Linux one uses the preadv2/pwritev2 syscall if defined, otherwise it
>> call preadv/writev.  Instead of using the previous __ASSUME_* to
>> unconditionally issue the syscall (and avoid building the fallback routine),
>> it call pread/write if the preadv2/pwritev2 syscalls fails.  The idea
>> is just avoid adding another __ASSUME_* and checking each architecture
>> on every kernel bump and simplify code conditionals.
> 
> I think we should have the __ASSUME_*; it's how we track when code can be 
> removed after an increase to the minimum supported kernel version (unless 
> you have some other way of the community tracking code that will become 
> obsolete after such a change).

My objection to __ASSUME_* is it adds more different possible build modes
which won't get actively tested unless you explicit adds a minimum kernel
option on build time.  And which different __ASSUME_* enabled by different
kernel version it would require different build with multiple different
enabled minimum kernel version to get all the coverage to check for all
permutations.  I think we can add an explicit comment and keep track based
on this, since with minimum kernel increase it will be eventually dead code.

> 
> What's the rationale for missing documentation for these functions?  That 
> preadv and pwritev are also missing documentation?
> 

None, it was a overlook from my part.  I will add the documentation and resend
the patch.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] posix: Implement preadv2 and pwritev2
  2017-04-27 21:31 ` [PATCH 4/4] posix: Implement preadv2 and pwritev2 Adhemerval Zanella
  2017-04-27 22:30   ` Joseph Myers
@ 2017-04-28 14:14   ` Zack Weinberg
  2017-04-28 14:30     ` Adhemerval Zanella
  1 sibling, 1 reply; 17+ messages in thread
From: Zack Weinberg @ 2017-04-28 14:14 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: GNU C Library

On Thu, Apr 27, 2017 at 5:30 PM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
> On default 'posix' implementation trying to emulate the Linux supported
> flags is troublesome:
>
>    * We can not temporary change the file state of the O_DSYNC and O_SYNC
>      flags to emulate RWF_{D}SYNC (attempts to change the state of using
>      fcntl are silently ignored).
>
>    * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal
>      semantic not provided by any other flag (O_NONBLOCK for instance).
>
> So default implementation just ignore the flag argument and calls generic
> preadv/pwritev.

Wouldn't it be better for the default implementation to fail if the
flags argument is nonzero?  Especially for sync operations - if it
fails, applications can fall back to fsync or whatever, but if it
succeeds without actually performing a sync, that's asking for data
loss.

zw

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] posix: Implement preadv2 and pwritev2
  2017-04-28 14:14   ` Zack Weinberg
@ 2017-04-28 14:30     ` Adhemerval Zanella
  2017-04-28 15:33       ` Zack Weinberg
  0 siblings, 1 reply; 17+ messages in thread
From: Adhemerval Zanella @ 2017-04-28 14:30 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: GNU C Library



On 28/04/2017 11:14, Zack Weinberg wrote:
> On Thu, Apr 27, 2017 at 5:30 PM, Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>>
>> On default 'posix' implementation trying to emulate the Linux supported
>> flags is troublesome:
>>
>>    * We can not temporary change the file state of the O_DSYNC and O_SYNC
>>      flags to emulate RWF_{D}SYNC (attempts to change the state of using
>>      fcntl are silently ignored).
>>
>>    * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal
>>      semantic not provided by any other flag (O_NONBLOCK for instance).
>>
>> So default implementation just ignore the flag argument and calls generic
>> preadv/pwritev.
> 
> Wouldn't it be better for the default implementation to fail if the
> flags argument is nonzero?  Especially for sync operations - if it
> fails, applications can fall back to fsync or whatever, but if it
> succeeds without actually performing a sync, that's asking for data
> loss.
> 
> zw

I think it is a reasonable change, although I think it will make preadv2
fallback fails in all the usable scenarios.  However it is might be a 
hint to programmer that libc does not actually supports it.  Would be
better to just return ENOSYS then? 

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] posix: Implement preadv2 and pwritev2
  2017-04-28 13:58     ` Adhemerval Zanella
@ 2017-04-28 14:53       ` Joseph Myers
  2017-04-28 16:18         ` Adhemerval Zanella
  0 siblings, 1 reply; 17+ messages in thread
From: Joseph Myers @ 2017-04-28 14:53 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Fri, 28 Apr 2017, Adhemerval Zanella wrote:

> My objection to __ASSUME_* is it adds more different possible build modes
> which won't get actively tested unless you explicit adds a minimum kernel
> option on build time.  And which different __ASSUME_* enabled by different
> kernel version it would require different build with multiple different
> enabled minimum kernel version to get all the coverage to check for all
> permutations.  I think we can add an explicit comment and keep track based
> on this, since with minimum kernel increase it will be eventually dead code.

Well, such comments would all need to be in a central place (e.g. 
kernel-features.h) identifying the relevant versions, not scattered across 
the source tree.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] posix: Implement preadv2 and pwritev2
  2017-04-28 14:30     ` Adhemerval Zanella
@ 2017-04-28 15:33       ` Zack Weinberg
  2017-04-28 16:19         ` Adhemerval Zanella
  0 siblings, 1 reply; 17+ messages in thread
From: Zack Weinberg @ 2017-04-28 15:33 UTC (permalink / raw)
  To: Adhemerval Zanella, GNU C Library

On Fri, Apr 28, 2017 at 10:29 AM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
> On 28/04/2017 11:14, Zack Weinberg wrote:
>>
>> Wouldn't it be better for the default implementation to fail if the
>> flags argument is nonzero?  Especially for sync operations - if it
>> fails, applications can fall back to fsync or whatever, but if it
>> succeeds without actually performing a sync, that's asking for data
>> loss.
>
> I think it is a reasonable change, although I think it will make preadv2
> fallback fails in all the usable scenarios.  However it is might be a
> hint to programmer that libc does not actually supports it.  Would be
> better to just return ENOSYS then?

I don't have a strong opinion here.  If we emulate where we can and
fail where we can't, though, that *might* provide a smoother upgrade
path when one of the targets that doesn't support it suddenly starts
supporting it.

zw

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] posix: Implement preadv2 and pwritev2
  2017-04-28 14:53       ` Joseph Myers
@ 2017-04-28 16:18         ` Adhemerval Zanella
  0 siblings, 0 replies; 17+ messages in thread
From: Adhemerval Zanella @ 2017-04-28 16:18 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha



> On 28 Apr 2017, at 11:53, Joseph Myers <joseph@codesourcery.com> wrote:
> 
>> On Fri, 28 Apr 2017, Adhemerval Zanella wrote:
>> 
>> My objection to __ASSUME_* is it adds more different possible build modes
>> which won't get actively tested unless you explicit adds a minimum kernel
>> option on build time.  And which different __ASSUME_* enabled by different
>> kernel version it would require different build with multiple different
>> enabled minimum kernel version to get all the coverage to check for all
>> permutations.  I think we can add an explicit comment and keep track based
>> on this, since with minimum kernel increase it will be eventually dead code.
> 
> Well, such comments would all need to be in a central place (e.g. 
> kernel-features.h) identifying the relevant versions, not scattered across 
> the source tree.

Right, I will add one on kernel-features.h with the information which kernel version is suppose to have preadv2 support (and any architecture difference as well).

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 4/4] posix: Implement preadv2 and pwritev2
  2017-04-28 15:33       ` Zack Weinberg
@ 2017-04-28 16:19         ` Adhemerval Zanella
  0 siblings, 0 replies; 17+ messages in thread
From: Adhemerval Zanella @ 2017-04-28 16:19 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: GNU C Library



> On 28 Apr 2017, at 12:33, Zack Weinberg <zackw@panix.com> wrote:
> 
> On Fri, Apr 28, 2017 at 10:29 AM, Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>> On 28/04/2017 11:14, Zack Weinberg wrote:
>>> 
>>> Wouldn't it be better for the default implementation to fail if the
>>> flags argument is nonzero?  Especially for sync operations - if it
>>> fails, applications can fall back to fsync or whatever, but if it
>>> succeeds without actually performing a sync, that's asking for data
>>> loss.
>> 
>> I think it is a reasonable change, although I think it will make preadv2
>> fallback fails in all the usable scenarios.  However it is might be a
>> hint to programmer that libc does not actually supports it.  Would be
>> better to just return ENOSYS then?
> 
> I don't have a strong opinion here.  If we emulate where we can and
> fail where we can't, though, that *might* provide a smoother upgrade
> path when one of the targets that doesn't support it suddenly starts
> supporting it.

Alright, it seems reasonable. I will update the patch with this modification.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 1/4] posix: Using libsupport for p{write,read}v tests
  2017-04-27 21:31 [PATCH 1/4] posix: Using libsupport for p{write,read}v tests Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2017-04-27 21:31 ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4* Adhemerval Zanella
@ 2017-05-01 14:59 ` Wainer dos Santos Moschetta
  3 siblings, 0 replies; 17+ messages in thread
From: Wainer dos Santos Moschetta @ 2017-05-01 14:59 UTC (permalink / raw)
  To: libc-alpha

LGTM.


On 27/04/2017 18:30, Adhemerval Zanella wrote:
> Checked on x86_64-linux-gnu.
>
> 	* misc/tst-preadvwritev-common.c (do_prepare): Use libsupport
> 	expected arguments.
> 	(do_test): Adapt to use libsupport.
> ---
>   ChangeLog                      |  6 ++++++
>   misc/tst-preadvwritev-common.c | 49 +++++++++++++++++++++---------------------
>   2 files changed, 30 insertions(+), 25 deletions(-)
>
> diff --git a/misc/tst-preadvwritev-common.c b/misc/tst-preadvwritev-common.c
> index 2943312..5540dfb 100644
> --- a/misc/tst-preadvwritev-common.c
> +++ b/misc/tst-preadvwritev-common.c
> @@ -16,31 +16,28 @@
>      License along with the GNU C Library; if not, see
>      <http://www.gnu.org/licenses/>.  */
>   
> +#include <stdio.h>
> +#include <stdint.h>
> +#include <string.h>
>   #include <sys/uio.h>
>   #include <sys/stat.h>
>   
> -static void do_prepare (void);
> -#define PREPARE(argc, argv)     do_prepare ()
> -static int do_test (void);
> -#define TEST_FUNCTION           do_test ()
> -#include "test-skeleton.c"
> +#include <support/check.h>
> +#include <support/temp_file.h>
>   
>   static char *temp_filename;
>   static int temp_fd;
>   
> +static int do_test (void);
> +
>   static void
> -do_prepare (void)
> +do_prepare (int argc, char **argv)
>   {
>     temp_fd = create_temp_file ("tst-preadvwritev.", &temp_filename);
>     if (temp_fd == -1)
> -    {
> -      printf ("cannot create temporary file: %m\n");
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("cannot create temporary file");
>   }
> -
> -#define FAIL(str) \
> -  do { printf ("error: %s (line %d)\n", str, __LINE__); return 1; } while (0)
> +#define PREPARE do_prepare
>   
>   static int
>   do_test_with_offset (off_t offset)
> @@ -63,15 +60,15 @@ do_test_with_offset (off_t offset)
>   
>     ret = pwritev (temp_fd, iov, 2, offset);
>     if (ret == -1)
> -    FAIL ("first pwritev returned -1");
> +    FAIL_RET ("first pwritev returned -1");
>     if (ret != (sizeof buf1 + sizeof buf2))
> -    FAIL ("first pwritev returned an unexpected value");
> +    FAIL_RET ("first pwritev returned an unexpected value");
>   
>     ret = pwritev (temp_fd, iov, 2, sizeof buf1 + sizeof buf2 + offset);
>     if (ret == -1)
> -    FAIL ("second pwritev returned -1");
> +    FAIL_RET ("second pwritev returned -1");
>     if (ret != (sizeof buf1 + sizeof buf2))
> -    FAIL ("second pwritev returned an unexpected value");
> +    FAIL_RET ("second pwritev returned an unexpected value");
>   
>     char buf3[32];
>     char buf4[64];
> @@ -87,26 +84,28 @@ do_test_with_offset (off_t offset)
>     /* Now read two buffer with 32 and 64 bytes respectively.  */
>     ret = preadv (temp_fd, iov, 2, offset);
>     if (ret == -1)
> -    FAIL ("first preadv returned -1");
> +    FAIL_RET ("first preadv returned -1");
>     if (ret != (sizeof buf3 + sizeof buf4))
> -    FAIL ("first preadv returned an unexpected value");
> +    FAIL_RET ("first preadv returned an unexpected value");
>   
>     if (memcmp (buf1, buf3, sizeof buf1) != 0)
> -    FAIL ("first buffer from first preadv different than expected");
> +    FAIL_RET ("first buffer from first preadv different than expected");
>     if (memcmp (buf2, buf4, sizeof buf2) != 0)
> -    FAIL ("second buffer from first preadv different than expected");
> +    FAIL_RET ("second buffer from first preadv different than expected");
>   
>     ret = preadv (temp_fd, iov, 2, sizeof buf3 + sizeof buf4 + offset);
>     if (ret == -1)
> -    FAIL ("second preadv returned -1");
> +    FAIL_RET ("second preadv returned -1");
>     if (ret != (sizeof buf3 + sizeof buf4))
> -    FAIL ("second preadv returned an unexpected value");
> +    FAIL_RET ("second preadv returned an unexpected value");
>   
>     /* And compare the buffers read and written to check if there are equal.  */
>     if (memcmp (buf1, buf3, sizeof buf1) != 0)
> -    FAIL ("first buffer from second preadv different than expected");
> +    FAIL_RET ("first buffer from second preadv different than expected");
>     if (memcmp (buf2, buf4, sizeof buf2) != 0)
> -    FAIL ("second buffer from second preadv different than expected");
> +    FAIL_RET ("second buffer from second preadv different than expected");
>   
>     return 0;
>   }
> +
> +#include <support/test-driver.c>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/4] nptl: Using libsupport for tst-cancel4
  2017-04-27 21:31 ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4* Adhemerval Zanella
@ 2017-05-01 15:31   ` Wainer dos Santos Moschetta
  2017-05-01 16:34     ` Adhemerval Zanella
  2017-05-01 17:18   ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4* Florian Weimer
  1 sibling, 1 reply; 17+ messages in thread
From: Wainer dos Santos Moschetta @ 2017-05-01 15:31 UTC (permalink / raw)
  To: libc-alpha



On 27/04/2017 18:30, Adhemerval Zanella wrote:
> Checked on x86_64-linux-gnu.
>
> 	* nptl/tst-cancel4-common.c: Use libsupport.
> 	* nptl/tst-cancel4-common.h: Likewise.
> 	* nptl/tst-cancel4.c (tf_read): Likewise.
> 	(tf_readv): Likewise.
> 	(tf_write): Likewise.
> 	(tf_writev): Likewise.
> 	(tf_sleep): Likewise.
> 	(tf_usleep): Likewise.
> 	(tf_nanosleep): Likewise.
> 	(tf_select): Likewise.
> 	(tf_pselect): Likewise.
> 	(tf_poll): Likewise.
> 	(tf_ppoll): Likewise.
> 	(tf_wait): Likewise.
> 	(tf_waitpid): Likewise.
> 	(tf_waitid): Likewise.
> 	(tf_sigpause): Likewise.
> 	(tf_sigsuspend): Likewise.
> 	(tf_sigwait): Likewise.
> 	(tf_sigwaitinfo): Likewise.
> 	(tf_sigtimedwait): Likewise.
> 	(tf_pause): Likewise.
> 	(tf_accept): Likewise.
> 	(tf_send): Likewise.
> 	(tf_recv): Likewise.
> 	(tf_recvfrom): Likewise.
> 	(tf_recvmsg): Likewise.
> 	(tf_open): Likewise.
> 	(tf_close): Likewise.
> 	(tf_pread): Likewise.
> 	(tf_pwrite): Likewise.
> 	(tf_preadv): Likewise.
> 	(tf_pwritev): Likewise.
> 	(tf_fsync): Likewise.
> 	(tf_fdatasync): Likewise.
> 	(tf_msync): Likewise.
> 	(tf_sendto): Likewise.
> 	(tf_sendmsg): Likewise.
> 	(tf_creat): Likewise.
> 	(tf_connect): Likewise.
> 	(tf_tcdrain): Likewise.
> 	(tf_msgrcv): Likewise.
> 	(tf_msgsnd): Likewise.
> 	* nptl/tst-cancel4_1.c (tf_sendmmsg): Likewise.
> 	* nptl/tst-cancel4_2.c (tf_recvmmsg): Likewise.
> ---
>   ChangeLog                 |  46 +++
>   nptl/tst-cancel4-common.c |   3 +-
>   nptl/tst-cancel4-common.h |   2 +
>   nptl/tst-cancel4.c        | 845 ++++++++++------------------------------------
>   nptl/tst-cancel4_1.c      |  33 +-
>   nptl/tst-cancel4_2.c      |  33 +-
>   6 files changed, 248 insertions(+), 714 deletions(-)
>
> diff --git a/nptl/tst-cancel4-common.c b/nptl/tst-cancel4-common.c
> index 3c57c99..eb32117 100644
> --- a/nptl/tst-cancel4-common.c
> +++ b/nptl/tst-cancel4-common.c
> @@ -259,5 +259,4 @@ do_test (void)
>   }
>   
>   #define TIMEOUT 60
> -#define TEST_FUNCTION do_test ()
> -#include "../test-skeleton.c"
> +#include <support/test-driver.c>
> diff --git a/nptl/tst-cancel4-common.h b/nptl/tst-cancel4-common.h
> index 1964564..ffec6c8 100644
> --- a/nptl/tst-cancel4-common.h
> +++ b/nptl/tst-cancel4-common.h
> @@ -19,6 +19,8 @@
>   
>   #include <pthread.h>
>   
> +#include <support/check.h>
> +
>   /* Pipe descriptors.  */
>   static int fds[2];
>   
> diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
> index 590ce0a..693c93f 100644
> --- a/nptl/tst-cancel4.c
> +++ b/nptl/tst-cancel4.c
> @@ -88,23 +88,17 @@ tf_read  (void *arg)
>         char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
>         tempfd = fd = mkstemp (fname);
>         if (fd == -1)
> -	printf ("%s: mkstemp failed\n", __FUNCTION__);
> +	FAIL_EXIT1 ("mkstemp failed: %m");
>         unlink (fname);
>   
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     ssize_t s;
>     pthread_cleanup_push (cl, NULL);
> @@ -114,9 +108,7 @@ tf_read  (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: read returns with %zd\n", __FUNCTION__, s);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("read returns with %zd", s);
>   }
>   
>   
> @@ -133,23 +125,17 @@ tf_readv  (void *arg)
>         char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
>         tempfd = fd = mkstemp (fname);
>         if (fd == -1)
> -	printf ("%s: mkstemp failed\n", __FUNCTION__);
> +	FAIL_EXIT1 ("mkstemp failed: %m");
>         unlink (fname);
>   
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     ssize_t s;
>     pthread_cleanup_push (cl, NULL);
> @@ -160,9 +146,7 @@ tf_readv  (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: readv returns with %zd\n", __FUNCTION__, s);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("readv returns with %zd", s);
>   }
>   
>   
> @@ -179,23 +163,17 @@ tf_write  (void *arg)
>         char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
>         tempfd = fd = mkstemp (fname);
>         if (fd == -1)
> -	printf ("%s: mkstemp failed\n", __FUNCTION__);
> +	FAIL_EXIT1 ("mkstemp failed: %m");
>         unlink (fname);
>   
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     ssize_t s;
>     pthread_cleanup_push (cl, NULL);
> @@ -206,9 +184,7 @@ tf_write  (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: write returns with %zd\n", __FUNCTION__, s);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("write returns with %zd", s);
>   }
>   
>   
> @@ -225,23 +201,17 @@ tf_writev  (void *arg)
>         char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
>         tempfd = fd = mkstemp (fname);
>         if (fd == -1)
> -	printf ("%s: mkstemp failed\n", __FUNCTION__);
> +	FAIL_EXIT1 ("mkstemp failed: %m");
>         unlink (fname);
>   
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     ssize_t s;
>     pthread_cleanup_push (cl, NULL);
> @@ -253,9 +223,7 @@ tf_writev  (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: writev returns with %zd\n", __FUNCTION__, s);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("writev returns with %zd", s);
>   }
>   
>   
> @@ -264,19 +232,13 @@ tf_sleep (void *arg)
>   {
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -285,9 +247,7 @@ tf_sleep (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: sleep returns\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("sleep returns");
>   }
>   
>   
> @@ -296,19 +256,13 @@ tf_usleep (void *arg)
>   {
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -317,9 +271,7 @@ tf_usleep (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: usleep returns\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("usleep returns");
>   }
>   
>   
> @@ -328,19 +280,13 @@ tf_nanosleep (void *arg)
>   {
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -350,9 +296,7 @@ tf_nanosleep (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: nanosleep returns\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("nanosleep returns");
>   }
>   
>   
> @@ -369,23 +313,17 @@ tf_select (void *arg)
>         char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
>         tempfd = fd = mkstemp (fname);
>         if (fd == -1)
> -	printf ("%s: mkstemp failed\n", __FUNCTION__);
> +	FAIL_EXIT1 ("mkstemp");
>         unlink (fname);
>   
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     fd_set rfs;
>     FD_ZERO (&rfs);
> @@ -398,10 +336,7 @@ tf_select (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: select returns with %d (%s)\n", __FUNCTION__, s,
> -	  strerror (errno));
> -
> -  exit (1);
> +  FAIL_EXIT1 ("select returns with %d: %m", s);
>   }
>   
>   
> @@ -418,23 +353,17 @@ tf_pselect (void *arg)
>         char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
>         tempfd = fd = mkstemp (fname);
>         if (fd == -1)
> -	printf ("%s: mkstemp failed\n", __FUNCTION__);
> +	FAIL_EXIT1 ("mkstemp");

Perhaps use...

FAIL_EXIT1 ("mkstemp failed: %m");

... like in many occurrences above. Or perhaps use:

FAIL_EXIT1 ("mkstemp: %m");

Unless the error string isn't important.

>         unlink (fname);
>   
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     fd_set rfs;
>     FD_ZERO (&rfs);
> @@ -447,10 +376,7 @@ tf_pselect (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: pselect returns with %d (%s)\n", __FUNCTION__, s,
> -	  strerror (errno));
> -
> -  exit (1);
> +  FAIL_EXIT1 ("pselect returns with %d: %m", s);
>   }
>   
>   
> @@ -467,23 +393,17 @@ tf_poll (void *arg)
>         char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
>         tempfd = fd = mkstemp (fname);
>         if (fd == -1)
> -	printf ("%s: mkstemp failed\n", __FUNCTION__);
> +	FAIL_EXIT1 ("mkstemp");

Likewise.

>         unlink (fname);
>   
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } };
>   
> @@ -494,10 +414,7 @@ tf_poll (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: poll returns with %d (%s)\n", __FUNCTION__, s,
> -	  strerror (errno));
> -
> -  exit (1);
> +  FAIL_EXIT1 ("poll returns with %d: %m", s);
>   }
>   
>   
> @@ -514,23 +431,17 @@ tf_ppoll (void *arg)
>         char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
>         tempfd = fd = mkstemp (fname);
>         if (fd == -1)
> -	printf ("%s: mkstemp failed\n", __FUNCTION__);
> +	FAIL_EXIT1 ("mkstemp");

Likewise.

>         unlink (fname);
>   
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     struct pollfd rfs[1] = { [0] = { .fd = fd, .events = POLLIN } };
>   
> @@ -541,10 +452,7 @@ tf_ppoll (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: ppoll returns with %d (%s)\n", __FUNCTION__, s,
> -	  strerror (errno));
> -
> -  exit (1);
> +  FAIL_EXIT1 ("ppoll returns with %d: %m", s);
>   }
>   
>   
> @@ -553,10 +461,7 @@ tf_wait (void *arg)
>   {
>     pid_t pid = fork ();
>     if (pid == -1)
> -    {
> -      puts ("fork failed");
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("fork: %m");
>   
>     if (pid == 0)
>       {
> @@ -575,18 +480,12 @@ tf_wait (void *arg)
>   
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     int s;
>     pthread_cleanup_push (cl, NULL);
> @@ -595,23 +494,16 @@ tf_wait (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: wait returns with %d (%s)\n", __FUNCTION__, s,
> -	  strerror (errno));
> -
> -  exit (1);
> +  FAIL_EXIT1 ("wait returns with %d: %m", s);
>   }
>   
>   
>   static void *
>   tf_waitpid (void *arg)
>   {
> -
>     pid_t pid = fork ();
>     if (pid == -1)
> -    {
> -      puts ("fork failed");
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("fork: %m");
>   
>     if (pid == 0)
>       {
> @@ -630,30 +522,21 @@ tf_waitpid (void *arg)
>   
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     int s;
> - pthread_cleanup_push (cl, NULL);
> +  pthread_cleanup_push (cl, NULL);
>   
>     s = waitpid (-1, NULL, 0);
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: waitpid returns with %d (%s)\n", __FUNCTION__, s,
> -	  strerror (errno));
> -
> -  exit (1);
> +  FAIL_EXIT1 ("waitpid returns with %d: %m", s);
>   }
>   
>   
> @@ -662,10 +545,7 @@ tf_waitid (void *arg)
>   {
>     pid_t pid = fork ();
>     if (pid == -1)
> -    {
> -      puts ("fork failed");
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("fork: %m");
>   
>     if (pid == 0)
>       {
> @@ -684,18 +564,12 @@ tf_waitid (void *arg)
>   
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     int s;
>     pthread_cleanup_push (cl, NULL);
> @@ -708,10 +582,7 @@ tf_waitid (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: waitid returns with %d (%s)\n", __FUNCTION__, s,
> -	  strerror (errno));
> -
> -  exit (1);
> +  FAIL_EXIT1 ("waitid returns with %di: %m", s);
>   }
>   
>   
> @@ -720,19 +591,13 @@ tf_sigpause (void *arg)
>   {
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -741,9 +606,7 @@ tf_sigpause (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: sigpause returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("sigpause returned");
>   }
>   
>   
> @@ -752,19 +615,13 @@ tf_sigsuspend (void *arg)
>   {
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -776,9 +633,7 @@ tf_sigsuspend (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: sigsuspend returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("sigsuspend returned");
>   }
>   
>   
> @@ -787,19 +642,13 @@ tf_sigwait (void *arg)
>   {
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     /* Block SIGUSR1.  */
> @@ -807,10 +656,7 @@ tf_sigwait (void *arg)
>     sigemptyset (&mask);
>     sigaddset (&mask, SIGUSR1);
>     if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
> -    {
> -      printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_sigmask");
>   
>     int sig;
>     pthread_cleanup_push (cl, NULL);
> @@ -820,9 +666,7 @@ tf_sigwait (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: sigwait returned with signal %d\n", __FUNCTION__, sig);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("sigwait returned with signal %d", sig);
>   }
>   
>   
> @@ -831,19 +675,13 @@ tf_sigwaitinfo (void *arg)
>   {
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     /* Block SIGUSR1.  */
> @@ -851,10 +689,7 @@ tf_sigwaitinfo (void *arg)
>     sigemptyset (&mask);
>     sigaddset (&mask, SIGUSR1);
>     if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
> -    {
> -      printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_sigmask");
>   
>     siginfo_t info;
>     pthread_cleanup_push (cl, NULL);
> @@ -864,10 +699,7 @@ tf_sigwaitinfo (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: sigwaitinfo returned with signal %d\n", __FUNCTION__,
> -	  info.si_signo);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("sigwaitinfo returned with signal %d", info.si_signo);
>   }
>   
>   
> @@ -876,19 +708,13 @@ tf_sigtimedwait (void *arg)
>   {
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     /* Block SIGUSR1.  */
> @@ -896,10 +722,7 @@ tf_sigtimedwait (void *arg)
>     sigemptyset (&mask);
>     sigaddset (&mask, SIGUSR1);
>     if (pthread_sigmask (SIG_BLOCK, &mask, NULL) != 0)
> -    {
> -      printf ("%s: pthread_sigmask failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_sigmask");
>   
>     /* Wait for SIGUSR1.  */
>     siginfo_t info;
> @@ -910,10 +733,7 @@ tf_sigtimedwait (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: sigtimedwait returned with signal %d\n", __FUNCTION__,
> -	  info.si_signo);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("sigtimedwait returned with signal %d", info.si_signo);
>   }
>   
>   
> @@ -922,19 +742,13 @@ tf_pause (void *arg)
>   {
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -943,9 +757,7 @@ tf_pause (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: pause returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("pause returned");
>   }
>   
>   
> @@ -959,25 +771,18 @@ tf_accept (void *arg)
>   
>     tempfd = socket (AF_UNIX, pf, 0);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, %s, 0): %m", arg == NULL ? "SOCK_STREAM"
> +					       : "SOCK_DGRAM");
>   
>     int tries = 0;
>     do
>       {
>         if (++tries > 10)
> -	{
> -	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
> -	}
> +	FAIL_EXIT1 ("too many unsuccessful bind calls");

really want to exit here?

>   
>         strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-1-XXXXXX");
>         if (mktemp (sun.sun_path) == NULL)
> -	{
> -	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("cannot generate temp file name");
>   
>         sun.sun_family = AF_UNIX;
>       }
> @@ -993,19 +798,13 @@ tf_accept (void *arg)
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -1014,9 +813,7 @@ tf_accept (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: accept returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("accept returned");
>   }
>   
>   
> @@ -1027,25 +824,17 @@ tf_send (void *arg)
>   
>     tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: first socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
>   
>     int tries = 0;
>     do
>       {
>         if (++tries > 10)
> -	{
> -	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
> -	}
> +	FAIL_EXIT1 ("too many unsuccessful bind calls");
>   
>         strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX");
>         if (mktemp (sun.sun_path) == NULL)
> -	{
> -	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("cannot generate temp file name");
>   
>         sun.sun_family = AF_UNIX;
>       }
> @@ -1057,34 +846,22 @@ tf_send (void *arg)
>   
>     tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
>     if (tempfd2 == -1)
> -    {
> -      printf ("%s: second socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
>   
>     if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0)
> -    {
> -      printf ("%s: connect failed\n", __FUNCTION__);
> -      exit(1);
> -    }
> +    FAIL_EXIT1 ("connect: %m");
>   
>     unlink (sun.sun_path);
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -1096,9 +873,7 @@ tf_send (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: send returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("send returned");
>   }
>   
>   
> @@ -1109,25 +884,17 @@ tf_recv (void *arg)
>   
>     tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: first socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
>   
>     int tries = 0;
>     do
>       {
>         if (++tries > 10)
> -	{
> -	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
> -	}
> +	FAIL_EXIT1 ("too many unsuccessful bind calls");
>   
>         strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-3-XXXXXX");
>         if (mktemp (sun.sun_path) == NULL)
> -	{
> -	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("cannot generate temp file name");
>   
>         sun.sun_family = AF_UNIX;
>       }
> @@ -1139,34 +906,22 @@ tf_recv (void *arg)
>   
>     tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
>     if (tempfd2 == -1)
> -    {
> -      printf ("%s: second socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
>   
>     if (connect (tempfd2, (struct sockaddr *) &sun, sizeof (sun)) != 0)
> -    {
> -      printf ("%s: connect failed\n", __FUNCTION__);
> -      exit(1);
> -    }
> +    FAIL_EXIT1 ("connect: %m");
>   
>     unlink (sun.sun_path);
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -1177,9 +932,7 @@ tf_recv (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: recv returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("recv returned");
>   }
>   
>   
> @@ -1190,25 +943,17 @@ tf_recvfrom (void *arg)
>   
>     tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: first socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
>   
>     int tries = 0;
>     do
>       {
>         if (++tries > 10)
> -	{
> -	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
> -	}
> +	FAIL_EXIT1 ("too many unsuccessful bind calls");
>   
>         strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-4-XXXXXX");
>         if (mktemp (sun.sun_path) == NULL)
> -	{
> -	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("cannot generate temp file name");
>   
>         sun.sun_family = AF_UNIX;
>       }
> @@ -1220,26 +965,17 @@ tf_recvfrom (void *arg)
>   
>     tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
>     if (tempfd2 == -1)
> -    {
> -      printf ("%s: second socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -1252,9 +988,7 @@ tf_recvfrom (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: recvfrom returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("recvfrom returned");
>   }
>   
>   
> @@ -1265,25 +999,17 @@ tf_recvmsg (void *arg)
>   
>     tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: first socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
>   
>     int tries = 0;
>     do
>       {
>         if (++tries > 10)
> -	{
> -	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
> -	}
> +	FAIL_EXIT1 ("too many unsuccessful bind calls");
>   
>         strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-5-XXXXXX");
>         if (mktemp (sun.sun_path) == NULL)
> -	{
> -	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("cannot generate temp file name");
>   
>         sun.sun_family = AF_UNIX;
>       }
> @@ -1295,26 +1021,17 @@ tf_recvmsg (void *arg)
>   
>     tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
>     if (tempfd2 == -1)
> -    {
> -      printf ("%s: second socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -1336,9 +1053,7 @@ tf_recvmsg (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: recvmsg returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("recvmsg returned");
>   }
>   
>   static void *
> @@ -1348,27 +1063,18 @@ tf_open (void *arg)
>       {
>         fifofd = mkfifo (fifoname, S_IWUSR | S_IRUSR);
>         if (fifofd == -1)
> -	{
> -	  printf ("%s: mkfifo failed: %m\n", __func__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("mkfifo: %m");
>       }
>     else
>       {
>         int r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed: %m\n", __func__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: 2nd barrier_wait failed: %m\n", __func__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     pthread_cleanup_push (cl_fifo, NULL);
>   
> @@ -1376,9 +1082,7 @@ tf_open (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: open returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("open returned");
>   }
>   
>   
> @@ -1393,25 +1097,16 @@ tf_close (void *arg)
>     char fname[] = "/tmp/tst-cancel-fd-XXXXXX";
>     tempfd = mkstemp (fname);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: mkstemp failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("mkstemp");
>     unlink (fname);
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     pthread_cleanup_push (cl, NULL);
>   
> @@ -1419,9 +1114,7 @@ tf_close (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: close returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("close returned");
>   }
>   
>   
> @@ -1435,24 +1128,15 @@ tf_pread (void *arg)
>   
>     tempfd = open ("Makefile", O_RDONLY);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: cannot open Makefile\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     pthread_cleanup_push (cl, NULL);
>   
> @@ -1461,9 +1145,7 @@ tf_pread (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: pread returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("pread returned");
>   }
>   
>   
> @@ -1478,25 +1160,16 @@ tf_pwrite (void *arg)
>     char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
>     tempfd = mkstemp (fname);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: mkstemp failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("mkstemp");
>     unlink (fname);
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     pthread_cleanup_push (cl, NULL);
>   
> @@ -1505,9 +1178,7 @@ tf_pwrite (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: pwrite returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("pwrite returned");
>   }
>   
>   static void *
> @@ -1524,22 +1195,16 @@ tf_preadv (void *arg)
>     char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
>     tempfd = fd = mkstemp (fname);
>     if (fd == -1)
> -    printf ("%s: mkstemp failed\n", __FUNCTION__);
> +    FAIL_EXIT1 ("mkstemp");
>     unlink (fname);
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     ssize_t s;
>     pthread_cleanup_push (cl, NULL);
> @@ -1550,9 +1215,7 @@ tf_preadv (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: preadv returns with %zd\n", __FUNCTION__, s);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("preadv returns with %zd", s);
>   }
>   
>   static void *
> @@ -1569,22 +1232,16 @@ tf_pwritev (void *arg)
>     char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
>     tempfd = fd = mkstemp (fname);
>     if (fd == -1)
> -    printf ("%s: mkstemp failed\n", __FUNCTION__);
> +    FAIL_EXIT1 ("mkstemp");
>     unlink (fname);
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     ssize_t s;
>     pthread_cleanup_push (cl, NULL);
> @@ -1596,9 +1253,7 @@ tf_pwritev (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: pwritev returns with %zd\n", __FUNCTION__, s);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("pwritev returns with %zd", s);
>   }
>   
>   static void *
> @@ -1611,24 +1266,15 @@ tf_fsync (void *arg)
>   
>     tempfd = open ("Makefile", O_RDONLY);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: cannot open Makefile\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     pthread_cleanup_push (cl, NULL);
>   
> @@ -1636,9 +1282,7 @@ tf_fsync (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: fsync returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("fsync returned");
>   }
>   
>   
> @@ -1652,24 +1296,15 @@ tf_fdatasync (void *arg)
>   
>     tempfd = open ("Makefile", O_RDONLY);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: cannot open Makefile\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     pthread_cleanup_push (cl, NULL);
>   
> @@ -1677,9 +1312,7 @@ tf_fdatasync (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: fdatasync returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("fdatasync returned");
>   }
>   
>   
> @@ -1693,30 +1326,19 @@ tf_msync (void *arg)
>   
>     tempfd = open ("Makefile", O_RDONLY);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: cannot open Makefile\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
> +

Wondering if wouldn't better replace above block with TEST_VERIFY_EXIT.  
Many occurrences throughout this patch have such as pattern though.

>     void *p = mmap (NULL, 10, PROT_READ, MAP_SHARED, tempfd, 0);
>     if (p == MAP_FAILED)
> -    {
> -      printf ("%s: mmap failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("mmap (NULL, 10, PROT_READ, MAP_SHARED, ...): %m");

Likewise, etc..

>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     pthread_cleanup_push (cl, NULL);
>   
> @@ -1724,9 +1346,7 @@ tf_msync (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: msync returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("msync returned");
>   }
>   
>   
> @@ -1742,25 +1362,17 @@ tf_sendto (void *arg)
>   
>     tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: first socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
>   
>     int tries = 0;
>     do
>       {
>         if (++tries > 10)
> -	{
> -	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
> -	}
> +	FAIL_EXIT1 ("too many unsuccessful bind calls");
>   
>         strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-6-XXXXXX");
>         if (mktemp (sun.sun_path) == NULL)
> -	{
> -	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("cannot generate temp file name");
>   
>         sun.sun_family = AF_UNIX;
>       }
> @@ -1771,24 +1383,15 @@ tf_sendto (void *arg)
>   
>     tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
>     if (tempfd2 == -1)
> -    {
> -      printf ("%s: second socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     pthread_cleanup_push (cl, NULL);
>   
> @@ -1800,9 +1403,7 @@ tf_sendto (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: sendto returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("sendto returned");
>   }
>   
>   
> @@ -1818,25 +1419,17 @@ tf_sendmsg (void *arg)
>   
>     tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: first socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
>   
>     int tries = 0;
>     do
>       {
>         if (++tries > 10)
> -	{
> -	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
> -	}
> +	FAIL_EXIT1 ("too many unsuccessful bind calls");
>   
>         strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-7-XXXXXX");
>         if (mktemp (sun.sun_path) == NULL)
> -	{
> -	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("cannot generate temp file name");
>   
>         sun.sun_family = AF_UNIX;
>       }
> @@ -1847,24 +1440,15 @@ tf_sendmsg (void *arg)
>   
>     tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
>     if (tempfd2 == -1)
> -    {
> -      printf ("%s: second socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     pthread_cleanup_push (cl, NULL);
>   
> @@ -1886,9 +1470,7 @@ tf_sendmsg (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: sendmsg returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("sendmsg returned");
>   }
>   
>   
> @@ -1902,17 +1484,11 @@ tf_creat (void *arg)
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     pthread_cleanup_push (cl, NULL);
>   
> @@ -1920,9 +1496,7 @@ tf_creat (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: creat returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("creat returned");
>   }
>   
>   
> @@ -1938,25 +1512,17 @@ tf_connect (void *arg)
>   
>     tempfd = socket (AF_UNIX, SOCK_STREAM, 0);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: first socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
>   
>     int tries = 0;
>     do
>       {
>         if (++tries > 10)
> -	{
> -	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
> -	}
> +	FAIL_EXIT1 ("too many unsuccessful bind calls");
>   
>         strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-2-XXXXXX");
>         if (mktemp (sun.sun_path) == NULL)
> -	{
> -	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("cannot generate temp file name");
>   
>         sun.sun_family = AF_UNIX;
>       }
> @@ -1969,26 +1535,17 @@ tf_connect (void *arg)
>   
>     tempfd2 = socket (AF_UNIX, SOCK_STREAM, 0);
>     if (tempfd2 == -1)
> -    {
> -      printf ("%s: second socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_STREAM, 0): %m");
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -1997,9 +1554,7 @@ tf_connect (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: connect returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("connect returned");
>   }
>   
>   
> @@ -2013,19 +1568,13 @@ tf_tcdrain (void *arg)
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -2036,9 +1585,7 @@ tf_tcdrain (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: tcdrain returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("tcdrain returned");
>   }
>   
>   
> @@ -2047,26 +1594,17 @@ tf_msgrcv (void *arg)
>   {
>     tempmsg = msgget (IPC_PRIVATE, 0666 | IPC_CREAT);
>     if (tempmsg == -1)
> -    {
> -      printf ("%s: msgget failed: %s\n", __FUNCTION__, strerror (errno));
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("msgget (IPC_PRIVATE, 0666 | IPC_CREAT): %m");
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     ssize_t s;
> @@ -2092,11 +1630,9 @@ tf_msgrcv (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: msgrcv returned %zd with errno = %m\n", __FUNCTION__, s);
> -
>     msgctl (tempmsg, IPC_RMID, NULL);
>   
> -  exit (1);
> +  FAIL_EXIT1 ("msgrcv returned %zd", s);
>   }
>   
>   
> @@ -2110,24 +1646,15 @@ tf_msgsnd (void *arg)
>   
>     tempmsg = msgget (IPC_PRIVATE, 0666 | IPC_CREAT);
>     if (tempmsg == -1)
> -    {
> -      printf ("%s: msgget failed: %s\n", __FUNCTION__, strerror (errno));
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("msgget (IPC_PRIVATE, 0666 | IPC_CREAT): %m");
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     pthread_cleanup_push (cl, NULL);
>   
> @@ -2144,11 +1671,9 @@ tf_msgsnd (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: msgsnd returned\n", __FUNCTION__);
> -
>     msgctl (tempmsg, IPC_RMID, NULL);
>   
> -  exit (1);
> +  FAIL_EXIT1 ("msgsnd returned");
>   }
>   
>   
> diff --git a/nptl/tst-cancel4_1.c b/nptl/tst-cancel4_1.c
> index 05b5f7b..0f41965 100644
> --- a/nptl/tst-cancel4_1.c
> +++ b/nptl/tst-cancel4_1.c
> @@ -44,25 +44,17 @@ tf_sendmmsg (void *arg)
>   
>     tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: first socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
>   
>     int tries = 0;
>     do
>       {
>         if (++tries > 10)
> -	{
> -	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
> -	}
> +	FAIL_EXIT1 ("too many unsuccessful bind calls");
>   
>         strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-7-XXXXXX");
>         if (mktemp (sun.sun_path) == NULL)
> -	{
> -	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("cannot generate temp file name");
>   
>         sun.sun_family = AF_UNIX;
>       }
> @@ -73,24 +65,15 @@ tf_sendmmsg (void *arg)
>   
>     tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
>     if (tempfd2 == -1)
> -    {
> -      printf ("%s: second socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     pthread_cleanup_push (cl, NULL);
>   
> @@ -114,9 +97,7 @@ tf_sendmmsg (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: sendmmsg returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("sendmmsg returned");
>   }
>   
>   struct cancel_tests tests[] =
> diff --git a/nptl/tst-cancel4_2.c b/nptl/tst-cancel4_2.c
> index f7a8797..1158609 100644
> --- a/nptl/tst-cancel4_2.c
> +++ b/nptl/tst-cancel4_2.c
> @@ -39,25 +39,17 @@ tf_recvmmsg (void *arg)
>   
>     tempfd = socket (AF_UNIX, SOCK_DGRAM, 0);
>     if (tempfd == -1)
> -    {
> -      printf ("%s: first socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
>   
>     int tries = 0;
>     do
>       {
>         if (++tries > 10)
> -	{
> -	  printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
> -	}
> +	FAIL_EXIT1 ("too many unsuccessful bind calls");
>   
>         strcpy (sun.sun_path, "/tmp/tst-cancel4-socket-5-XXXXXX");
>         if (mktemp (sun.sun_path) == NULL)
> -	{
> -	  printf ("%s: cannot generate temp file name\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("cannot generate temp file name");
>   
>         sun.sun_family = AF_UNIX;
>       }
> @@ -69,26 +61,17 @@ tf_recvmmsg (void *arg)
>   
>     tempfd2 = socket (AF_UNIX, SOCK_DGRAM, 0);
>     if (tempfd2 == -1)
> -    {
> -      printf ("%s: second socket call failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("socket (AF_UNIX, SOCK_DGRAM, 0): %m");
>   
>     int r = pthread_barrier_wait (&b2);
>     if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -    {
> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -      exit (1);
> -    }
> +    FAIL_EXIT1 ("pthread_barrier_wait");
>   
>     if (arg != NULL)
>       {
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: 2nd barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }
>   
>     pthread_cleanup_push (cl, NULL);
> @@ -112,9 +95,7 @@ tf_recvmmsg (void *arg)
>   
>     pthread_cleanup_pop (0);
>   
> -  printf ("%s: recvmmsg returned\n", __FUNCTION__);
> -
> -  exit (1);
> +  FAIL_EXIT1 ("recvmmsg returned");
>   }
>   
>   struct cancel_tests tests[] =

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/4] nptl: Using libsupport for tst-cancel4
  2017-05-01 15:31   ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4 Wainer dos Santos Moschetta
@ 2017-05-01 16:34     ` Adhemerval Zanella
  0 siblings, 0 replies; 17+ messages in thread
From: Adhemerval Zanella @ 2017-05-01 16:34 UTC (permalink / raw)
  To: libc-alpha

On 01/05/2017 12:31, Wainer dos Santos Moschetta wrote:
>> -      strerror (errno));
>> -
>> -  exit (1);
>> +  FAIL_EXIT1 ("select returns with %d: %m", s);
>>   }
>>     @@ -418,23 +353,17 @@ tf_pselect (void *arg)
>>         char fname[] = "/tmp/tst-cancel4-fd-XXXXXX";
>>         tempfd = fd = mkstemp (fname);
>>         if (fd == -1)
>> -    printf ("%s: mkstemp failed\n", __FUNCTION__);
>> +    FAIL_EXIT1 ("mkstemp");
> 
> Perhaps use...
> 
> FAIL_EXIT1 ("mkstemp failed: %m");
> 
> ... like in many occurrences above. Or perhaps use:
> 
> FAIL_EXIT1 ("mkstemp: %m");
> 
> Unless the error string isn't important.

Ack, I will use the first definition for consistency.


>> @@ -943,9 +757,7 @@ tf_pause (void *arg)
>>       pthread_cleanup_pop (0);
>>   -  printf ("%s: pause returned\n", __FUNCTION__);
>> -
>> -  exit (1);
>> +  FAIL_EXIT1 ("pause returned");
>>   }
>>     @@ -959,25 +771,18 @@ tf_accept (void *arg)
>>       tempfd = socket (AF_UNIX, pf, 0);
>>     if (tempfd == -1)
>> -    {
>> -      printf ("%s: socket call failed\n", __FUNCTION__);
>> -      exit (1);
>> -    }
>> +    FAIL_EXIT1 ("socket (AF_UNIX, %s, 0): %m", arg == NULL ? "SOCK_STREAM"
>> +                           : "SOCK_DGRAM");
>>       int tries = 0;
>>     do
>>       {
>>         if (++tries > 10)
>> -    {
>> -      printf ("%s: too many unsuccessful bind calls\n", __FUNCTION__);
>> -    }
>> +    FAIL_EXIT1 ("too many unsuccessful bind calls");
> 
> really want to exit here?

We need some fallback mechanism for the very unlikely case of having all the
files with the template name used on mkstemp already used to avoid an infinite
loop.  Usually 10 times should be suffice, since it should success on first
try.

>>   -  printf ("%s: fdatasync returned\n", __FUNCTION__);
>> -
>> -  exit (1);
>> +  FAIL_EXIT1 ("fdatasync returned");
>>   }
>>     @@ -1693,30 +1326,19 @@ tf_msync (void *arg)
>>       tempfd = open ("Makefile", O_RDONLY);
>>     if (tempfd == -1)
>> -    {
>> -      printf ("%s: cannot open Makefile\n", __FUNCTION__);
>> -      exit (1);
>> -    }
>> +    FAIL_EXIT1 ("open (\"Makefile\", O_RDONLY): %m");
>> +
> 
> Wondering if wouldn't better replace above block with TEST_VERIFY_EXIT.  Many occurrences throughout this patch have such as pattern though.

It really depends of what kind of error failure information we want to
inform.  FAIL_EXIT1 allows a variadic argument to allow more informative
strings, where TEST_VERIFY_EXIT just prints the 'stringification' of the
test passed as argument.  I think for mmap we may use, although for
open I prefer to still printing the resulting errno information (thorough
%m).

> 
>>     void *p = mmap (NULL, 10, PROT_READ, MAP_SHARED, tempfd, 0);
>>     if (p == MAP_FAILED)
>> -    {
>> -      printf ("%s: mmap failed\n", __FUNCTION__);
>> -      exit (1);
>> -    }
>> +    FAIL_EXIT1 ("mmap (NULL, 10, PROT_READ, MAP_SHARED, ...): %m");
> 
> Likewise, etc..

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/4] nptl: Using libsupport for tst-cancel4*
  2017-04-27 21:31 ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4* Adhemerval Zanella
  2017-05-01 15:31   ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4 Wainer dos Santos Moschetta
@ 2017-05-01 17:18   ` Florian Weimer
  2017-05-01 17:41     ` Adhemerval Zanella
  1 sibling, 1 reply; 17+ messages in thread
From: Florian Weimer @ 2017-05-01 17:18 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

On 04/27/2017 11:30 PM, Adhemerval Zanella wrote:
>         r = pthread_barrier_wait (&b2);
>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
> -	{
> -	  printf ("%s: barrier_wait failed\n", __FUNCTION__);
> -	  exit (1);
> -	}
> +	FAIL_EXIT1 ("pthread_barrier_wait");
>       }

Just a quick comment that we already have xpthread_barrier_wait and 
xmmap, so you could use them for error checking.  There are also strdup 
calls which should be xstrdup.

Thanks,
Florian

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH 2/4] nptl: Using libsupport for tst-cancel4*
  2017-05-01 17:18   ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4* Florian Weimer
@ 2017-05-01 17:41     ` Adhemerval Zanella
  0 siblings, 0 replies; 17+ messages in thread
From: Adhemerval Zanella @ 2017-05-01 17:41 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha



On 01/05/2017 14:18, Florian Weimer wrote:
> On 04/27/2017 11:30 PM, Adhemerval Zanella wrote:
>>         r = pthread_barrier_wait (&b2);
>>         if (r != 0 && r != PTHREAD_BARRIER_SERIAL_THREAD)
>> -    {
>> -      printf ("%s: barrier_wait failed\n", __FUNCTION__);
>> -      exit (1);
>> -    }
>> +    FAIL_EXIT1 ("pthread_barrier_wait");
>>       }
> 
> Just a quick comment that we already have xpthread_barrier_wait and xmmap, so you could use them for error checking.  There are also strdup calls which should be xstrdup.

Right, I will change to use them.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-05-01 17:41 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-27 21:31 [PATCH 1/4] posix: Using libsupport for p{write,read}v tests Adhemerval Zanella
2017-04-27 21:31 ` [PATCH 3/4] posix: Fix internal p{read,write} plt usage Adhemerval Zanella
2017-04-27 21:31 ` [PATCH 4/4] posix: Implement preadv2 and pwritev2 Adhemerval Zanella
2017-04-27 22:30   ` Joseph Myers
2017-04-28 13:58     ` Adhemerval Zanella
2017-04-28 14:53       ` Joseph Myers
2017-04-28 16:18         ` Adhemerval Zanella
2017-04-28 14:14   ` Zack Weinberg
2017-04-28 14:30     ` Adhemerval Zanella
2017-04-28 15:33       ` Zack Weinberg
2017-04-28 16:19         ` Adhemerval Zanella
2017-04-27 21:31 ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4* Adhemerval Zanella
2017-05-01 15:31   ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4 Wainer dos Santos Moschetta
2017-05-01 16:34     ` Adhemerval Zanella
2017-05-01 17:18   ` [PATCH 2/4] nptl: Using libsupport for tst-cancel4* Florian Weimer
2017-05-01 17:41     ` Adhemerval Zanella
2017-05-01 14:59 ` [PATCH 1/4] posix: Using libsupport for p{write,read}v tests Wainer dos Santos Moschetta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).