]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Consolidate non cancellable pause call
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 21 Aug 2017 20:23:56 +0000 (17:23 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 22 Aug 2017 17:25:03 +0000 (14:25 -0300)
This patch consolidates all the non cancellable pause calls to use
the __pause_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.

* nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Replace
pause_not_cancel with __pause_nocancel.
* sysdeps/generic/not-cancel.h (pause_not_cancel): Remove macro.
(__pause_nocancel): New macro.
* sysdeps/unix/sysv/linux/not-cancel.h (pause_not_cancel): Remove
macro.
(__pause_nocancel): New prototype.
* sysdeps/unix/sysv/linux/pause.c (__pause_nocancel): New function.

ChangeLog
include/unistd.h
nptl/pthread_mutex_lock.c
sysdeps/generic/not-cancel.h
sysdeps/posix/pause.c
sysdeps/unix/sysv/linux/not-cancel.h
sysdeps/unix/sysv/linux/pause.c

index 573bd51ab5633d25adba6bb65b309e579119fc0b..912921f8eabcd82dadc587682d53cb7db3da55ad 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2017-08-22  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
+
+       * nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Replace
+       pause_not_cancel with __pause_nocancel.
+       * sysdeps/generic/not-cancel.h (pause_not_cancel): Remove macro.
+       (__pause_nocancel): New macro.
+       * sysdeps/unix/sysv/linux/not-cancel.h (pause_not_cancel): Remove
+       macro.
+       (__pause_nocancel): New prototype.
+       * sysdeps/unix/sysv/linux/pause.c (__pause_nocancel): New function.
+
 2017-08-22  Martin Sebor  <msebor@redhat.com>
 
        * include/libc-symbols.h (__ifunc_resolver): Declare resolver
index 7f1c2ccd4b97996e92fde47e96a88041e1b10ffa..a5625ed7f48d8561d34fb90c5d3c3659c3df1ea5 100644 (file)
@@ -172,8 +172,6 @@ extern __pid_t __libc_fork (void);
 /* Suspend the process until a signal arrives.
    This always returns -1 and sets `errno' to EINTR.  */
 extern int __libc_pause (void);
-/* Not cancelable variant.  */
-extern int __pause_nocancel (void) attribute_hidden;
 
 extern int __getlogin_r_loginuid (char *name, size_t namesize)
      attribute_hidden;
index 8c485035eb9b34eff3a38fe529e7fd1c9f6b59b7..b1586079ad4a4a8fb0de2f16d470020f695d9eb8 100644 (file)
@@ -428,7 +428,7 @@ __pthread_mutex_lock_full (pthread_mutex_t *mutex)
 
                /* Delay the thread indefinitely.  */
                while (1)
-                 pause_not_cancel ();
+                 __pause_nocancel ();
              }
 
            oldval = mutex->__data.__lock;
index 3f924c895db53ccab44ef72cd68a82eb069521dd..f2140c245bf2f0a801ca372eee410aa26f585e6b 100644 (file)
@@ -38,7 +38,7 @@
   (void) __writev (fd, iov, n)
 # define __waitpid_nocancel(pid, stat_loc, options) \
   __waitpid (pid, stat_loc, options)
-#define pause_not_cancel() \
+#define __pause_nocancel() \
   __pause ()
 #define nanosleep_not_cancel(requested_time, remaining) \
   __nanosleep (requested_time, remaining)
index 7996cd6dbbf8f900044bd61603abed3096530fe8..53e143d98f35b4ae82ad66b4d18259c2c0bd06e6 100644 (file)
@@ -39,18 +39,3 @@ __libc_pause (void)
 weak_alias (__libc_pause, pause)
 
 LIBC_CANCEL_HANDLED ();                /* sigsuspend handles our cancellation.  */
-
-#ifndef NO_CANCELLATION
-# include <not-cancel.h>
-
-int
-__pause_nocancel (void)
-{
-  sigset_t set;
-
-  __sigemptyset (&set);
-  __sigprocmask (SIG_BLOCK, NULL, &set);
-
-  return sigsuspend_not_cancel (&set);
-}
-#endif
index c4a60b8d6713510f14fe8f849cc73dda87f80383..ac78cb38c340efd66c09b89b9c79fa092163dadf 100644 (file)
@@ -77,14 +77,8 @@ __typeof (waitpid) __waitpid_nocancel;
 libc_hidden_proto (__waitpid_nocancel)
 
 /* Uncancelable pause.  */
-#define pause_not_cancel() \
-  ({ sigset_t set;                                                          \
-     int __rc = INLINE_SYSCALL (rt_sigprocmask, 4, SIG_BLOCK, NULL, &set,    \
-                               _NSIG / 8);                                  \
-     if (__rc == 0)                                                         \
-       __rc = INLINE_SYSCALL (rt_sigsuspend, 2, &set, _NSIG / 8);           \
-     __rc;                                                                  \
-  })
+__typeof (pause) __pause_nocancel;
+libc_hidden_proto (__pause_nocancel)
 
 /* Uncancelable nanosleep.  */
 #define nanosleep_not_cancel(requested_time, remaining) \
index 4ccce9ebd892503e85fa5cf48152a068323b54c4..3300eb8b0796781848ab9b6c3e9c101bc3ca60e3 100644 (file)
 #include <signal.h>
 #include <unistd.h>
 #include <sysdep-cancel.h>
+#include <not-cancel.h>
 
 /* Suspend the process until a signal arrives.
    This always returns -1 and sets errno to EINTR.  */
-
 int
 __libc_pause (void)
 {
@@ -33,3 +33,14 @@ __libc_pause (void)
 #endif
 }
 weak_alias (__libc_pause, pause)
+
+int
+__pause_nocancel (void)
+{
+#ifdef __NR_pause
+  return INLINE_SYSCALL_CALL (pause);
+#else
+  return INLINE_SYSCALL_CALL (ppoll, NULL, 0, NULL, NULL);
+#endif
+}
+libc_hidden_def (__pause_nocancel)