diff mbox series

[08/14] Consolidate non cancellable waitpid call

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

Commit Message

Adhemerval Zanella Aug. 3, 2017, 1:11 p.m. UTC
This patch consolidates all the non cancellable waitpid calls to use
the __waitpid_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.

	* login/utmp_file.c (timeout_handler): Replace fcntl_not_cancel with
	__fcntl_nocancel.
	* sysdeps/generic/not-cancel.h (fcntl_not_cancel): Remove macro.
	* sysdeps/unix/sysv/linux/not-cancel.h (fcntl_not_cancel): Likewise.
	* sysdeps/unix/sysv/linux/waitpid.c (__waitpid_nocancel): New symbol.
---
 libio/iopopen.c                      |  2 +-
 sysdeps/generic/not-cancel.h         |  2 +-
 sysdeps/unix/sysv/linux/not-cancel.h |  7 +++----
 sysdeps/unix/sysv/linux/waitpid.c    | 15 ++++++++++++++-
 4 files changed, 19 insertions(+), 7 deletions(-)

-- 
2.7.4

Comments

Adhemerval Zanella 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 waitpid calls to use

> the __waitpid_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.

> 

> 	* login/utmp_file.c (timeout_handler): Replace fcntl_not_cancel with

> 	__fcntl_nocancel.

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

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

> 	* sysdeps/unix/sysv/linux/waitpid.c (__waitpid_nocancel): New symbol.

> ---

>  libio/iopopen.c                      |  2 +-

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

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

>  sysdeps/unix/sysv/linux/waitpid.c    | 15 ++++++++++++++-

>  4 files changed, 19 insertions(+), 7 deletions(-)

> 

> diff --git a/libio/iopopen.c b/libio/iopopen.c

> index 0c20cbb..a2ddebb 100644

> --- a/libio/iopopen.c

> +++ b/libio/iopopen.c

> @@ -61,7 +61,7 @@ extern int _IO_dup2 (int fd, int fd2) __THROW;

>  

>  #ifndef _IO_waitpid

>  #ifdef _LIBC

> -#define _IO_waitpid waitpid_not_cancel

> +#define _IO_waitpid __waitpid_nocancel

>  #else

>  #define _IO_waitpid waitpid

>  #endif

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

> index cf84550..3f924c8 100644

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

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

> @@ -36,7 +36,7 @@

>    __write (fd, buf, n)

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

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

> -# define waitpid_not_cancel(pid, stat_loc, options) \

> +# define __waitpid_nocancel(pid, stat_loc, options) \

>    __waitpid (pid, stat_loc, options)

>  #define pause_not_cancel() \

>    __pause ()

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

> index 8f567d3..ad46d62 100644

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

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

> @@ -25,6 +25,7 @@

>  #include <errno.h>

>  #include <unistd.h>

>  #include <sys/syscall.h>

> +#include <sys/wait.h>

>  

>  /* Non cancellable open syscall.  */

>  __typeof (open) __open_nocancel;

> @@ -73,10 +74,8 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)

>  }

>  

>  /* Uncancelable waitpid.  */

> -#define __waitpid_nocancel(pid, stat_loc, options) \

> -  INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)

> -#define waitpid_not_cancel(pid, stat_loc, options) \

> -  __waitpid_nocancel(pid, stat_loc, options)

> +__typeof (waitpid) __waitpid_nocancel;

> +libc_hidden_proto (__waitpid_nocancel)

>  

>  /* Uncancelable pause.  */

>  #define pause_not_cancel() \

> diff --git a/sysdeps/unix/sysv/linux/waitpid.c b/sysdeps/unix/sysv/linux/waitpid.c

> index 2fed421..052462d 100644

> --- a/sysdeps/unix/sysv/linux/waitpid.c

> +++ b/sysdeps/unix/sysv/linux/waitpid.c

> @@ -16,10 +16,12 @@

>     <http://www.gnu.org/licenses/>.  */

>  

>  #include <errno.h>

> -#include <sysdep-cancel.h>

>  #include <stdlib.h>

>  #include <sys/wait.h>

>  

> +#include <sysdep-cancel.h>

> +#include <not-cancel.h>

> +

>  __pid_t

>  __waitpid (__pid_t pid, int *stat_loc, int options)

>  {

> @@ -31,3 +33,14 @@ __waitpid (__pid_t pid, int *stat_loc, int options)

>  }

>  libc_hidden_def (__waitpid)

>  weak_alias (__waitpid, waitpid)

> +

> +__pid_t

> +__waitpid_nocancel (__pid_t pid, int *stat_loc, int options)

> +{

> +#ifdef __NR_waitpid

> +  return INLINE_SYSCALL_CALL (waitpid, pid, stat_loc, options);

> +#else

> +  return INLINE_SYSCALL_CALL (wait4, pid, stat_loc, options, NULL);

> +#endif

> +}

> +libc_hidden_def (__waitpid_nocancel)

>
diff mbox series

Patch

diff --git a/libio/iopopen.c b/libio/iopopen.c
index 0c20cbb..a2ddebb 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -61,7 +61,7 @@  extern int _IO_dup2 (int fd, int fd2) __THROW;
 
 #ifndef _IO_waitpid
 #ifdef _LIBC
-#define _IO_waitpid waitpid_not_cancel
+#define _IO_waitpid __waitpid_nocancel
 #else
 #define _IO_waitpid waitpid
 #endif
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index cf84550..3f924c8 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -36,7 +36,7 @@ 
   __write (fd, buf, n)
 #define __writev_nocancel_nostatus(fd, iov, n) \
   (void) __writev (fd, iov, n)
-# define waitpid_not_cancel(pid, stat_loc, options) \
+# define __waitpid_nocancel(pid, stat_loc, options) \
   __waitpid (pid, stat_loc, options)
 #define pause_not_cancel() \
   __pause ()
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 8f567d3..ad46d62 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -25,6 +25,7 @@ 
 #include <errno.h>
 #include <unistd.h>
 #include <sys/syscall.h>
+#include <sys/wait.h>
 
 /* Non cancellable open syscall.  */
 __typeof (open) __open_nocancel;
@@ -73,10 +74,8 @@  __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
 }
 
 /* Uncancelable waitpid.  */
-#define __waitpid_nocancel(pid, stat_loc, options) \
-  INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
-#define waitpid_not_cancel(pid, stat_loc, options) \
-  __waitpid_nocancel(pid, stat_loc, options)
+__typeof (waitpid) __waitpid_nocancel;
+libc_hidden_proto (__waitpid_nocancel)
 
 /* Uncancelable pause.  */
 #define pause_not_cancel() \
diff --git a/sysdeps/unix/sysv/linux/waitpid.c b/sysdeps/unix/sysv/linux/waitpid.c
index 2fed421..052462d 100644
--- a/sysdeps/unix/sysv/linux/waitpid.c
+++ b/sysdeps/unix/sysv/linux/waitpid.c
@@ -16,10 +16,12 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <sysdep-cancel.h>
 #include <stdlib.h>
 #include <sys/wait.h>
 
+#include <sysdep-cancel.h>
+#include <not-cancel.h>
+
 __pid_t
 __waitpid (__pid_t pid, int *stat_loc, int options)
 {
@@ -31,3 +33,14 @@  __waitpid (__pid_t pid, int *stat_loc, int options)
 }
 libc_hidden_def (__waitpid)
 weak_alias (__waitpid, waitpid)
+
+__pid_t
+__waitpid_nocancel (__pid_t pid, int *stat_loc, int options)
+{
+#ifdef __NR_waitpid
+  return INLINE_SYSCALL_CALL (waitpid, pid, stat_loc, options);
+#else
+  return INLINE_SYSCALL_CALL (wait4, pid, stat_loc, options, NULL);
+#endif
+}
+libc_hidden_def (__waitpid_nocancel)