diff mbox series

[5/6] Optimize sighold implementation

Message ID 1509745249-11404-5-git-send-email-adhemerval.zanella@linaro.org
State Superseded
Headers show
Series [1/6] Consolidate Linux sigprocmask implementation (BZ #22391) | expand

Commit Message

Adhemerval Zanella Nov. 3, 2017, 9:40 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/sighold.c | 10 ++--------
 2 files changed, 4 insertions(+), 8 deletions(-)

-- 
2.7.4

Comments

Zack Weinberg Nov. 5, 2017, 7:15 p.m. UTC | #1
On Fri, Nov 3, 2017 at 5:41 PM Adhemerval Zanella <
adhemerval.zanella@linaro.org> 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).

>

LGtM. Might a similar improvement be possible for sigrelse?
<div><br><div class="gmail_quote"><div dir="auto">On Fri, Nov 3, 2017 at 5:41 PM Adhemerval Zanella &lt;<a href="mailto:adhemerval.zanella@linaro.org">adhemerval.zanella@linaro.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This patch simplifies sighold a bit by removing an extra sigprocmask<br>
and using SIG_BLOCK (which union of the current set and the set argument).<br></blockquote></div></div><div dir="auto">LGtM. Might a similar improvement be possible for sigrelse?</div>
Adhemerval Zanella Nov. 6, 2017, 11:05 a.m. UTC | #2
On 05/11/2017 17:15, Zack Weinberg wrote:
> 

> On Fri, Nov 3, 2017 at 5:41 PM Adhemerval Zanella <adhemerval.zanella@linaro.org <mailto:adhemerval.zanella@linaro.org>> 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).

> 

> LGtM. Might a similar improvement be possible for sigrelse?


Indeed, I will sent it along the patch refactor asked by Joseph on 2/6.
diff mbox series

Patch

diff --git a/signal/sighold.c b/signal/sighold.c
index 2e32e47..955ac5b 100644
--- a/signal/sighold.c
+++ b/signal/sighold.c
@@ -26,14 +26,8 @@  sighold (int sig)
 {
   sigset_t set;
 
-  /* Retrieve current signal set.  */
-  if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0)
-    return -1;
-
-  /* Add the specified signal.  */
+  sigemptyset (&set);
   if (sigaddset (&set, sig) < 0)
     return -1;
-
-  /* Set the new mask.  */
-  return __sigprocmask (SIG_SETMASK, &set, NULL);
+  return __sigprocmask (SIG_BLOCK, &set, NULL);
 }