diff mbox series

[v2,8/8] Optimize sigrelse implementation

Message ID 1509975426-1772-8-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show
Series [v2,1/8] Rename nptl-signals.h to internal-signals.h | expand

Commit Message

Adhemerval Zanella Netto Nov. 6, 2017, 1:37 p.m. UTC
This patch simplifies sighold a bit by removing an extra sigprocmask
and using SIG_BLOCK (which union of the current set and the set argument).

Checked on x86_64-linux-gnu.

	* signal/sighold.c (sighold): Optimize implementation.

Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

---
 ChangeLog         |  2 ++
 signal/sigrelse.c | 12 +++---------
 2 files changed, 5 insertions(+), 9 deletions(-)

-- 
2.7.4

Comments

Adhemerval Zanella Netto Nov. 15, 2017, 4:44 p.m. UTC | #1
If nobody opposes it I will commit this shortly.

On 06/11/2017 11:37, Adhemerval Zanella wrote:
> This patch simplifies sighold a bit by removing an extra sigprocmask

> and using SIG_BLOCK (which union of the current set and the set argument).

> 

> Checked on x86_64-linux-gnu.

> 

> 	* signal/sighold.c (sighold): Optimize implementation.

> 

> Signed-off-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>

> ---

>  ChangeLog         |  2 ++

>  signal/sigrelse.c | 12 +++---------

>  2 files changed, 5 insertions(+), 9 deletions(-)

> 

> diff --git a/signal/sigrelse.c b/signal/sigrelse.c

> index e41c2bd..61f240b 100644

> --- a/signal/sigrelse.c

> +++ b/signal/sigrelse.c

> @@ -26,14 +26,8 @@ sigrelse (int sig)

>  {

>    sigset_t set;

>  

> -  /* Retrieve current signal set.  */

> -  if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0)

> +  sigemptyset (&set);

> +  if (sigaddset (&set, sig) < 0)

>      return -1;

> -

> -  /* Remove the specified signal.  */

> -  if (sigdelset (&set, sig) < 0)

> -    return -1;

> -

> -  /* Set the new mask.  */

> -  return __sigprocmask (SIG_SETMASK, &set, NULL);

> +  return __sigprocmask (SIG_UNBLOCK, &set, NULL);

>  }

>
diff mbox series

Patch

diff --git a/signal/sigrelse.c b/signal/sigrelse.c
index e41c2bd..61f240b 100644
--- a/signal/sigrelse.c
+++ b/signal/sigrelse.c
@@ -26,14 +26,8 @@  sigrelse (int sig)
 {
   sigset_t set;
 
-  /* Retrieve current signal set.  */
-  if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0)
+  sigemptyset (&set);
+  if (sigaddset (&set, sig) < 0)
     return -1;
-
-  /* Remove the specified signal.  */
-  if (sigdelset (&set, sig) < 0)
-    return -1;
-
-  /* Set the new mask.  */
-  return __sigprocmask (SIG_SETMASK, &set, NULL);
+  return __sigprocmask (SIG_UNBLOCK, &set, NULL);
 }