summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2017-11-06 09:31:37 -0200
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2017-11-15 15:45:39 -0200
commit1ba1d8a44d244110c1f8d768f098ac44351acb76 (patch)
treecb0d5bb38299dd3755f7496d111bdd00e450e8a4
parentad4f43a2344864ae2304060dcc722a7a63bad1b4 (diff)
downloadglibc-1ba1d8a44d244110c1f8d768f098ac44351acb76.tar.gz
glibc-1ba1d8a44d244110c1f8d768f098ac44351acb76.tar.xz
glibc-1ba1d8a44d244110c1f8d768f098ac44351acb76.zip
Optimize sigrelse implementation
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>
-rw-r--r--ChangeLog2
-rw-r--r--signal/sigrelse.c12
2 files changed, 5 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 6f10dd94fb..88f3ac8478 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2017-11-15  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
+	* signal/sigrelse.c (sigrelse): Optimize implementation.
+
 	* sysdeps/posix/sigpause.c (do_sigpause): Remove.
 	(__sigpause): Rely on __sigsuspend to implement single thread
 	optimization.  Add LIBC_CANCEL_HANDLED for cancellation marking.
diff --git a/signal/sigrelse.c b/signal/sigrelse.c
index e41c2bd261..61f240be5e 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);
 }