diff mbox series

[06/14] Consolidate non cancellable writev call

Message ID 1501765874-6201-7-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show
Series None | expand

Commit Message

Adhemerval Zanella Netto Aug. 3, 2017, 1:11 p.m. UTC
This patch consolidates all the non cancellable writev calls to use
the __writev_nocancel identifier.  For non cancellable targets it will
be just a macro to call the default respective symbol while on Linux
will be a internal one.

Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu.

	* gmon/gmon.c (write_hist): Replace writev_not_cancel_no_status with
	__writev_nocancel_nostatus.
	(write_call_graph): Likewise.
	(write_bb_counts): Likewise.
	* resolv/herror.c (herror): Likewise.
	* sysdeps/generic/not-cancel.h (writev_not_cancel_no_status): Remove
	macro.
	(__writev_nocancel_nostatus): New macro.
	* sysdeps/unix/sysv/linux/not-cancel.h (writev_not_cancel_no_status):
	Remove macro.
	(__writev_nocancel_nostatus): New function.
---
 ChangeLog                            | 12 ++++++++++++
 gmon/gmon.c                          | 12 ++++++------
 resolv/herror.c                      |  2 +-
 sysdeps/generic/not-cancel.h         |  2 +-
 sysdeps/unix/sysv/linux/not-cancel.h | 12 ++++++++----
 5 files changed, 28 insertions(+), 12 deletions(-)

-- 
2.7.4

Comments

Adhemerval Zanella Netto Aug. 21, 2017, 2:37 p.m. UTC | #1
Since this is a refactor, if no one opposes I will commit it shortly.

On 03/08/2017 10:11, Adhemerval Zanella wrote:
> This patch consolidates all the non cancellable writev calls to use

> the __writev_nocancel identifier.  For non cancellable targets it will

> be just a macro to call the default respective symbol while on Linux

> will be a internal one.

> 

> Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu.

> 

> 	* gmon/gmon.c (write_hist): Replace writev_not_cancel_no_status with

> 	__writev_nocancel_nostatus.

> 	(write_call_graph): Likewise.

> 	(write_bb_counts): Likewise.

> 	* resolv/herror.c (herror): Likewise.

> 	* sysdeps/generic/not-cancel.h (writev_not_cancel_no_status): Remove

> 	macro.

> 	(__writev_nocancel_nostatus): New macro.

> 	* sysdeps/unix/sysv/linux/not-cancel.h (writev_not_cancel_no_status):

> 	Remove macro.

> 	(__writev_nocancel_nostatus): New function.

> ---

>  ChangeLog                            | 12 ++++++++++++

>  gmon/gmon.c                          | 12 ++++++------

>  resolv/herror.c                      |  2 +-

>  sysdeps/generic/not-cancel.h         |  2 +-

>  sysdeps/unix/sysv/linux/not-cancel.h | 12 ++++++++----

>  5 files changed, 28 insertions(+), 12 deletions(-)

> 

> diff --git a/ChangeLog b/ChangeLog

> index 4ee70fb..fbf0c6a 100644

> --- a/ChangeLog

> +++ b/ChangeLog

> @@ -1,5 +1,17 @@

>  2017-08-02  Adhemerval Zanella  <adhemerval.zanella@linaro.org>

>  

> +	* gmon/gmon.c (write_hist): Replace writev_not_cancel_no_status with

> +	__writev_nocancel_nostatus.

> +	(write_call_graph): Likewise.

> +	(write_bb_counts): Likewise.

> +	* resolv/herror.c (herror): Likewise.

> +	* sysdeps/generic/not-cancel.h (writev_not_cancel_no_status): Remove

> +	macro.

> +	(__writev_nocancel_nostatus): New macro.

> +	* sysdeps/unix/sysv/linux/not-cancel.h (writev_not_cancel_no_status):

> +	Remove macro.

> +	(__writev_nocancel_nostatus): New function.

> +

>  	* sysdeps/generic/not-cancel.h (close_not_cancel): Remove macro.

>  	(close_not_cancel_no_status): Likewise.

>  	(__close_nocancel): New macro.

> diff --git a/gmon/gmon.c b/gmon/gmon.c

> index 90c7895..c1d1701 100644

> --- a/gmon/gmon.c

> +++ b/gmon/gmon.c

> @@ -216,7 +216,7 @@ write_hist (int fd)

>        strncpy (thdr.dimen, "seconds", sizeof (thdr.dimen));

>        thdr.dimen_abbrev = 's';

>  

> -      writev_not_cancel_no_status (fd, iov, 3);

> +      __writev_nocancel_nostatus (fd, iov, 3);

>      }

>  }

>  

> @@ -273,13 +273,13 @@ write_call_graph (int fd)

>  

>  	  if (++nfilled == NARCS_PER_WRITEV)

>  	    {

> -	      writev_not_cancel_no_status (fd, iov, 2 * nfilled);

> +	      __writev_nocancel_nostatus (fd, iov, 2 * nfilled);

>  	      nfilled = 0;

>  	    }

>  	}

>      }

>    if (nfilled > 0)

> -    writev_not_cancel_no_status (fd, iov, 2 * nfilled);

> +    __writev_nocancel_nostatus (fd, iov, 2 * nfilled);

>  }

>  

>  

> @@ -312,12 +312,12 @@ write_bb_counts (int fd)

>    for (grp = __bb_head; grp; grp = grp->next)

>      {

>        ncounts = grp->ncounts;

> -      writev_not_cancel_no_status (fd, bbhead, 2);

> +      __writev_nocancel_nostatus (fd, bbhead, 2);

>        for (nfilled = i = 0; i < ncounts; ++i)

>  	{

>  	  if (nfilled > (sizeof (bbbody) / sizeof (bbbody[0])) - 2)

>  	    {

> -	      writev_not_cancel_no_status (fd, bbbody, nfilled);

> +	      __writev_nocancel_nostatus (fd, bbbody, nfilled);

>  	      nfilled = 0;

>  	    }

>  

> @@ -325,7 +325,7 @@ write_bb_counts (int fd)

>  	  bbbody[nfilled++].iov_base = &grp->counts[i];

>  	}

>        if (nfilled > 0)

> -	writev_not_cancel_no_status (fd, bbbody, nfilled);

> +	__writev_nocancel_nostatus (fd, bbbody, nfilled);

>      }

>  }

>  

> diff --git a/resolv/herror.c b/resolv/herror.c

> index b3df236..45c0a5d 100644

> --- a/resolv/herror.c

> +++ b/resolv/herror.c

> @@ -89,7 +89,7 @@ herror(const char *s) {

>  	v++;

>  	v->iov_base = (char *) "\n";

>  	v->iov_len = 1;

> -	writev_not_cancel_no_status(STDERR_FILENO, iov, (v - iov) + 1);

> +	__writev_nocancel_nostatus(STDERR_FILENO, iov, (v - iov) + 1);

>  }

>  

>  /*

> diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h

> index ee9988a..e3ed0e6 100644

> --- a/sysdeps/generic/not-cancel.h

> +++ b/sysdeps/generic/not-cancel.h

> @@ -34,7 +34,7 @@

>    __read (fd, buf, n)

>  #define __write_nocancel(fd, buf, n) \

>    __write (fd, buf, n)

> -#define writev_not_cancel_no_status(fd, iov, n) \

> +#define __writev_nocancel_nostatus(fd, iov, n) \

>    (void) __writev (fd, iov, n)

>  #define fcntl_not_cancel(fd, cmd, val) \

>    __fcntl (fd, cmd, val)

> diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h

> index 684541a..419a3fa 100644

> --- a/sysdeps/unix/sysv/linux/not-cancel.h

> +++ b/sysdeps/unix/sysv/linux/not-cancel.h

> @@ -63,10 +63,14 @@ __close_nocancel_nostatus (int fd)

>    INTERNAL_SYSCALL (close, err, 1, (fd));

>  }

>  

> -/* Uncancelable writev.  */

> -#define writev_not_cancel_no_status(fd, iov, n) \

> -  (void) ({ INTERNAL_SYSCALL_DECL (err);				      \

> -	    INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })

> +/* Non cancellable writev syscall that does not also set errno in case of

> +   failure.  */

> +static inline void

> +__writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)

> +{

> +  INTERNAL_SYSCALL_DECL (err);

> +  INTERNAL_SYSCALL_CALL (writev, err, fd, iov, iovcnt);

> +}

>  

>  /* Uncancelable fcntl.  */

>  #define fcntl_not_cancel(fd, cmd, val) \

>
diff mbox series

Patch

diff --git a/ChangeLog b/ChangeLog
index 4ee70fb..fbf0c6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@ 
 2017-08-02  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+	* gmon/gmon.c (write_hist): Replace writev_not_cancel_no_status with
+	__writev_nocancel_nostatus.
+	(write_call_graph): Likewise.
+	(write_bb_counts): Likewise.
+	* resolv/herror.c (herror): Likewise.
+	* sysdeps/generic/not-cancel.h (writev_not_cancel_no_status): Remove
+	macro.
+	(__writev_nocancel_nostatus): New macro.
+	* sysdeps/unix/sysv/linux/not-cancel.h (writev_not_cancel_no_status):
+	Remove macro.
+	(__writev_nocancel_nostatus): New function.
+
 	* sysdeps/generic/not-cancel.h (close_not_cancel): Remove macro.
 	(close_not_cancel_no_status): Likewise.
 	(__close_nocancel): New macro.
diff --git a/gmon/gmon.c b/gmon/gmon.c
index 90c7895..c1d1701 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -216,7 +216,7 @@  write_hist (int fd)
       strncpy (thdr.dimen, "seconds", sizeof (thdr.dimen));
       thdr.dimen_abbrev = 's';
 
-      writev_not_cancel_no_status (fd, iov, 3);
+      __writev_nocancel_nostatus (fd, iov, 3);
     }
 }
 
@@ -273,13 +273,13 @@  write_call_graph (int fd)
 
 	  if (++nfilled == NARCS_PER_WRITEV)
 	    {
-	      writev_not_cancel_no_status (fd, iov, 2 * nfilled);
+	      __writev_nocancel_nostatus (fd, iov, 2 * nfilled);
 	      nfilled = 0;
 	    }
 	}
     }
   if (nfilled > 0)
-    writev_not_cancel_no_status (fd, iov, 2 * nfilled);
+    __writev_nocancel_nostatus (fd, iov, 2 * nfilled);
 }
 
 
@@ -312,12 +312,12 @@  write_bb_counts (int fd)
   for (grp = __bb_head; grp; grp = grp->next)
     {
       ncounts = grp->ncounts;
-      writev_not_cancel_no_status (fd, bbhead, 2);
+      __writev_nocancel_nostatus (fd, bbhead, 2);
       for (nfilled = i = 0; i < ncounts; ++i)
 	{
 	  if (nfilled > (sizeof (bbbody) / sizeof (bbbody[0])) - 2)
 	    {
-	      writev_not_cancel_no_status (fd, bbbody, nfilled);
+	      __writev_nocancel_nostatus (fd, bbbody, nfilled);
 	      nfilled = 0;
 	    }
 
@@ -325,7 +325,7 @@  write_bb_counts (int fd)
 	  bbbody[nfilled++].iov_base = &grp->counts[i];
 	}
       if (nfilled > 0)
-	writev_not_cancel_no_status (fd, bbbody, nfilled);
+	__writev_nocancel_nostatus (fd, bbbody, nfilled);
     }
 }
 
diff --git a/resolv/herror.c b/resolv/herror.c
index b3df236..45c0a5d 100644
--- a/resolv/herror.c
+++ b/resolv/herror.c
@@ -89,7 +89,7 @@  herror(const char *s) {
 	v++;
 	v->iov_base = (char *) "\n";
 	v->iov_len = 1;
-	writev_not_cancel_no_status(STDERR_FILENO, iov, (v - iov) + 1);
+	__writev_nocancel_nostatus(STDERR_FILENO, iov, (v - iov) + 1);
 }
 
 /*
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index ee9988a..e3ed0e6 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -34,7 +34,7 @@ 
   __read (fd, buf, n)
 #define __write_nocancel(fd, buf, n) \
   __write (fd, buf, n)
-#define writev_not_cancel_no_status(fd, iov, n) \
+#define __writev_nocancel_nostatus(fd, iov, n) \
   (void) __writev (fd, iov, n)
 #define fcntl_not_cancel(fd, cmd, val) \
   __fcntl (fd, cmd, val)
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 684541a..419a3fa 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -63,10 +63,14 @@  __close_nocancel_nostatus (int fd)
   INTERNAL_SYSCALL (close, err, 1, (fd));
 }
 
-/* Uncancelable writev.  */
-#define writev_not_cancel_no_status(fd, iov, n) \
-  (void) ({ INTERNAL_SYSCALL_DECL (err);				      \
-	    INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
+/* Non cancellable writev syscall that does not also set errno in case of
+   failure.  */
+static inline void
+__writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
+{
+  INTERNAL_SYSCALL_DECL (err);
+  INTERNAL_SYSCALL_CALL (writev, err, fd, iov, iovcnt);
+}
 
 /* Uncancelable fcntl.  */
 #define fcntl_not_cancel(fd, cmd, val) \