[v2,7/8] Cleanup sigpause implementation
Commit Message
This patch simplify sigpause by remobing the single thread optimization
since it will be handled already by the __sigsuspend call.
Checked on x86_64-linux-gnu.
* sysdeps/posix/sigpause.c (do_sigpause): Remove.
(__sigpause): Rely on __sigsuspend to implement single thread
optimization. Add LIBC_CANCEL_HANDLED for cancellation marking.
Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Reviewed-by: Zack Weinberg <zackw@panix.com>
---
ChangeLog | 4 ++++
sysdeps/posix/sigpause.c | 26 ++++++--------------------
2 files changed, 10 insertions(+), 20 deletions(-)
Comments
If nobody opposes it I will commit this shortly.
On 06/11/2017 11:37, Adhemerval Zanella wrote:
> This patch simplify sigpause by remobing the single thread optimization
> since it will be handled already by the __sigsuspend call.
>
> Checked on x86_64-linux-gnu.
>
> * sysdeps/posix/sigpause.c (do_sigpause): Remove.
> (__sigpause): Rely on __sigsuspend to implement single thread
> optimization. Add LIBC_CANCEL_HANDLED for cancellation marking.
>
> Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> Reviewed-by: Zack Weinberg <zackw@panix.com>
> ---
> ChangeLog | 4 ++++
> sysdeps/posix/sigpause.c | 26 ++++++--------------------
> 2 files changed, 10 insertions(+), 20 deletions(-)
>
> diff --git a/sysdeps/posix/sigpause.c b/sysdeps/posix/sigpause.c
> index 9038ed3..a61e056 100644
> --- a/sysdeps/posix/sigpause.c
> +++ b/sysdeps/posix/sigpause.c
> @@ -19,15 +19,13 @@
> #include <errno.h>
> #include <signal.h>
> #include <stddef.h> /* For NULL. */
> -#include <sysdep-cancel.h>
> #undef sigpause
>
> #include <sigset-cvt-mask.h>
> +#include <sysdep-cancel.h>
>
> -/* Set the mask of blocked signals to MASK,
> - wait for a signal to arrive, and then restore the mask. */
> -static int
> -do_sigpause (int sig_or_mask, int is_sig)
> +int
> +__sigpause (int sig_or_mask, int is_sig)
> {
> sigset_t set;
>
> @@ -46,21 +44,6 @@ do_sigpause (int sig_or_mask, int is_sig)
> to do anything here. */
> return __sigsuspend (&set);
> }
> -
> -int
> -__sigpause (int sig_or_mask, int is_sig)
> -{
> - if (SINGLE_THREAD_P)
> - return do_sigpause (sig_or_mask, is_sig);
> -
> - int oldtype = LIBC_CANCEL_ASYNC ();
> -
> - int result = do_sigpause (sig_or_mask, is_sig);
> -
> - LIBC_CANCEL_RESET (oldtype);
> -
> - return result;
> -}
> libc_hidden_def (__sigpause)
>
> /* We have to provide a default version of this function since the
> @@ -87,3 +70,6 @@ __xpg_sigpause (int sig)
> return __sigpause (sig, 1);
> }
> strong_alias (__xpg_sigpause, __libc___xpg_sigpause)
> +
> +/* __sigsuspend handles cancellation. */
> +LIBC_CANCEL_HANDLED ();
>
nits only...
On 11/15/2017 10:44 AM, Adhemerval Zanella wrote:
> If nobody opposes it I will commit this shortly.
>
> On 06/11/2017 11:37, Adhemerval Zanella wrote:
>> This patch simplify sigpause by remobing the single thread optimization
s/simplify/simplifies/
s/remobing/removing/
PC
@@ -19,15 +19,13 @@
#include <errno.h>
#include <signal.h>
#include <stddef.h> /* For NULL. */
-#include <sysdep-cancel.h>
#undef sigpause
#include <sigset-cvt-mask.h>
+#include <sysdep-cancel.h>
-/* Set the mask of blocked signals to MASK,
- wait for a signal to arrive, and then restore the mask. */
-static int
-do_sigpause (int sig_or_mask, int is_sig)
+int
+__sigpause (int sig_or_mask, int is_sig)
{
sigset_t set;
@@ -46,21 +44,6 @@ do_sigpause (int sig_or_mask, int is_sig)
to do anything here. */
return __sigsuspend (&set);
}
-
-int
-__sigpause (int sig_or_mask, int is_sig)
-{
- if (SINGLE_THREAD_P)
- return do_sigpause (sig_or_mask, is_sig);
-
- int oldtype = LIBC_CANCEL_ASYNC ();
-
- int result = do_sigpause (sig_or_mask, is_sig);
-
- LIBC_CANCEL_RESET (oldtype);
-
- return result;
-}
libc_hidden_def (__sigpause)
/* We have to provide a default version of this function since the
@@ -87,3 +70,6 @@ __xpg_sigpause (int sig)
return __sigpause (sig, 1);
}
strong_alias (__xpg_sigpause, __libc___xpg_sigpause)
+
+/* __sigsuspend handles cancellation. */
+LIBC_CANCEL_HANDLED ();