diff mbox series

[1/3] Remove NO_CANCELLATION macro

Message ID 1502140314-16598-1-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show
Series [1/3] Remove NO_CANCELLATION macro | expand

Commit Message

Adhemerval Zanella Netto Aug. 7, 2017, 9:11 p.m. UTC
The NO_CANCELLATION macro is used currently on generic headers to
define non cancellable syscalls on Linux fcntl to actually implement
the non cancellable variation.  Former should be handled by not-cancel.h
header and former could be simplified to just build the non cancellable
version only for loader objects (since Linux already support cancellation
as default).

This patch thus removes the NO_CANCELLATION macro and its usage.  The
generic non cancellable fcntl is route to internal fcntl.

This is based on my "Remove sysdep-cancel assembly macro" patchset [1].

Checked on x86_64-linux-gnu and i686-linux-gnu.

	* include/fcntl.h (__fcntl_nocancel): Remove definition.
	* include/signal.h (__sigsuspend_nocancel): Likewise.
	* sysdeps/generic/not-cancel.h (__fcntl_nocancel): New macro.
	* sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h (NO_CANCELLATION):
	Remove macro.
	* sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (NO_CANCELLATION):
	Likewise.
	* sysdeps/unix/sysv/linux/arm/sysdep-cancel.h (NO_CANCELLATION):
	Likewise.
	* sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h (NO_CANCELLATION):
	Likewise.
	* sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (NO_CANCELLATION):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (NO_CANCELLATION):
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h (NO_CANCELLATION):
	Likewise.
	* sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h
	(NO_CANCELLATION): Likewise.
	* sysdeps/unix/sysv/linux/mips/sysdep-cancel.h (NO_CANCELLATION):
	Likewise.
	* sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h (NO_CANCELLATION):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h (NO_CANCELLATION):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
	(NO_CANCELLATION): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
	(NO_CANCELLATION): Likewise.
	* sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (NO_CANCELLATION):
	Likewise
	* sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h (NO_CANCELLATION):
	Likewise.
	* sysdeps/unix/sysv/linux/tile/sysdep-cancel.h (NO_CANCELLATION):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (NO_CANCELLATION):
	Likewise.
	* sysdeps/unix/sysv/linux/not-cancel.h (__fcntl_nocancel): New
	prototype.
	* sysdeps/unix/sysv/linux/fcntl.c (__fcntl_nocancel): Define only
	for !IS_IN (rtld).

[1] https://sourceware.org/ml/libc-alpha/2017-08/msg00095.html

---
 ChangeLog                                          | 42 ++++++++++++++++++++++
 include/fcntl.h                                    |  3 --
 include/signal.h                                   |  3 --
 sysdeps/generic/not-cancel.h                       |  4 +--
 sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h    |  1 -
 sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h      |  1 -
 sysdeps/unix/sysv/linux/arm/sysdep-cancel.h        |  1 -
 sysdeps/unix/sysv/linux/fcntl.c                    | 24 +++++++------
 sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h       |  1 -
 sysdeps/unix/sysv/linux/i386/sysdep-cancel.h       |  1 -
 sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h       |  1 -
 sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h       |  1 -
 sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h |  1 -
 sysdeps/unix/sysv/linux/mips/sysdep-cancel.h       |  1 -
 sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h      |  1 -
 sysdeps/unix/sysv/linux/not-cancel.h               |  4 +++
 sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h    |  1 -
 .../unix/sysv/linux/s390/s390-32/sysdep-cancel.h   |  1 -
 .../unix/sysv/linux/s390/s390-64/sysdep-cancel.h   |  1 -
 sysdeps/unix/sysv/linux/sh/sysdep-cancel.h         |  1 -
 sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h      |  1 -
 sysdeps/unix/sysv/linux/tile/sysdep-cancel.h       |  1 -
 sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h     |  1 -
 23 files changed, 62 insertions(+), 35 deletions(-)

-- 
2.7.4
diff mbox series

Patch

diff --git a/include/fcntl.h b/include/fcntl.h
index 9a007c3..3d68c5e 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -9,10 +9,7 @@  extern int __libc_open64 (const char *file, int oflag, ...);
 extern int __libc_open (const char *file, int oflag, ...);
 libc_hidden_proto (__libc_open)
 extern int __libc_fcntl (int fd, int cmd, ...) attribute_hidden;
-#ifndef NO_CANCELLATION
-extern int __fcntl_nocancel (int fd, int cmd, ...) attribute_hidden;
 libc_hidden_proto (__libc_fcntl)
-#endif
 extern int __open (const char *__file, int __oflag, ...);
 libc_hidden_proto (__open)
 extern int __fcntl (int __fd, int __cmd, ...);
diff --git a/include/signal.h b/include/signal.h
index bcf1455..61ad422 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -26,9 +26,6 @@  extern int __sigprocmask (int __how,
 			  const sigset_t *__set, sigset_t *__oset);
 extern int __sigsuspend (const sigset_t *__set);
 libc_hidden_proto (__sigsuspend)
-#ifndef NO_CANCELLATION
-extern int __sigsuspend_nocancel (const sigset_t *__set) attribute_hidden;
-#endif
 extern int __sigwait (const sigset_t *__set, int *__sig);
 libc_hidden_proto (__sigwait)
 extern int __sigwaitinfo (const sigset_t *__set, siginfo_t *__info);
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index 70ead55..3bab664 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -42,5 +42,5 @@ 
   __pause ()
 #define __nanosleep_nocancel(requested_time, remaining) \
   __nanosleep (requested_time, remaining)
-
-#define NO_CANCELLATION 1
+#define __fcntl_nocancel(...) \
+  __fcntl(__VA_ARGS__)
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h
index d39b6a2..2299526 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h
@@ -44,7 +44,6 @@  extern int __local_multiple_threads attribute_hidden;
 
 /* For rtld, et cetera.  */
 # define SINGLE_THREAD_P 1
-# define NO_CANCELLATION 1
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h b/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
index 366cf31..e7d080d 100644
--- a/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
@@ -40,7 +40,6 @@  extern int __local_multiple_threads attribute_hidden;
 #else
 
 # define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h b/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
index 738e749..3e6840e 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
@@ -43,7 +43,6 @@  extern int __local_multiple_threads attribute_hidden;
 
 /* For rtld, et cetera.  */
 # define SINGLE_THREAD_P 1
-# define NO_CANCELLATION 1
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c
index 76e846c..cda6be7 100644
--- a/sysdeps/unix/sysv/linux/fcntl.c
+++ b/sysdeps/unix/sysv/linux/fcntl.c
@@ -19,6 +19,7 @@ 
 #include <stdarg.h>
 #include <errno.h>
 #include <sysdep-cancel.h>
+#include <not-cancel.h>
 
 #ifndef __NR_fcntl64
 # define __NR_fcntl64 __NR_fcntl
@@ -46,9 +47,8 @@  fcntl_common (int fd, int cmd, void *arg)
   return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg);
 }
 
-#ifndef NO_CANCELLATION
 int
-__fcntl_nocancel (int fd, int cmd, ...)
+__libc_fcntl (int fd, int cmd, ...)
 {
   va_list ap;
   void *arg;
@@ -57,12 +57,18 @@  __fcntl_nocancel (int fd, int cmd, ...)
   arg = va_arg (ap, void *);
   va_end (ap);
 
+  cmd = FCNTL_ADJUST_CMD (cmd);
+
+  if (cmd == F_SETLKW || cmd == F_SETLKW64)
+    return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg);
+
   return fcntl_common (fd, cmd, arg);
 }
-#endif
+libc_hidden_def (__libc_fcntl)
 
+#if !IS_IN (rtld)
 int
-__libc_fcntl (int fd, int cmd, ...)
+__fcntl_nocancel (int fd, int cmd, ...)
 {
   va_list ap;
   void *arg;
@@ -71,14 +77,12 @@  __libc_fcntl (int fd, int cmd, ...)
   arg = va_arg (ap, void *);
   va_end (ap);
 
-  cmd = FCNTL_ADJUST_CMD (cmd);
-
-  if (cmd == F_SETLKW || cmd == F_SETLKW64)
-    return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg);
-
   return fcntl_common (fd, cmd, arg);
 }
-libc_hidden_def (__libc_fcntl)
+#else
+strong_alias (__libc_fcntl, __fcntl_nocancel)
+#endif
+libc_hidden_def (__fcntl_nocancel)
 
 weak_alias (__libc_fcntl, __fcntl)
 libc_hidden_weak (__fcntl)
diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h b/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h
index a6189a7..d5966d9 100644
--- a/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h
@@ -41,7 +41,6 @@ 
 
 /* This code should never be used but we define it anyhow.  */
 # define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
 
 #endif
 /* IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) */
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h b/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
index 34e2b6f..42ec62f 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
@@ -31,7 +31,6 @@ 
 #else
 
 # define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
index 96d04de..02117ad 100644
--- a/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
@@ -27,7 +27,6 @@ 
   __builtin_expect (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0, 1)
 #else
 # define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
 #endif
 
 #define RTLD_SINGLE_THREAD_P \
diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h b/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h
index 1603c5f..b91451d 100644
--- a/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h
@@ -28,7 +28,6 @@ 
 #else
 
 # define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION (1)
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h b/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h
index 7fe030b..ec32745 100644
--- a/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h
@@ -41,7 +41,6 @@  extern int __local_multiple_threads attribute_hidden;
 #else
 
 # define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION (1)
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h b/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
index fe9a3fc..f40a86d 100644
--- a/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
@@ -30,7 +30,6 @@ 
 #else
 
 # define SINGLE_THREAD_P 1
-# define NO_CANCELLATION 1
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h b/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h
index 7647363..b84365a 100644
--- a/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h
@@ -30,7 +30,6 @@ 
 #else
 
 # define SINGLE_THREAD_P 1
-# define NO_CANCELLATION 1
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 8740d40..ef99bac 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -86,4 +86,8 @@  libc_hidden_proto (__pause_nocancel)
 __typeof (__nanosleep) __nanosleep_nocancel;
 hidden_proto (__nanosleep_nocancel)
 
+/* Uncancelable fcntl.  */
+__typeof (__fcntl) __fcntl_nocancel;
+libc_hidden_proto (__fcntl_nocancel)
+
 #endif /* NOT_CANCEL_H  */
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h b/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h
index 85af880..23dbbbd 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h
@@ -29,7 +29,6 @@ 
 #else
 
 # define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
index 82763b7..a6ff391 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
@@ -31,7 +31,6 @@ 
 #else
 
 # define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
index 952d2af..e54a696 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
@@ -44,7 +44,6 @@  extern int __local_multiple_threads attribute_hidden;
 #else
 
 # define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
index 1ea501b..1b8c5d7 100644
--- a/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
@@ -30,7 +30,6 @@ 
 #else
 
 # define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
index 61bfa33..f3eb49f 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
@@ -29,7 +29,6 @@ 
 #else
 
 # define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h b/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h
index c8994db..fedabfb 100644
--- a/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h
@@ -30,7 +30,6 @@ 
 #else
 
 # define SINGLE_THREAD_P 1
-# define NO_CANCELLATION 1
 
 #endif
 
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
index 0979bde..39f9453 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
@@ -46,7 +46,6 @@  extern int __local_multiple_threads attribute_hidden;
 #else
 
 # define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
 
 #endif