aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2017-08-21 17:23:56 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2017-08-22 14:25:03 -0300
commit08d6eb46caf13f46ce052d2be34522068c5a6d33 (patch)
treecca7bafaa85ba2dbe2dc6ea09bc4aabdb06d848d
parentee4e992ebe5f9712faedeefe8958b67d61eaa0f2 (diff)
downloadglibc-08d6eb46caf13f46ce052d2be34522068c5a6d33.tar
glibc-08d6eb46caf13f46ce052d2be34522068c5a6d33.tar.gz
glibc-08d6eb46caf13f46ce052d2be34522068c5a6d33.tar.bz2
glibc-08d6eb46caf13f46ce052d2be34522068c5a6d33.zip
Consolidate non cancellable pause call
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.
-rw-r--r--ChangeLog11
-rw-r--r--include/unistd.h2
-rw-r--r--nptl/pthread_mutex_lock.c2
-rw-r--r--sysdeps/generic/not-cancel.h2
-rw-r--r--sysdeps/posix/pause.c15
-rw-r--r--sysdeps/unix/sysv/linux/not-cancel.h10
-rw-r--r--sysdeps/unix/sysv/linux/pause.c13
7 files changed, 27 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 573bd51ab5..912921f8ea 100644
--- 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
diff --git a/include/unistd.h b/include/unistd.h
index 7f1c2ccd4b..a5625ed7f4 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -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;
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index 8c485035eb..b1586079ad 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -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;
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index 3f924c895d..f2140c245b 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -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)
diff --git a/sysdeps/posix/pause.c b/sysdeps/posix/pause.c
index 7996cd6dbb..53e143d98f 100644
--- a/sysdeps/posix/pause.c
+++ b/sysdeps/posix/pause.c
@@ -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
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index c4a60b8d67..ac78cb38c3 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -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) \
diff --git a/sysdeps/unix/sysv/linux/pause.c b/sysdeps/unix/sysv/linux/pause.c
index 4ccce9ebd8..3300eb8b07 100644
--- a/sysdeps/unix/sysv/linux/pause.c
+++ b/sysdeps/unix/sysv/linux/pause.c
@@ -19,10 +19,10 @@
#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)