* [PATCH 04/14] Consolidate non cancellable openat call
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 12/14] Fix {INLINE,INTERNAL}_SYSCALL macros for x32 Adhemerval Zanella
` (13 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
This patch consolidates all the non cancellable openat{64} calls to use
the __openat{64}_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.
* sysdeps/generic/not-cancel.h (openat_not_cancel): Remove macro.
(openat_not_cancel_3): Likewise.
(openat64_not_cancel_3): Likewise).
(openat_not_cancel_3): Likewise).
* sysdeps/unix/sysv/linux/not-cancel.h (openat_not_cancel): Remove
macro.
(openat_not_cancel_3): Likewise.
(openat64_not_cancel): Likewise.
(openat64_not_cancel_3): Likewise.
* sysdeps/unix/sysv/linux/openat.c (__openat_nocancel): New function.
* sysdeps/unix/sysv/linux/openat64.c (__openat64_nocancel): Likewise.
* io/ftw.c (open_dir_stream): Replace openat{64}_not_cancel{_3} with
__open{64}_nocancel.
* sysdeps/mach/hurd/opendir.c (__opendirat): Likewise.
* sysdeps/posix/getcwd.c (__getcwd): Likewise.
* sysdeps/posix/opendir.c (__opendirat): Likewise.
---
ChangeLog | 17 +++++++++++++++++
io/ftw.c | 4 ++--
sysdeps/generic/not-cancel.h | 12 ++++--------
sysdeps/mach/hurd/opendir.c | 2 +-
sysdeps/posix/getcwd.c | 4 ++--
sysdeps/posix/opendir.c | 2 +-
sysdeps/unix/sysv/linux/not-cancel.h | 18 ++++++++----------
sysdeps/unix/sysv/linux/openat.c | 16 ++++++++++++++++
sysdeps/unix/sysv/linux/openat64.c | 32 ++++++++++++++++++++++++++------
9 files changed, 77 insertions(+), 30 deletions(-)
diff --git a/io/ftw.c b/io/ftw.c
index 140a237..f33fed3 100644
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -337,8 +337,8 @@ open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp)
if (dfdp != NULL && *dfdp != -1)
{
- int fd = openat64_not_cancel_3 (*dfdp, data->dirbuf + data->ftw.base,
- O_RDONLY | O_DIRECTORY | O_NDELAY);
+ int fd = __openat64_nocancel (*dfdp, data->dirbuf + data->ftw.base,
+ O_RDONLY | O_DIRECTORY | O_NDELAY);
dirp->stream = NULL;
if (fd != -1 && (dirp->stream = __fdopendir (fd)) == NULL)
close_not_cancel_no_status (fd);
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index e91cb6c..df9aea6 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -22,14 +22,10 @@
__open (__VA_ARGS__)
#define __open64_nocancel(...) \
__open64 (__VA_ARGS__)
-#define openat_not_cancel(fd, name, flags, mode) \
- __openat (fd, name, flags, mode)
-#define openat_not_cancel_3(fd, name, flags) \
- __openat (fd, name, flags, 0)
-#define openat64_not_cancel(fd, name, flags, mode) \
- __openat64 (fd, name, flags, mode)
-#define openat64_not_cancel_3(fd, name, flags) \
- __openat64 (fd, name, flags, 0)
+#define __openat_nocancel(...) \
+ __openat (__VA_ARGS__)
+#define __openat64_nocancel(...) \
+ __openat64 (__VA_ARGS__)
#define close_not_cancel(fd) \
__close (fd)
#define close_not_cancel_no_status(fd) \
diff --git a/sysdeps/mach/hurd/opendir.c b/sysdeps/mach/hurd/opendir.c
index 8db70b2..d3757f0 100644
--- a/sysdeps/mach/hurd/opendir.c
+++ b/sysdeps/mach/hurd/opendir.c
@@ -86,7 +86,7 @@ __opendirat (int dfd, const char *name)
assert (dfd == AT_FDCWD);
fd = __open_nocancel (name, flags);
#else
- fd = openat_not_cancel_3 (dfd, name, flags);
+ fd = __openat_nocancel (dfd, name, flags);
#endif
if (fd < 0)
return NULL;
diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
index eb1706a..ecae628 100644
--- a/sysdeps/posix/getcwd.c
+++ b/sysdeps/posix/getcwd.c
@@ -175,7 +175,7 @@ extern char *alloca ();
# include <not-cancel.h>
# include <kernel-features.h>
#else
-# define openat64_not_cancel_3(dfd, name, mode) openat64 (dfd, name, mode)
+# define __openat64_nocancel(dfd, name, mode) openat64 (dfd, name, mode)
# define close_not_cancel_no_status(fd) close (fd)
#endif
@@ -281,7 +281,7 @@ __getcwd (char *buf, size_t size)
while (!(thisdev == rootdev && thisino == rootino))
{
if (__have_atfcts >= 0)
- fd = openat64_not_cancel_3 (fd, "..", O_RDONLY | O_CLOEXEC);
+ fd = __openat64_nocancel (fd, "..", O_RDONLY | O_CLOEXEC);
else
fd = -1;
if (fd >= 0)
diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c
index 3ee27b2..51a92e8 100644
--- a/sysdeps/posix/opendir.c
+++ b/sysdeps/posix/opendir.c
@@ -161,7 +161,7 @@ __opendirat (int dfd, const char *name)
}
}
- return opendir_tail (openat_not_cancel_3 (dfd, name, opendir_oflags));
+ return opendir_tail (__openat_nocancel (dfd, name, opendir_oflags));
}
#endif
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 84dc72a..08ad773 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -34,6 +34,14 @@ libc_hidden_proto (__open_nocancel)
__typeof (open64) __open64_nocancel;
libc_hidden_proto (__open64_nocancel)
+/* Non cancellable openat syscall. */
+__typeof (openat) __openat_nocancel;
+libc_hidden_proto (__openat_nocancel)
+
+/* Non cacellable openat syscall (LFS version). */
+__typeof (openat64) __openat64_nocancel;
+libc_hidden_proto (__openat64_nocancel)
+
/* Non cancellable read syscall. */
__typeof (__read) __read_nocancel;
libc_hidden_proto (__read_nocancel)
@@ -42,16 +50,6 @@ libc_hidden_proto (__read_nocancel)
__typeof (__write) __write_nocancel;
libc_hidden_proto (__write_nocancel)
-/* Uncancelable openat. */
-#define openat_not_cancel(fd, fname, oflag, mode) \
- INLINE_SYSCALL (openat, 4, fd, fname, oflag, mode)
-#define openat_not_cancel_3(fd, fname, oflag) \
- INLINE_SYSCALL (openat, 3, fd, fname, oflag)
-#define openat64_not_cancel(fd, fname, oflag, mode) \
- INLINE_SYSCALL (openat, 4, fd, fname, oflag | O_LARGEFILE, mode)
-#define openat64_not_cancel_3(fd, fname, oflag) \
- INLINE_SYSCALL (openat, 3, fd, fname, oflag | O_LARGEFILE)
-
/* Uncancelable close. */
#define __close_nocancel(fd) \
INLINE_SYSCALL (close, 1, fd)
diff --git a/sysdeps/unix/sysv/linux/openat.c b/sysdeps/unix/sysv/linux/openat.c
index 1587305..3057301 100644
--- a/sysdeps/unix/sysv/linux/openat.c
+++ b/sysdeps/unix/sysv/linux/openat.c
@@ -19,6 +19,7 @@
#include <stdarg.h>
#include <sysdep-cancel.h>
+#include <not-cancel.h>
#ifndef __OFF_T_MATCHES_OFF64_T
@@ -43,4 +44,19 @@ weak_alias (__libc_openat, __openat)
libc_hidden_weak (__openat)
weak_alias (__libc_openat, openat)
+int
+__openat_nocancel (int fd, const char *file, int oflag, ...)
+{
+ mode_t mode = 0;
+ if (__OPEN_NEEDS_MODE (oflag))
+ {
+ va_list arg;
+ va_start (arg, oflag);
+ mode = va_arg (arg, mode_t);
+ va_end (arg);
+ }
+
+ return SYSCALL_CANCEL (openat, fd, file, oflag, mode);
+}
+libc_hidden_weak (__openat_nocancel)
#endif
diff --git a/sysdeps/unix/sysv/linux/openat64.c b/sysdeps/unix/sysv/linux/openat64.c
index 4942061..3c1cdf8 100644
--- a/sysdeps/unix/sysv/linux/openat64.c
+++ b/sysdeps/unix/sysv/linux/openat64.c
@@ -19,6 +19,13 @@
#include <stdarg.h>
#include <sysdep-cancel.h>
+#include <not-cancel.h>
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+# define EXTRA_OPEN_FLAGS 0
+#else
+# define EXTRA_OPEN_FLAGS O_LARGEFILE
+#endif
/* Open FILE with access OFLAG. Interpret relative paths relative to
the directory associated with FD. If OFLAG includes O_CREAT or
@@ -35,12 +42,6 @@ __libc_openat64 (int fd, const char *file, int oflag, ...)
va_end (arg);
}
-#ifdef __OFF_T_MATCHES_OFF64_T
-# define EXTRA_OPEN_FLAGS 0
-#else
-# define EXTRA_OPEN_FLAGS O_LARGEFILE
-#endif
-
return SYSCALL_CANCEL (openat, fd, file, oflag | EXTRA_OPEN_FLAGS, mode);
}
@@ -48,8 +49,27 @@ strong_alias (__libc_openat64, __openat64)
libc_hidden_weak (__openat64)
weak_alias (__libc_openat64, openat64)
+int
+__openat64_nocancel (int fd, const char *file, int oflag, ...)
+{
+ mode_t mode = 0;
+ if (__OPEN_NEEDS_MODE (oflag))
+ {
+ va_list arg;
+ va_start (arg, oflag);
+ mode = va_arg (arg, mode_t);
+ va_end (arg);
+ }
+
+ return INLINE_SYSCALL_CALL (openat, fd, file, oflag | EXTRA_OPEN_FLAGS,
+ mode);
+}
+libc_hidden_def (__openat64_nocancel)
+
#ifdef __OFF_T_MATCHES_OFF64_T
strong_alias (__libc_openat64, __openat)
libc_hidden_weak (__openat)
weak_alias (__libc_openat64, openat)
+
+strong_alias (__openat64_nocancel, __openat_nocancel)
#endif
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 12/14] Fix {INLINE,INTERNAL}_SYSCALL macros for x32
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 04/14] Consolidate non cancellable openat call Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 20:09 ` H.J. Lu
2017-07-04 19:54 ` [PATCH 01/14] Consolidate non cancellable open call Adhemerval Zanella
` (12 subsequent siblings)
14 siblings, 1 reply; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha; +Cc: Adhemerval Zanella
From: Adhemerval Zanella <adhemerval.zanella@linaro.com>
The problem for x32 is the {INTERNAL,INLINE}_SYSCALL C macros explicit
cast the arguments to 'long int', thus passing as 32 bits arguments
that should be passed to 64 bits.
Previous x32 implementation uses the auto-generated syscalls from
assembly macros (syscalls.list), so the {INTERNAL,INLINE}_SYSCALL
macros are never used with 64 bit argument in x32 (which are
internally broken for this ILP).
To fix it I used a strategy similar to MIPS64n32 (although both
ABI differs for some syscalls on how top pass 64-bits arguments)
where argument types for kernel call are defined using GCC extension
'typeof' with a arithmetic operation. This allows 64-bits arguments
to be defined while 32-bits argument will still passed as 32-bits.
I also cleanup the {INLINE,INTERNAL}_SYSCALL definition by defining
'inline_syscallX' instead of constructing the argument passing using
macros (it adds some readability) and removed the ununsed
INTERNAL_SYSCALL_NCS_TYPES define (since the patch idea is exactly to
avoid requiric explicit types passing).
Tested on x86_64 and x32.
* sysdeps/unix/sysv/linux/x86_64/sysdep.h
(INTERNAL_SYSCALL_NCS_TYPES): Remove define.
(LOAD_ARGS_0): Likewise.
(LOAD_ARGS_1): Likewise.
(LOAD_ARGS_2): Likewise.
(LOAD_ARGS_3): Likewise.
(LOAD_ARGS_4): Likewise.
(LOAD_ARGS_5): Likewise.
(LOAD_ARGS_6): Likewise.
(LOAD_REGS_0): Likewise.
(LOAD_REGS_1): Likewise.
(LOAD_REGS_2): Likewise.
(LOAD_REGS_3): Likewise.
(LOAD_REGS_4): Likewise.
(LOAD_REGS_5): Likewise.
(LOAD_REGS_6): Likewise.
(ASM_ARGS_0): Likewise.
(ASM_ARGS_1): Likewise.
(ASM_ARGS_2): Likewise.
(ASM_ARGS_3): Likewise.
(ASM_ARGS_4): Likewise.
(ASM_ARGS_5): Likewise.
(ASM_ARGS_6): Likewise.
(LOAD_ARGS_TYPES_1): Likewise.
(LOAD_ARGS_TYPES_2): Likewise.
(LOAD_ARGS_TYPES_3): Likewise.
(LOAD_ARGS_TYPES_4): Likewise.
(LOAD_ARGS_TYPES_5): Likewise.
(LOAD_ARGS_TYPES_6): Likewise.
(LOAD_REGS_TYPES_1): Likewise.
(LOAD_REGS_TYPES_2): Likewise.
(LOAD_REGS_TYPES_3): Likewise.
(LOAD_REGS_TYPES_4): Likewise.
(LOAD_REGS_TYPES_5): Likewise.
(LOAD_REGS_TYPES_6): Likewise.
(TYPEFY): New define.
(ARGIFY): Likewise.
(internal_syscall0): Likewise.
(internal_syscall1): Likewise.
(internal_syscall2): Likewise.
(internal_syscall3): Likewise.
(internal_syscall4): Likewise.
(internal_syscall5): Likewise.
(internal_syscall6): Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/times.c
(INTERNAL_SYSCALL_NCS): Remove define.
(internal_syscall1): Add define.
---
ChangeLog | 48 ++++++
sysdeps/unix/sysv/linux/x86_64/sysdep.h | 251 ++++++++++++++++-------------
sysdeps/unix/sysv/linux/x86_64/x32/times.c | 24 +--
3 files changed, 203 insertions(+), 120 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index 880e496..f299bf2 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -221,33 +221,148 @@
/* Registers clobbered by syscall. */
# define REGISTERS_CLOBBERED_BY_SYSCALL "cc", "r11", "cx"
-# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
- ({ \
- unsigned long int resultvar; \
- LOAD_ARGS_##nr (args) \
- LOAD_REGS_##nr \
- asm volatile ( \
- "syscall\n\t" \
- : "=a" (resultvar) \
- : "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
- (long int) resultvar; })
-# undef INTERNAL_SYSCALL
-# define INTERNAL_SYSCALL(name, err, nr, args...) \
- INTERNAL_SYSCALL_NCS (__NR_##name, err, nr, ##args)
-
-# define INTERNAL_SYSCALL_NCS_TYPES(name, err, nr, args...) \
- ({ \
- unsigned long int resultvar; \
- LOAD_ARGS_TYPES_##nr (args) \
- LOAD_REGS_TYPES_##nr (args) \
- asm volatile ( \
- "syscall\n\t" \
- : "=a" (resultvar) \
- : "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
- (long int) resultvar; })
-# undef INTERNAL_SYSCALL_TYPES
-# define INTERNAL_SYSCALL_TYPES(name, err, nr, args...) \
- INTERNAL_SYSCALL_NCS_TYPES (__NR_##name, err, nr, ##args)
+/* Create a variable 'name' based on type 'X' to avoid explicit types.
+ This is mainly used set use 64-bits arguments in x32. */
+#define TYPEFY(X, name) __typeof__ ((X) - (X)) name
+/* Explicit cast the argument to avoid integer from pointer warning on
+ x32. */
+#define ARGIFY(X) ((__typeof__ ((X) - (X))) (X))
+
+#undef INTERNAL_SYSCALL
+#define INTERNAL_SYSCALL(name, err, nr, args...) \
+ internal_syscall##nr (SYS_ify (name), err, args)
+
+#undef INTERNAL_SYSCALL_NCS
+#define INTERNAL_SYSCALL_NCS(number, err, nr, args...) \
+ internal_syscall##nr (number, err, args)
+
+#undef internal_syscall0
+#define internal_syscall0(number, err, dummy...) \
+({ \
+ unsigned long int resultvar; \
+ asm volatile ( \
+ "syscall\n\t" \
+ : "=a" (resultvar) \
+ : "0" (number) \
+ : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
+ (long int) resultvar; \
+})
+
+#undef internal_syscall1
+#define internal_syscall1(number, err, arg1) \
+({ \
+ unsigned long int resultvar; \
+ TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
+ register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ asm volatile ( \
+ "syscall\n\t" \
+ : "=a" (resultvar) \
+ : "0" (number), "r" (_a1) \
+ : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
+ (long int) resultvar; \
+})
+
+#undef internal_syscall2
+#define internal_syscall2(number, err, arg1, arg2) \
+({ \
+ unsigned long int resultvar; \
+ TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
+ TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
+ register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
+ register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ asm volatile ( \
+ "syscall\n\t" \
+ : "=a" (resultvar) \
+ : "0" (number), "r" (_a1), "r" (_a2) \
+ : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
+ (long int) resultvar; \
+})
+
+#undef internal_syscall3
+#define internal_syscall3(number, err, arg1, arg2, arg3) \
+({ \
+ unsigned long int resultvar; \
+ TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
+ TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
+ TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
+ register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
+ register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
+ register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ asm volatile ( \
+ "syscall\n\t" \
+ : "=a" (resultvar) \
+ : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3) \
+ : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
+ (long int) resultvar; \
+})
+
+#undef internal_syscall4
+#define internal_syscall4(number, err, arg1, arg2, arg3, arg4) \
+({ \
+ unsigned long int resultvar; \
+ TYPEFY (arg4, __arg4) = ARGIFY (arg4); \
+ TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
+ TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
+ TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
+ register TYPEFY (arg4, _a4) asm ("r10") = __arg4; \
+ register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
+ register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
+ register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ asm volatile ( \
+ "syscall\n\t" \
+ : "=a" (resultvar) \
+ : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4) \
+ : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
+ (long int) resultvar; \
+})
+
+#undef internal_syscall5
+#define internal_syscall5(number, err, arg1, arg2, arg3, arg4, arg5) \
+({ \
+ unsigned long int resultvar; \
+ TYPEFY (arg5, __arg5) = ARGIFY (arg5); \
+ TYPEFY (arg4, __arg4) = ARGIFY (arg4); \
+ TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
+ TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
+ TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
+ register TYPEFY (arg5, _a5) asm ("r8") = __arg5; \
+ register TYPEFY (arg4, _a4) asm ("r10") = __arg4; \
+ register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
+ register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
+ register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ asm volatile ( \
+ "syscall\n\t" \
+ : "=a" (resultvar) \
+ : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4), \
+ "r" (_a5) \
+ : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
+ (long int) resultvar; \
+})
+
+#undef internal_syscall6
+#define internal_syscall6(number, err, arg1, arg2, arg3, arg4, arg5, arg6) \
+({ \
+ unsigned long int resultvar; \
+ TYPEFY (arg6, __arg6) = ARGIFY (arg6); \
+ TYPEFY (arg5, __arg5) = ARGIFY (arg5); \
+ TYPEFY (arg4, __arg4) = ARGIFY (arg4); \
+ TYPEFY (arg3, __arg3) = ARGIFY (arg3); \
+ TYPEFY (arg2, __arg2) = ARGIFY (arg2); \
+ TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
+ register TYPEFY (arg6, _a6) asm ("r9") = __arg6; \
+ register TYPEFY (arg5, _a5) asm ("r8") = __arg5; \
+ register TYPEFY (arg4, _a4) asm ("r10") = __arg4; \
+ register TYPEFY (arg3, _a3) asm ("rdx") = __arg3; \
+ register TYPEFY (arg2, _a2) asm ("rsi") = __arg2; \
+ register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ asm volatile ( \
+ "syscall\n\t" \
+ : "=a" (resultvar) \
+ : "0" (number), "r" (_a1), "r" (_a2), "r" (_a3), "r" (_a4), \
+ "r" (_a5), "r" (_a6) \
+ : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
+ (long int) resultvar; \
+})
# undef INTERNAL_SYSCALL_ERROR_P
# define INTERNAL_SYSCALL_ERROR_P(val, err) \
@@ -261,88 +376,6 @@
# define HAVE_GETTIMEOFDAY_VSYSCALL 1
# define HAVE_GETCPU_VSYSCALL 1
-# define LOAD_ARGS_0()
-# define LOAD_REGS_0
-# define ASM_ARGS_0
-
-# define LOAD_ARGS_TYPES_1(t1, a1) \
- t1 __arg1 = (t1) (a1); \
- LOAD_ARGS_0 ()
-# define LOAD_REGS_TYPES_1(t1, a1) \
- register t1 _a1 asm ("rdi") = __arg1; \
- LOAD_REGS_0
-# define ASM_ARGS_1 ASM_ARGS_0, "r" (_a1)
-# define LOAD_ARGS_1(a1) \
- LOAD_ARGS_TYPES_1 (long int, a1)
-# define LOAD_REGS_1 \
- LOAD_REGS_TYPES_1 (long int, a1)
-
-# define LOAD_ARGS_TYPES_2(t1, a1, t2, a2) \
- t2 __arg2 = (t2) (a2); \
- LOAD_ARGS_TYPES_1 (t1, a1)
-# define LOAD_REGS_TYPES_2(t1, a1, t2, a2) \
- register t2 _a2 asm ("rsi") = __arg2; \
- LOAD_REGS_TYPES_1(t1, a1)
-# define ASM_ARGS_2 ASM_ARGS_1, "r" (_a2)
-# define LOAD_ARGS_2(a1, a2) \
- LOAD_ARGS_TYPES_2 (long int, a1, long int, a2)
-# define LOAD_REGS_2 \
- LOAD_REGS_TYPES_2 (long int, a1, long int, a2)
-
-# define LOAD_ARGS_TYPES_3(t1, a1, t2, a2, t3, a3) \
- t3 __arg3 = (t3) (a3); \
- LOAD_ARGS_TYPES_2 (t1, a1, t2, a2)
-# define LOAD_REGS_TYPES_3(t1, a1, t2, a2, t3, a3) \
- register t3 _a3 asm ("rdx") = __arg3; \
- LOAD_REGS_TYPES_2(t1, a1, t2, a2)
-# define ASM_ARGS_3 ASM_ARGS_2, "r" (_a3)
-# define LOAD_ARGS_3(a1, a2, a3) \
- LOAD_ARGS_TYPES_3 (long int, a1, long int, a2, long int, a3)
-# define LOAD_REGS_3 \
- LOAD_REGS_TYPES_3 (long int, a1, long int, a2, long int, a3)
-
-# define LOAD_ARGS_TYPES_4(t1, a1, t2, a2, t3, a3, t4, a4) \
- t4 __arg4 = (t4) (a4); \
- LOAD_ARGS_TYPES_3 (t1, a1, t2, a2, t3, a3)
-# define LOAD_REGS_TYPES_4(t1, a1, t2, a2, t3, a3, t4, a4) \
- register t4 _a4 asm ("r10") = __arg4; \
- LOAD_REGS_TYPES_3(t1, a2, t2, a2, t3, a3)
-# define ASM_ARGS_4 ASM_ARGS_3, "r" (_a4)
-# define LOAD_ARGS_4(a1, a2, a3, a4) \
- LOAD_ARGS_TYPES_4 (long int, a1, long int, a2, long int, a3, \
- long int, a4)
-# define LOAD_REGS_4 \
- LOAD_REGS_TYPES_4 (long int, a1, long int, a2, long int, a3, \
- long int, a4)
-
-# define LOAD_ARGS_TYPES_5(t1, a1, t2, a2, t3, a3, t4, a4, t5, a5) \
- t5 __arg5 = (t5) (a5); \
- LOAD_ARGS_TYPES_4 (t1, a1, t2, a2, t3, a3, t4, a4)
-# define LOAD_REGS_TYPES_5(t1, a1, t2, a2, t3, a3, t4, a4, t5, a5) \
- register t5 _a5 asm ("r8") = __arg5; \
- LOAD_REGS_TYPES_4 (t1, a1, t2, a2, t3, a3, t4, a4)
-# define ASM_ARGS_5 ASM_ARGS_4, "r" (_a5)
-# define LOAD_ARGS_5(a1, a2, a3, a4, a5) \
- LOAD_ARGS_TYPES_5 (long int, a1, long int, a2, long int, a3, \
- long int, a4, long int, a5)
-# define LOAD_REGS_5 \
- LOAD_REGS_TYPES_5 (long int, a1, long int, a2, long int, a3, \
- long int, a4, long int, a5)
-
-# define LOAD_ARGS_TYPES_6(t1, a1, t2, a2, t3, a3, t4, a4, t5, a5, t6, a6) \
- t6 __arg6 = (t6) (a6); \
- LOAD_ARGS_TYPES_5 (t1, a1, t2, a2, t3, a3, t4, a4, t5, a5)
-# define LOAD_REGS_TYPES_6(t1, a1, t2, a2, t3, a3, t4, a4, t5, a5, t6, a6) \
- register t6 _a6 asm ("r9") = __arg6; \
- LOAD_REGS_TYPES_5 (t1, a1, t2, a2, t3, a3, t4, a4, t5, a5)
-# define ASM_ARGS_6 ASM_ARGS_5, "r" (_a6)
-# define LOAD_ARGS_6(a1, a2, a3, a4, a5, a6) \
- LOAD_ARGS_TYPES_6 (long int, a1, long int, a2, long int, a3, \
- long int, a4, long int, a5, long int, a6)
-# define LOAD_REGS_6 \
- LOAD_REGS_TYPES_6 (long int, a1, long int, a2, long int, a3, \
- long int, a4, long int, a5, long int, a6)
-
#endif /* __ASSEMBLER__ */
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/times.c b/sysdeps/unix/sysv/linux/x86_64/x32/times.c
index d56106e..8763047 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/times.c
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/times.c
@@ -19,17 +19,19 @@
#include <sysdep.h>
/* Linux times system call returns 64-bit integer. */
-#undef INTERNAL_SYSCALL_NCS
-#define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
- ({ \
- unsigned long long int resultvar; \
- LOAD_ARGS_##nr (args) \
- LOAD_REGS_##nr \
- asm volatile ( \
- "syscall\n\t" \
- : "=a" (resultvar) \
- : "0" (name) ASM_ARGS_##nr : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
- (long long int) resultvar; })
+#undef internal_syscall1
+#define internal_syscall1(number, err, arg1) \
+({ \
+ unsigned long long int resultvar; \
+ TYPEFY (arg1, __arg1) = ARGIFY (arg1); \
+ register TYPEFY (arg1, _a1) asm ("rdi") = __arg1; \
+ asm volatile ( \
+ "syscall\n\t" \
+ : "=a" (resultvar) \
+ : "0" (number), "r" (_a1) \
+ : "memory", REGISTERS_CLOBBERED_BY_SYSCALL); \
+ (long long int) resultvar; \
+})
#undef INTERNAL_SYSCALL_ERROR_P
#define INTERNAL_SYSCALL_ERROR_P(val, err) \
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 12/14] Fix {INLINE,INTERNAL}_SYSCALL macros for x32
2017-07-04 19:54 ` [PATCH 12/14] Fix {INLINE,INTERNAL}_SYSCALL macros for x32 Adhemerval Zanella
@ 2017-07-04 20:09 ` H.J. Lu
2017-07-04 20:22 ` Adhemerval Zanella
0 siblings, 1 reply; 21+ messages in thread
From: H.J. Lu @ 2017-07-04 20:09 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: GNU C Library, Adhemerval Zanella
On Tue, Jul 4, 2017 at 12:53 PM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
> From: Adhemerval Zanella <adhemerval.zanella@linaro.com>
>
> The problem for x32 is the {INTERNAL,INLINE}_SYSCALL C macros explicit
> cast the arguments to 'long int', thus passing as 32 bits arguments
> that should be passed to 64 bits.
>
> Previous x32 implementation uses the auto-generated syscalls from
> assembly macros (syscalls.list), so the {INTERNAL,INLINE}_SYSCALL
> macros are never used with 64 bit argument in x32 (which are
> internally broken for this ILP).
>
> To fix it I used a strategy similar to MIPS64n32 (although both
> ABI differs for some syscalls on how top pass 64-bits arguments)
> where argument types for kernel call are defined using GCC extension
> 'typeof' with a arithmetic operation. This allows 64-bits arguments
> to be defined while 32-bits argument will still passed as 32-bits.
>
> I also cleanup the {INLINE,INTERNAL}_SYSCALL definition by defining
> 'inline_syscallX' instead of constructing the argument passing using
> macros (it adds some readability) and removed the ununsed
> INTERNAL_SYSCALL_NCS_TYPES define (since the patch idea is exactly to
> avoid requiric explicit types passing).
>
> Tested on x86_64 and x32.
>
> * sysdeps/unix/sysv/linux/x86_64/sysdep.h
> (INTERNAL_SYSCALL_NCS_TYPES): Remove define.
> (LOAD_ARGS_0): Likewise.
> (LOAD_ARGS_1): Likewise.
> (LOAD_ARGS_2): Likewise.
> (LOAD_ARGS_3): Likewise.
> (LOAD_ARGS_4): Likewise.
> (LOAD_ARGS_5): Likewise.
> (LOAD_ARGS_6): Likewise.
> (LOAD_REGS_0): Likewise.
> (LOAD_REGS_1): Likewise.
> (LOAD_REGS_2): Likewise.
> (LOAD_REGS_3): Likewise.
> (LOAD_REGS_4): Likewise.
> (LOAD_REGS_5): Likewise.
> (LOAD_REGS_6): Likewise.
> (ASM_ARGS_0): Likewise.
> (ASM_ARGS_1): Likewise.
> (ASM_ARGS_2): Likewise.
> (ASM_ARGS_3): Likewise.
> (ASM_ARGS_4): Likewise.
> (ASM_ARGS_5): Likewise.
> (ASM_ARGS_6): Likewise.
> (LOAD_ARGS_TYPES_1): Likewise.
> (LOAD_ARGS_TYPES_2): Likewise.
> (LOAD_ARGS_TYPES_3): Likewise.
> (LOAD_ARGS_TYPES_4): Likewise.
> (LOAD_ARGS_TYPES_5): Likewise.
> (LOAD_ARGS_TYPES_6): Likewise.
> (LOAD_REGS_TYPES_1): Likewise.
> (LOAD_REGS_TYPES_2): Likewise.
> (LOAD_REGS_TYPES_3): Likewise.
> (LOAD_REGS_TYPES_4): Likewise.
> (LOAD_REGS_TYPES_5): Likewise.
> (LOAD_REGS_TYPES_6): Likewise.
> (TYPEFY): New define.
> (ARGIFY): Likewise.
> (internal_syscall0): Likewise.
> (internal_syscall1): Likewise.
> (internal_syscall2): Likewise.
> (internal_syscall3): Likewise.
> (internal_syscall4): Likewise.
> (internal_syscall5): Likewise.
> (internal_syscall6): Likewise.
> * sysdeps/unix/sysv/linux/x86_64/x32/times.c
> (INTERNAL_SYSCALL_NCS): Remove define.
> (internal_syscall1): Add define.
Could you please push your branch to glibc git repo so that I can
check out the whole patch series?
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 12/14] Fix {INLINE,INTERNAL}_SYSCALL macros for x32
2017-07-04 20:09 ` H.J. Lu
@ 2017-07-04 20:22 ` Adhemerval Zanella
2017-07-04 21:34 ` H.J. Lu
0 siblings, 1 reply; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 20:22 UTC (permalink / raw)
To: H.J. Lu; +Cc: GNU C Library, Adhemerval Zanella
On 04/07/2017 17:09, H.J. Lu wrote:
> On Tue, Jul 4, 2017 at 12:53 PM, Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
>> From: Adhemerval Zanella <adhemerval.zanella@linaro.com>
>>
>> The problem for x32 is the {INTERNAL,INLINE}_SYSCALL C macros explicit
>> cast the arguments to 'long int', thus passing as 32 bits arguments
>> that should be passed to 64 bits.
>>
>> Previous x32 implementation uses the auto-generated syscalls from
>> assembly macros (syscalls.list), so the {INTERNAL,INLINE}_SYSCALL
>> macros are never used with 64 bit argument in x32 (which are
>> internally broken for this ILP).
>>
>> To fix it I used a strategy similar to MIPS64n32 (although both
>> ABI differs for some syscalls on how top pass 64-bits arguments)
>> where argument types for kernel call are defined using GCC extension
>> 'typeof' with a arithmetic operation. This allows 64-bits arguments
>> to be defined while 32-bits argument will still passed as 32-bits.
>>
>> I also cleanup the {INLINE,INTERNAL}_SYSCALL definition by defining
>> 'inline_syscallX' instead of constructing the argument passing using
>> macros (it adds some readability) and removed the ununsed
>> INTERNAL_SYSCALL_NCS_TYPES define (since the patch idea is exactly to
>> avoid requiric explicit types passing).
>>
>> Tested on x86_64 and x32.
>>
>> * sysdeps/unix/sysv/linux/x86_64/sysdep.h
>> (INTERNAL_SYSCALL_NCS_TYPES): Remove define.
>> (LOAD_ARGS_0): Likewise.
>> (LOAD_ARGS_1): Likewise.
>> (LOAD_ARGS_2): Likewise.
>> (LOAD_ARGS_3): Likewise.
>> (LOAD_ARGS_4): Likewise.
>> (LOAD_ARGS_5): Likewise.
>> (LOAD_ARGS_6): Likewise.
>> (LOAD_REGS_0): Likewise.
>> (LOAD_REGS_1): Likewise.
>> (LOAD_REGS_2): Likewise.
>> (LOAD_REGS_3): Likewise.
>> (LOAD_REGS_4): Likewise.
>> (LOAD_REGS_5): Likewise.
>> (LOAD_REGS_6): Likewise.
>> (ASM_ARGS_0): Likewise.
>> (ASM_ARGS_1): Likewise.
>> (ASM_ARGS_2): Likewise.
>> (ASM_ARGS_3): Likewise.
>> (ASM_ARGS_4): Likewise.
>> (ASM_ARGS_5): Likewise.
>> (ASM_ARGS_6): Likewise.
>> (LOAD_ARGS_TYPES_1): Likewise.
>> (LOAD_ARGS_TYPES_2): Likewise.
>> (LOAD_ARGS_TYPES_3): Likewise.
>> (LOAD_ARGS_TYPES_4): Likewise.
>> (LOAD_ARGS_TYPES_5): Likewise.
>> (LOAD_ARGS_TYPES_6): Likewise.
>> (LOAD_REGS_TYPES_1): Likewise.
>> (LOAD_REGS_TYPES_2): Likewise.
>> (LOAD_REGS_TYPES_3): Likewise.
>> (LOAD_REGS_TYPES_4): Likewise.
>> (LOAD_REGS_TYPES_5): Likewise.
>> (LOAD_REGS_TYPES_6): Likewise.
>> (TYPEFY): New define.
>> (ARGIFY): Likewise.
>> (internal_syscall0): Likewise.
>> (internal_syscall1): Likewise.
>> (internal_syscall2): Likewise.
>> (internal_syscall3): Likewise.
>> (internal_syscall4): Likewise.
>> (internal_syscall5): Likewise.
>> (internal_syscall6): Likewise.
>> * sysdeps/unix/sysv/linux/x86_64/x32/times.c
>> (INTERNAL_SYSCALL_NCS): Remove define.
>> (internal_syscall1): Add define.
>
> Could you please push your branch to glibc git repo so that I can
> check out the whole patch series?
>
> Thanks.
I have created the azanella/master-not-cancel branch.
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 12/14] Fix {INLINE,INTERNAL}_SYSCALL macros for x32
2017-07-04 20:22 ` Adhemerval Zanella
@ 2017-07-04 21:34 ` H.J. Lu
0 siblings, 0 replies; 21+ messages in thread
From: H.J. Lu @ 2017-07-04 21:34 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: GNU C Library, Adhemerval Zanella
On Tue, Jul 4, 2017 at 1:22 PM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
> On 04/07/2017 17:09, H.J. Lu wrote:
>> On Tue, Jul 4, 2017 at 12:53 PM, Adhemerval Zanella
>> <adhemerval.zanella@linaro.org> wrote:
>>> From: Adhemerval Zanella <adhemerval.zanella@linaro.com>
>>>
>>> The problem for x32 is the {INTERNAL,INLINE}_SYSCALL C macros explicit
>>> cast the arguments to 'long int', thus passing as 32 bits arguments
>>> that should be passed to 64 bits.
>>>
>>> Previous x32 implementation uses the auto-generated syscalls from
>>> assembly macros (syscalls.list), so the {INTERNAL,INLINE}_SYSCALL
>>> macros are never used with 64 bit argument in x32 (which are
>>> internally broken for this ILP).
>>>
>>> To fix it I used a strategy similar to MIPS64n32 (although both
>>> ABI differs for some syscalls on how top pass 64-bits arguments)
>>> where argument types for kernel call are defined using GCC extension
>>> 'typeof' with a arithmetic operation. This allows 64-bits arguments
>>> to be defined while 32-bits argument will still passed as 32-bits.
>>>
>>> I also cleanup the {INLINE,INTERNAL}_SYSCALL definition by defining
>>> 'inline_syscallX' instead of constructing the argument passing using
>>> macros (it adds some readability) and removed the ununsed
>>> INTERNAL_SYSCALL_NCS_TYPES define (since the patch idea is exactly to
>>> avoid requiric explicit types passing).
>>>
>>> Tested on x86_64 and x32.
>>>
>>> * sysdeps/unix/sysv/linux/x86_64/sysdep.h
>>> (INTERNAL_SYSCALL_NCS_TYPES): Remove define.
>>> (LOAD_ARGS_0): Likewise.
>>> (LOAD_ARGS_1): Likewise.
>>> (LOAD_ARGS_2): Likewise.
>>> (LOAD_ARGS_3): Likewise.
>>> (LOAD_ARGS_4): Likewise.
>>> (LOAD_ARGS_5): Likewise.
>>> (LOAD_ARGS_6): Likewise.
>>> (LOAD_REGS_0): Likewise.
>>> (LOAD_REGS_1): Likewise.
>>> (LOAD_REGS_2): Likewise.
>>> (LOAD_REGS_3): Likewise.
>>> (LOAD_REGS_4): Likewise.
>>> (LOAD_REGS_5): Likewise.
>>> (LOAD_REGS_6): Likewise.
>>> (ASM_ARGS_0): Likewise.
>>> (ASM_ARGS_1): Likewise.
>>> (ASM_ARGS_2): Likewise.
>>> (ASM_ARGS_3): Likewise.
>>> (ASM_ARGS_4): Likewise.
>>> (ASM_ARGS_5): Likewise.
>>> (ASM_ARGS_6): Likewise.
>>> (LOAD_ARGS_TYPES_1): Likewise.
>>> (LOAD_ARGS_TYPES_2): Likewise.
>>> (LOAD_ARGS_TYPES_3): Likewise.
>>> (LOAD_ARGS_TYPES_4): Likewise.
>>> (LOAD_ARGS_TYPES_5): Likewise.
>>> (LOAD_ARGS_TYPES_6): Likewise.
>>> (LOAD_REGS_TYPES_1): Likewise.
>>> (LOAD_REGS_TYPES_2): Likewise.
>>> (LOAD_REGS_TYPES_3): Likewise.
>>> (LOAD_REGS_TYPES_4): Likewise.
>>> (LOAD_REGS_TYPES_5): Likewise.
>>> (LOAD_REGS_TYPES_6): Likewise.
>>> (TYPEFY): New define.
>>> (ARGIFY): Likewise.
>>> (internal_syscall0): Likewise.
>>> (internal_syscall1): Likewise.
>>> (internal_syscall2): Likewise.
>>> (internal_syscall3): Likewise.
>>> (internal_syscall4): Likewise.
>>> (internal_syscall5): Likewise.
>>> (internal_syscall6): Likewise.
>>> * sysdeps/unix/sysv/linux/x86_64/x32/times.c
>>> (INTERNAL_SYSCALL_NCS): Remove define.
>>> (internal_syscall1): Add define.
>>
>> Could you please push your branch to glibc git repo so that I can
>> check out the whole patch series?
>>
>> Thanks.
>
> I have created the azanella/master-not-cancel branch.
x32 patch is OK.
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 01/14] Consolidate non cancellable open call
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 04/14] Consolidate non cancellable openat call Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 12/14] Fix {INLINE,INTERNAL}_SYSCALL macros for x32 Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 06/14] Consolidate non cancellable writev call Adhemerval Zanella
` (11 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
This patch consolidates all the non cancellable open calls to use
the __open_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.
To be consistent with the following non cancellable openat call, a
new __open64_nocancel is also added (although not currently used).
Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu.
* sysdeps/generic/not-cancel.h (open_not_cancel): Remove macro.
(open_not_cancel_2): Likewise.
(open_nocancel): New macro.
(open64_nocancel): Likewise.
* sysdeps/unix/sysv/linux/not-cancel.h (open_not_cancel): Remove macro.
(open_not_cancel_2): Likewise.
(__open_nocancel): New prototype.
(__open64_nocancel): Likewise.
* sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add
__open_nocancel.
* sysdeps/unix/sysv/linux/open.c (__open_nocancel): New function.
* sysdeps/unix/sysv/linux/open64.c (__open64_nocancel): Likewise.
* catgets/open_catalog.c (__open_catalog): Replace open_not_cancel{_2}
with __open_nocancel.
* csu/check_fds.c (check_one_fd): Likewise.
* gmon/gmon.c (write_gmon): Likewise.
* iconv/gconv_cache.c (__gconv_load_cached): Likewise.
* intl/loadmsgcat.c (open): Likewise.
* libio/fileops.c (_IO_file_open): Likewise.
* locale/loadarchive.c (_nl_load_locale_from_archive): Likewise.
* locale/loadlocale.c (_nl_load_locale): Likewise.
* login/utmp_file.c (setutent_file): Likewise.
* misc/daemon.c (daemon): Likewise.
* nss/nss_db/db-open.c (internal_setent): Likewise.
* sysdeps/mach/hurd/opendir.c (__opendirat): Likewise.
* sysdeps/posix/libc_fatal.c (__libc_message): Likewise.
* sysdeps/posix/opendir.c (tryopen_o_directory): Likewise.
(__opendir): Likewise.
* sysdeps/posix/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/fips-private.h (fips_enable_p): Likewise.
* sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise.
(gethostid): Likewise.
* sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise.
* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
Likewise.
* sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Likewise.
* sysdeps/unix/sysv/linux/grantpt.c (__close_all_fds): Likewise.
* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
* sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock):
Likewise.
* sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps):
Likewise.
* sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c (__get_clockfreq):
Likewise.
* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np):
Likewise.
* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
Likewise.
* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise.
---
ChangeLog | 55 +++++++++++++++++++++++++
catgets/open_catalog.c | 4 +-
csu/check_fds.c | 2 +-
gmon/gmon.c | 4 +-
iconv/gconv_cache.c | 2 +-
intl/loadmsgcat.c | 2 +-
libio/fileops.c | 2 +-
locale/loadarchive.c | 4 +-
locale/loadlocale.c | 4 +-
login/utmp_file.c | 6 +--
misc/daemon.c | 2 +-
nss/nss_db/db-open.c | 2 +-
sysdeps/generic/not-cancel.h | 8 ++--
sysdeps/mach/hurd/opendir.c | 2 +-
sysdeps/posix/libc_fatal.c | 2 +-
sysdeps/posix/opendir.c | 4 +-
sysdeps/posix/spawni.c | 2 +-
sysdeps/unix/sysv/linux/Versions | 1 +
sysdeps/unix/sysv/linux/fips-private.h | 2 +-
sysdeps/unix/sysv/linux/gethostid.c | 4 +-
sysdeps/unix/sysv/linux/getloadavg.c | 2 +-
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +--
sysdeps/unix/sysv/linux/grantpt.c | 4 +-
sysdeps/unix/sysv/linux/i386/smp.h | 2 +-
sysdeps/unix/sysv/linux/ia64/has_cpuclock.c | 2 +-
sysdeps/unix/sysv/linux/libc_fatal.c | 2 +-
sysdeps/unix/sysv/linux/malloc-sysdep.h | 4 +-
sysdeps/unix/sysv/linux/not-cancel.h | 20 ++++-----
sysdeps/unix/sysv/linux/open.c | 18 ++++++++
sysdeps/unix/sysv/linux/open64.c | 35 +++++++++++++---
sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c | 2 +-
sysdeps/unix/sysv/linux/pthread_getname.c | 2 +-
sysdeps/unix/sysv/linux/pthread_setname.c | 2 +-
sysdeps/unix/sysv/linux/spawni.c | 2 +-
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
36 files changed, 157 insertions(+), 64 deletions(-)
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index cbb305a..4621b26 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -50,7 +50,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
char *buf = NULL;
if (strchr (cat_name, '/') != NULL || nlspath == NULL)
- fd = open_not_cancel_2 (cat_name, O_RDONLY);
+ fd = __open_nocancel (cat_name, O_RDONLY);
else
{
const char *run_nlspath = nlspath;
@@ -178,7 +178,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
if (bufact != 0)
{
- fd = open_not_cancel_2 (buf, O_RDONLY);
+ fd = __open_nocancel (buf, O_RDONLY);
if (fd >= 0)
break;
}
diff --git a/csu/check_fds.c b/csu/check_fds.c
index 062c879..5bd6392 100644
--- a/csu/check_fds.c
+++ b/csu/check_fds.c
@@ -61,7 +61,7 @@ check_one_fd (int fd, int mode)
/* Something is wrong with this descriptor, it's probably not
opened. Open /dev/null so that the SUID program we are
about to start does not accidentally use this descriptor. */
- int nullfd = open_not_cancel (name, mode, 0);
+ int nullfd = __open_nocancel (name, mode, 0);
/* We are very paranoid here. With all means we try to ensure
that we are actually opening the /dev/null device and nothing
diff --git a/gmon/gmon.c b/gmon/gmon.c
index f394a78..87c3c4e 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -342,12 +342,12 @@ write_gmon (void)
size_t len = strlen (env);
char buf[len + 20];
__snprintf (buf, sizeof (buf), "%s.%u", env, __getpid ());
- fd = open_not_cancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW, 0666);
+ fd = __open_nocancel (buf, O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW, 0666);
}
if (fd == -1)
{
- fd = open_not_cancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
+ fd = __open_nocancel ("gmon.out", O_CREAT|O_TRUNC|O_WRONLY|O_NOFOLLOW,
0666);
if (fd < 0)
{
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index 0cadea3..f1dce29 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -59,7 +59,7 @@ __gconv_load_cache (void)
return -1;
/* See whether the cache file exists. */
- fd = open_not_cancel (GCONV_MODULES_CACHE, O_RDONLY, 0);
+ fd = __open_nocancel (GCONV_MODULES_CACHE, O_RDONLY, 0);
if (__builtin_expect (fd, 0) == -1)
/* Not available. */
return -1;
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index c2ff64e..adca419 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -445,7 +445,7 @@
/* Rename the non ISO C functions. This is required by the standard
because some ISO C functions will require linking with this object
file and the name space must not be polluted. */
-# define open(name, flags) open_not_cancel_2 (name, flags)
+# define open(name, flags) __open_nocancel (name, flags)
# define close(fd) close_not_cancel_no_status (fd)
# define read(fd, buf, n) read_not_cancel (fd, buf, n)
# define mmap(addr, len, prot, flags, fd, offset) \
diff --git a/libio/fileops.c b/libio/fileops.c
index c55e196..67f3d72 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -223,7 +223,7 @@ _IO_file_open (_IO_FILE *fp, const char *filename, int posix_mode, int prot,
int fdesc;
#ifdef _LIBC
if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL))
- fdesc = open_not_cancel (filename,
+ fdesc = __open_nocancel (filename,
posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
else
fdesc = open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
diff --git a/locale/loadarchive.c b/locale/loadarchive.c
index e6e1a05..aebb590 100644
--- a/locale/loadarchive.c
+++ b/locale/loadarchive.c
@@ -203,7 +203,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
archmapped = &headmap;
/* The archive has never been opened. */
- fd = open_not_cancel_2 (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
+ fd = __open_nocancel (archfname, O_RDONLY|O_LARGEFILE|O_CLOEXEC);
if (fd < 0)
/* Cannot open the archive, for whatever reason. */
return NULL;
@@ -398,7 +398,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
if (fd == -1)
{
struct stat64 st;
- fd = open_not_cancel_2 (archfname,
+ fd = __open_nocancel (archfname,
O_RDONLY|O_LARGEFILE|O_CLOEXEC);
if (fd == -1)
/* Cannot open the archive, for whatever reason. */
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index 9bca304..9c69ad4 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -173,7 +173,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
file->decided = 1;
file->data = NULL;
- fd = open_not_cancel_2 (file->filename, O_RDONLY | O_CLOEXEC);
+ fd = __open_nocancel (file->filename, O_RDONLY | O_CLOEXEC);
if (__builtin_expect (fd, 0) < 0)
/* Cannot open the file. */
return;
@@ -201,7 +201,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
_nl_category_names.str + _nl_category_name_idxs[category],
_nl_category_name_sizes[category] + 1);
- fd = open_not_cancel_2 (newp, O_RDONLY | O_CLOEXEC);
+ fd = __open_nocancel (newp, O_RDONLY | O_CLOEXEC);
if (__builtin_expect (fd, 0) < 0)
return;
diff --git a/login/utmp_file.c b/login/utmp_file.c
index 240e0e3..1407116 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -143,7 +143,7 @@ setutent_file (void)
file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
file_writable = false;
- file_fd = open_not_cancel_2
+ file_fd = __open_nocancel
(file_name, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (file_fd == -1)
return 0;
@@ -374,7 +374,7 @@ pututline_file (const struct utmp *data)
/* We must make the file descriptor writable before going on. */
const char *file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
- int new_fd = open_not_cancel_2
+ int new_fd = __open_nocancel
(file_name, O_RDWR | O_LARGEFILE | O_CLOEXEC);
if (new_fd == -1)
return NULL;
@@ -484,7 +484,7 @@ updwtmp_file (const char *file, const struct utmp *utmp)
int fd;
/* Open WTMP file. */
- fd = open_not_cancel_2 (file, O_WRONLY | O_LARGEFILE);
+ fd = __open_nocancel (file, O_WRONLY | O_LARGEFILE);
if (fd < 0)
return -1;
diff --git a/misc/daemon.c b/misc/daemon.c
index 9d186b2..dd38f2b 100644
--- a/misc/daemon.c
+++ b/misc/daemon.c
@@ -63,7 +63,7 @@ daemon (int nochdir, int noclose)
if (!noclose) {
struct stat64 st;
- if ((fd = open_not_cancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
+ if ((fd = __open_nocancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
&& (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0)
== 0)) {
if (__builtin_expect (S_ISCHR (st.st_mode), 1) != 0
diff --git a/nss/nss_db/db-open.c b/nss/nss_db/db-open.c
index 1c58bd1..40a2540 100644
--- a/nss/nss_db/db-open.c
+++ b/nss/nss_db/db-open.c
@@ -36,7 +36,7 @@ internal_setent (const char *file, struct nss_db_map *mapping)
{
enum nss_status status = NSS_STATUS_UNAVAIL;
- int fd = open_not_cancel_2 (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
+ int fd = __open_nocancel (file, O_RDONLY | O_LARGEFILE | O_CLOEXEC);
if (fd != -1)
{
struct nss_db_header header;
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index 5eabd2b..a4f7b7b 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -18,10 +18,10 @@
<http://www.gnu.org/licenses/>. */
/* By default we have none. Map the name to the normal functions. */
-#define open_not_cancel(name, flags, mode) \
- __libc_open (name, flags, mode)
-#define open_not_cancel_2(name, flags) \
- __libc_open (name, flags)
+#define __open_nocancel(...) \
+ __open (__VA_ARGS__)
+#define __open64_nocancel(...) \
+ __open64 (__VA_ARGS__)
#define openat_not_cancel(fd, name, flags, mode) \
__openat (fd, name, flags, mode)
#define openat_not_cancel_3(fd, name, flags) \
diff --git a/sysdeps/mach/hurd/opendir.c b/sysdeps/mach/hurd/opendir.c
index b3dab24..8db70b2 100644
--- a/sysdeps/mach/hurd/opendir.c
+++ b/sysdeps/mach/hurd/opendir.c
@@ -84,7 +84,7 @@ __opendirat (int dfd, const char *name)
int fd;
#if IS_IN (rtld)
assert (dfd == AT_FDCWD);
- fd = open_not_cancel_2 (name, flags);
+ fd = __open_nocancel (name, flags);
#else
fd = openat_not_cancel_3 (dfd, name, flags);
#endif
diff --git a/sysdeps/posix/libc_fatal.c b/sysdeps/posix/libc_fatal.c
index b261963..37834c7 100644
--- a/sysdeps/posix/libc_fatal.c
+++ b/sysdeps/posix/libc_fatal.c
@@ -79,7 +79,7 @@ __libc_message (int do_abort, const char *fmt, ...)
requests errors on standard error. */
const char *on_2 = __libc_secure_getenv ("LIBC_FATAL_STDERR_");
if (on_2 == NULL || *on_2 == '\0')
- fd = open_not_cancel_2 (_PATH_TTY, O_RDWR | O_NOCTTY | O_NDELAY);
+ fd = __open_nocancel (_PATH_TTY, O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
fd = STDERR_FILENO;
diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c
index 909aa61..3ee27b2 100644
--- a/sysdeps/posix/opendir.c
+++ b/sysdeps/posix/opendir.c
@@ -61,7 +61,7 @@ static void
tryopen_o_directory (void)
{
int serrno = errno;
- int x = open_not_cancel_2 ("/dev/null", O_RDONLY|O_NDELAY|O_DIRECTORY);
+ int x = __open_nocancel ("/dev/null", O_RDONLY|O_NDELAY|O_DIRECTORY);
if (x >= 0)
{
@@ -188,7 +188,7 @@ __opendir (const char *name)
}
}
- return opendir_tail (open_not_cancel_2 (name, opendir_oflags));
+ return opendir_tail (__open_nocancel (name, opendir_oflags));
}
weak_alias (__opendir, opendir)
diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c
index 1979830..aaca6e2 100644
--- a/sysdeps/posix/spawni.c
+++ b/sysdeps/posix/spawni.c
@@ -185,7 +185,7 @@ __spawni_child (void *arguments)
paths (like /dev/watchdog). */
close_not_cancel (action->action.open_action.fd);
- int new_fd = open_not_cancel (action->action.open_action.path,
+ int new_fd = __open_nocancel (action->action.open_action.path,
action->action.open_action.oflag
| O_LARGEFILE,
action->action.open_action.mode);
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index 202ffcc..3c64077 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -169,6 +169,7 @@ libc {
GLIBC_PRIVATE {
# functions used in other libraries
__syscall_rt_sigqueueinfo;
+ __open_nocancel;
# functions used by nscd
__netlink_assert_response;
}
diff --git a/sysdeps/unix/sysv/linux/fips-private.h b/sysdeps/unix/sysv/linux/fips-private.h
index c9fe266..3a83a0f 100644
--- a/sysdeps/unix/sysv/linux/fips-private.h
+++ b/sysdeps/unix/sysv/linux/fips-private.h
@@ -42,7 +42,7 @@ fips_enabled_p (void)
if (checked == FIPS_UNTESTED)
{
- int fd = open_not_cancel_2 ("/proc/sys/crypto/fips_enabled", O_RDONLY);
+ int fd = __open_nocancel ("/proc/sys/crypto/fips_enabled", O_RDONLY);
if (fd != -1)
{
diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
index cc108aa..3ea8656 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -47,7 +47,7 @@ sethostid (long int id)
}
/* Open file for writing. Everybody is allowed to read this file. */
- fd = open_not_cancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644);
+ fd = __open_nocancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644);
if (fd < 0)
return -1;
@@ -77,7 +77,7 @@ gethostid (void)
int fd;
/* First try to get the ID from a former invocation of sethostid. */
- fd = open_not_cancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0);
+ fd = __open_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0);
if (fd >= 0)
{
ssize_t n = read_not_cancel (fd, &id, sizeof (id));
diff --git a/sysdeps/unix/sysv/linux/getloadavg.c b/sysdeps/unix/sysv/linux/getloadavg.c
index 117f8c2..0bfe41d 100644
--- a/sysdeps/unix/sysv/linux/getloadavg.c
+++ b/sysdeps/unix/sysv/linux/getloadavg.c
@@ -33,7 +33,7 @@ getloadavg (double loadavg[], int nelem)
{
int fd;
- fd = open_not_cancel_2 ("/proc/loadavg", O_RDONLY);
+ fd = __open_nocancel ("/proc/loadavg", O_RDONLY);
if (fd < 0)
return -1;
else
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 05ac36b..2519792 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -34,7 +34,7 @@ int
attribute_hidden
__getlogin_r_loginuid (char *name, size_t namesize)
{
- int fd = open_not_cancel_2 ("/proc/self/loginuid", O_RDONLY);
+ int fd = __open_nocancel ("/proc/self/loginuid", O_RDONLY);
if (fd == -1)
return -1;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index a0dd6eb..e21a34c 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -143,7 +143,7 @@ __get_nprocs (void)
char *re = buffer_end;
const int flags = O_RDONLY | O_CLOEXEC;
- int fd = open_not_cancel_2 ("/sys/devices/system/cpu/online", flags);
+ int fd = __open_nocancel ("/sys/devices/system/cpu/online", flags);
char *l;
int result = 0;
if (fd != -1)
@@ -194,7 +194,7 @@ __get_nprocs (void)
result = 2;
/* The /proc/stat format is more uniform, use it by default. */
- fd = open_not_cancel_2 ("/proc/stat", flags);
+ fd = __open_nocancel ("/proc/stat", flags);
if (fd != -1)
{
result = 0;
@@ -211,7 +211,7 @@ __get_nprocs (void)
}
else
{
- fd = open_not_cancel_2 ("/proc/cpuinfo", flags);
+ fd = __open_nocancel ("/proc/cpuinfo", flags);
if (fd != -1)
{
GET_NPROCS_PARSER (fd, buffer, cp, re, buffer_end, result);
diff --git a/sysdeps/unix/sysv/linux/grantpt.c b/sysdeps/unix/sysv/linux/grantpt.c
index 8cebde3..97c6ba7 100644
--- a/sysdeps/unix/sysv/linux/grantpt.c
+++ b/sysdeps/unix/sysv/linux/grantpt.c
@@ -31,9 +31,9 @@ close_all_fds (void)
__closedir (dir);
- int nullfd = open_not_cancel_2 (_PATH_DEVNULL, O_RDONLY);
+ int nullfd = __open_nocancel (_PATH_DEVNULL, O_RDONLY);
assert (nullfd == STDIN_FILENO);
- nullfd = open_not_cancel_2 (_PATH_DEVNULL, O_WRONLY);
+ nullfd = __open_nocancel (_PATH_DEVNULL, O_WRONLY);
assert (nullfd == STDOUT_FILENO);
__dup2 (STDOUT_FILENO, STDERR_FILENO);
}
diff --git a/sysdeps/unix/sysv/linux/i386/smp.h b/sysdeps/unix/sysv/linux/i386/smp.h
index 3109ea9..c24f2fd 100644
--- a/sysdeps/unix/sysv/linux/i386/smp.h
+++ b/sysdeps/unix/sysv/linux/i386/smp.h
@@ -41,7 +41,7 @@ is_smp_system (void)
else
{
/* This was not successful. Now try reading the /proc filesystem. */
- int fd = open_not_cancel_2 ("/proc/sys/kernel/version", O_RDONLY);
+ int fd = __open_nocancel ("/proc/sys/kernel/version", O_RDONLY);
if (__builtin_expect (fd, 0) == -1
|| read_not_cancel (fd, u.buf, sizeof (u.buf)) <= 0)
/* This also didn't work. We give up and say it's a UP machine. */
diff --git a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
index 2207c88..04e395b 100644
--- a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
+++ b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
@@ -30,7 +30,7 @@ has_cpuclock (void)
if (__builtin_expect (itc_usable == 0, 0))
{
int newval = 1;
- int fd = open_not_cancel_2 ("/proc/sal/itc_drift", O_RDONLY);
+ int fd = __open_nocancel ("/proc/sal/itc_drift", O_RDONLY);
if (__builtin_expect (fd != -1, 1))
{
char buf[16];
diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c
index d22bfdc..5b484cf 100644
--- a/sysdeps/unix/sysv/linux/libc_fatal.c
+++ b/sysdeps/unix/sysv/linux/libc_fatal.c
@@ -53,7 +53,7 @@ backtrace_and_maps (int do_abort, bool written, int fd)
__backtrace_symbols_fd (addrs + 1, n - 1, fd);
writestr (strnsize ("======= Memory map: ========\n"));
- int fd2 = open_not_cancel_2 ("/proc/self/maps", O_RDONLY);
+ int fd2 = __open_nocancel ("/proc/self/maps", O_RDONLY);
char buf[1024];
ssize_t n2;
while ((n2 = read_not_cancel (fd2, buf, sizeof (buf))) > 0)
diff --git a/sysdeps/unix/sysv/linux/malloc-sysdep.h b/sysdeps/unix/sysv/linux/malloc-sysdep.h
index 48cf7c1..cb87b58 100644
--- a/sysdeps/unix/sysv/linux/malloc-sysdep.h
+++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h
@@ -42,8 +42,8 @@ check_may_shrink_heap (void)
if (__builtin_expect (may_shrink_heap == 0, 1))
{
- int fd = open_not_cancel_2 ("/proc/sys/vm/overcommit_memory",
- O_RDONLY | O_CLOEXEC);
+ int fd = __open_nocancel ("/proc/sys/vm/overcommit_memory",
+ O_RDONLY | O_CLOEXEC);
if (fd >= 0)
{
char val;
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 43959ba..8d897f0 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -20,23 +20,19 @@
#ifndef NOT_CANCEL_H
# define NOT_CANCEL_H
+#include <fcntl.h>
#include <sysdep.h>
#include <errno.h>
#include <unistd.h>
#include <sys/syscall.h>
-/* Uncancelable open. */
-#ifdef __NR_open
-# define open_not_cancel(name, flags, mode) \
- INLINE_SYSCALL (open, 3, name, flags, mode)
-# define open_not_cancel_2(name, flags) \
- INLINE_SYSCALL (open, 2, name, flags)
-#else
-# define open_not_cancel(name, flags, mode) \
- INLINE_SYSCALL (openat, 4, AT_FDCWD, name, flags, mode)
-# define open_not_cancel_2(name, flags) \
- INLINE_SYSCALL (openat, 3, AT_FDCWD, name, flags)
-#endif
+/* Non cancellable open syscall. */
+__typeof (open) __open_nocancel;
+libc_hidden_proto (__open_nocancel)
+
+/* Non cancellable open syscall (LFS version). */
+__typeof (open64) __open64_nocancel;
+libc_hidden_proto (__open64_nocancel)
/* Uncancelable read. */
#define __read_nocancel(fd, buf, len) \
diff --git a/sysdeps/unix/sysv/linux/open.c b/sysdeps/unix/sysv/linux/open.c
index b3912d5..5069333 100644
--- a/sysdeps/unix/sysv/linux/open.c
+++ b/sysdeps/unix/sysv/linux/open.c
@@ -22,6 +22,7 @@
#include <stdarg.h>
#include <sysdep-cancel.h>
+#include <not-cancel.h>
#ifndef __OFF_T_MATCHES_OFF64_T
@@ -48,4 +49,21 @@ weak_alias (__libc_open, __open)
libc_hidden_weak (__open)
weak_alias (__libc_open, open)
+int
+__open_nocancel (const char *file, int oflag, ...)
+{
+ int mode = 0;
+
+ if (__OPEN_NEEDS_MODE (oflag))
+ {
+ va_list arg;
+ va_start (arg, oflag);
+ mode = va_arg (arg, int);
+ va_end (arg);
+ }
+
+ return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag, mode);
+}
+libc_hidden_def (__open_nocancel)
+
#endif
diff --git a/sysdeps/unix/sysv/linux/open64.c b/sysdeps/unix/sysv/linux/open64.c
index fcac984..d5839e3 100644
--- a/sysdeps/unix/sysv/linux/open64.c
+++ b/sysdeps/unix/sysv/linux/open64.c
@@ -21,6 +21,13 @@
#include <stdarg.h>
#include <sysdep-cancel.h>
+#include <not-cancel.h>
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+# define EXTRA_OPEN_FLAGS 0
+#else
+# define EXTRA_OPEN_FLAGS O_LARGEFILE
+#endif
/* Open FILE with access OFLAG. If O_CREAT or O_TMPFILE is in OFLAG,
a third argument is the file protection. */
@@ -37,12 +44,6 @@ __libc_open64 (const char *file, int oflag, ...)
va_end (arg);
}
-#ifdef __OFF_T_MATCHES_OFF64_T
-# define EXTRA_OPEN_FLAGS 0
-#else
-# define EXTRA_OPEN_FLAGS O_LARGEFILE
-#endif
-
return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | EXTRA_OPEN_FLAGS,
mode);
}
@@ -51,9 +52,31 @@ strong_alias (__libc_open64, __open64)
libc_hidden_weak (__open64)
weak_alias (__libc_open64, open64)
+
+int
+__open64_nocancel (const char *file, int oflag, ...)
+{
+ int mode = 0;
+
+ if (__OPEN_NEEDS_MODE (oflag))
+ {
+ va_list arg;
+ va_start (arg, oflag);
+ mode = va_arg (arg, int);
+ va_end (arg);
+ }
+
+ return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | EXTRA_OPEN_FLAGS,
+ mode);
+}
+libc_hidden_def (__open64_nocancel)
+
#ifdef __OFF_T_MATCHES_OFF64_T
strong_alias (__libc_open64, __libc_open)
strong_alias (__libc_open64, __open)
libc_hidden_weak (__open)
weak_alias (__libc_open64, open)
+
+strong_alias (__open64_nocancel, __open_nocancel)
+libc_hidden_weak (__open_nocancel)
#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
index b8d01d8..c99e7de 100644
--- a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
+++ b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
@@ -40,7 +40,7 @@ __get_clockfreq (void)
contains at least one line like:
timebase : 33333333
We search for this line and convert the number into an integer. */
- int fd = open_not_cancel_2 ("/proc/cpuinfo", O_RDONLY);
+ int fd = __open_nocancel ("/proc/cpuinfo", O_RDONLY);
if (__glibc_likely (fd != -1))
return result;
diff --git a/sysdeps/unix/sysv/linux/pthread_getname.c b/sysdeps/unix/sysv/linux/pthread_getname.c
index 9a5343a..caab2cc 100644
--- a/sysdeps/unix/sysv/linux/pthread_getname.c
+++ b/sysdeps/unix/sysv/linux/pthread_getname.c
@@ -45,7 +45,7 @@ pthread_getname_np (pthread_t th, char *buf, size_t len)
char fname[sizeof (FMT) + 8];
sprintf (fname, FMT, (unsigned int) pd->tid);
- int fd = open_not_cancel_2 (fname, O_RDONLY);
+ int fd = __open_nocancel (fname, O_RDONLY);
if (fd == -1)
return errno;
diff --git a/sysdeps/unix/sysv/linux/pthread_setname.c b/sysdeps/unix/sysv/linux/pthread_setname.c
index 5769c5b..93f0e9d 100644
--- a/sysdeps/unix/sysv/linux/pthread_setname.c
+++ b/sysdeps/unix/sysv/linux/pthread_setname.c
@@ -46,7 +46,7 @@ pthread_setname_np (pthread_t th, const char *name)
char fname[sizeof (FMT) + 8];
sprintf (fname, FMT, (unsigned int) pd->tid);
- int fd = open_not_cancel_2 (fname, O_RDWR);
+ int fd = __open_nocancel (fname, O_RDWR);
if (fd == -1)
return errno;
diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index c56f894..4994a07 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -230,7 +230,7 @@ __spawni_child (void *arguments)
paths (like /dev/watchdog). */
close_not_cancel (action->action.open_action.fd);
- int ret = open_not_cancel (action->action.open_action.path,
+ int ret = __open_nocancel (action->action.open_action.path,
action->action.
open_action.oflag | O_LARGEFILE,
action->action.open_action.mode);
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index db20977..ab068ab 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -115,7 +115,7 @@ __sysconf (int name)
if (procfname != NULL)
{
- int fd = open_not_cancel_2 (procfname, O_RDONLY);
+ int fd = __open_nocancel (procfname, O_RDONLY);
if (fd != -1)
{
/* This is more than enough, the file contains a single integer. */
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 06/14] Consolidate non cancellable writev call
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (2 preceding siblings ...)
2017-07-04 19:54 ` [PATCH 01/14] Consolidate non cancellable open call Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 02/14] Consolidate non cancellable read call Adhemerval Zanella
` (10 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
This patch consolidates all the non cancellable writev calls to use
the __writev_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.
* gmon/gmon.c (write_hist): Replace writev_not_cancel_no_status with
__writev_nocancel_nostatus.
(write_call_graph): Likewise.
(write_bb_counts): Likewise.
* resolv/herror.c (herror): Likewise.
* sysdeps/generic/not-cancel.h (writev_not_cancel_no_status): Remove
macro.
(__writev_nocancel_nostatus): New macro.
* sysdeps/unix/sysv/linux/not-cancel.h (writev_not_cancel_no_status):
Remove macro.
(__writev_nocancel_nostatus): New function.
---
ChangeLog | 12 ++++++++++++
gmon/gmon.c | 12 ++++++------
resolv/herror.c | 2 +-
sysdeps/generic/not-cancel.h | 2 +-
sysdeps/unix/sysv/linux/not-cancel.h | 12 ++++++++----
5 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/gmon/gmon.c b/gmon/gmon.c
index b26c27a..8408e53 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -216,7 +216,7 @@ write_hist (int fd)
strncpy (thdr.dimen, "seconds", sizeof (thdr.dimen));
thdr.dimen_abbrev = 's';
- writev_not_cancel_no_status (fd, iov, 3);
+ __writev_nocancel_nostatus (fd, iov, 3);
}
}
@@ -273,13 +273,13 @@ write_call_graph (int fd)
if (++nfilled == NARCS_PER_WRITEV)
{
- writev_not_cancel_no_status (fd, iov, 2 * nfilled);
+ __writev_nocancel_nostatus (fd, iov, 2 * nfilled);
nfilled = 0;
}
}
}
if (nfilled > 0)
- writev_not_cancel_no_status (fd, iov, 2 * nfilled);
+ __writev_nocancel_nostatus (fd, iov, 2 * nfilled);
}
@@ -312,12 +312,12 @@ write_bb_counts (int fd)
for (grp = __bb_head; grp; grp = grp->next)
{
ncounts = grp->ncounts;
- writev_not_cancel_no_status (fd, bbhead, 2);
+ __writev_nocancel_nostatus (fd, bbhead, 2);
for (nfilled = i = 0; i < ncounts; ++i)
{
if (nfilled > (sizeof (bbbody) / sizeof (bbbody[0])) - 2)
{
- writev_not_cancel_no_status (fd, bbbody, nfilled);
+ __writev_nocancel_nostatus (fd, bbbody, nfilled);
nfilled = 0;
}
@@ -325,7 +325,7 @@ write_bb_counts (int fd)
bbbody[nfilled++].iov_base = &grp->counts[i];
}
if (nfilled > 0)
- writev_not_cancel_no_status (fd, bbbody, nfilled);
+ __writev_nocancel_nostatus (fd, bbbody, nfilled);
}
}
diff --git a/resolv/herror.c b/resolv/herror.c
index b3df236..45c0a5d 100644
--- a/resolv/herror.c
+++ b/resolv/herror.c
@@ -89,7 +89,7 @@ herror(const char *s) {
v++;
v->iov_base = (char *) "\n";
v->iov_len = 1;
- writev_not_cancel_no_status(STDERR_FILENO, iov, (v - iov) + 1);
+ __writev_nocancel_nostatus(STDERR_FILENO, iov, (v - iov) + 1);
}
/*
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index 53214cd..9959c87 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -34,7 +34,7 @@
__read (fd, buf, n)
#define __write_nocancel(fd, buf, n) \
__write (fd, buf, n)
-#define writev_not_cancel_no_status(fd, iov, n) \
+#define __writev_nocancel_nostatus(fd, iov, n) \
(void) __writev (fd, iov, n)
#define fcntl_not_cancel(fd, cmd, val) \
__fcntl (fd, cmd, val)
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index c620c8a..7fd42c2 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -63,10 +63,14 @@ __close_nocancel_no_status (int fd)
return INTERNAL_SYSCALL (close, err, 1, (fd));
}
-/* Uncancelable writev. */
-#define writev_not_cancel_no_status(fd, iov, n) \
- (void) ({ INTERNAL_SYSCALL_DECL (err); \
- INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
+/* Non cancellable writev syscall that does not also set errno in case of
+ failure. */
+static inline int
+__writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
+{
+ INTERNAL_SYSCALL_DECL (err);
+ return INTERNAL_SYSCALL_CALL (writev, err, fd, iov, iovcnt);
+}
/* Uncancelable fcntl. */
#define fcntl_not_cancel(fd, cmd, val) \
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 02/14] Consolidate non cancellable read call
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (3 preceding siblings ...)
2017-07-04 19:54 ` [PATCH 06/14] Consolidate non cancellable writev call Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 03/14] Consolidate non cancellable write call Adhemerval Zanella
` (9 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
This patch consolidates all the non cancellable read calls to use
the __read_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.
Also, since it is used on libcrypto it is exported in GLIBC_PRIVATE
namespace.
Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu.
* sysdeps/generic/not-cancel.h (read_not_cancel): Remove macro.
(__read_nocancel): New macro.
* sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add
__read_nocancel.
* sysdeps/unix/sysv/linux/not-cancel.h (__read_nocancel): Remove
macro.
(__read_nocancel): New prototype.
* sysdeps/unix/sysv/linux/read.c (__read_nocancel): New function.
* catgets/open_catalog.c (__open_catalog): Replace read_not_cancel
with __read_nocancel.
* intl/loadmsgcat.c (read): Likewise.
* libio/fileops.c (_IO_file_read): Likewise.
* locale/loadlocale.c (_nl_load_locale): Likewise.
* login/utmp_file.c (getutent_r_file): Likewise.
(internal_getut_r): Likewise.
(getutline_r_file): Likewise.
* sysdeps/unix/sysv/linux/fips-private.h (fips_enable_p): Likewise.
* sysdeps/unix/sysv/linux/gethostid.c (gethostid): Likewise.
* sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise.
* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
Likewise.
* sysdeps/unix/sysv/linux/getsysstats.c (next_line): Likewise.
* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
* sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock):
Likewise.
* sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps):
Likewise.
* sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap):
Likewise.
* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np):
Likewise.
* sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise.
---
ChangeLog | 33 +++++++++++++++++++++++++++++
catgets/open_catalog.c | 2 +-
intl/loadmsgcat.c | 2 +-
libio/fileops.c | 2 +-
locale/loadlocale.c | 2 +-
login/utmp_file.c | 8 +++----
sysdeps/generic/not-cancel.h | 2 +-
sysdeps/unix/sysv/linux/Versions | 1 +
sysdeps/unix/sysv/linux/fips-private.h | 2 +-
sysdeps/unix/sysv/linux/gethostid.c | 2 +-
sysdeps/unix/sysv/linux/getloadavg.c | 2 +-
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 4 ++--
sysdeps/unix/sysv/linux/i386/smp.h | 2 +-
sysdeps/unix/sysv/linux/ia64/has_cpuclock.c | 2 +-
sysdeps/unix/sysv/linux/libc_fatal.c | 2 +-
sysdeps/unix/sysv/linux/malloc-sysdep.h | 2 +-
sysdeps/unix/sysv/linux/not-cancel.h | 10 +++------
sysdeps/unix/sysv/linux/pthread_getname.c | 2 +-
sysdeps/unix/sysv/linux/read.c | 8 +++++++
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
21 files changed, 66 insertions(+), 28 deletions(-)
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index 4621b26..d79a6b1 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -237,7 +237,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
/* Save read, handle partial reads. */
do
{
- size_t now = read_not_cancel (fd, (((char *) catalog->file_ptr)
+ size_t now = __read_nocancel (fd, (((char *) catalog->file_ptr)
+ (st.st_size - todo)), todo);
if (now == 0 || now == (size_t) -1)
{
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index adca419..514e38f 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -447,7 +447,7 @@
file and the name space must not be polluted. */
# define open(name, flags) __open_nocancel (name, flags)
# define close(fd) close_not_cancel_no_status (fd)
-# define read(fd, buf, n) read_not_cancel (fd, buf, n)
+# define read(fd, buf, n) __read_nocancel (fd, buf, n)
# define mmap(addr, len, prot, flags, fd, offset) \
__mmap (addr, len, prot, flags, fd, offset)
# define munmap(addr, len) __munmap (addr, len)
diff --git a/libio/fileops.c b/libio/fileops.c
index 67f3d72..80bd3f5 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -1204,7 +1204,7 @@ _IO_ssize_t
_IO_file_read (_IO_FILE *fp, void *buf, _IO_ssize_t size)
{
return (__builtin_expect (fp->_flags2 & _IO_FLAGS2_NOTCANCEL, 0)
- ? read_not_cancel (fp->_fileno, buf, size)
+ ? __read_nocancel (fp->_fileno, buf, size)
: read (fp->_fileno, buf, size));
}
libc_hidden_def (_IO_file_read)
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index 9c69ad4..a733557 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -238,7 +238,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
char *p = (char *) filedata;
while (to_read > 0)
{
- nread = read_not_cancel (fd, p, to_read);
+ nread = __read_nocancel (fd, p, to_read);
if (__builtin_expect (nread, 1) <= 0)
{
free (filedata);
diff --git a/login/utmp_file.c b/login/utmp_file.c
index 1407116..61d03d6 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -187,7 +187,7 @@ getutent_r_file (struct utmp *buffer, struct utmp **result)
}
/* Read the next entry. */
- nbytes = read_not_cancel (file_fd, &last_entry, sizeof (struct utmp));
+ nbytes = __read_nocancel (file_fd, &last_entry, sizeof (struct utmp));
UNLOCK_FILE (file_fd);
@@ -231,7 +231,7 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer,
while (1)
{
/* Read the next entry. */
- if (read_not_cancel (file_fd, buffer, sizeof (struct utmp))
+ if (__read_nocancel (file_fd, buffer, sizeof (struct utmp))
!= sizeof (struct utmp))
{
__set_errno (ESRCH);
@@ -253,7 +253,7 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer,
while (1)
{
/* Read the next entry. */
- if (read_not_cancel (file_fd, buffer, sizeof (struct utmp))
+ if (__read_nocancel (file_fd, buffer, sizeof (struct utmp))
!= sizeof (struct utmp))
{
__set_errno (ESRCH);
@@ -329,7 +329,7 @@ getutline_r_file (const struct utmp *line, struct utmp *buffer,
while (1)
{
/* Read the next entry. */
- if (read_not_cancel (file_fd, &last_entry, sizeof (struct utmp))
+ if (__read_nocancel (file_fd, &last_entry, sizeof (struct utmp))
!= sizeof (struct utmp))
{
__set_errno (ESRCH);
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index a4f7b7b..4fada2f 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -34,7 +34,7 @@
__close (fd)
#define close_not_cancel_no_status(fd) \
(void) __close (fd)
-#define read_not_cancel(fd, buf, n) \
+#define __read_nocancel(fd, buf, n) \
__read (fd, buf, n)
#define write_not_cancel(fd, buf, n) \
__write (fd, buf, n)
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index 3c64077..b553514 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -170,6 +170,7 @@ libc {
# functions used in other libraries
__syscall_rt_sigqueueinfo;
__open_nocancel;
+ __read_nocancel;
# functions used by nscd
__netlink_assert_response;
}
diff --git a/sysdeps/unix/sysv/linux/fips-private.h b/sysdeps/unix/sysv/linux/fips-private.h
index 3a83a0f..775f2c2 100644
--- a/sysdeps/unix/sysv/linux/fips-private.h
+++ b/sysdeps/unix/sysv/linux/fips-private.h
@@ -49,7 +49,7 @@ fips_enabled_p (void)
/* This is more than enough, the file contains a single integer. */
char buf[32];
ssize_t n;
- n = TEMP_FAILURE_RETRY (read_not_cancel (fd, buf, sizeof (buf) - 1));
+ n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, sizeof (buf) - 1));
close_not_cancel_no_status (fd);
if (n > 0)
diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
index 3ea8656..6e19dee 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -80,7 +80,7 @@ gethostid (void)
fd = __open_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0);
if (fd >= 0)
{
- ssize_t n = read_not_cancel (fd, &id, sizeof (id));
+ ssize_t n = __read_nocancel (fd, &id, sizeof (id));
close_not_cancel_no_status (fd);
diff --git a/sysdeps/unix/sysv/linux/getloadavg.c b/sysdeps/unix/sysv/linux/getloadavg.c
index 0bfe41d..64bad17 100644
--- a/sysdeps/unix/sysv/linux/getloadavg.c
+++ b/sysdeps/unix/sysv/linux/getloadavg.c
@@ -42,7 +42,7 @@ getloadavg (double loadavg[], int nelem)
ssize_t nread;
int i;
- nread = read_not_cancel (fd, buf, sizeof buf - 1);
+ nread = __read_nocancel (fd, buf, sizeof buf - 1);
close_not_cancel_no_status (fd);
if (nread <= 0)
return -1;
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 2519792..1de746b 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -41,7 +41,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
/* We are reading a 32-bit number. 12 bytes are enough for the text
representation. If not, something is wrong. */
char uidbuf[12];
- ssize_t n = TEMP_FAILURE_RETRY (read_not_cancel (fd, uidbuf,
+ ssize_t n = TEMP_FAILURE_RETRY (__read_nocancel (fd, uidbuf,
sizeof (uidbuf)));
close_not_cancel_no_status (fd);
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index e21a34c..d1400d6 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -85,7 +85,7 @@ next_line (int fd, char *const buffer, char **cp, char **re,
*re = buffer + (*re - *cp);
*cp = buffer;
- ssize_t n = read_not_cancel (fd, *re, buffer_end - *re);
+ ssize_t n = __read_nocancel (fd, *re, buffer_end - *re);
if (n < 0)
return NULL;
@@ -96,7 +96,7 @@ next_line (int fd, char *const buffer, char **cp, char **re,
{
/* Truncate too long lines. */
*re = buffer + 3 * (buffer_end - buffer) / 4;
- n = read_not_cancel (fd, *re, buffer_end - *re);
+ n = __read_nocancel (fd, *re, buffer_end - *re);
if (n < 0)
return NULL;
diff --git a/sysdeps/unix/sysv/linux/i386/smp.h b/sysdeps/unix/sysv/linux/i386/smp.h
index c24f2fd..eb1ac5d 100644
--- a/sysdeps/unix/sysv/linux/i386/smp.h
+++ b/sysdeps/unix/sysv/linux/i386/smp.h
@@ -43,7 +43,7 @@ is_smp_system (void)
/* This was not successful. Now try reading the /proc filesystem. */
int fd = __open_nocancel ("/proc/sys/kernel/version", O_RDONLY);
if (__builtin_expect (fd, 0) == -1
- || read_not_cancel (fd, u.buf, sizeof (u.buf)) <= 0)
+ || __read_nocancel (fd, u.buf, sizeof (u.buf)) <= 0)
/* This also didn't work. We give up and say it's a UP machine. */
u.buf[0] = '\0';
diff --git a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
index 04e395b..6aab1e8 100644
--- a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
+++ b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
@@ -37,7 +37,7 @@ has_cpuclock (void)
/* We expect the file to contain a single digit followed by
a newline. If the format changes we better not rely on
the file content. */
- if (read_not_cancel (fd, buf, sizeof buf) != 2
+ if (__read_nocancel (fd, buf, sizeof buf) != 2
|| buf[0] != '0' || buf[1] != '\n')
newval = -1;
diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c
index 5b484cf..ca838a7 100644
--- a/sysdeps/unix/sysv/linux/libc_fatal.c
+++ b/sysdeps/unix/sysv/linux/libc_fatal.c
@@ -56,7 +56,7 @@ backtrace_and_maps (int do_abort, bool written, int fd)
int fd2 = __open_nocancel ("/proc/self/maps", O_RDONLY);
char buf[1024];
ssize_t n2;
- while ((n2 = read_not_cancel (fd2, buf, sizeof (buf))) > 0)
+ while ((n2 = __read_nocancel (fd2, buf, sizeof (buf))) > 0)
if (write_not_cancel (fd, buf, n2) != n2)
break;
close_not_cancel_no_status (fd2);
diff --git a/sysdeps/unix/sysv/linux/malloc-sysdep.h b/sysdeps/unix/sysv/linux/malloc-sysdep.h
index cb87b58..7a7acba 100644
--- a/sysdeps/unix/sysv/linux/malloc-sysdep.h
+++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h
@@ -47,7 +47,7 @@ check_may_shrink_heap (void)
if (fd >= 0)
{
char val;
- ssize_t n = read_not_cancel (fd, &val, 1);
+ ssize_t n = __read_nocancel (fd, &val, 1);
may_shrink_heap = n > 0 && val == '2';
close_not_cancel_no_status (fd);
}
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 8d897f0..3d26075 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -34,9 +34,9 @@ libc_hidden_proto (__open_nocancel)
__typeof (open64) __open64_nocancel;
libc_hidden_proto (__open64_nocancel)
-/* Uncancelable read. */
-#define __read_nocancel(fd, buf, len) \
- INLINE_SYSCALL (read, 3, fd, buf, len)
+/* Non cancellable read syscall. */
+__typeof (__read) __read_nocancel;
+libc_hidden_proto (__read_nocancel)
/* Uncancelable write. */
#define __write_nocancel(fd, buf, len) \
@@ -61,10 +61,6 @@ libc_hidden_proto (__open64_nocancel)
(void) ({ INTERNAL_SYSCALL_DECL (err); \
INTERNAL_SYSCALL (close, err, 1, (fd)); })
-/* Uncancelable read. */
-#define read_not_cancel(fd, buf, n) \
- __read_nocancel (fd, buf, n)
-
/* Uncancelable write. */
#define write_not_cancel(fd, buf, n) \
__write_nocancel (fd, buf, n)
diff --git a/sysdeps/unix/sysv/linux/pthread_getname.c b/sysdeps/unix/sysv/linux/pthread_getname.c
index caab2cc..93c1dfd 100644
--- a/sysdeps/unix/sysv/linux/pthread_getname.c
+++ b/sysdeps/unix/sysv/linux/pthread_getname.c
@@ -50,7 +50,7 @@ pthread_getname_np (pthread_t th, char *buf, size_t len)
return errno;
int res = 0;
- ssize_t n = TEMP_FAILURE_RETRY (read_not_cancel (fd, buf, len));
+ ssize_t n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, len));
if (n < 0)
res = errno;
else
diff --git a/sysdeps/unix/sysv/linux/read.c b/sysdeps/unix/sysv/linux/read.c
index 2a02c1b..e519474 100644
--- a/sysdeps/unix/sysv/linux/read.c
+++ b/sysdeps/unix/sysv/linux/read.c
@@ -18,6 +18,7 @@
#include <unistd.h>
#include <sysdep-cancel.h>
+#include <not-cancel.h>
/* Read NBYTES into BUF from FD. Return the number read or -1. */
ssize_t
@@ -31,3 +32,10 @@ libc_hidden_def (__read)
weak_alias (__libc_read, __read)
libc_hidden_def (read)
weak_alias (__libc_read, read)
+
+ssize_t
+__read_nocancel (int fd, void *buf, size_t nbytes)
+{
+ return INLINE_SYSCALL_CALL (read, fd, buf, nbytes);
+}
+libc_hidden_def (__read_nocancel)
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index ab068ab..f9becfb 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -121,7 +121,7 @@ __sysconf (int name)
/* This is more than enough, the file contains a single integer. */
char buf[32];
ssize_t n;
- n = TEMP_FAILURE_RETRY (read_not_cancel (fd, buf, sizeof (buf) - 1));
+ n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, sizeof (buf) - 1));
close_not_cancel_no_status (fd);
if (n > 0)
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 03/14] Consolidate non cancellable write call
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (4 preceding siblings ...)
2017-07-04 19:54 ` [PATCH 02/14] Consolidate non cancellable read call Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 11/14] Remove non cancellable sigsuspend definition Adhemerval Zanella
` (8 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
This patch consolidates all the non cancellable write calls to use
the __write_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.
* sysdeps/generic/not-cancel.h (write_not_cancel): Remove macro.
(__write_nocancel): New macro.
* sysdeps/unix/sysv/linux/not-cancel.h (__write_nocancel):
Rewrite as a function prototype.
(write_not_cancel): Remove macro.
* sysdeps/unix/sysv/linux/write.c (__write_nocancel): New function.
* gmon/gmon.c (ERR): Replace write_not_cancel with __write_nocancel.
(write_gmon): Likewise.
* libio/fileops.c (_IO_new_file_write): Likewise.
* login/utmp_file.c (pututline_file): Likewise.
(updwtmp_file): Likewise.
* stdio-common/psiginfo.c (psiginfo): Likewise.
* sysdeps/posix/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise.
* sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps):
Likewise.
* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
Likewise.
---
ChangeLog | 19 +++++++++++++++++++
gmon/gmon.c | 4 ++--
libio/fileops.c | 2 +-
login/utmp_file.c | 4 ++--
stdio-common/psiginfo.c | 2 +-
sysdeps/generic/not-cancel.h | 2 +-
sysdeps/posix/spawni.c | 2 +-
sysdeps/unix/sysv/linux/gethostid.c | 2 +-
sysdeps/unix/sysv/linux/libc_fatal.c | 4 ++--
sysdeps/unix/sysv/linux/not-cancel.h | 8 ++------
sysdeps/unix/sysv/linux/pthread_setname.c | 2 +-
sysdeps/unix/sysv/linux/write.c | 8 ++++++++
12 files changed, 41 insertions(+), 18 deletions(-)
diff --git a/gmon/gmon.c b/gmon/gmon.c
index 87c3c4e..e7701b9 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -58,7 +58,7 @@ struct gmonparam _gmonparam attribute_hidden = { GMON_PROF_OFF };
static int s_scale;
#define SCALE_1_TO_1 0x10000L
-#define ERR(s) write_not_cancel (STDERR_FILENO, s, sizeof (s) - 1)
+#define ERR(s) __write_nocancel (STDERR_FILENO, s, sizeof (s) - 1)
void moncontrol (int mode);
void __moncontrol (int mode);
@@ -375,7 +375,7 @@ write_gmon (void)
memcpy (&ghdr.cookie[0], GMON_MAGIC, sizeof (ghdr.cookie));
ghdr.version = GMON_VERSION;
memset (ghdr.spare, '\0', sizeof (ghdr.spare));
- write_not_cancel (fd, &ghdr, sizeof (struct gmon_hdr));
+ __write_nocancel (fd, &ghdr, sizeof (struct gmon_hdr));
/* write PC histogram: */
write_hist (fd);
diff --git a/libio/fileops.c b/libio/fileops.c
index 80bd3f5..f025178 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -1251,7 +1251,7 @@ _IO_new_file_write (_IO_FILE *f, const void *data, _IO_ssize_t n)
{
_IO_ssize_t count = (__builtin_expect (f->_flags2
& _IO_FLAGS2_NOTCANCEL, 0)
- ? write_not_cancel (f->_fileno, data, to_do)
+ ? __write_nocancel (f->_fileno, data, to_do)
: write (f->_fileno, data, to_do));
if (count < 0)
{
diff --git a/login/utmp_file.c b/login/utmp_file.c
index 61d03d6..26e3f4b 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -444,7 +444,7 @@ pututline_file (const struct utmp *data)
}
/* Write the new data. */
- if (write_not_cancel (file_fd, data, sizeof (struct utmp))
+ if (__write_nocancel (file_fd, data, sizeof (struct utmp))
!= sizeof (struct utmp))
{
/* If we appended a new record this is only partially written.
@@ -505,7 +505,7 @@ updwtmp_file (const char *file, const struct utmp *utmp)
/* Write the entry. If we can't write all the bytes, reset the file
size back to the original size. That way, no partial entries
will remain. */
- if (write_not_cancel (fd, utmp, sizeof (struct utmp))
+ if (__write_nocancel (fd, utmp, sizeof (struct utmp))
!= sizeof (struct utmp))
{
__ftruncate64 (fd, offset);
diff --git a/stdio-common/psiginfo.c b/stdio-common/psiginfo.c
index 6954a42..7bf2e2d 100644
--- a/stdio-common/psiginfo.c
+++ b/stdio-common/psiginfo.c
@@ -199,5 +199,5 @@ Signal generated by the completion of an I/O request");
fclose (fp);
- write_not_cancel (STDERR_FILENO, buf, strlen (buf));
+ __write_nocancel (STDERR_FILENO, buf, strlen (buf));
}
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index 4fada2f..e91cb6c 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -36,7 +36,7 @@
(void) __close (fd)
#define __read_nocancel(fd, buf, n) \
__read (fd, buf, n)
-#define write_not_cancel(fd, buf, n) \
+#define __write_nocancel(fd, buf, n) \
__write (fd, buf, n)
#define writev_not_cancel_no_status(fd, iov, n) \
(void) __writev (fd, iov, n)
diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c
index aaca6e2..7617279 100644
--- a/sysdeps/posix/spawni.c
+++ b/sysdeps/posix/spawni.c
@@ -234,7 +234,7 @@ fail:
/* Since sizeof errno < PIPE_BUF, the write is atomic. */
ret = -ret;
if (ret)
- while (write_not_cancel (args->pipe[1], &ret, sizeof (ret)) < 0);
+ while (__write_nocancel (args->pipe[1], &ret, sizeof (ret)) < 0);
_exit (SPAWN_ERROR);
}
diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
index 6e19dee..11c7e73 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -51,7 +51,7 @@ sethostid (long int id)
if (fd < 0)
return -1;
- written = write_not_cancel (fd, &id32, sizeof (id32));
+ written = __write_nocancel (fd, &id32, sizeof (id32));
close_not_cancel_no_status (fd);
diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c
index ca838a7..c7c6a07 100644
--- a/sysdeps/unix/sysv/linux/libc_fatal.c
+++ b/sysdeps/unix/sysv/linux/libc_fatal.c
@@ -48,7 +48,7 @@ backtrace_and_maps (int do_abort, bool written, int fd)
if (n > 2)
{
#define strnsize(str) str, strlen (str)
-#define writestr(str) write_not_cancel (fd, str)
+#define writestr(str) __write_nocancel (fd, str)
writestr (strnsize ("======= Backtrace: =========\n"));
__backtrace_symbols_fd (addrs + 1, n - 1, fd);
@@ -57,7 +57,7 @@ backtrace_and_maps (int do_abort, bool written, int fd)
char buf[1024];
ssize_t n2;
while ((n2 = __read_nocancel (fd2, buf, sizeof (buf))) > 0)
- if (write_not_cancel (fd, buf, n2) != n2)
+ if (__write_nocancel (fd, buf, n2) != n2)
break;
close_not_cancel_no_status (fd2);
}
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 3d26075..84dc72a 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -39,8 +39,8 @@ __typeof (__read) __read_nocancel;
libc_hidden_proto (__read_nocancel)
/* Uncancelable write. */
-#define __write_nocancel(fd, buf, len) \
- INLINE_SYSCALL (write, 3, fd, buf, len)
+__typeof (__write) __write_nocancel;
+libc_hidden_proto (__write_nocancel)
/* Uncancelable openat. */
#define openat_not_cancel(fd, fname, oflag, mode) \
@@ -61,10 +61,6 @@ libc_hidden_proto (__read_nocancel)
(void) ({ INTERNAL_SYSCALL_DECL (err); \
INTERNAL_SYSCALL (close, err, 1, (fd)); })
-/* Uncancelable write. */
-#define write_not_cancel(fd, buf, n) \
- __write_nocancel (fd, buf, n)
-
/* Uncancelable writev. */
#define writev_not_cancel_no_status(fd, iov, n) \
(void) ({ INTERNAL_SYSCALL_DECL (err); \
diff --git a/sysdeps/unix/sysv/linux/pthread_setname.c b/sysdeps/unix/sysv/linux/pthread_setname.c
index 93f0e9d..c5e9a33 100644
--- a/sysdeps/unix/sysv/linux/pthread_setname.c
+++ b/sysdeps/unix/sysv/linux/pthread_setname.c
@@ -51,7 +51,7 @@ pthread_setname_np (pthread_t th, const char *name)
return errno;
int res = 0;
- ssize_t n = TEMP_FAILURE_RETRY (write_not_cancel (fd, name, name_len));
+ ssize_t n = TEMP_FAILURE_RETRY (__write_nocancel (fd, name, name_len));
if (n < 0)
res = errno;
else if (n != name_len)
diff --git a/sysdeps/unix/sysv/linux/write.c b/sysdeps/unix/sysv/linux/write.c
index d495145..bf12ca5 100644
--- a/sysdeps/unix/sysv/linux/write.c
+++ b/sysdeps/unix/sysv/linux/write.c
@@ -18,6 +18,7 @@
#include <unistd.h>
#include <sysdep-cancel.h>
+#include <not-cancel.h>
/* Write NBYTES of BUF to FD. Return the number written, or -1. */
ssize_t
@@ -31,3 +32,10 @@ weak_alias (__libc_write, __write)
libc_hidden_weak (__write)
weak_alias (__libc_write, write)
libc_hidden_weak (write)
+
+ssize_t
+__write_nocancel (int fd, const void *buf, size_t nbytes)
+{
+ return INLINE_SYSCALL_CALL (write, fd, buf, nbytes);
+}
+libc_hidden_def (__write_nocancel)
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 11/14] Remove non cancellable sigsuspend definition
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (5 preceding siblings ...)
2017-07-04 19:54 ` [PATCH 03/14] Consolidate non cancellable write call Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 05/14] Consolidate non cancellable close call Adhemerval Zanella
` (7 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
There is no current internal usage fo non cancellable sigsuspend calls.
Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu.
* sysdeps/generic/not-cancel.h (sigsuspend_not_cancel): Remove
macro.
* sysdeps/unix/sysv/linux/not-cancel.h (sigsuspend_not_cancel):
Likewise.
---
ChangeLog | 5 +++++
sysdeps/generic/not-cancel.h | 2 --
sysdeps/unix/sysv/linux/not-cancel.h | 4 ----
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index 8eb2995..3418db5 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -42,7 +42,5 @@
__pause ()
#define __nanosleep_nocancel(requested_time, remaining) \
__nanosleep (requested_time, remaining)
-#define sigsuspend_not_cancel(set) \
- __sigsuspend (set)
#define NO_CANCELLATION 1
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 9aaa781..797c925 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -86,8 +86,4 @@ libc_hidden_proto (__pause_nocancel)
__typeof (__nanosleep) __nanosleep_nocancel;
hidden_proto (__nanosleep_nocancel)
-/* Uncancelable sigsuspend. */
-#define sigsuspend_not_cancel(set) \
- INLINE_SYSCALL (rt_sigsuspend, 2, set, _NSIG / 8)
-
#endif /* NOT_CANCEL_H */
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 05/14] Consolidate non cancellable close call
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (6 preceding siblings ...)
2017-07-04 19:54 ` [PATCH 11/14] Remove non cancellable sigsuspend definition Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 10/14] Consolidate non cancellable nanosleep call Adhemerval Zanella
` (6 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
This patch consolidates all the non cancellable close calls to use
the __close_nocancel{_nostatus} 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.
* sysdeps/generic/not-cancel.h (close_not_cancel): Remove macro.
(close_not_cancel_no_status): Likewise.
(__close_nocancel): New macro.
(__close_nocancel_no_status): Likewise.
* sysdeps/unix/sysv/linux/not-cancel.h (__close_nocancel): Remove
macro.
(close_not_cancel): Likewise.
(close_not_cancel_no_status): Likewise.
(__close_nocancel): New prototype.
(__close_nocancel_no_status): New function.
* sysdeps/unix/sysv/linux/close.c (__close_nocancel): New function.
* catgets/open_catalog.c (__open_catalog): Replace
close_not_cancel{_no_status) with __close_nocancel{_nostatus}.
* gmon/gmon.c (write_gmon): Likewise.
* iconv/gconv_cache.c (__gconv_load_cache): Likewise.
* intl/loadmsgcat.c (close): Likewise.
* io/ftw.c (open_dir_stream): Likewise.
(ftw_startup): Likewise.
* libio/fileops.c (_IO_file_open): Likewise.
(_IO_file_close_mmap): Likewise.
(_IO_file_close): Likewise.
* libio/iopopen.c (_IO_dup2): Likewise.
* locale/loadarchive.c (_nl_load_locale_from_archive): Likewise.
* locale/loadlocale.c (_nl_load_locale): Likewise.
* login/utmp_file.c (pututline_file): Likewise.
(endutent_file): Likewise.
* misc/daemon.c (daemon): Likewise.
* nscd/nscd_getai.c (__nscd_getai): Likewise.
* nscd/nscd_getgr_r.c (nscd_getgr_r): Likewise.
* nscd/nscd_gethst_r.c (nscd_gethst_r): Likewise.
* nscd/nscd_getpw_r.c (nscd_getpw_r): Likewise.
* nscd/nscd_getserv_r.c (nscd_getserv_r): Likewise.
* nscd/nscd_helper.c (open_socket): Likewise.
(__nscd_open_socket): Likewise.
* nscd/nscd_initgroups.c (__nscd_getgrouplist): Likewise.
* nscd/nscd_netgroup.c (__nscd_setnetgrent): Likewise.
(__nscd_innetgr): Likewise.
* nss/nss_db/db-open.c (internal_setent): Likewise.
* resolv/res-close.c (__res_iclose): Likewise.
* sunrpc/pm_getmaps.c (pmap_getmaps): Likewise.
* sysdeps/posix/closedir.c (__closedir): Likewise.
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Likewise.
* sysdeps/posix/getcwd.c (__getcwd): Likewise.
* sysdeps/posix/opendir.c (tryopen_o_directory): Likewise.
(opendir_tail): Likewise.
* sysdeps/posix/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/check_native.c (__check_native): Likewise.
* sysdeps/unix/sysv/linux/check_pf.c (__check_pf): Likewise.
* sysdeps/unix/sysv/linux/fips-private.h (fips_enabled_p): Likewise.
* sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise.
(gethostid): Likewise.
* sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise.
* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
Likewise.
* sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Likewise.
* sysdeps/unix/sysv/linux/grantpt.c (close_all_fds): Likewise.
* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
* sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock):
Likewise.
* sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex): Likewise.
* sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps): Likewise.
* sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap):
Likewise.
* sysdeps/unix/sysv/linux/mq_notify.c (init_mq_netlink): Likewise.
* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np):
Likewise.
* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
Likewise.
* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise.
---
ChangeLog | 71 +++++++++++++++++++++++++++++
catgets/open_catalog.c | 2 +-
gmon/gmon.c | 2 +-
iconv/gconv_cache.c | 4 +-
intl/loadmsgcat.c | 2 +-
io/ftw.c | 4 +-
libio/fileops.c | 6 +--
libio/iopopen.c | 2 +-
locale/loadarchive.c | 6 +--
locale/loadlocale.c | 6 +--
login/utmp_file.c | 8 ++--
misc/daemon.c | 4 +-
nscd/nscd_getai.c | 2 +-
nscd/nscd_getgr_r.c | 2 +-
nscd/nscd_gethst_r.c | 2 +-
nscd/nscd_getpw_r.c | 2 +-
nscd/nscd_getserv_r.c | 2 +-
nscd/nscd_helper.c | 4 +-
nscd/nscd_initgroups.c | 2 +-
nscd/nscd_netgroup.c | 4 +-
nss/nss_db/db-open.c | 2 +-
resolv/res-close.c | 4 +-
sunrpc/pm_getmaps.c | 2 +-
sysdeps/generic/not-cancel.h | 4 +-
sysdeps/posix/closedir.c | 2 +-
sysdeps/posix/getaddrinfo.c | 4 +-
sysdeps/posix/getcwd.c | 4 +-
sysdeps/posix/opendir.c | 6 +--
sysdeps/posix/spawni.c | 6 +--
sysdeps/unix/sysv/linux/check_native.c | 2 +-
sysdeps/unix/sysv/linux/check_pf.c | 2 +-
sysdeps/unix/sysv/linux/close.c | 8 ++++
sysdeps/unix/sysv/linux/fips-private.h | 2 +-
sysdeps/unix/sysv/linux/gethostid.c | 4 +-
sysdeps/unix/sysv/linux/getloadavg.c | 2 +-
sysdeps/unix/sysv/linux/getlogin_r.c | 2 +-
sysdeps/unix/sysv/linux/getsysstats.c | 6 +--
sysdeps/unix/sysv/linux/grantpt.c | 2 +-
sysdeps/unix/sysv/linux/i386/smp.h | 2 +-
sysdeps/unix/sysv/linux/ia64/has_cpuclock.c | 2 +-
sysdeps/unix/sysv/linux/if_index.c | 6 +--
sysdeps/unix/sysv/linux/libc_fatal.c | 2 +-
sysdeps/unix/sysv/linux/malloc-sysdep.h | 2 +-
sysdeps/unix/sysv/linux/mq_notify.c | 2 +-
sysdeps/unix/sysv/linux/not-cancel.h | 18 +++++---
sysdeps/unix/sysv/linux/pthread_getname.c | 2 +-
sysdeps/unix/sysv/linux/pthread_setname.c | 2 +-
sysdeps/unix/sysv/linux/spawni.c | 6 +--
sysdeps/unix/sysv/linux/sysconf.c | 2 +-
49 files changed, 165 insertions(+), 82 deletions(-)
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index d79a6b1..73b7243 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -328,7 +328,7 @@ __open_catalog (const char *cat_name, const char *nlspath, const char *env_var,
/* Release the lock again. */
close_unlock_return:
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
free (buf);
return result;
diff --git a/gmon/gmon.c b/gmon/gmon.c
index e7701b9..b26c27a 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -386,7 +386,7 @@ write_gmon (void)
/* write basic-block execution counts: */
write_bb_counts (fd);
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
}
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index f1dce29..0ff1c3b 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -71,7 +71,7 @@ __gconv_load_cache (void)
|| (size_t) st.st_size < sizeof (struct gconvcache_header))
{
close_and_exit:
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
return -1;
}
@@ -108,7 +108,7 @@ __gconv_load_cache (void)
}
/* We don't need the file descriptor anymore. */
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
/* Check the consistency. */
header = (struct gconvcache_header *) gconv_cache;
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index 514e38f..745bd53 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -446,7 +446,7 @@
because some ISO C functions will require linking with this object
file and the name space must not be polluted. */
# define open(name, flags) __open_nocancel (name, flags)
-# define close(fd) close_not_cancel_no_status (fd)
+# define close(fd) __close_nocancel_no_status (fd)
# define read(fd, buf, n) __read_nocancel (fd, buf, n)
# define mmap(addr, len, prot, flags, fd, offset) \
__mmap (addr, len, prot, flags, fd, offset)
diff --git a/io/ftw.c b/io/ftw.c
index f33fed3..4dac3b6 100644
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -341,7 +341,7 @@ open_dir_stream (int *dfdp, struct ftw_data *data, struct dir_data *dirp)
O_RDONLY | O_DIRECTORY | O_NDELAY);
dirp->stream = NULL;
if (fd != -1 && (dirp->stream = __fdopendir (fd)) == NULL)
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
}
else
{
@@ -791,7 +791,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
{
int save_err = errno;
__fchdir (cwdfd);
- close_not_cancel_no_status (cwdfd);
+ __close_nocancel_no_status (cwdfd);
__set_errno (save_err);
}
else if (cwd != NULL)
diff --git a/libio/fileops.c b/libio/fileops.c
index f025178..b8b02ba 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -242,7 +242,7 @@ _IO_file_open (_IO_FILE *fp, const char *filename, int posix_mode, int prot,
_IO_off64_t new_pos = _IO_SYSSEEK (fp, 0, _IO_seek_end);
if (new_pos == _IO_pos_BAD && errno != ESPIPE)
{
- close_not_cancel (fdesc);
+ __close_nocancel (fdesc);
return NULL;
}
}
@@ -1231,7 +1231,7 @@ _IO_file_close_mmap (_IO_FILE *fp)
fp->_IO_buf_base = fp->_IO_buf_end = NULL;
/* Cancelling close should be avoided if possible since it leaves an
unrecoverable state behind. */
- return close_not_cancel (fp->_fileno);
+ return __close_nocancel (fp->_fileno);
}
int
@@ -1239,7 +1239,7 @@ _IO_file_close (_IO_FILE *fp)
{
/* Cancelling close should be avoided if possible since it leaves an
unrecoverable state behind. */
- return close_not_cancel (fp->_fileno);
+ return __close_nocancel (fp->_fileno);
}
libc_hidden_def (_IO_file_close)
diff --git a/libio/iopopen.c b/libio/iopopen.c
index b78e7e5..0c20cbb 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -76,7 +76,7 @@ extern int _IO_dup2 (int fd, int fd2) __THROW;
#ifndef _IO_close
#ifdef _LIBC
-#define _IO_close close_not_cancel
+#define _IO_close __close_nocancel
#else
#define _IO_close close
#endif
diff --git a/locale/loadarchive.c b/locale/loadarchive.c
index aebb590..86fa584 100644
--- a/locale/loadarchive.c
+++ b/locale/loadarchive.c
@@ -213,7 +213,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
/* stat failed, very strange. */
close_and_out:
if (fd >= 0)
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
return NULL;
}
@@ -253,7 +253,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
{
/* We've mapped the whole file already, so we can be
sure we won't need this file descriptor later. */
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
fd = -1;
}
@@ -452,7 +452,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
/* We don't need the file descriptor any longer. */
if (fd >= 0)
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
fd = -1;
/* We succeeded in mapping all the necessary regions of the archive.
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index a733557..552d03f 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -181,7 +181,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) < 0)
{
puntfd:
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
return;
}
if (__glibc_unlikely (S_ISDIR (st.st_mode)))
@@ -191,7 +191,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
char *newp;
size_t filenamelen;
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
filenamelen = strlen (file->filename);
newp = (char *) alloca (filenamelen
@@ -257,7 +257,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
#endif /* _POSIX_MAPPED_FILES */
/* We have mapped the data, so we no longer need the descriptor. */
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
if (__glibc_unlikely (filedata == NULL))
/* We failed to map or read the data. */
diff --git a/login/utmp_file.c b/login/utmp_file.c
index 26e3f4b..4dd38dd 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -382,10 +382,10 @@ pututline_file (const struct utmp *data)
if (__lseek64 (new_fd, __lseek64 (file_fd, 0, SEEK_CUR), SEEK_SET) == -1
|| __dup2 (new_fd, file_fd) < 0)
{
- close_not_cancel_no_status (new_fd);
+ __close_nocancel_no_status (new_fd);
return NULL;
}
- close_not_cancel_no_status (new_fd);
+ __close_nocancel_no_status (new_fd);
file_writable = true;
}
@@ -471,7 +471,7 @@ endutent_file (void)
{
assert (file_fd >= 0);
- close_not_cancel_no_status (file_fd);
+ __close_nocancel_no_status (file_fd);
file_fd = -1;
}
@@ -518,7 +518,7 @@ unlock_return:
UNLOCK_FILE (fd);
/* Close WTMP file. */
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
return result;
}
diff --git a/misc/daemon.c b/misc/daemon.c
index dd38f2b..b35e20f 100644
--- a/misc/daemon.c
+++ b/misc/daemon.c
@@ -80,12 +80,12 @@ daemon (int nochdir, int noclose)
} else {
/* We must set an errno value since no
function call actually failed. */
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
__set_errno (ENODEV);
return -1;
}
} else {
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
return -1;
}
}
diff --git a/nscd/nscd_getai.c b/nscd/nscd_getai.c
index daaf6d6..73347ff 100644
--- a/nscd/nscd_getai.c
+++ b/nscd/nscd_getai.c
@@ -189,7 +189,7 @@ __nscd_getai (const char *key, struct nscd_ai_result **result, int *h_errnop)
out_close:
if (sock != -1)
- close_not_cancel_no_status (sock);
+ __close_nocancel_no_status (sock);
out:
if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
{
diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c
index 87b4552..5f743c8 100644
--- a/nscd/nscd_getgr_r.c
+++ b/nscd/nscd_getgr_r.c
@@ -305,7 +305,7 @@ nscd_getgr_r (const char *key, size_t keylen, request_type type,
out_close:
if (sock != -1)
- close_not_cancel_no_status (sock);
+ __close_nocancel_no_status (sock);
out:
if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
{
diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c
index daa708b..d986824 100644
--- a/nscd/nscd_gethst_r.c
+++ b/nscd/nscd_gethst_r.c
@@ -436,7 +436,7 @@ nscd_gethst_r (const char *key, size_t keylen, request_type type,
out_close:
if (sock != -1)
- close_not_cancel_no_status (sock);
+ __close_nocancel_no_status (sock);
out:
if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
{
diff --git a/nscd/nscd_getpw_r.c b/nscd/nscd_getpw_r.c
index b291d2f..a969d60 100644
--- a/nscd/nscd_getpw_r.c
+++ b/nscd/nscd_getpw_r.c
@@ -218,7 +218,7 @@ nscd_getpw_r (const char *key, size_t keylen, request_type type,
out_close:
if (sock != -1)
- close_not_cancel_no_status (sock);
+ __close_nocancel_no_status (sock);
out:
if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
{
diff --git a/nscd/nscd_getserv_r.c b/nscd/nscd_getserv_r.c
index 7dfb1c8..1ac5aac 100644
--- a/nscd/nscd_getserv_r.c
+++ b/nscd/nscd_getserv_r.c
@@ -356,7 +356,7 @@ nscd_getserv_r (const char *crit, size_t critlen, const char *proto,
out_close:
if (sock != -1)
- close_not_cancel_no_status (sock);
+ __close_nocancel_no_status (sock);
out:
if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
{
diff --git a/nscd/nscd_helper.c b/nscd/nscd_helper.c
index 22905d0..bc884aa 100644
--- a/nscd/nscd_helper.c
+++ b/nscd/nscd_helper.c
@@ -236,7 +236,7 @@ open_socket (request_type type, const char *key, size_t keylen)
}
out:
- close_not_cancel_no_status (sock);
+ __close_nocancel_no_status (sock);
return -1;
}
@@ -555,7 +555,7 @@ __nscd_open_socket (const char *key, size_t keylen, request_type type,
return sock;
}
- close_not_cancel_no_status (sock);
+ __close_nocancel_no_status (sock);
}
__set_errno (saved_errno);
diff --git a/nscd/nscd_initgroups.c b/nscd/nscd_initgroups.c
index 00c6508..b696b66 100644
--- a/nscd/nscd_initgroups.c
+++ b/nscd/nscd_initgroups.c
@@ -157,7 +157,7 @@ __nscd_getgrouplist (const char *user, gid_t group, long int *size,
out_close:
if (sock != -1)
- close_not_cancel_no_status (sock);
+ __close_nocancel_no_status (sock);
out:
if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
{
diff --git a/nscd/nscd_netgroup.c b/nscd/nscd_netgroup.c
index 44f37ef..14c780b 100644
--- a/nscd/nscd_netgroup.c
+++ b/nscd/nscd_netgroup.c
@@ -139,7 +139,7 @@ __nscd_setnetgrent (const char *group, struct __netgrent *datap)
out_close:
if (sock != -1)
- close_not_cancel_no_status (sock);
+ __close_nocancel_no_status (sock);
out:
if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
{
@@ -263,7 +263,7 @@ __nscd_innetgr (const char *netgroup, const char *host, const char *user,
out_close:
if (sock != -1)
- close_not_cancel_no_status (sock);
+ __close_nocancel_no_status (sock);
out:
if (__nscd_drop_map_ref (mapped, &gc_cycle) != 0)
{
diff --git a/nss/nss_db/db-open.c b/nss/nss_db/db-open.c
index 40a2540..97eb0a6 100644
--- a/nss/nss_db/db-open.c
+++ b/nss/nss_db/db-open.c
@@ -52,7 +52,7 @@ internal_setent (const char *file, struct nss_db_map *mapping)
status = NSS_STATUS_TRYAGAIN;
}
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
}
return status;
diff --git a/resolv/res-close.c b/resolv/res-close.c
index 21f038c..2adf47c 100644
--- a/resolv/res-close.c
+++ b/resolv/res-close.c
@@ -94,7 +94,7 @@ __res_iclose (res_state statp, bool free_addr)
{
if (statp->_vcsock >= 0)
{
- close_not_cancel_no_status (statp->_vcsock);
+ __close_nocancel_no_status (statp->_vcsock);
statp->_vcsock = -1;
statp->_flags &= ~(RES_F_VC | RES_F_CONN);
}
@@ -103,7 +103,7 @@ __res_iclose (res_state statp, bool free_addr)
{
if (statp->_u._ext.nssocks[ns] != -1)
{
- close_not_cancel_no_status (statp->_u._ext.nssocks[ns]);
+ __close_nocancel_no_status (statp->_u._ext.nssocks[ns]);
statp->_u._ext.nssocks[ns] = -1;
}
if (free_addr)
diff --git a/sunrpc/pm_getmaps.c b/sunrpc/pm_getmaps.c
index 88c44f0..094492b 100644
--- a/sunrpc/pm_getmaps.c
+++ b/sunrpc/pm_getmaps.c
@@ -81,7 +81,7 @@ pmap_getmaps (struct sockaddr_in *address)
}
/* We only need to close the socket here if we opened it. */
if (closeit)
- close_not_cancel (socket);
+ __close_nocancel (socket);
address->sin_port = 0;
return head;
}
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index df9aea6..53214cd 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -26,9 +26,9 @@
__openat (__VA_ARGS__)
#define __openat64_nocancel(...) \
__openat64 (__VA_ARGS__)
-#define close_not_cancel(fd) \
+#define __close_nocancel(fd) \
__close (fd)
-#define close_not_cancel_no_status(fd) \
+#define __close_nocancel_no_status(fd) \
(void) __close (fd)
#define __read_nocancel(fd, buf, n) \
__read (fd, buf, n)
diff --git a/sysdeps/posix/closedir.c b/sysdeps/posix/closedir.c
index e7b7d77..dbde65f 100644
--- a/sysdeps/posix/closedir.c
+++ b/sysdeps/posix/closedir.c
@@ -49,6 +49,6 @@ __closedir (DIR *dirp)
free ((void *) dirp);
- return close_not_cancel (fd);
+ return __close_nocancel (fd);
}
weak_alias (__closedir, closedir)
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index efa7118..868fee0 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -2401,7 +2401,7 @@ getaddrinfo (const char *name, const char *service,
{
if (fd != -1)
close_retry:
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
af = q->ai_family;
fd = __socket (af, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_IP);
}
@@ -2504,7 +2504,7 @@ getaddrinfo (const char *name, const char *service,
}
if (fd != -1)
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
/* We got all the source addresses we can get, now sort using
the information. */
diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
index ecae628..79a4cd0 100644
--- a/sysdeps/posix/getcwd.c
+++ b/sysdeps/posix/getcwd.c
@@ -176,7 +176,7 @@ extern char *alloca ();
# include <kernel-features.h>
#else
# define __openat64_nocancel(dfd, name, mode) openat64 (dfd, name, mode)
-# define close_not_cancel_no_status(fd) close (fd)
+# define __close_nocancel_no_status(fd) close (fd)
#endif
#ifndef PATH_MAX
@@ -521,7 +521,7 @@ __getcwd (char *buf, size_t size)
if (dirstream != NULL)
__closedir (dirstream);
if (fd_needs_closing)
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
#ifndef NO_ALLOCATION
if (buf == NULL)
free (path);
diff --git a/sysdeps/posix/opendir.c b/sysdeps/posix/opendir.c
index 51a92e8..90d28ca 100644
--- a/sysdeps/posix/opendir.c
+++ b/sysdeps/posix/opendir.c
@@ -65,7 +65,7 @@ tryopen_o_directory (void)
if (x >= 0)
{
- close_not_cancel_no_status (x);
+ __close_nocancel_no_status (x);
o_directory_works = -1;
}
else if (errno != ENOTDIR)
@@ -129,7 +129,7 @@ opendir_tail (int fd)
{
__set_errno (ENOTDIR);
lose:
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
return NULL;
}
@@ -227,7 +227,7 @@ __alloc_dir (int fd, bool close_fd, int flags, const struct stat64 *statp)
if (close_fd)
{
int save_errno = errno;
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
__set_errno (save_errno);
}
return NULL;
diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c
index 7617279..e308f08 100644
--- a/sysdeps/posix/spawni.c
+++ b/sysdeps/posix/spawni.c
@@ -157,7 +157,7 @@ __spawni_child (void *arguments)
switch (action->tag)
{
case spawn_do_close:
- if (close_not_cancel (action->action.close_action.fd) != 0)
+ if (__close_nocancel (action->action.close_action.fd) != 0)
{
if (have_fdlimit == 0)
{
@@ -183,7 +183,7 @@ __spawni_child (void *arguments)
with the process already at maximum number of file descriptor
opened and also for multiple actions on single-open special
paths (like /dev/watchdog). */
- close_not_cancel (action->action.open_action.fd);
+ __close_nocancel (action->action.open_action.fd);
int new_fd = __open_nocancel (action->action.open_action.path,
action->action.open_action.oflag
@@ -200,7 +200,7 @@ __spawni_child (void *arguments)
!= action->action.open_action.fd)
goto fail;
- if ((ret = close_not_cancel (new_fd) != 0))
+ if ((ret = __close_nocancel (new_fd) != 0))
goto fail;
}
}
diff --git a/sysdeps/unix/sysv/linux/check_native.c b/sysdeps/unix/sysv/linux/check_native.c
index 7e5a7c9..933e6f8 100644
--- a/sysdeps/unix/sysv/linux/check_native.c
+++ b/sysdeps/unix/sysv/linux/check_native.c
@@ -167,7 +167,7 @@ __check_native (uint32_t a1_index, int *a1_native,
while (! done);
out:
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
return;
diff --git a/sysdeps/unix/sysv/linux/check_pf.c b/sysdeps/unix/sysv/linux/check_pf.c
index 3bf221a..79f1456 100644
--- a/sysdeps/unix/sysv/linux/check_pf.c
+++ b/sysdeps/unix/sysv/linux/check_pf.c
@@ -328,7 +328,7 @@ __check_pf (bool *seen_ipv4, bool *seen_ipv6,
&addr_len) == 0)
data = make_request (fd, nladdr.nl_pid);
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
}
if (data != NULL)
diff --git a/sysdeps/unix/sysv/linux/close.c b/sysdeps/unix/sysv/linux/close.c
index 1ac71ce..47b21ee 100644
--- a/sysdeps/unix/sysv/linux/close.c
+++ b/sysdeps/unix/sysv/linux/close.c
@@ -18,6 +18,7 @@
#include <unistd.h>
#include <sysdep-cancel.h>
+#include <not-cancel.h>
/* Close the file descriptor FD. */
int
@@ -28,3 +29,10 @@ __close (int fd)
libc_hidden_def (__close)
strong_alias (__close, __libc_close)
weak_alias (__close, close)
+
+int
+__close_nocancel (int fd)
+{
+ return INLINE_SYSCALL_CALL (close, fd);
+}
+libc_hidden_def (__close_nocancel)
diff --git a/sysdeps/unix/sysv/linux/fips-private.h b/sysdeps/unix/sysv/linux/fips-private.h
index 775f2c2..66d29d3 100644
--- a/sysdeps/unix/sysv/linux/fips-private.h
+++ b/sysdeps/unix/sysv/linux/fips-private.h
@@ -50,7 +50,7 @@ fips_enabled_p (void)
char buf[32];
ssize_t n;
n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, sizeof (buf) - 1));
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
if (n > 0)
{
diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
index 11c7e73..a719dad 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -53,7 +53,7 @@ sethostid (long int id)
written = __write_nocancel (fd, &id32, sizeof (id32));
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
return written != sizeof (id32) ? -1 : 0;
}
@@ -82,7 +82,7 @@ gethostid (void)
{
ssize_t n = __read_nocancel (fd, &id, sizeof (id));
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
if (n == sizeof (id))
return id;
diff --git a/sysdeps/unix/sysv/linux/getloadavg.c b/sysdeps/unix/sysv/linux/getloadavg.c
index 64bad17..60c470e 100644
--- a/sysdeps/unix/sysv/linux/getloadavg.c
+++ b/sysdeps/unix/sysv/linux/getloadavg.c
@@ -43,7 +43,7 @@ getloadavg (double loadavg[], int nelem)
int i;
nread = __read_nocancel (fd, buf, sizeof buf - 1);
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
if (nread <= 0)
return -1;
buf[nread - 1] = '\0';
diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c
index 1de746b..ecc7eb4 100644
--- a/sysdeps/unix/sysv/linux/getlogin_r.c
+++ b/sysdeps/unix/sysv/linux/getlogin_r.c
@@ -43,7 +43,7 @@ __getlogin_r_loginuid (char *name, size_t namesize)
char uidbuf[12];
ssize_t n = TEMP_FAILURE_RETRY (__read_nocancel (fd, uidbuf,
sizeof (uidbuf)));
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
uid_t uid;
char *endp;
diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c
index d1400d6..977642f 100644
--- a/sysdeps/unix/sysv/linux/getsysstats.c
+++ b/sysdeps/unix/sysv/linux/getsysstats.c
@@ -180,7 +180,7 @@ __get_nprocs (void)
}
while (l < re);
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
if (result > 0)
goto out;
@@ -207,7 +207,7 @@ __get_nprocs (void)
else if (isdigit (l[3]))
++result;
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
}
else
{
@@ -215,7 +215,7 @@ __get_nprocs (void)
if (fd != -1)
{
GET_NPROCS_PARSER (fd, buffer, cp, re, buffer_end, result);
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
}
}
diff --git a/sysdeps/unix/sysv/linux/grantpt.c b/sysdeps/unix/sysv/linux/grantpt.c
index 97c6ba7..af2a9db 100644
--- a/sysdeps/unix/sysv/linux/grantpt.c
+++ b/sysdeps/unix/sysv/linux/grantpt.c
@@ -26,7 +26,7 @@ close_all_fds (void)
char *endp;
long int fd = strtol (d->d_name, &endp, 10);
if (*endp == '\0' && fd != PTY_FILENO && fd != dirfd (dir))
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
}
__closedir (dir);
diff --git a/sysdeps/unix/sysv/linux/i386/smp.h b/sysdeps/unix/sysv/linux/i386/smp.h
index eb1ac5d..2efbc71 100644
--- a/sysdeps/unix/sysv/linux/i386/smp.h
+++ b/sysdeps/unix/sysv/linux/i386/smp.h
@@ -47,7 +47,7 @@ is_smp_system (void)
/* This also didn't work. We give up and say it's a UP machine. */
u.buf[0] = '\0';
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
cp = u.buf;
}
diff --git a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
index 6aab1e8..8267848 100644
--- a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
+++ b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c
@@ -41,7 +41,7 @@ has_cpuclock (void)
|| buf[0] != '0' || buf[1] != '\n')
newval = -1;
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
}
itc_usable = newval;
diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c
index 8ba5eae..3474d4f 100644
--- a/sysdeps/unix/sysv/linux/if_index.c
+++ b/sysdeps/unix/sysv/linux/if_index.c
@@ -47,12 +47,12 @@ __if_nametoindex (const char *ifname)
if (__ioctl (fd, SIOCGIFINDEX, &ifr) < 0)
{
int saved_errno = errno;
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
if (saved_errno == EINVAL)
__set_errno (ENOSYS);
return 0;
}
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
return ifr.ifr_ifindex;
#endif
}
@@ -224,7 +224,7 @@ __if_indextoname (unsigned int ifindex, char *ifname)
ifr.ifr_ifindex = ifindex;
status = __ioctl (fd, SIOCGIFNAME, &ifr);
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
if (status < 0)
{
diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c
index c7c6a07..4e06c90 100644
--- a/sysdeps/unix/sysv/linux/libc_fatal.c
+++ b/sysdeps/unix/sysv/linux/libc_fatal.c
@@ -59,7 +59,7 @@ backtrace_and_maps (int do_abort, bool written, int fd)
while ((n2 = __read_nocancel (fd2, buf, sizeof (buf))) > 0)
if (__write_nocancel (fd, buf, n2) != n2)
break;
- close_not_cancel_no_status (fd2);
+ __close_nocancel_no_status (fd2);
}
}
}
diff --git a/sysdeps/unix/sysv/linux/malloc-sysdep.h b/sysdeps/unix/sysv/linux/malloc-sysdep.h
index 7a7acba..0dcd3d1 100644
--- a/sysdeps/unix/sysv/linux/malloc-sysdep.h
+++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h
@@ -49,7 +49,7 @@ check_may_shrink_heap (void)
char val;
ssize_t n = __read_nocancel (fd, &val, 1);
may_shrink_heap = n > 0 && val == '2';
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
}
}
diff --git a/sysdeps/unix/sysv/linux/mq_notify.c b/sysdeps/unix/sysv/linux/mq_notify.c
index 626430c..e724a46 100644
--- a/sysdeps/unix/sysv/linux/mq_notify.c
+++ b/sysdeps/unix/sysv/linux/mq_notify.c
@@ -209,7 +209,7 @@ init_mq_netlink (void)
if (err != 0)
{
- close_not_cancel_no_status (netlink_socket);
+ __close_nocancel_no_status (netlink_socket);
netlink_socket = -1;
}
}
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 08ad773..c620c8a 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -51,13 +51,17 @@ __typeof (__write) __write_nocancel;
libc_hidden_proto (__write_nocancel)
/* Uncancelable close. */
-#define __close_nocancel(fd) \
- INLINE_SYSCALL (close, 1, fd)
-#define close_not_cancel(fd) \
- __close_nocancel (fd)
-#define close_not_cancel_no_status(fd) \
- (void) ({ INTERNAL_SYSCALL_DECL (err); \
- INTERNAL_SYSCALL (close, err, 1, (fd)); })
+__typeof (__close) __close_nocancel;
+libc_hidden_proto (__close_nocancel)
+
+/* Non cancellable close syscall that does not also set errno in case of
+ failure. */
+static inline int
+__close_nocancel_no_status (int fd)
+{
+ INTERNAL_SYSCALL_DECL (err);
+ return INTERNAL_SYSCALL (close, err, 1, (fd));
+}
/* Uncancelable writev. */
#define writev_not_cancel_no_status(fd, iov, n) \
diff --git a/sysdeps/unix/sysv/linux/pthread_getname.c b/sysdeps/unix/sysv/linux/pthread_getname.c
index 93c1dfd..919a25b 100644
--- a/sysdeps/unix/sysv/linux/pthread_getname.c
+++ b/sysdeps/unix/sysv/linux/pthread_getname.c
@@ -63,7 +63,7 @@ pthread_getname_np (pthread_t th, char *buf, size_t len)
buf[n] = '\0';
}
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
return res;
}
diff --git a/sysdeps/unix/sysv/linux/pthread_setname.c b/sysdeps/unix/sysv/linux/pthread_setname.c
index c5e9a33..3cb112f 100644
--- a/sysdeps/unix/sysv/linux/pthread_setname.c
+++ b/sysdeps/unix/sysv/linux/pthread_setname.c
@@ -57,7 +57,7 @@ pthread_setname_np (pthread_t th, const char *name)
else if (n != name_len)
res = EIO;
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
return res;
}
diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c
index 4994a07..dea1650 100644
--- a/sysdeps/unix/sysv/linux/spawni.c
+++ b/sysdeps/unix/sysv/linux/spawni.c
@@ -205,7 +205,7 @@ __spawni_child (void *arguments)
switch (action->tag)
{
case spawn_do_close:
- if (close_not_cancel (action->action.close_action.fd) != 0)
+ if (__close_nocancel (action->action.close_action.fd) != 0)
{
if (!have_fdlimit)
{
@@ -228,7 +228,7 @@ __spawni_child (void *arguments)
with the process already at maximum number of file descriptor
opened and also for multiple actions on single-open special
paths (like /dev/watchdog). */
- close_not_cancel (action->action.open_action.fd);
+ __close_nocancel (action->action.open_action.fd);
int ret = __open_nocancel (action->action.open_action.path,
action->action.
@@ -247,7 +247,7 @@ __spawni_child (void *arguments)
!= action->action.open_action.fd)
goto fail;
- if (close_not_cancel (new_fd) != 0)
+ if (__close_nocancel (new_fd) != 0)
goto fail;
}
}
diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c
index f9becfb..d2a124b 100644
--- a/sysdeps/unix/sysv/linux/sysconf.c
+++ b/sysdeps/unix/sysv/linux/sysconf.c
@@ -122,7 +122,7 @@ __sysconf (int name)
char buf[32];
ssize_t n;
n = TEMP_FAILURE_RETRY (__read_nocancel (fd, buf, sizeof (buf) - 1));
- close_not_cancel_no_status (fd);
+ __close_nocancel_no_status (fd);
if (n > 0)
{
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 10/14] Consolidate non cancellable nanosleep call
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (7 preceding siblings ...)
2017-07-04 19:54 ` [PATCH 05/14] Consolidate non cancellable close call Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 09/14] Consolidate non cancellable pause call Adhemerval Zanella
` (5 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
This patch consolidates all the non cancellable nanosleep calls to use
the __nanosleep_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_timedlock.c (__pthread_mutex_timedlock): Replace
nanosleep_not_cancel with __nanosleep_nocancel.
* sysdeps/generic/not-cancel.h (nanosleep_not_cancel): Remove macro.
(__nanosleep_nocancel): New macro.
* sysdeps/unix/sysv/linux/nanosleep.c (__nanosleep_nocancel): New
function.
* sysdeps/unix/sysv/linux/not-cancel.h (nanosleep_not_cancel): Remove
macro.
(__nanosleep_nocancel): New prototype.
---
ChangeLog | 10 ++++++++++
nptl/pthread_mutex_timedlock.c | 2 +-
sysdeps/generic/not-cancel.h | 2 +-
sysdeps/unix/sysv/linux/nanosleep.c | 9 +++++++++
sysdeps/unix/sysv/linux/not-cancel.h | 5 +++--
5 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c
index be53381..c522abe 100644
--- a/nptl/pthread_mutex_timedlock.c
+++ b/nptl/pthread_mutex_timedlock.c
@@ -429,7 +429,7 @@ __pthread_mutex_timedlock (pthread_mutex_t *mutex,
--reltime.tv_sec;
}
if (reltime.tv_sec >= 0)
- while (nanosleep_not_cancel (&reltime, &reltime) != 0)
+ while (__nanosleep_nocancel (&reltime, &reltime) != 0)
continue;
return ETIMEDOUT;
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index e80b89a..8eb2995 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -40,7 +40,7 @@
__waitpid (pid, stat_loc, options)
#define __pause_nocancel() \
__pause ()
-#define nanosleep_not_cancel(requested_time, remaining) \
+#define __nanosleep_nocancel(requested_time, remaining) \
__nanosleep (requested_time, remaining)
#define sigsuspend_not_cancel(set) \
__sigsuspend (set)
diff --git a/sysdeps/unix/sysv/linux/nanosleep.c b/sysdeps/unix/sysv/linux/nanosleep.c
index 2d15328..e7ac2c0 100644
--- a/sysdeps/unix/sysv/linux/nanosleep.c
+++ b/sysdeps/unix/sysv/linux/nanosleep.c
@@ -18,6 +18,7 @@
#include <time.h>
#include <sysdep-cancel.h>
+#include <not-cancel.h>
/* Pause execution for a number of nanoseconds. */
int
@@ -28,3 +29,11 @@ __nanosleep (const struct timespec *requested_time,
}
hidden_def (__nanosleep)
weak_alias (__nanosleep, nanosleep)
+
+int
+__nanosleep_nocancel (const struct timespec *requested_time,
+ struct timespec *remaining)
+{
+ return INLINE_SYSCALL_CALL (nanosleep, requested_time, remaining);
+}
+hidden_def (__nanosleep_nocancel)
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 00070fd..9aaa781 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -26,6 +26,7 @@
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/wait.h>
+#include <time.h>
/* Non cancellable open syscall. */
__typeof (open) __open_nocancel;
@@ -82,8 +83,8 @@ __typeof (pause) __pause_nocancel;
libc_hidden_proto (__pause_nocancel)
/* Uncancelable nanosleep. */
-#define nanosleep_not_cancel(requested_time, remaining) \
- INLINE_SYSCALL (nanosleep, 2, requested_time, remaining)
+__typeof (__nanosleep) __nanosleep_nocancel;
+hidden_proto (__nanosleep_nocancel)
/* Uncancelable sigsuspend. */
#define sigsuspend_not_cancel(set) \
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 09/14] Consolidate non cancellable pause call
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (8 preceding siblings ...)
2017-07-04 19:54 ` [PATCH 10/14] Consolidate non cancellable nanosleep call Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 14/14] Remove cancellation support for syscall generation Adhemerval Zanella
` (4 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
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 | 9 +++++++++
nptl/pthread_mutex_lock.c | 2 +-
sysdeps/generic/not-cancel.h | 2 +-
sysdeps/unix/sysv/linux/not-cancel.h | 10 ++--------
sysdeps/unix/sysv/linux/pause.c | 14 +++++++++++++-
5 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/nptl/pthread_mutex_lock.c b/nptl/pthread_mutex_lock.c
index b76475b..8fa23c6 100644
--- a/nptl/pthread_mutex_lock.c
+++ b/nptl/pthread_mutex_lock.c
@@ -425,7 +425,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 6c3afc2..e80b89a 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/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 3047848..00070fd 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -78,14 +78,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 4ccce9e..ad105d9 100644
--- a/sysdeps/unix/sysv/linux/pause.c
+++ b/sysdeps/unix/sysv/linux/pause.c
@@ -18,11 +18,12 @@
#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 +34,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)
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 14/14] Remove cancellation support for syscall generation
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (9 preceding siblings ...)
2017-07-04 19:54 ` [PATCH 09/14] Consolidate non cancellable pause call Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 07/14] Consolidate non cancellable fcntl call Adhemerval Zanella
` (3 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
This patch removes the cancellation mark from the auto-generation syscall
script. Now all the cancellable syscalls are done throught C code using
the SYSCALL_CANCEL macro. It simplifies the assembly required to each
architecture port, since the SYSCALL_CANCEL uses the already defined
INLINE_SYSCALL macros, and allows a more straigh fix on cancellation
machanism (since no more specific assembly fixes will be required).
Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
aarch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.
* sysdeps/unix/make-syscalls.sh: Remove cancellable tagging for
syscall definitions.
* sysdeps/unix/syscall-template.S (SYSCALL_CANCELLABLE): Remove
definition.
* sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (__local_enable_asynccancel): Likewise.
[IS_IN (libpthread)] (__local_disable_asynccancel): Likewise.
[IS_IN (libc)] (__local_enable_asynccancel): Likewise.
[IS_IN (libc)] (__local_enable_asynccancel): Likewise.
[IS_IN (librt)] (__local_disable_asynccancel): Likewise.
[IS_IN (librt)] (__local_disable_asynccancel): Likewise.
(CENABLE): Likewise.
(CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/arm/sysdep-cancel.h (PSEUDO): Remove
defintion.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/i386/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h (PSEUDO):
Remove definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
(SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/mips/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/sysv/linux/powerpc/powerpc32/sysdep-cancel.h: Remove file.
* sysdeps/sysv/linux/powerpc/powerpc64/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h: New file.
* sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/sh/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h: Remove file.
* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h: New file.
* sysdeps/unix/sysv/linux/tile/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
* sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h (PSEUDO): Remove
definition.
(PSEUDO_END): Likewise.
[IS_IN (libpthread)] (CENABLE): Likewise.
[IS_IN (libpthread)] (CDISABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (libc)] (CENABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[IS_IN (librt)] (CDISABLE): Likewise.
[__ASSEMBLER__] (SINGLE_THREAD_P): Likewise.
---
ChangeLog | 173 ++++++++++++++
sysdeps/unix/make-syscalls.sh | 4 -
sysdeps/unix/syscall-template.S | 7 +-
sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h | 87 +------
sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h | 131 +----------
sysdeps/unix/sysv/linux/arm/sysdep-cancel.h | 197 +---------------
sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h | 236 +------------------
sysdeps/unix/sysv/linux/i386/sysdep-cancel.h | 119 +---------
sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h | 194 +---------------
sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h | 108 +--------
sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h | 116 +---------
.../unix/sysv/linux/mips/mips64/sysdep-cancel.h | 249 ---------------------
sysdeps/unix/sysv/linux/mips/sysdep-cancel.h | 159 +------------
sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h | 110 +--------
.../sysv/linux/powerpc/powerpc32/sysdep-cancel.h | 118 ----------
.../sysv/linux/powerpc/powerpc64/sysdep-cancel.h | 147 ------------
sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h | 38 ++++
.../unix/sysv/linux/s390/s390-32/sysdep-cancel.h | 105 +--------
.../unix/sysv/linux/s390/s390-64/sysdep-cancel.h | 109 +--------
sysdeps/unix/sysv/linux/sh/sysdep-cancel.h | 136 +----------
.../unix/sysv/linux/sparc/sparc32/sysdep-cancel.h | 111 ---------
.../unix/sysv/linux/sparc/sparc64/sysdep-cancel.h | 109 ---------
sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h | 38 ++++
sysdeps/unix/sysv/linux/tile/sysdep-cancel.h | 123 +---------
sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h | 62 +----
25 files changed, 305 insertions(+), 2681 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
create mode 100644 sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h
delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h
create mode 100644 sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
diff --git a/sysdeps/unix/make-syscalls.sh b/sysdeps/unix/make-syscalls.sh
index 123553c..042cfac 100644
--- a/sysdeps/unix/make-syscalls.sh
+++ b/sysdeps/unix/make-syscalls.sh
@@ -12,7 +12,6 @@
#
# Syscall Signature Prefixes:
#
-# C: cancellable (i.e., this syscall is a cancellation point)
# E: errno and return value are not set by the call
# V: errno is not set, but errno or zero (success) is returned from the call
#
@@ -171,11 +170,9 @@ while read file srcfile caller syscall args strong weak; do
;;
esac
- cancellable=0
noerrno=0
errval=0
case $args in
- C*) cancellable=1; args=`echo $args | sed 's/C:\?//'`;;
E*) noerrno=1; args=`echo $args | sed 's/E:\?//'`;;
V*) errval=1; args=`echo $args | sed 's/V:\?//'`;;
esac
@@ -258,7 +255,6 @@ while read file srcfile caller syscall args strong weak; do
(echo '#define SYSCALL_NAME $syscall'; \\
echo '#define SYSCALL_NARGS $nargs'; \\
echo '#define SYSCALL_SYMBOL $strong'; \\
- echo '#define SYSCALL_CANCELLABLE $cancellable'; \\
echo '#define SYSCALL_NOERRNO $noerrno'; \\
echo '#define SYSCALL_ERRVAL $errval'; \\
echo '#include <syscall-template.S>'; \\"
diff --git a/sysdeps/unix/syscall-template.S b/sysdeps/unix/syscall-template.S
index 4993ff5..d4584a9 100644
--- a/sysdeps/unix/syscall-template.S
+++ b/sysdeps/unix/syscall-template.S
@@ -27,7 +27,6 @@
SYSCALL_NAME syscall name
SYSCALL_NARGS number of arguments this call takes
SYSCALL_SYMBOL primary symbol name
- SYSCALL_CANCELLABLE 1 if the call is a cancelation point
SYSCALL_NOERRNO 1 to define a no-errno version (see below)
SYSCALL_ERRVAL 1 to define an error-value version (see below)
@@ -41,11 +40,7 @@
instructions long and the untrained eye might not distinguish them from
some compiled code that inexplicably lacks source line information. */
-#if SYSCALL_CANCELLABLE
-# include <sysdep-cancel.h>
-#else
-# include <sysdep.h>
-#endif
+#include <sysdep.h>
/* This indirection is needed so that SYMBOL gets macro-expanded. */
#define syscall_hidden_def(SYMBOL) hidden_def (SYMBOL)
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h
index 4be2259..d39b6a2 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h
@@ -24,102 +24,23 @@
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .section ".text"; \
-ENTRY (__##syscall_name##_nocancel); \
-.Lpseudo_nocancel: \
- DO_CALL (syscall_name, args); \
-.Lpseudo_finish: \
- cmn x0, 4095; \
- b.cs .Lsyscall_error; \
- .subsection 2; \
- .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
-ENTRY (name); \
- SINGLE_THREAD_P(16); \
- cbz w16, .Lpseudo_nocancel; \
- /* Setup common stack frame no matter the number of args. \
- Also save the first arg, since it's basically free. */ \
- stp x30, x0, [sp, -64]!; \
- cfi_adjust_cfa_offset (64); \
- cfi_rel_offset (x30, 0); \
- DOCARGS_##args; /* save syscall args around CENABLE. */ \
- CENABLE; \
- mov x16, x0; /* save mask around syscall. */ \
- UNDOCARGS_##args; /* restore syscall args. */ \
- DO_CALL (syscall_name, args); \
- str x0, [sp, 8]; /* save result around CDISABLE. */ \
- mov x0, x16; /* restore mask for CDISABLE. */ \
- CDISABLE; \
- /* Break down the stack frame, restoring result at once. */ \
- ldp x30, x0, [sp], 64; \
- cfi_adjust_cfa_offset (-64); \
- cfi_restore (x30); \
- b .Lpseudo_finish; \
- cfi_endproc; \
- .size name, .-name; \
- .previous
-
-# undef PSEUDO_END
-# define PSEUDO_END(name) \
- SYSCALL_ERROR_HANDLER; \
- cfi_endproc
-
-# define DOCARGS_0
-# define DOCARGS_1
-# define DOCARGS_2 str x1, [sp, 16]
-# define DOCARGS_3 stp x1, x2, [sp, 16]
-# define DOCARGS_4 DOCARGS_3; str x3, [sp, 32]
-# define DOCARGS_5 DOCARGS_3; stp x3, x4, [sp, 32]
-# define DOCARGS_6 DOCARGS_5; str x5, [sp, 48]
-
-# define UNDOCARGS_0
-# define UNDOCARGS_1 ldr x0, [sp, 8]
-# define UNDOCARGS_2 ldp x0, x1, [sp, 8]
-# define UNDOCARGS_3 UNDOCARGS_1; ldp x1, x2, [sp, 16]
-# define UNDOCARGS_4 UNDOCARGS_2; ldp x2, x3, [sp, 24]
-# define UNDOCARGS_5 UNDOCARGS_3; ldp x3, x4, [sp, 32]
-# define UNDOCARGS_6 UNDOCARGS_4; ldp x4, x5, [sp, 40]
-
# if IS_IN (libpthread)
-# define CENABLE bl __pthread_enable_asynccancel
-# define CDISABLE bl __pthread_disable_asynccancel
# define __local_multiple_threads __pthread_multiple_threads
# elif IS_IN (libc)
-# define CENABLE bl __libc_enable_asynccancel
-# define CDISABLE bl __libc_disable_asynccancel
# define __local_multiple_threads __libc_multiple_threads
-# elif IS_IN (librt)
-# define CENABLE bl __librt_enable_asynccancel
-# define CDISABLE bl __librt_disable_asynccancel
-# else
-# error Unsupported library
# endif
# if IS_IN (libpthread) || IS_IN (libc)
-# ifndef __ASSEMBLER__
extern int __local_multiple_threads attribute_hidden;
-# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
-# else
-# define SINGLE_THREAD_P(R) \
- adrp x##R, __local_multiple_threads; \
- ldr w##R, [x##R, :lo12:__local_multiple_threads]
-# endif
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
# else
/* There is no __local_multiple_threads for librt, so use the TCB. */
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P(R) \
- mrs x##R, tpidr_el0; \
- sub x##R, x##R, PTHREAD_SIZEOF; \
- ldr w##R, [x##R, PTHREAD_MULTIPLE_THREADS_OFFSET]
-# endif
# endif
-#elif !defined __ASSEMBLER__
+#else
/* For rtld, et cetera. */
# define SINGLE_THREAD_P 1
@@ -127,8 +48,6 @@ extern int __local_multiple_threads attribute_hidden;
#endif
-#ifndef __ASSEMBLER__
# define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h b/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
index 66d6962..366cf31 100644
--- a/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h
@@ -17,147 +17,24 @@
#include <sysdep.h>
#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <nptl/pthreadP.h>
-#endif
+#include <nptl/pthreadP.h>
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-/* ??? Assumes that nothing comes between PSEUDO and PSEUDO_END
- besides "ret". */
-
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .globl __##syscall_name##_nocancel; \
- .type __##syscall_name##_nocancel, @function; \
- .usepv __##syscall_name##_nocancel, std; \
- .align 4; \
- cfi_startproc; \
-__LABEL(__##syscall_name##_nocancel) \
- ldgp gp, 0(pv); \
- PSEUDO_PROF; \
-__LABEL($pseudo_nocancel) \
- PSEUDO_PREPARE_ARGS; \
- lda v0, SYS_ify(syscall_name); \
- call_pal PAL_callsys; \
- bne a3, SYSCALL_ERROR_LABEL; \
-__LABEL($pseudo_ret) \
- .subsection 2; \
- .size __##syscall_name##_nocancel, .-__##syscall_name##_nocancel; \
- .globl name; \
- .type name, @function; \
- .usepv name, std; \
- .align 4; \
- cfi_startproc; \
-__LABEL(name) \
- ldgp gp, 0(pv); \
- PSEUDO_PROF; \
- SINGLE_THREAD_P(t0); \
- beq t0, $pseudo_nocancel; \
- subq sp, 64, sp; \
- cfi_def_cfa_offset(64); \
- stq ra, 0(sp); \
- cfi_offset(ra, -64); \
- SAVE_ARGS_##args; \
- CENABLE; \
- LOAD_ARGS_##args; \
- /* Save the CENABLE return value in RA. That register \
- is preserved across syscall and the real return \
- address is saved on the stack. */ \
- mov v0, ra; \
- lda v0, SYS_ify(syscall_name); \
- call_pal PAL_callsys; \
- stq v0, 8(sp); \
- mov ra, a0; \
- bne a3, $multi_error; \
- CDISABLE; \
- ldq ra, 0(sp); \
- ldq v0, 8(sp); \
- addq sp, 64, sp; \
- cfi_remember_state; \
- cfi_restore(ra); \
- cfi_def_cfa_offset(0); \
- ret; \
- cfi_restore_state; \
-__LABEL($multi_error) \
- CDISABLE; \
- ldq ra, 0(sp); \
- ldq v0, 8(sp); \
- addq sp, 64, sp; \
- cfi_restore(ra); \
- cfi_def_cfa_offset(0); \
- SYSCALL_ERROR_FALLTHRU; \
- SYSCALL_ERROR_HANDLER; \
- cfi_endproc; \
- .previous
-
-# undef PSEUDO_END
-# define PSEUDO_END(sym) \
- cfi_endproc; \
- .subsection 2; \
- .size sym, .-sym
-
-# define SAVE_ARGS_0 /* Nothing. */
-# define SAVE_ARGS_1 SAVE_ARGS_0; stq a0, 8(sp)
-# define SAVE_ARGS_2 SAVE_ARGS_1; stq a1, 16(sp)
-# define SAVE_ARGS_3 SAVE_ARGS_2; stq a2, 24(sp)
-# define SAVE_ARGS_4 SAVE_ARGS_3; stq a3, 32(sp)
-# define SAVE_ARGS_5 SAVE_ARGS_4; stq a4, 40(sp)
-# define SAVE_ARGS_6 SAVE_ARGS_5; stq a5, 48(sp)
-
-# define LOAD_ARGS_0 /* Nothing. */
-# define LOAD_ARGS_1 LOAD_ARGS_0; ldq a0, 8(sp)
-# define LOAD_ARGS_2 LOAD_ARGS_1; ldq a1, 16(sp)
-# define LOAD_ARGS_3 LOAD_ARGS_2; ldq a2, 24(sp)
-# define LOAD_ARGS_4 LOAD_ARGS_3; ldq a3, 32(sp)
-# define LOAD_ARGS_5 LOAD_ARGS_4; ldq a4, 40(sp)
-# define LOAD_ARGS_6 LOAD_ARGS_5; ldq a5, 48(sp)
-
# if IS_IN (libpthread)
-# define __local_enable_asynccancel __pthread_enable_asynccancel
-# define __local_disable_asynccancel __pthread_disable_asynccancel
# define __local_multiple_threads __pthread_multiple_threads
# elif IS_IN (libc)
-# define __local_enable_asynccancel __libc_enable_asynccancel
-# define __local_disable_asynccancel __libc_disable_asynccancel
# define __local_multiple_threads __libc_multiple_threads
-# elif IS_IN (librt)
-# define __local_enable_asynccancel __librt_enable_asynccancel
-# define __local_disable_asynccancel __librt_disable_asynccancel
-# else
-# error Unsupported library
-# endif
-
-# ifdef PIC
-# define CENABLE bsr ra, __local_enable_asynccancel !samegp
-# define CDISABLE bsr ra, __local_disable_asynccancel !samegp
-# else
-# define CENABLE jsr ra, __local_enable_asynccancel; ldgp ra, 0(gp)
-# define CDISABLE jsr ra, __local_disable_asynccancel; ldgp ra, 0(gp)
# endif
# if IS_IN (libpthread) || IS_IN (libc)
-# ifndef __ASSEMBLER__
extern int __local_multiple_threads attribute_hidden;
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (__local_multiple_threads == 0, 1)
-# elif defined(PIC)
-# define SINGLE_THREAD_P(reg) ldl reg, __local_multiple_threads(gp) !gprel
-# else
-# define SINGLE_THREAD_P(reg) \
- ldah reg, __local_multiple_threads(gp) !gprelhigh; \
- ldl reg, __local_multiple_threads(reg) !gprellow
-# endif
# else
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P(reg) \
- call_pal PAL_rduniq; \
- ldl reg, MULTIPLE_THREADS_OFFSET($0)
-# endif
# endif
#else
@@ -167,8 +44,6 @@ extern int __local_multiple_threads attribute_hidden;
#endif
-#ifndef __ASSEMBLER__
# define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h b/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
index de12acf..738e749 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h
@@ -23,210 +23,23 @@
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-/* NOTE: We do mark syscalls with unwind annotations, for the benefit of
- cancellation; but they're really only accurate at the point of the
- syscall. The ARM unwind directives are not rich enough without adding
- a custom personality function. */
-
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
- ENTRY (__##syscall_name##_nocancel); \
- CFI_SECTIONS; \
- DO_CALL (syscall_name, args); \
- cmn r0, $4096; \
- PSEUDO_RET; \
- END (__##syscall_name##_nocancel); \
- ENTRY (name); \
- SINGLE_THREAD_P; \
- DOARGS_##args; \
- bne .Lpseudo_cancel; \
- cfi_remember_state; \
- ldr r7, =SYS_ify (syscall_name); \
- swi 0x0; \
- UNDOARGS_##args; \
- cmn r0, $4096; \
- PSEUDO_RET; \
- cfi_restore_state; \
- .Lpseudo_cancel: \
- .fnstart; /* matched by the .fnend in UNDOARGS below. */ \
- DOCARGS_##args; /* save syscall args etc. around CENABLE. */ \
- CENABLE; \
- mov ip, r0; /* put mask in safe place. */ \
- UNDOCARGS_##args; /* restore syscall args. */ \
- ldr r7, =SYS_ify (syscall_name); \
- swi 0x0; /* do the call. */ \
- mov r7, r0; /* save syscall return value. */ \
- mov r0, ip; /* get mask back. */ \
- CDISABLE; \
- mov r0, r7; /* retrieve return value. */ \
- RESTORE_LR_##args; \
- UNDOARGS_##args; \
- cmn r0, $4096
-
-/* DOARGS pushes eight bytes on the stack for five arguments, twelve bytes for
- six arguments, and four bytes for fewer. In order to preserve doubleword
- alignment, sometimes we must save an extra register. */
-
-# define RESTART_UNWIND \
- .fnend; \
- .fnstart; \
- .save {r7}; \
- .save {lr}
-
-# define DOCARGS_0 \
- .save {r7}; \
- push {lr}; \
- cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (lr, 0); \
- .save {lr}
-# define UNDOCARGS_0
-# define RESTORE_LR_0 \
- pop {lr}; \
- cfi_adjust_cfa_offset (-4); \
- cfi_restore (lr)
-
-# define DOCARGS_1 \
- .save {r7}; \
- push {r0, r1, lr}; \
- cfi_adjust_cfa_offset (12); \
- cfi_rel_offset (lr, 8); \
- .save {lr}; \
- .pad #8
-# define UNDOCARGS_1 \
- ldr r0, [sp], #8; \
- cfi_adjust_cfa_offset (-8); \
- RESTART_UNWIND
-# define RESTORE_LR_1 \
- RESTORE_LR_0
-
-# define DOCARGS_2 \
- .save {r7}; \
- push {r0, r1, lr}; \
- cfi_adjust_cfa_offset (12); \
- cfi_rel_offset (lr, 8); \
- .save {lr}; \
- .pad #8
-# define UNDOCARGS_2 \
- pop {r0, r1}; \
- cfi_adjust_cfa_offset (-8); \
- RESTART_UNWIND
-# define RESTORE_LR_2 \
- RESTORE_LR_0
-
-# define DOCARGS_3 \
- .save {r7}; \
- push {r0, r1, r2, r3, lr}; \
- cfi_adjust_cfa_offset (20); \
- cfi_rel_offset (lr, 16); \
- .save {lr}; \
- .pad #16
-# define UNDOCARGS_3 \
- pop {r0, r1, r2, r3}; \
- cfi_adjust_cfa_offset (-16); \
- RESTART_UNWIND
-# define RESTORE_LR_3 \
- RESTORE_LR_0
-
-# define DOCARGS_4 \
- .save {r7}; \
- push {r0, r1, r2, r3, lr}; \
- cfi_adjust_cfa_offset (20); \
- cfi_rel_offset (lr, 16); \
- .save {lr}; \
- .pad #16
-# define UNDOCARGS_4 \
- pop {r0, r1, r2, r3}; \
- cfi_adjust_cfa_offset (-16); \
- RESTART_UNWIND
-# define RESTORE_LR_4 \
- RESTORE_LR_0
-
-/* r4 is only stmfd'ed for correct stack alignment. */
-# define DOCARGS_5 \
- .save {r4, r7}; \
- push {r0, r1, r2, r3, r4, lr}; \
- cfi_adjust_cfa_offset (24); \
- cfi_rel_offset (lr, 20); \
- .save {lr}; \
- .pad #20
-# define UNDOCARGS_5 \
- pop {r0, r1, r2, r3}; \
- cfi_adjust_cfa_offset (-16); \
- .fnend; \
- .fnstart; \
- .save {r4, r7}; \
- .save {lr}; \
- .pad #4
-# define RESTORE_LR_5 \
- pop {r4, lr}; \
- cfi_adjust_cfa_offset (-8); \
- /* r4 will be marked as restored later. */ \
- cfi_restore (lr)
-
-# define DOCARGS_6 \
- .save {r4, r5, r7}; \
- push {r0, r1, r2, r3, lr}; \
- cfi_adjust_cfa_offset (20); \
- cfi_rel_offset (lr, 16); \
- .save {lr}; \
- .pad #16
-# define UNDOCARGS_6 \
- pop {r0, r1, r2, r3}; \
- cfi_adjust_cfa_offset (-16); \
- .fnend; \
- .fnstart; \
- .save {r4, r5, r7}; \
- .save {lr};
-# define RESTORE_LR_6 \
- RESTORE_LR_0
-
# if IS_IN (libpthread)
-# define CENABLE bl PLTJMP(__pthread_enable_asynccancel)
-# define CDISABLE bl PLTJMP(__pthread_disable_asynccancel)
# define __local_multiple_threads __pthread_multiple_threads
# elif IS_IN (libc)
-# define CENABLE bl PLTJMP(__libc_enable_asynccancel)
-# define CDISABLE bl PLTJMP(__libc_disable_asynccancel)
# define __local_multiple_threads __libc_multiple_threads
-# elif IS_IN (librt)
-# define CENABLE bl PLTJMP(__librt_enable_asynccancel)
-# define CDISABLE bl PLTJMP(__librt_disable_asynccancel)
-# else
-# error Unsupported library
# endif
# if IS_IN (libpthread) || IS_IN (libc)
-# ifndef __ASSEMBLER__
extern int __local_multiple_threads attribute_hidden;
-# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
-# else
-# define SINGLE_THREAD_P \
- LDST_PCREL(ldr, ip, ip, __local_multiple_threads); \
- teq ip, #0
-# endif
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
# else
/* There is no __local_multiple_threads for librt, so use the TCB. */
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P \
- push {r0, lr}; \
- cfi_adjust_cfa_offset (8); \
- cfi_rel_offset (lr, 4); \
- GET_TLS (lr); \
- NEGOFF_ADJ_BASE (r0, MULTIPLE_THREADS_OFFSET); \
- ldr ip, NEGOFF_OFF1 (r0, MULTIPLE_THREADS_OFFSET); \
- pop {r0, lr}; \
- cfi_adjust_cfa_offset (-8); \
- cfi_restore (lr); \
- teq ip, #0
-# endif
# endif
-#elif !defined __ASSEMBLER__
+#else
/* For rtld, et cetera. */
# define SINGLE_THREAD_P 1
@@ -234,8 +47,6 @@ extern int __local_multiple_threads attribute_hidden;
#endif
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h b/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h
index 5ea2972..a6189a7 100644
--- a/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h
@@ -23,226 +23,6 @@
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-# ifndef NO_ERROR
-# define NO_ERROR -0x1000
-# endif
-
-/* The syscall cancellation mechanism requires userspace
- assistance, the following code does roughly this:
-
- do arguments (read arg5 and arg6 to registers)
- setup frame
-
- check if there are threads, yes jump to pseudo_cancel
-
- unthreaded:
- syscall
- check syscall return (jump to pre_end)
- set errno
- set return to -1
- (jump to pre_end)
-
- pseudo_cancel:
- cenable
- syscall
- cdisable
- check syscall return (jump to pre_end)
- set errno
- set return to -1
-
- pre_end
- restore stack
-
- It is expected that 'ret' and 'END' macros will
- append an 'undo arguments' and 'return' to the
- this PSEUDO macro. */
-
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- ENTRY (__##syscall_name##_nocancel) \
- DOARGS_##args ASM_LINE_SEP \
- stwm TREG, 64(%sp) ASM_LINE_SEP \
- .cfi_offset TREG, 0 ASM_LINE_SEP \
- .cfi_adjust_cfa_offset 64 ASM_LINE_SEP \
- stw %sp, -4(%sp) ASM_LINE_SEP \
- .cfi_offset 30, -4 ASM_LINE_SEP \
- stw %r19, -32(%sp) ASM_LINE_SEP \
- .cfi_offset 19, -32 ASM_LINE_SEP \
- /* Save r19 */ ASM_LINE_SEP \
- SAVE_PIC(TREG) ASM_LINE_SEP \
- /* Do syscall, delay loads # */ ASM_LINE_SEP \
- ble 0x100(%sr2,%r0) ASM_LINE_SEP \
- ldi SYS_ify (syscall_name), %r20 /* delay */ ASM_LINE_SEP \
- ldi NO_ERROR,%r1 ASM_LINE_SEP \
- cmpb,>>=,n %r1,%ret0,L(pre_nc_end) ASM_LINE_SEP \
- /* Restore r19 from TREG */ ASM_LINE_SEP \
- LOAD_PIC(TREG) /* delay */ ASM_LINE_SEP \
- SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
- /* Use TREG for temp storage */ ASM_LINE_SEP \
- copy %ret0, TREG /* delay */ ASM_LINE_SEP \
- /* OPTIMIZE: Don't reload r19 */ ASM_LINE_SEP \
- /* do a -1*syscall_ret0 */ ASM_LINE_SEP \
- sub %r0, TREG, TREG ASM_LINE_SEP \
- /* Store into errno location */ ASM_LINE_SEP \
- stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \
- /* return -1 as error */ ASM_LINE_SEP \
- ldi -1, %ret0 ASM_LINE_SEP \
-L(pre_nc_end): ASM_LINE_SEP \
- /* No need to LOAD_PIC */ ASM_LINE_SEP \
- /* Undo frame */ ASM_LINE_SEP \
- ldwm -64(%sp),TREG ASM_LINE_SEP \
- .cfi_adjust_cfa_offset -64 ASM_LINE_SEP \
- /* Restore rp before exit */ ASM_LINE_SEP \
- ldw -20(%sp), %rp ASM_LINE_SEP \
- .cfi_restore 2 ASM_LINE_SEP \
- ret ASM_LINE_SEP \
- END(__##syscall_name##_nocancel) ASM_LINE_SEP \
- /**********************************************/ASM_LINE_SEP \
- ENTRY (name) \
- DOARGS_##args ASM_LINE_SEP \
- stwm TREG, 64(%sp) ASM_LINE_SEP \
- .cfi_adjust_cfa_offset 64 ASM_LINE_SEP \
- stw %sp, -4(%sp) ASM_LINE_SEP \
- .cfi_offset 30, -4 ASM_LINE_SEP \
- stw %r19, -32(%sp) ASM_LINE_SEP \
- .cfi_offset 19, -32 ASM_LINE_SEP \
- /* Done setting up frame, continue... */ ASM_LINE_SEP \
- SINGLE_THREAD_P ASM_LINE_SEP \
- cmpib,<>,n 0,%ret0,L(pseudo_cancel) ASM_LINE_SEP \
-L(unthreaded): ASM_LINE_SEP \
- /* Save r19 */ ASM_LINE_SEP \
- SAVE_PIC(TREG) ASM_LINE_SEP \
- /* Do syscall, delay loads # */ ASM_LINE_SEP \
- ble 0x100(%sr2,%r0) ASM_LINE_SEP \
- ldi SYS_ify (syscall_name), %r20 /* delay */ ASM_LINE_SEP \
- ldi NO_ERROR,%r1 ASM_LINE_SEP \
- cmpb,>>=,n %r1,%ret0,L(pre_end) ASM_LINE_SEP \
- /* Restore r19 from TREG */ ASM_LINE_SEP \
- LOAD_PIC(TREG) /* delay */ ASM_LINE_SEP \
- SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
- /* Use TREG for temp storage */ ASM_LINE_SEP \
- copy %ret0, TREG /* delay */ ASM_LINE_SEP \
- /* OPTIMIZE: Don't reload r19 */ ASM_LINE_SEP \
- /* do a -1*syscall_ret0 */ ASM_LINE_SEP \
- sub %r0, TREG, TREG ASM_LINE_SEP \
- /* Store into errno location */ ASM_LINE_SEP \
- stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \
- b L(pre_end) ASM_LINE_SEP \
- /* return -1 as error */ ASM_LINE_SEP \
- ldi -1, %ret0 /* delay */ ASM_LINE_SEP \
-L(pseudo_cancel): ASM_LINE_SEP \
- PUSHARGS_##args /* Save args */ ASM_LINE_SEP \
- /* Save r19 into TREG */ ASM_LINE_SEP \
- CENABLE /* FUNC CALL */ ASM_LINE_SEP \
- SAVE_PIC(TREG) /* delay */ ASM_LINE_SEP \
- /* restore syscall args */ ASM_LINE_SEP \
- POPARGS_##args ASM_LINE_SEP \
- /* save mask from cenable (use stub rp slot) */ ASM_LINE_SEP \
- stw %ret0, -24(%sp) ASM_LINE_SEP \
- /* ... SYSCALL ... */ ASM_LINE_SEP \
- ble 0x100(%sr2,%r0) ASM_LINE_SEP \
- ldi SYS_ify (syscall_name), %r20 /* delay */ ASM_LINE_SEP \
- /* ............... */ ASM_LINE_SEP \
- LOAD_PIC(TREG) ASM_LINE_SEP \
- /* pass mask as arg0 to cdisable */ ASM_LINE_SEP \
- ldw -24(%sp), %r26 ASM_LINE_SEP \
- CDISABLE ASM_LINE_SEP \
- stw %ret0, -24(%sp) /* delay */ ASM_LINE_SEP \
- /* Restore syscall return */ ASM_LINE_SEP \
- ldw -24(%sp), %ret0 ASM_LINE_SEP \
- /* compare error */ ASM_LINE_SEP \
- ldi NO_ERROR,%r1 ASM_LINE_SEP \
- /* branch if no error */ ASM_LINE_SEP \
- cmpb,>>=,n %r1,%ret0,L(pre_end) ASM_LINE_SEP \
- LOAD_PIC(TREG) /* cond. nullify */ ASM_LINE_SEP \
- copy %ret0, TREG /* save syscall return */ ASM_LINE_SEP \
- SYSCALL_ERROR_HANDLER ASM_LINE_SEP \
- /* make syscall res value positive */ ASM_LINE_SEP \
- sub %r0, TREG, TREG /* delay */ ASM_LINE_SEP \
- /* No need to LOAD_PIC */ ASM_LINE_SEP \
- /* store into errno location */ ASM_LINE_SEP \
- stw TREG, 0(%sr0,%ret0) ASM_LINE_SEP \
- /* return -1 */ ASM_LINE_SEP \
- ldi -1, %ret0 ASM_LINE_SEP \
-L(pre_end): ASM_LINE_SEP \
- /* No need to LOAD_PIC */ ASM_LINE_SEP \
- /* Undo frame */ ASM_LINE_SEP \
- ldwm -64(%sp),TREG ASM_LINE_SEP \
- .cfi_adjust_cfa_offset -64 ASM_LINE_SEP \
- /* Restore rp before exit */ ASM_LINE_SEP \
- ldw -20(%sp), %rp ASM_LINE_SEP \
- .cfi_restore 2 ASM_LINE_SEP
-
-/* Save arguments into our frame */
-# define PUSHARGS_0 /* nothing to do */
-# define PUSHARGS_1 PUSHARGS_0 stw %r26, -36(%sr0,%sp) ASM_LINE_SEP \
- .cfi_offset 26, -36 ASM_LINE_SEP
-# define PUSHARGS_2 PUSHARGS_1 stw %r25, -40(%sr0,%sp) ASM_LINE_SEP \
- .cfi_offset 25, -40 ASM_LINE_SEP
-# define PUSHARGS_3 PUSHARGS_2 stw %r24, -44(%sr0,%sp) ASM_LINE_SEP \
- .cfi_offset 24, -44 ASM_LINE_SEP
-# define PUSHARGS_4 PUSHARGS_3 stw %r23, -48(%sr0,%sp) ASM_LINE_SEP \
- .cfi_offset 23, -48 ASM_LINE_SEP
-# define PUSHARGS_5 PUSHARGS_4 stw %r22, -52(%sr0,%sp) ASM_LINE_SEP \
- .cfi_offset 22, -52 ASM_LINE_SEP
-# define PUSHARGS_6 PUSHARGS_5 stw %r21, -56(%sr0,%sp) ASM_LINE_SEP \
- .cfi_offset 21, -56 ASM_LINE_SEP
-
-/* Bring them back from the stack */
-# define POPARGS_0 /* nothing to do */
-# define POPARGS_1 POPARGS_0 ldw -36(%sr0,%sp), %r26 ASM_LINE_SEP \
- .cfi_restore 26 ASM_LINE_SEP
-# define POPARGS_2 POPARGS_1 ldw -40(%sr0,%sp), %r25 ASM_LINE_SEP \
- .cfi_restore 25 ASM_LINE_SEP
-# define POPARGS_3 POPARGS_2 ldw -44(%sr0,%sp), %r24 ASM_LINE_SEP \
- .cfi_restore 24 ASM_LINE_SEP
-# define POPARGS_4 POPARGS_3 ldw -48(%sr0,%sp), %r23 ASM_LINE_SEP \
- .cfi_restore 23 ASM_LINE_SEP
-# define POPARGS_5 POPARGS_4 ldw -52(%sr0,%sp), %r22 ASM_LINE_SEP \
- .cfi_restore 22 ASM_LINE_SEP
-# define POPARGS_6 POPARGS_5 ldw -56(%sr0,%sp), %r21 ASM_LINE_SEP \
- .cfi_restore 21 ASM_LINE_SEP
-
-# if IS_IN (libpthread)
-# ifdef PIC
-# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \
- bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP
-# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \
- bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP
-# else
-# define CENABLE .import __pthread_enable_asynccancel,code ASM_LINE_SEP \
- bl __pthread_enable_asynccancel,%r2 ASM_LINE_SEP
-# define CDISABLE .import __pthread_disable_asynccancel,code ASM_LINE_SEP \
- bl __pthread_disable_asynccancel,%r2 ASM_LINE_SEP
-# endif
-# elif IS_IN (libc)
-# ifdef PIC
-# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \
- bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP
-# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \
- bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP
-# else
-# define CENABLE .import __libc_enable_asynccancel,code ASM_LINE_SEP \
- bl __libc_enable_asynccancel,%r2 ASM_LINE_SEP
-# define CDISABLE .import __libc_disable_asynccancel,code ASM_LINE_SEP \
- bl __libc_disable_asynccancel,%r2 ASM_LINE_SEP
-# endif
-# elif IS_IN (librt)
-# ifdef PIC
-# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \
- bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP
-# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \
- bl __librt_disable_asynccancel,%r2 ASM_LINE_SEP
-# else
-# define CENABLE .import __librt_enable_asynccancel,code ASM_LINE_SEP \
- bl __librt_enable_asynccancel,%r2 ASM_LINE_SEP
-# define CDISABLE .import __librt_disable_asynccancel,code ASM_LINE_SEP \
- bl __librt_disable_asynccancel,%r2 ASM_LINE_SEP
-# endif
-# else
-# error Unsupported library
-# endif
-
# if IS_IN (libpthread)
# define __local_multiple_threads __pthread_multiple_threads
# elif IS_IN (libc)
@@ -253,17 +33,11 @@ L(pre_end): ASM_LINE_SEP \
# error Unsupported library
# endif
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-# else
-/* Read the value of header.multiple_threads from the thread pointer */
-# define SINGLE_THREAD_P \
- mfctl %cr27, %ret0 ASM_LINE_SEP \
- ldw MULTIPLE_THREADS_THREAD_OFFSET(%sr0,%ret0),%ret0 ASM_LINE_SEP
-# endif
-#elif !defined __ASSEMBLER__
+
+#else
/* This code should never be used but we define it anyhow. */
# define SINGLE_THREAD_P (1)
@@ -272,8 +46,6 @@ L(pre_end): ASM_LINE_SEP \
#endif
/* IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt) */
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h b/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
index ebf6019..34e2b6f 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h
@@ -24,130 +24,17 @@
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
- ENTRY (name) \
- cmpl $0, %gs:MULTIPLE_THREADS_OFFSET; \
- jne L(pseudo_cancel); \
- .type __##syscall_name##_nocancel,@function; \
- .globl __##syscall_name##_nocancel; \
- __##syscall_name##_nocancel: \
- DO_CALL (syscall_name, args); \
- cmpl $-4095, %eax; \
- jae SYSCALL_ERROR_LABEL; \
- ret; \
- .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
- L(pseudo_cancel): \
- CENABLE \
- SAVE_OLDTYPE_##args \
- PUSHCARGS_##args \
- DOCARGS_##args \
- movl $SYS_ify (syscall_name), %eax; \
- ENTER_KERNEL; \
- POPCARGS_##args; \
- POPSTATE_##args \
- cmpl $-4095, %eax; \
- jae SYSCALL_ERROR_LABEL
-
-# define SAVE_OLDTYPE_0 movl %eax, %ecx;
-# define SAVE_OLDTYPE_1 SAVE_OLDTYPE_0
-# define SAVE_OLDTYPE_2 pushl %eax; cfi_adjust_cfa_offset (4);
-# define SAVE_OLDTYPE_3 SAVE_OLDTYPE_2
-# define SAVE_OLDTYPE_4 SAVE_OLDTYPE_2
-# define SAVE_OLDTYPE_5 SAVE_OLDTYPE_2
-# define SAVE_OLDTYPE_6 SAVE_OLDTYPE_2
-
-# define PUSHCARGS_0 /* No arguments to push. */
-# define DOCARGS_0 /* No arguments to frob. */
-# define POPCARGS_0 /* No arguments to pop. */
-# define _PUSHCARGS_0 /* No arguments to push. */
-# define _POPCARGS_0 /* No arguments to pop. */
-
-# define PUSHCARGS_1 movl %ebx, %edx; cfi_register (ebx, edx); PUSHCARGS_0
-# define DOCARGS_1 _DOARGS_1 (4)
-# define POPCARGS_1 POPCARGS_0; movl %edx, %ebx; cfi_restore (ebx);
-# define _PUSHCARGS_1 pushl %ebx; cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (ebx, 0); _PUSHCARGS_0
-# define _POPCARGS_1 _POPCARGS_0; popl %ebx; \
- cfi_adjust_cfa_offset (-4); cfi_restore (ebx);
-
-# define PUSHCARGS_2 PUSHCARGS_1
-# define DOCARGS_2 _DOARGS_2 (12)
-# define POPCARGS_2 POPCARGS_1
-# define _PUSHCARGS_2 _PUSHCARGS_1
-# define _POPCARGS_2 _POPCARGS_1
-
-# define PUSHCARGS_3 _PUSHCARGS_2
-# define DOCARGS_3 _DOARGS_3 (20)
-# define POPCARGS_3 _POPCARGS_3
-# define _PUSHCARGS_3 _PUSHCARGS_2
-# define _POPCARGS_3 _POPCARGS_2
-
-# define PUSHCARGS_4 _PUSHCARGS_4
-# define DOCARGS_4 _DOARGS_4 (28)
-# define POPCARGS_4 _POPCARGS_4
-# define _PUSHCARGS_4 pushl %esi; cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (esi, 0); _PUSHCARGS_3
-# define _POPCARGS_4 _POPCARGS_3; popl %esi; \
- cfi_adjust_cfa_offset (-4); cfi_restore (esi);
-
-# define PUSHCARGS_5 _PUSHCARGS_5
-# define DOCARGS_5 _DOARGS_5 (36)
-# define POPCARGS_5 _POPCARGS_5
-# define _PUSHCARGS_5 pushl %edi; cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (edi, 0); _PUSHCARGS_4
-# define _POPCARGS_5 _POPCARGS_4; popl %edi; \
- cfi_adjust_cfa_offset (-4); cfi_restore (edi);
-
-# define PUSHCARGS_6 _PUSHCARGS_6
-# define DOCARGS_6 _DOARGS_6 (44)
-# define POPCARGS_6 _POPCARGS_6
-# define _PUSHCARGS_6 pushl %ebp; cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (ebp, 0); _PUSHCARGS_5
-# define _POPCARGS_6 _POPCARGS_5; popl %ebp; \
- cfi_adjust_cfa_offset (-4); cfi_restore (ebp);
-
-# if IS_IN (libpthread)
-# define CENABLE call __pthread_enable_asynccancel;
-# define CDISABLE call __pthread_disable_asynccancel
-# elif IS_IN (libc)
-# define CENABLE call __libc_enable_asynccancel;
-# define CDISABLE call __libc_disable_asynccancel
-# elif IS_IN (librt)
-# define CENABLE call __librt_enable_asynccancel;
-# define CDISABLE call __librt_disable_asynccancel
-# else
-# error Unsupported library
-# endif
-# define POPSTATE_0 \
- pushl %eax; cfi_adjust_cfa_offset (4); movl %ecx, %eax; \
- CDISABLE; popl %eax; cfi_adjust_cfa_offset (-4);
-# define POPSTATE_1 POPSTATE_0
-# define POPSTATE_2 xchgl (%esp), %eax; CDISABLE; popl %eax; \
- cfi_adjust_cfa_offset (-4);
-# define POPSTATE_3 POPSTATE_2
-# define POPSTATE_4 POPSTATE_3
-# define POPSTATE_5 POPSTATE_4
-# define POPSTATE_6 POPSTATE_5
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P cmpl $0, %gs:MULTIPLE_THREADS_OFFSET
-# endif
-#elif !defined __ASSEMBLER__
+#else
# define SINGLE_THREAD_P (1)
# define NO_CANCELLATION 1
#endif
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
index 7c7f619..96d04de 100644
--- a/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h
@@ -23,201 +23,13 @@
#endif
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-
-# undef PSEUDO
-
-# if IS_IN (libc)
-# define SYSDEP_CANCEL_ERRNO __libc_errno
-# else
-# define SYSDEP_CANCEL_ERRNO errno
-# endif
-# define SYSDEP_CANCEL_ERROR(args) \
-.section .gnu.linkonce.t.__syscall_error_##args, "ax"; \
- .align 32; \
- .proc __syscall_error_##args; \
- .global __syscall_error_##args; \
- .hidden __syscall_error_##args; \
- .size __syscall_error_##args, 64; \
-__syscall_error_##args: \
- .prologue; \
- .regstk args, 5, args, 0; \
- .save ar.pfs, loc0; \
- .save rp, loc1; \
- .body; \
- addl loc4 = @ltoff(@tprel(SYSDEP_CANCEL_ERRNO)), gp;; \
- ld8 loc4 = [loc4]; \
- mov rp = loc1;; \
- mov r8 = -1; \
- add loc4 = loc4, r13;; \
- st4 [loc4] = loc3; \
- mov ar.pfs = loc0
-
-# ifndef USE_DL_SYSINFO
-
-# define PSEUDO(name, syscall_name, args) \
-.text; \
-ENTRY (name) \
- adds r14 = MULTIPLE_THREADS_OFFSET, r13;; \
- ld4 r14 = [r14]; \
- mov r15 = SYS_ify(syscall_name);; \
- cmp4.ne p6, p7 = 0, r14; \
-(p6) br.cond.spnt .Lpseudo_cancel;; \
- break __BREAK_SYSCALL;; \
- cmp.eq p6,p0=-1,r10; \
-(p6) br.cond.spnt.few __syscall_error; \
- ret;; \
- .endp name; \
- .proc __GC_##name; \
- .globl __GC_##name; \
- .hidden __GC_##name; \
-__GC_##name: \
-.Lpseudo_cancel: \
- .prologue; \
- .regstk args, 5, args, 0; \
- .save ar.pfs, loc0; \
- alloc loc0 = ar.pfs, args, 5, args, 0; \
- .save rp, loc1; \
- mov loc1 = rp;; \
- .body; \
- CENABLE;; \
- mov loc2 = r8; \
- COPY_ARGS_##args \
- mov r15 = SYS_ify(syscall_name); \
- break __BREAK_SYSCALL;; \
- mov loc3 = r8; \
- mov loc4 = r10; \
- mov out0 = loc2; \
- CDISABLE;; \
- cmp.eq p6,p0=-1,loc4; \
-(p6) br.cond.spnt.few __syscall_error_##args; \
- mov r8 = loc3; \
- mov rp = loc1; \
- mov ar.pfs = loc0; \
-.Lpseudo_end: \
- ret; \
- .endp __GC_##name; \
- SYSDEP_CANCEL_ERROR(args)
-
-# else /* USE_DL_SYSINFO */
-
-# define PSEUDO(name, syscall_name, args) \
-.text; \
-ENTRY (name) \
- .prologue; \
- adds r2 = SYSINFO_OFFSET, r13; \
- adds r14 = MULTIPLE_THREADS_OFFSET, r13; \
- .save ar.pfs, r11; \
- mov r11 = ar.pfs;; \
- .body; \
- ld4 r14 = [r14]; \
- ld8 r2 = [r2]; \
- mov r15 = SYS_ify(syscall_name);; \
- cmp4.ne p6, p7 = 0, r14; \
- mov b7 = r2; \
-(p6) br.cond.spnt .Lpseudo_cancel; \
- br.call.sptk.many b6 = b7;; \
- mov ar.pfs = r11; \
- cmp.eq p6,p0 = -1, r10; \
-(p6) br.cond.spnt.few __syscall_error; \
- ret;; \
- .endp name; \
- \
- .proc __##syscall_name##_nocancel; \
- .globl __##syscall_name##_nocancel; \
-__##syscall_name##_nocancel: \
- .prologue; \
- adds r2 = SYSINFO_OFFSET, r13; \
- .save ar.pfs, r11; \
- mov r11 = ar.pfs;; \
- .body; \
- ld8 r2 = [r2]; \
- mov r15 = SYS_ify(syscall_name);; \
- mov b7 = r2; \
- br.call.sptk.many b6 = b7;; \
- mov ar.pfs = r11; \
- cmp.eq p6,p0 = -1, r10; \
-(p6) br.cond.spnt.few __syscall_error; \
- ret;; \
- .endp __##syscall_name##_nocancel; \
- \
- .proc __GC_##name; \
- .globl __GC_##name; \
- .hidden __GC_##name; \
-__GC_##name: \
-.Lpseudo_cancel: \
- .prologue; \
- .regstk args, 5, args, 0; \
- .save ar.pfs, loc0; \
- alloc loc0 = ar.pfs, args, 5, args, 0; \
- adds loc4 = SYSINFO_OFFSET, r13; \
- .save rp, loc1; \
- mov loc1 = rp;; \
- .body; \
- ld8 loc4 = [loc4]; \
- CENABLE;; \
- mov loc2 = r8; \
- mov b7 = loc4; \
- COPY_ARGS_##args \
- mov r15 = SYS_ify(syscall_name); \
- br.call.sptk.many b6 = b7;; \
- mov loc3 = r8; \
- mov loc4 = r10; \
- mov out0 = loc2; \
- CDISABLE;; \
- cmp.eq p6,p0=-1,loc4; \
-(p6) br.cond.spnt.few __syscall_error_##args; \
- mov r8 = loc3; \
- mov rp = loc1; \
- mov ar.pfs = loc0; \
-.Lpseudo_end: \
- ret; \
- .endp __GC_##name; \
- SYSDEP_CANCEL_ERROR(args)
-
-# endif /* USE_DL_SYSINFO */
-
-# undef PSEUDO_END
-# define PSEUDO_END(name) .endp
-
-# if IS_IN (libpthread)
-# define CENABLE br.call.sptk.many b0 = __pthread_enable_asynccancel
-# define CDISABLE br.call.sptk.many b0 = __pthread_disable_asynccancel
-# elif IS_IN (libc)
-# define CENABLE br.call.sptk.many b0 = __libc_enable_asynccancel
-# define CDISABLE br.call.sptk.many b0 = __libc_disable_asynccancel
-# elif IS_IN (librt)
-# define CENABLE br.call.sptk.many b0 = __librt_enable_asynccancel
-# define CDISABLE br.call.sptk.many b0 = __librt_disable_asynccancel
-# else
-# error Unsupported library
-# endif
-
-# define COPY_ARGS_0 /* Nothing */
-# define COPY_ARGS_1 COPY_ARGS_0 mov out0 = in0;
-# define COPY_ARGS_2 COPY_ARGS_1 mov out1 = in1;
-# define COPY_ARGS_3 COPY_ARGS_2 mov out2 = in2;
-# define COPY_ARGS_4 COPY_ARGS_3 mov out3 = in3;
-# define COPY_ARGS_5 COPY_ARGS_4 mov out4 = in4;
-# define COPY_ARGS_6 COPY_ARGS_5 mov out5 = in5;
-# define COPY_ARGS_7 COPY_ARGS_6 mov out6 = in6;
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P \
- adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14
-# endif
-
-#elif !defined __ASSEMBLER__
-
+#else
# define SINGLE_THREAD_P (1)
# define NO_CANCELLATION 1
-
#endif
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h b/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h
index 9bc9e13..1603c5f 100644
--- a/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h
@@ -18,121 +18,21 @@
#include <sysdep.h>
#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <nptl/pthreadP.h>
-#endif
+#include <nptl/pthreadP.h>
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
- ENTRY (name) \
- SINGLE_THREAD_P; \
- jne .Lpseudo_cancel; \
- .type __##syscall_name##_nocancel,@function; \
- .globl __##syscall_name##_nocancel; \
- __##syscall_name##_nocancel: \
- DO_CALL (syscall_name, args); \
- cmp.l &-4095, %d0; \
- jcc SYSCALL_ERROR_LABEL; \
- rts; \
- .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
- .Lpseudo_cancel: \
- CENABLE; \
- DOCARGS_##args \
- move.l %d0, -(%sp); /* Save result of CENABLE. */ \
- cfi_adjust_cfa_offset (4); \
- move.l &SYS_ify (syscall_name), %d0; \
- trap &0; \
- move.l %d0, %d2; \
- CDISABLE; \
- addq.l &4, %sp; /* Remove result of CENABLE from the stack. */ \
- cfi_adjust_cfa_offset (-4); \
- move.l %d2, %d0; \
- UNDOCARGS_##args \
- cmp.l &-4095, %d0; \
- jcc SYSCALL_ERROR_LABEL
-
-/* Note: we use D2 to save syscall's return value as D0 will be clobbered in
- CDISABLE. */
-# define DOCARGS_0 move.l %d2, -(%sp); \
- cfi_adjust_cfa_offset (4); cfi_rel_offset (%d2, 0);
-# define UNDOCARGS_0 move.l (%sp)+, %d2; \
- cfi_adjust_cfa_offset (-4); cfi_restore (%d2);
-
-# define DOCARGS_1 _DOCARGS_1 (4); DOCARGS_0
-# define _DOCARGS_1(n) move.l n(%sp), %d1;
-# define UNDOCARGS_1 UNDOCARGS_0
-
-# define DOCARGS_2 _DOCARGS_2 (8)
-# define _DOCARGS_2(n) DOCARGS_0 move.l n+4(%sp), %d2; _DOCARGS_1 (n)
-# define UNDOCARGS_2 UNDOCARGS_0
-
-# define DOCARGS_3 _DOCARGS_3 (12)
-# define _DOCARGS_3(n) move.l %d3, -(%sp); \
- cfi_adjust_cfa_offset (4); cfi_rel_offset (%d3, 0); \
- move.l n+4(%sp), %d3; _DOCARGS_2 (n)
-# define UNDOCARGS_3 UNDOCARGS_2 move.l (%sp)+, %d3; \
- cfi_adjust_cfa_offset (-4); cfi_restore (%d3);
-
-# define DOCARGS_4 _DOCARGS_4 (16)
-# define _DOCARGS_4(n) move.l %d4, -(%sp); \
- cfi_adjust_cfa_offset (4); cfi_rel_offset (%d4, 0); \
- move.l n+4(%sp), %d4; _DOCARGS_3 (n)
-# define UNDOCARGS_4 UNDOCARGS_3 move.l (%sp)+, %d4; \
- cfi_adjust_cfa_offset (-4); cfi_restore (%d4);
-
-# define DOCARGS_5 _DOCARGS_5 (20)
-# define _DOCARGS_5(n) move.l %d5, -(%sp); \
- cfi_adjust_cfa_offset (4); cfi_rel_offset (%d5, 0); \
- move.l n+4(%sp), %d5; _DOCARGS_4 (n)
-# define UNDOCARGS_5 UNDOCARGS_4 move.l (%sp)+, %d5; \
- cfi_adjust_cfa_offset (-4); cfi_restore (%d5);
-
-# define DOCARGS_6 _DOCARGS_6 (24)
-# define _DOCARGS_6(n) move.l n(%sp), %a0; _DOCARGS_5 (n-4)
-# define UNDOCARGS_6 UNDOCARGS_5
-
-# ifdef PIC
-# define PSEUDO_JMP(sym) jbsr sym ## @PLTPC
-# else
-# define PSEUDO_JMP(sym) jbsr sym
-# endif
-
-# if IS_IN (libpthread)
-# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel)
-# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel)
-# elif IS_IN (libc)
-# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel)
-# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel)
-# elif IS_IN (librt)
-# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel)
-# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel)
-# else
-# error Unsupported library
-# endif
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P \
- PSEUDO_JMP (__m68k_read_tp); \
- tst.l MULTIPLE_THREADS_OFFSET(%a0)
-# endif
-
-#elif !defined __ASSEMBLER__
+#else
# define SINGLE_THREAD_P (1)
# define NO_CANCELLATION (1)
#endif
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, \
1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h b/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h
index dbcc2b2..7fe030b 100644
--- a/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h
@@ -23,136 +23,28 @@
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-# if !IS_IN (librt) || !defined(PIC)
-# define AC_STACK_SIZE 16 /* space for r15, async_cancel arg and 2 temp words */
-# define AC_SET_GOT /* empty */
-# define AC_RESTORE_GOT /* empty */
-# else
-# define AC_STACK_SIZE 20 /* extra 4 bytes for r20 */
-# define AC_SET_GOT \
- swi r20, r1, AC_STACK_SIZE-4; \
- mfs r20, rpc; \
- addik r20, r20, _GLOBAL_OFFSET_TABLE_+8;
-# define AC_RESTORE_GOT \
- lwi r20, r1, AC_STACK_SIZE-4;
-# endif
-
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
- ENTRY (name) \
- SINGLE_THREAD_P(r12); \
- bnei r12, L(pseudo_cancel); \
- .globl __##syscall_name##_nocancel; \
- .type __##syscall_name##_nocancel,@function; \
-__##syscall_name##_nocancel: \
- DO_CALL (syscall_name, args); \
- addik r4, r0, -4095; \
- cmpu r4, r4, r3; \
- bgei r4, SYSCALL_ERROR_LABEL; \
- rtsd r15, 8; \
- nop; \
- .size __##syscall_name##_nocancel, .-__##syscall_name##_nocancel; \
-L(pseudo_cancel): \
- addik r1, r1, -AC_STACK_SIZE; \
- swi r15, r1, 0; \
- AC_SET_GOT \
- DOCARGS_##args \
- CENABLE; \
- swi r3, r1, 8; \
- UNDOCARGS_##args \
- DO_CALL (syscall_name, args); \
- swi r3, r1, 12; \
- lwi r5, r1, 8; \
- CDISABLE; \
- lwi r3, r1, 12; \
- lwi r15, r1, 0; \
- AC_RESTORE_GOT \
- addik r1, r1, AC_STACK_SIZE; \
- addik r4, r0, -4095; \
- cmpu r4, r4, r3; \
- bgei r4, SYSCALL_ERROR_LABEL; \
- rtsd r15, 8; \
- nop;
-
-/*
- * Macros to save/restore syscall arguments across CENABLE
- * The arguments are saved into the caller's stack (original r1 + 4)
- */
-
-# define DOCARGS_0
-# define DOCARGS_1 swi r5, r1, AC_STACK_SIZE + 4;
-# define DOCARGS_2 swi r6, r1, AC_STACK_SIZE + 8; DOCARGS_1
-# define DOCARGS_3 swi r7, r1, AC_STACK_SIZE + 12; DOCARGS_2
-# define DOCARGS_4 swi r8, r1, AC_STACK_SIZE + 16; DOCARGS_3
-# define DOCARGS_5 swi r9, r1, AC_STACK_SIZE + 20; DOCARGS_4
-# define DOCARGS_6 swi r10, r1, AC_STACK_SIZE + 24; DOCARGS_5
-
-# define UNDOCARGS_0
-# define UNDOCARGS_1 lwi r5, r1, AC_STACK_SIZE + 4;
-# define UNDOCARGS_2 UNDOCARGS_1 lwi r6, r1, AC_STACK_SIZE + 8;
-# define UNDOCARGS_3 UNDOCARGS_2 lwi r7, r1, AC_STACK_SIZE + 12;
-# define UNDOCARGS_4 UNDOCARGS_3 lwi r8, r1, AC_STACK_SIZE + 16;
-# define UNDOCARGS_5 UNDOCARGS_4 lwi r9, r1, AC_STACK_SIZE + 20;
-# define UNDOCARGS_6 UNDOCARGS_5 lwi r10, r1, AC_STACK_SIZE + 24;
-
-# ifdef PIC
-# define PSEUDO_JMP(sym) brlid r15, sym##@PLTPC; addk r0, r0, r0
-# else
-# define PSEUDO_JMP(sym) brlid r15, sym; addk r0, r0, r0
-# endif
-
# if IS_IN (libpthread)
-# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel)
-# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel)
# define __local_multiple_threads __pthread_multiple_threads
# elif IS_IN (libc)
-# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel)
-# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel)
# define __local_multiple_threads __libc_multiple_threads
-# elif IS_IN (librt)
-# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel)
-# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel)
-# else
-# error Unsupported library
# endif
-
# if IS_IN (libpthread) || IS_IN (libc)
-# ifndef __ASSEMBLER__
extern int __local_multiple_threads attribute_hidden;
-# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
-# else
-# if !defined PIC
-# define SINGLE_THREAD_P(reg) lwi reg, r0, __local_multiple_threads;
-# else
-# define SINGLE_THREAD_P(reg) \
- mfs reg, rpc; \
- addik reg, reg, _GLOBAL_OFFSET_TABLE_+8; \
- lwi reg, reg, __local_multiple_threads@GOT; \
- lwi reg, reg, 0;
-# endif
-# endif
+# define SINGLE_THREAD_P __builtin_expect (__local_multiple_threads == 0, 1)
# else
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P(reg) \
- lwi reg, r0, MULTIPLE_THREADS_OFFSET(reg)
-# endif
# endif
-#elif !defined __ASSEMBLER__
+#else
# define SINGLE_THREAD_P (1)
# define NO_CANCELLATION (1)
#endif
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
deleted file mode 100644
index 0ed3e3d..0000000
--- a/sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
+++ /dev/null
@@ -1,249 +0,0 @@
-/* Copyright (C) 2003-2017 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library. If not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#include <sysdeps/generic/sysdep.h>
-#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <nptl/pthreadP.h>
-#endif
-#include <sys/asm.h>
-
-/* Gas will put the initial save of $gp into the CIE, because it appears to
- happen before any instructions. So we use cfi_same_value instead of
- cfi_restore. */
-
-#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-
-#ifdef __PIC__
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .align 2; \
- L(pseudo_start): \
- cfi_startproc; \
- cfi_adjust_cfa_offset (STKSPACE); \
- cfi_rel_offset (gp, STKOFF_GP); \
- 99: PTR_LA t9,__syscall_error; \
- /* manual cpreturn */ \
- REG_L gp, STKOFF_GP(sp); \
- cfi_same_value (gp); \
- RESTORESTK; \
- jr t9; \
- .type __##syscall_name##_nocancel, @function; \
- .globl __##syscall_name##_nocancel; \
- __##syscall_name##_nocancel: \
- SAVESTK; \
- .cpsetup t9, STKOFF_GP, __##syscall_name##_nocancel; \
- cfi_rel_offset (gp, STKOFF_GP); \
- li v0, SYS_ify(syscall_name); \
- syscall; \
- bne a3, zero, SYSCALL_ERROR_LABEL; \
- /* manual cpreturn */ \
- REG_L gp, STKOFF_GP(sp); \
- cfi_same_value (gp); \
- RESTORESTK; \
- ret; \
- cfi_endproc; \
- .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
- ENTRY (name) \
- SAVESTK; \
- .cpsetup t9, STKOFF_GP, name; \
- cfi_rel_offset (gp, STKOFF_GP); \
- SINGLE_THREAD_P(v1); \
- bne zero, v1, L(pseudo_cancel); \
- .set noreorder; \
- li v0, SYS_ify(syscall_name); \
- syscall; \
- .set reorder; \
- bne a3, zero, SYSCALL_ERROR_LABEL; \
- /* manual cpreturn */ \
- REG_L gp, STKOFF_GP(sp); \
- cfi_same_value (gp); \
- RESTORESTK; \
- ret; \
- L(pseudo_cancel): \
- cfi_adjust_cfa_offset (STKSPACE); \
- cfi_rel_offset (gp, STKOFF_GP); \
- REG_S ra, STKOFF_RA(sp); \
- cfi_rel_offset (ra, STKOFF_RA); \
- PUSHARGS_##args; /* save syscall args */ \
- CENABLE; \
- REG_S v0, STKOFF_SVMSK(sp); /* save mask */ \
- POPARGS_##args; /* restore syscall args */ \
- .set noreorder; \
- li v0, SYS_ify (syscall_name); \
- syscall; \
- .set reorder; \
- REG_S v0, STKOFF_SC_V0(sp); /* save syscall result */ \
- REG_S a3, STKOFF_SC_ERR(sp); /* save syscall error flag */ \
- REG_L a0, STKOFF_SVMSK(sp); /* pass mask as arg1 */ \
- CDISABLE; \
- REG_L a3, STKOFF_SC_ERR(sp); /* restore syscall error flag */ \
- REG_L ra, STKOFF_RA(sp); /* restore return address */ \
- REG_L v0, STKOFF_SC_V0(sp); /* restore syscall result */ \
- bne a3, zero, SYSCALL_ERROR_LABEL; \
- /* manual cpreturn */ \
- REG_L gp, STKOFF_GP(sp); \
- cfi_same_value (gp); \
- RESTORESTK; \
- L(pseudo_end):
-#else
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .align 2; \
- L(pseudo_start): \
- cfi_startproc; \
- cfi_adjust_cfa_offset (STKSPACE); \
- 99: RESTORESTK; \
- j __syscall_error; \
- .type __##syscall_name##_nocancel, @function; \
- .globl __##syscall_name##_nocancel; \
- __##syscall_name##_nocancel: \
- SAVESTK; \
- li v0, SYS_ify(syscall_name); \
- syscall; \
- bne a3, zero, SYSCALL_ERROR_LABEL; \
- RESTORESTK; \
- ret; \
- cfi_endproc; \
- .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
- ENTRY (name) \
- SAVESTK; \
- SINGLE_THREAD_P(v1); \
- bne zero, v1, L(pseudo_cancel); \
- .set noreorder; \
- li v0, SYS_ify(syscall_name); \
- syscall; \
- .set reorder; \
- bne a3, zero, SYSCALL_ERROR_LABEL; \
- RESTORESTK; \
- ret; \
- L(pseudo_cancel): \
- cfi_adjust_cfa_offset (STKSPACE); \
- REG_S ra, STKOFF_RA(sp); \
- cfi_rel_offset (ra, STKOFF_RA); \
- PUSHARGS_##args; /* save syscall args */ \
- CENABLE; \
- REG_S v0, STKOFF_SVMSK(sp); /* save mask */ \
- POPARGS_##args; /* restore syscall args */ \
- .set noreorder; \
- li v0, SYS_ify (syscall_name); \
- syscall; \
- .set reorder; \
- REG_S v0, STKOFF_SC_V0(sp); /* save syscall result */ \
- REG_S a3, STKOFF_SC_ERR(sp); /* save syscall error flag */ \
- REG_L a0, STKOFF_SVMSK(sp); /* pass mask as arg1 */ \
- CDISABLE; \
- REG_L a3, STKOFF_SC_ERR(sp); /* restore syscall error flag */ \
- REG_L ra, STKOFF_RA(sp); /* restore return address */ \
- REG_L v0, STKOFF_SC_V0(sp); /* restore syscall result */ \
- bne a3, zero, SYSCALL_ERROR_LABEL; \
- RESTORESTK; \
- L(pseudo_end):
-#endif
-
-# undef PSEUDO_END
-# define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym
-
-# define PUSHARGS_0 /* nothing to do */
-# define PUSHARGS_1 PUSHARGS_0 REG_S a0, STKOFF_A0(sp); cfi_rel_offset (a0, STKOFF_A0);
-# define PUSHARGS_2 PUSHARGS_1 REG_S a1, STKOFF_A1(sp); cfi_rel_offset (a1, STKOFF_A1);
-# define PUSHARGS_3 PUSHARGS_2 REG_S a2, STKOFF_A2(sp); cfi_rel_offset (a2, STKOFF_A2);
-# define PUSHARGS_4 PUSHARGS_3 REG_S a3, STKOFF_A3(sp); cfi_rel_offset (a3, STKOFF_A3);
-# define PUSHARGS_5 PUSHARGS_4 REG_S a4, STKOFF_A4(sp); cfi_rel_offset (a3, STKOFF_A4);
-# define PUSHARGS_6 PUSHARGS_5 REG_S a5, STKOFF_A5(sp); cfi_rel_offset (a3, STKOFF_A5);
-
-# define POPARGS_0 /* nothing to do */
-# define POPARGS_1 POPARGS_0 REG_L a0, STKOFF_A0(sp);
-# define POPARGS_2 POPARGS_1 REG_L a1, STKOFF_A1(sp);
-# define POPARGS_3 POPARGS_2 REG_L a2, STKOFF_A2(sp);
-# define POPARGS_4 POPARGS_3 REG_L a3, STKOFF_A3(sp);
-# define POPARGS_5 POPARGS_4 REG_L a4, STKOFF_A4(sp);
-# define POPARGS_6 POPARGS_5 REG_L a5, STKOFF_A5(sp);
-
-/* Save an even number of slots. Should be 0 if an even number of slots
- are used below, or SZREG if an odd number are used. */
-# ifdef __PIC__
-# define STK_PAD SZREG
-# else
-# define STK_PAD 0
-# endif
-
-/* Place values that we are more likely to use later in this sequence, i.e.
- closer to the SP at function entry. If you do that, the are more
- likely to already be in your d-cache. */
-# define STKOFF_A5 (STK_PAD)
-# define STKOFF_A4 (STKOFF_A5 + SZREG)
-# define STKOFF_A3 (STKOFF_A4 + SZREG)
-# define STKOFF_A2 (STKOFF_A3 + SZREG) /* MT and more args. */
-# define STKOFF_A1 (STKOFF_A2 + SZREG) /* MT and 2 args. */
-# define STKOFF_A0 (STKOFF_A1 + SZREG) /* MT and 1 arg. */
-# define STKOFF_RA (STKOFF_A0 + SZREG) /* Used if MT. */
-# define STKOFF_SC_V0 (STKOFF_RA + SZREG) /* Used if MT. */
-# define STKOFF_SC_ERR (STKOFF_SC_V0 + SZREG) /* Used if MT. */
-# define STKOFF_SVMSK (STKOFF_SC_ERR + SZREG) /* Used if MT. */
-
-# ifdef __PIC__
-# define STKOFF_GP (STKOFF_SVMSK + SZREG) /* Always used. */
-# define STKSPACE (STKOFF_GP + SZREG)
-# else
-# define STKSPACE (STKOFF_SVMSK + SZREG)
-# endif
-
-# define SAVESTK PTR_SUBU sp, STKSPACE; cfi_adjust_cfa_offset(STKSPACE)
-# define RESTORESTK PTR_ADDU sp, STKSPACE; cfi_adjust_cfa_offset(-STKSPACE)
-
-# ifdef __PIC__
-# define PSEUDO_JMP(sym) PTR_LA t9, sym; jalr t9
-# else
-# define PSEUDO_JMP(sym) jal sym
-# endif
-
-# if IS_IN (libpthread)
-# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel)
-# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel)
-# elif IS_IN (librt)
-# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel)
-# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel)
-# else
-# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel)
-# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel)
-# endif
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) \
- == 0, 1)
-# else
-# define SINGLE_THREAD_P(reg) \
- READ_THREAD_POINTER(reg); \
- lw reg, MULTIPLE_THREADS_OFFSET(reg)
-#endif
-
-#elif !defined __ASSEMBLER__
-
-# define SINGLE_THREAD_P 1
-# define NO_CANCELLATION 1
-
-#endif
-
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h b/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
index 0e45f00..fe9a3fc 100644
--- a/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/mips/sysdep-cancel.h
@@ -18,173 +18,22 @@
#include <sysdep.h>
#include <sysdeps/generic/sysdep.h>
#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <nptl/pthreadP.h>
-#endif
+#include <nptl/pthreadP.h>
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-# ifdef __PIC__
-# define PSEUDO_CPLOAD .cpload t9;
-# define PSEUDO_ERRJMP la t9, __syscall_error; jr t9;
-# define PSEUDO_SAVEGP sw gp, 32(sp); cfi_rel_offset (gp, 32);
-# define PSEUDO_LOADGP lw gp, 32(sp);
-# else
-# define PSEUDO_CPLOAD
-# define PSEUDO_ERRJMP j __syscall_error;
-# define PSEUDO_SAVEGP
-# define PSEUDO_LOADGP
-# endif
-
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .align 2; \
- .set nomips16; \
- L(pseudo_start): \
- cfi_startproc; \
- 99: PSEUDO_ERRJMP \
- .type __##syscall_name##_nocancel, @function; \
- .globl __##syscall_name##_nocancel; \
- __##syscall_name##_nocancel: \
- .set noreorder; \
- PSEUDO_CPLOAD \
- li v0, SYS_ify(syscall_name); \
- syscall; \
- .set reorder; \
- bne a3, zero, 99b; \
- ret; \
- cfi_endproc; \
- .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
- ENTRY (name) \
- .set noreorder; \
- PSEUDO_CPLOAD \
- .set reorder; \
- SINGLE_THREAD_P(v1); \
- bne zero, v1, L(pseudo_cancel); \
- .set noreorder; \
- li v0, SYS_ify(syscall_name); \
- syscall; \
- .set reorder; \
- bne a3, zero, 99b; \
- ret; \
- L(pseudo_cancel): \
- SAVESTK_##args; \
- sw ra, 28(sp); \
- cfi_rel_offset (ra, 28); \
- PSEUDO_SAVEGP \
- PUSHARGS_##args; /* save syscall args */ \
- CENABLE; \
- PSEUDO_LOADGP \
- sw v0, 44(sp); /* save mask */ \
- POPARGS_##args; /* restore syscall args */ \
- .set noreorder; \
- li v0, SYS_ify (syscall_name); \
- syscall; \
- .set reorder; \
- sw v0, 36(sp); /* save syscall result */ \
- sw a3, 40(sp); /* save syscall error flag */ \
- lw a0, 44(sp); /* pass mask as arg1 */ \
- CDISABLE; \
- PSEUDO_LOADGP \
- lw v0, 36(sp); /* restore syscall result */ \
- lw a3, 40(sp); /* restore syscall error flag */ \
- lw ra, 28(sp); /* restore return address */ \
- .set noreorder; \
- bne a3, zero, 99b; \
- RESTORESTK; \
- L(pseudo_end): \
- .set reorder;
-
-# undef PSEUDO_END
-# define PSEUDO_END(sym) cfi_endproc; .end sym; .size sym,.-sym
-
-# define PUSHARGS_0 /* nothing to do */
-# define PUSHARGS_1 PUSHARGS_0 sw a0, 0(sp); cfi_rel_offset (a0, 0);
-# define PUSHARGS_2 PUSHARGS_1 sw a1, 4(sp); cfi_rel_offset (a1, 4);
-# define PUSHARGS_3 PUSHARGS_2 sw a2, 8(sp); cfi_rel_offset (a2, 8);
-# define PUSHARGS_4 PUSHARGS_3 sw a3, 12(sp); cfi_rel_offset (a3, 12);
-# define PUSHARGS_5 PUSHARGS_4 /* handled by SAVESTK_## */
-# define PUSHARGS_6 PUSHARGS_5
-# define PUSHARGS_7 PUSHARGS_6
-
-# define POPARGS_0 /* nothing to do */
-# define POPARGS_1 POPARGS_0 lw a0, 0(sp);
-# define POPARGS_2 POPARGS_1 lw a1, 4(sp);
-# define POPARGS_3 POPARGS_2 lw a2, 8(sp);
-# define POPARGS_4 POPARGS_3 lw a3, 12(sp);
-# define POPARGS_5 POPARGS_4 /* args already in new stackframe */
-# define POPARGS_6 POPARGS_5
-# define POPARGS_7 POPARGS_6
-
-
-# define STKSPACE 48
-# define SAVESTK_0 subu sp, STKSPACE; cfi_adjust_cfa_offset(STKSPACE)
-# define SAVESTK_1 SAVESTK_0
-# define SAVESTK_2 SAVESTK_1
-# define SAVESTK_3 SAVESTK_2
-# define SAVESTK_4 SAVESTK_3
-# define SAVESTK_5 lw t0, 16(sp); \
- SAVESTK_0; \
- sw t0, 16(sp)
-
-# define SAVESTK_6 lw t0, 16(sp); \
- lw t1, 20(sp); \
- SAVESTK_0; \
- sw t0, 16(sp); \
- sw t1, 20(sp)
-
-# define SAVESTK_7 lw t0, 16(sp); \
- lw t1, 20(sp); \
- lw t2, 24(sp); \
- SAVESTK_0; \
- sw t0, 16(sp); \
- sw t1, 20(sp); \
- sw t2, 24(sp)
-
-# define RESTORESTK addu sp, STKSPACE; cfi_adjust_cfa_offset(-STKSPACE)
-
-
-# ifdef __PIC__
-/* We use jalr rather than jal. This means that the assembler will not
- automatically restore $gp (in case libc has multiple GOTs) so we must
- do it manually - which we have to do anyway since we don't use .cprestore.
- It also shuts up the assembler warning about not using .cprestore. */
-# define PSEUDO_JMP(sym) la t9, sym; jalr t9;
-# else
-# define PSEUDO_JMP(sym) jal sym;
-# endif
-
-# if IS_IN (libpthread)
-# define CENABLE PSEUDO_JMP (__pthread_enable_asynccancel)
-# define CDISABLE PSEUDO_JMP (__pthread_disable_asynccancel)
-# elif IS_IN (librt)
-# define CENABLE PSEUDO_JMP (__librt_enable_asynccancel)
-# define CDISABLE PSEUDO_JMP (__librt_disable_asynccancel)
-# else
-# define CENABLE PSEUDO_JMP (__libc_enable_asynccancel)
-# define CDISABLE PSEUDO_JMP (__libc_disable_asynccancel)
-# endif
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) \
== 0, 1)
-# else
-# define SINGLE_THREAD_P(reg) \
- READ_THREAD_POINTER(reg); \
- lw reg, MULTIPLE_THREADS_OFFSET(reg)
-#endif
-#elif !defined __ASSEMBLER__
+#else
# define SINGLE_THREAD_P 1
# define NO_CANCELLATION 1
#endif
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h b/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h
index 47b92d9..7647363 100644
--- a/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h
@@ -18,124 +18,22 @@
#include <sysdep.h>
#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <nptl/pthreadP.h>
-#endif
+#include <nptl/pthreadP.h>
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .type __##syscall_name##_nocancel, @function; \
- .globl __##syscall_name##_nocancel; \
- __##syscall_name##_nocancel: \
- cfi_startproc; \
- DO_CALL (syscall_name, args); \
- bne r7, zero, SYSCALL_ERROR_LABEL; \
- ret; \
- cfi_endproc; \
- .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
- ENTRY (name) \
- SINGLE_THREAD_P(r2); \
- bne r2, zero, pseudo_cancel; \
- DO_CALL (syscall_name, args); \
- bne r7, zero, SYSCALL_ERROR_LABEL; \
- ret; \
- pseudo_cancel: \
- SAVESTK_##args; /* save syscall args and adjust stack */ \
- SAVEREG(ra, 0); /* save return address */ \
- SAVEREG(r22, 4); /* save GOT pointer */ \
- nextpc r22; \
-1: movhi r2, %hiadj(_gp_got - 1b); \
- addi r2, r2, %lo(_gp_got - 1b); \
- add r22, r22, r2; \
- CENABLE; \
- callr r3; \
- stw r2, 8(sp); /* save mask */ \
- LOADARGS_##args; \
- movi r2, SYS_ify(syscall_name); \
- trap; \
- stw r2, 12(sp); /* save syscall result */ \
- stw r7, 16(sp); /* save syscall error flag */ \
- ldw r4, 8(sp); /* pass mask as argument 1 */ \
- CDISABLE; \
- callr r3; \
- ldw r7, 16(sp); /* restore syscall error flag */ \
- ldw r2, 12(sp); /* restore syscall result */ \
- ldw ra, 0(sp); /* restore return address */ \
- ldw r22, 4(sp); /* restore GOT pointer */ \
- RESTORESTK_##args; \
- bne r7, zero, SYSCALL_ERROR_LABEL;
-
-
-# undef PSEUDO_END
-# define PSEUDO_END(sym) \
- SYSCALL_ERROR_HANDLER \
- END (sym)
-
-#define SAVEREG(REG, LOC) stw REG, LOC(sp); cfi_rel_offset (REG, LOC)
-#define SAVESTK(X) subi sp, sp, X; cfi_adjust_cfa_offset(X)
-#define SAVESTK_0 SAVESTK(20)
-#define SAVEARG_1 SAVEREG(r4, 20)
-#define SAVESTK_1 SAVESTK(24); SAVEARG_1
-#define SAVEARG_2 SAVEREG(r5, 24); SAVEARG_1
-#define SAVESTK_2 SAVESTK(28); SAVEARG_2
-#define SAVEARG_3 SAVEREG(r6, 28); SAVEARG_2
-#define SAVESTK_3 SAVESTK(32); SAVEARG_3
-#define SAVEARG_4 SAVEREG(r7, 32); SAVEARG_3
-#define SAVESTK_4 SAVESTK(36); SAVEARG_4
-#define SAVESTK_5 SAVESTK_4
-#define SAVESTK_6 SAVESTK_5
-
-#define LOADARGS_0
-#define LOADARGS_1 ldw r4, 20(sp)
-#define LOADARGS_2 LOADARGS_1; ldw r5, 24(sp)
-#define LOADARGS_3 LOADARGS_2; ldw r6, 28(sp)
-#define LOADARGS_4 LOADARGS_3; ldw r7, 32(sp)
-#define LOADARGS_5 LOADARGS_4; ldw r8, 36(sp)
-#define LOADARGS_6 LOADARGS_5; ldw r9, 40(sp)
-
-#define RESTORESTK(X) addi sp, sp, X; cfi_adjust_cfa_offset(-X)
-#define RESTORESTK_0 RESTORESTK(20)
-#define RESTORESTK_1 RESTORESTK(24)
-#define RESTORESTK_2 RESTORESTK(28)
-#define RESTORESTK_3 RESTORESTK(32)
-#define RESTORESTK_4 RESTORESTK(36)
-#define RESTORESTK_5 RESTORESTK(36)
-#define RESTORESTK_6 RESTORESTK(36)
-
-# if IS_IN (libpthread)
-# define CENABLE ldw r3, %call(__pthread_enable_asynccancel)(r22)
-# define CDISABLE ldw r3, %call(__pthread_disable_asynccancel)(r22)
-# elif IS_IN (librt)
-# define CENABLE ldw r3, %call(__librt_enable_asynccancel)(r22)
-# define CDISABLE ldw r3, %call(__librt_disable_asynccancel)(r22)
-# elif IS_IN (libc)
-# define CENABLE ldw r3, %call(__libc_enable_asynccancel)(r22)
-# define CDISABLE ldw r3, %call(__libc_disable_asynccancel)(r22)
-# else
-# error Unsupported library
-# endif
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) \
== 0, 1)
-# else
-# define SINGLE_THREAD_P(reg) \
- ldw reg, MULTIPLE_THREADS_OFFSET(r23)
-#endif
-#elif !defined __ASSEMBLER__
+#else
# define SINGLE_THREAD_P 1
# define NO_CANCELLATION 1
#endif
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
deleted file mode 100644
index 35d3f05..0000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Cancellable system call stubs. Linux/PowerPC version.
- Copyright (C) 2003-2017 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <nptl/pthreadP.h>
-#endif
-
-#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .section ".text"; \
- ENTRY (name) \
- SINGLE_THREAD_P; \
- bne- .Lpseudo_cancel; \
- .type __##syscall_name##_nocancel,@function; \
- .globl __##syscall_name##_nocancel; \
- __##syscall_name##_nocancel: \
- DO_CALL (SYS_ify (syscall_name)); \
- PSEUDO_RET; \
- .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
- .Lpseudo_cancel: \
- stwu 1,-48(1); \
- cfi_adjust_cfa_offset (48); \
- mflr 9; \
- stw 9,52(1); \
- cfi_offset (lr, 4); \
- DOCARGS_##args; /* save syscall args around CENABLE. */ \
- CENABLE; \
- stw 3,16(1); /* store CENABLE return value (MASK). */ \
- UNDOCARGS_##args; /* restore syscall args. */ \
- DO_CALL (SYS_ify (syscall_name)); \
- mfcr 0; /* save CR/R3 around CDISABLE. */ \
- stw 3,8(1); \
- stw 0,12(1); \
- lwz 3,16(1); /* pass MASK to CDISABLE. */ \
- CDISABLE; \
- lwz 4,52(1); \
- lwz 0,12(1); /* restore CR/R3. */ \
- lwz 3,8(1); \
- mtlr 4; \
- mtcr 0; \
- addi 1,1,48;
-
-# define DOCARGS_0
-# define UNDOCARGS_0
-
-# define DOCARGS_1 stw 3,20(1); DOCARGS_0
-# define UNDOCARGS_1 lwz 3,20(1); UNDOCARGS_0
-
-# define DOCARGS_2 stw 4,24(1); DOCARGS_1
-# define UNDOCARGS_2 lwz 4,24(1); UNDOCARGS_1
-
-# define DOCARGS_3 stw 5,28(1); DOCARGS_2
-# define UNDOCARGS_3 lwz 5,28(1); UNDOCARGS_2
-
-# define DOCARGS_4 stw 6,32(1); DOCARGS_3
-# define UNDOCARGS_4 lwz 6,32(1); UNDOCARGS_3
-
-# define DOCARGS_5 stw 7,36(1); DOCARGS_4
-# define UNDOCARGS_5 lwz 7,36(1); UNDOCARGS_4
-
-# define DOCARGS_6 stw 8,40(1); DOCARGS_5
-# define UNDOCARGS_6 lwz 8,40(1); UNDOCARGS_5
-
-# if IS_IN (libpthread)
-# define CENABLE bl __pthread_enable_asynccancel@local
-# define CDISABLE bl __pthread_disable_asynccancel@local
-# elif IS_IN (libc)
-# define CENABLE bl __libc_enable_asynccancel@local
-# define CDISABLE bl __libc_disable_asynccancel@local
-# elif IS_IN (librt)
-# define CENABLE bl __librt_enable_asynccancel@local
-# define CDISABLE bl __librt_disable_asynccancel@local
-# else
-# error Unsupported library
-# endif
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P \
- lwz 10,MULTIPLE_THREADS_OFFSET(2); \
- cmpwi 10,0
-# endif
-
-#elif !defined __ASSEMBLER__
-
-# define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
-
-#endif
-
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
deleted file mode 100644
index cad13da..0000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/* Cancellable system call stubs. Linux/PowerPC64 version.
- Copyright (C) 2003-2017 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Franz Sirl <Franz.Sirl-kernel@lauterbach.com>, 2003.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <nptl/pthreadP.h>
-#endif
-
-#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-
-# define DASHDASHPFX(str) __##str
-
-#if _CALL_ELF == 2
-#define CANCEL_FRAMESIZE (FRAME_MIN_SIZE+16+48)
-#define CANCEL_PARM_SAVE (FRAME_MIN_SIZE+16)
-#else
-#define CANCEL_FRAMESIZE (FRAME_MIN_SIZE+16)
-#define CANCEL_PARM_SAVE (CANCEL_FRAMESIZE+FRAME_PARM_SAVE)
-#endif
-
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .section ".text"; \
- ENTRY (name) \
- SINGLE_THREAD_P; \
- bne- .Lpseudo_cancel; \
- .type DASHDASHPFX(syscall_name##_nocancel),@function; \
- .globl DASHDASHPFX(syscall_name##_nocancel); \
- DASHDASHPFX(syscall_name##_nocancel): \
- DO_CALL (SYS_ify (syscall_name)); \
- PSEUDO_RET; \
- .size DASHDASHPFX(syscall_name##_nocancel),.-DASHDASHPFX(syscall_name##_nocancel); \
- .Lpseudo_cancel: \
- stdu 1,-CANCEL_FRAMESIZE(1); \
- cfi_adjust_cfa_offset (CANCEL_FRAMESIZE); \
- mflr 9; \
- std 9,CANCEL_FRAMESIZE+FRAME_LR_SAVE(1); \
- cfi_offset (lr, FRAME_LR_SAVE); \
- DOCARGS_##args; /* save syscall args around CENABLE. */ \
- CENABLE; \
- std 3,FRAME_MIN_SIZE(1); /* store CENABLE return value (MASK). */ \
- UNDOCARGS_##args; /* restore syscall args. */ \
- DO_CALL (SYS_ify (syscall_name)); \
- mfcr 0; /* save CR/R3 around CDISABLE. */ \
- std 3,FRAME_MIN_SIZE+8(1); \
- std 0,CANCEL_FRAMESIZE+FRAME_CR_SAVE(1); \
- cfi_offset (cr, FRAME_CR_SAVE); \
- ld 3,FRAME_MIN_SIZE(1); /* pass MASK to CDISABLE. */ \
- CDISABLE; \
- ld 9,CANCEL_FRAMESIZE+FRAME_LR_SAVE(1); \
- ld 0,CANCEL_FRAMESIZE+FRAME_CR_SAVE(1); /* restore CR/R3. */ \
- ld 3,FRAME_MIN_SIZE+8(1); \
- mtlr 9; \
- mtcr 0; \
- addi 1,1,CANCEL_FRAMESIZE; \
- cfi_adjust_cfa_offset (-CANCEL_FRAMESIZE); \
- cfi_restore (lr); \
- cfi_restore (cr)
-
-# define DOCARGS_0
-# define UNDOCARGS_0
-
-# define DOCARGS_1 std 3,CANCEL_PARM_SAVE(1); DOCARGS_0
-# define UNDOCARGS_1 ld 3,CANCEL_PARM_SAVE(1); UNDOCARGS_0
-
-# define DOCARGS_2 std 4,CANCEL_PARM_SAVE+8(1); DOCARGS_1
-# define UNDOCARGS_2 ld 4,CANCEL_PARM_SAVE+8(1); UNDOCARGS_1
-
-# define DOCARGS_3 std 5,CANCEL_PARM_SAVE+16(1); DOCARGS_2
-# define UNDOCARGS_3 ld 5,CANCEL_PARM_SAVE+16(1); UNDOCARGS_2
-
-# define DOCARGS_4 std 6,CANCEL_PARM_SAVE+24(1); DOCARGS_3
-# define UNDOCARGS_4 ld 6,CANCEL_PARM_SAVE+24(1); UNDOCARGS_3
-
-# define DOCARGS_5 std 7,CANCEL_PARM_SAVE+32(1); DOCARGS_4
-# define UNDOCARGS_5 ld 7,CANCEL_PARM_SAVE+32(1); UNDOCARGS_4
-
-# define DOCARGS_6 std 8,CANCEL_PARM_SAVE+40(1); DOCARGS_5
-# define UNDOCARGS_6 ld 8,CANCEL_PARM_SAVE+40(1); UNDOCARGS_5
-
-# if IS_IN (libpthread)
-# ifdef SHARED
-# define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel)
-# define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel)
-# else
-# define CENABLE bl JUMPTARGET(__pthread_enable_asynccancel); nop
-# define CDISABLE bl JUMPTARGET(__pthread_disable_asynccancel); nop
-# endif
-# elif IS_IN (libc)
-# ifdef SHARED
-# define CENABLE bl JUMPTARGET(__libc_enable_asynccancel)
-# define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel)
-# else
-# define CENABLE bl JUMPTARGET(__libc_enable_asynccancel); nop
-# define CDISABLE bl JUMPTARGET(__libc_disable_asynccancel); nop
-# endif
-# elif IS_IN (librt)
-# ifdef SHARED
-# define CENABLE bl JUMPTARGET(__librt_enable_asynccancel)
-# define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel)
-# else
-# define CENABLE bl JUMPTARGET(__librt_enable_asynccancel); nop
-# define CDISABLE bl JUMPTARGET(__librt_disable_asynccancel); nop
-# endif
-# else
-# error Unsupported library
-# endif
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P \
- lwz 10,MULTIPLE_THREADS_OFFSET(13); \
- cmpwi 10,0
-# endif
-
-#elif !defined __ASSEMBLER__
-
-# define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
-
-#endif
-
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h b/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h
new file mode 100644
index 0000000..85af880
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h
@@ -0,0 +1,38 @@
+/* Cancellable system call stubs. Linux/PowerPC version.
+ Copyright (C) 2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <tls.h>
+#include <nptl/pthreadP.h>
+
+#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
+
+# define SINGLE_THREAD_P \
+ __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 \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
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 b1e80bc..82763b7 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep-cancel.h
@@ -24,116 +24,17 @@
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
-L(pseudo_cancel): \
- cfi_startproc; \
- STM_##args \
- stm %r12,%r15,48(%r15); \
- cfi_offset (%r15, -36); \
- cfi_offset (%r14, -40); \
- cfi_offset (%r13, -44); \
- cfi_offset (%r12, -48); \
- lr %r14,%r15; \
- ahi %r15,-96; \
- cfi_adjust_cfa_offset (96); \
- st %r14,0(%r15); \
- basr %r13,0; \
-0: l %r1,1f-0b(%r13); \
- bas %r14,0(%r1,%r13); \
- lr %r0,%r2; \
- LM_##args \
- .if SYS_ify (syscall_name) < 256; \
- svc SYS_ify (syscall_name); \
- .else; \
- lhi %r1,SYS_ify (syscall_name); \
- svc 0; \
- .endif; \
- LR7_##args \
- l %r1,2f-0b(%r13); \
- lr %r12,%r2; \
- lr %r2,%r0; \
- bas %r14,0(%r1,%r13); \
- lr %r2,%r12; \
- lm %r12,%r15,48+96(%r15); \
- cfi_endproc; \
- j L(pseudo_check); \
-1: .long CENABLE-0b; \
-2: .long CDISABLE-0b; \
-ENTRY(name) \
- SINGLE_THREAD_P(%r1) \
- jne L(pseudo_cancel); \
-.type __##syscall_name##_nocancel,@function; \
-.globl __##syscall_name##_nocancel; \
-__##syscall_name##_nocancel: \
- DO_CALL(syscall_name, args); \
-L(pseudo_check): \
- lhi %r4,-4095; \
- clr %r2,%r4; \
- jnl SYSCALL_ERROR_LABEL; \
-.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
-L(pseudo_end):
-
-# if IS_IN (libpthread)
-# define CENABLE __pthread_enable_asynccancel
-# define CDISABLE __pthread_disable_asynccancel
-# elif IS_IN (libc)
-# define CENABLE __libc_enable_asynccancel
-# define CDISABLE __libc_disable_asynccancel
-# elif IS_IN (librt)
-# define CENABLE __librt_enable_asynccancel
-# define CDISABLE __librt_disable_asynccancel
-# else
-# error Unsupported library
-# endif
-
-#define STM_0 /* Nothing */
-#define STM_1 st %r2,8(%r15);
-#define STM_2 stm %r2,%r3,8(%r15);
-#define STM_3 stm %r2,%r4,8(%r15);
-#define STM_4 stm %r2,%r5,8(%r15);
-#define STM_5 stm %r2,%r5,8(%r15);
-#define STM_6 stm %r2,%r7,8(%r15);
-
-#define LM_0 /* Nothing */
-#define LM_1 l %r2,8+96(%r15);
-#define LM_2 lm %r2,%r3,8+96(%r15);
-#define LM_3 lm %r2,%r4,8+96(%r15);
-#define LM_4 lm %r2,%r5,8+96(%r15);
-#define LM_5 lm %r2,%r5,8+96(%r15);
-#define LM_6 lm %r2,%r5,8+96(%r15); \
- cfi_offset (%r7, -68); \
- l %r7,96+96(%r15);
-
-#define LR7_0 /* Nothing */
-#define LR7_1 /* Nothing */
-#define LR7_2 /* Nothing */
-#define LR7_3 /* Nothing */
-#define LR7_4 /* Nothing */
-#define LR7_5 /* Nothing */
-#define LR7_6 l %r7,28+96(%r15); \
- cfi_restore (%r7);
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P(reg) \
- ear reg,%a0; \
- icm reg,15,MULTIPLE_THREADS_OFFSET(reg);
-# endif
-#elif !defined __ASSEMBLER__
+#else
# define SINGLE_THREAD_P (1)
# define NO_CANCELLATION 1
#endif
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 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 9b2c546..952d2af 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep-cancel.h
@@ -18,135 +18,36 @@
#include <sysdep.h>
#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <nptl/pthreadP.h>
-#endif
+#include <nptl/pthreadP.h>
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
-L(pseudo_cancel): \
- cfi_startproc; \
- STM_##args \
- stmg %r13,%r15,104(%r15); \
- cfi_offset (%r15,-40); \
- cfi_offset (%r14,-48); \
- cfi_offset (%r13,-56); \
- lgr %r14,%r15; \
- aghi %r15,-160; \
- cfi_adjust_cfa_offset (160); \
- stg %r14,0(%r15); \
- brasl %r14,CENABLE; \
- lgr %r0,%r2; \
- LM_##args \
- .if SYS_ify (syscall_name) < 256; \
- svc SYS_ify (syscall_name); \
- .else; \
- lghi %r1,SYS_ify (syscall_name); \
- svc 0; \
- .endif; \
- LR7_##args \
- lgr %r13,%r2; \
- lgr %r2,%r0; \
- brasl %r14,CDISABLE; \
- lgr %r2,%r13; \
- lmg %r13,%r15,104+160(%r15); \
- cfi_endproc; \
- j L(pseudo_check); \
-ENTRY(name) \
- SINGLE_THREAD_P \
- jne L(pseudo_cancel); \
-.type __##syscall_name##_nocancel,@function; \
-.globl __##syscall_name##_nocancel; \
-__##syscall_name##_nocancel: \
- DO_CALL(syscall_name, args); \
-L(pseudo_check): \
- lghi %r4,-4095; \
- clgr %r2,%r4; \
- jgnl SYSCALL_ERROR_LABEL; \
-.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
-L(pseudo_end):
-
# if IS_IN (libpthread)
-# define CENABLE __pthread_enable_asynccancel
-# define CDISABLE __pthread_disable_asynccancel
# define __local_multiple_threads __pthread_multiple_threads
# elif IS_IN (libc)
-# define CENABLE __libc_enable_asynccancel
-# define CDISABLE __libc_disable_asynccancel
# define __local_multiple_threads __libc_multiple_threads
-# elif IS_IN (librt)
-# define CENABLE __librt_enable_asynccancel
-# define CDISABLE __librt_disable_asynccancel
-# else
-# error Unsupported library
# endif
-#define STM_0 /* Nothing */
-#define STM_1 stg %r2,16(%r15);
-#define STM_2 stmg %r2,%r3,16(%r15);
-#define STM_3 stmg %r2,%r4,16(%r15);
-#define STM_4 stmg %r2,%r5,16(%r15);
-#define STM_5 stmg %r2,%r5,16(%r15);
-#define STM_6 stmg %r2,%r7,16(%r15);
-
-#define LM_0 /* Nothing */
-#define LM_1 lg %r2,16+160(%r15);
-#define LM_2 lmg %r2,%r3,16+160(%r15);
-#define LM_3 lmg %r2,%r4,16+160(%r15);
-#define LM_4 lmg %r2,%r5,16+160(%r15);
-#define LM_5 lmg %r2,%r5,16+160(%r15);
-#define LM_6 lmg %r2,%r5,16+160(%r15); \
- cfi_offset (%r7, -104); \
- lg %r7,160+160(%r15);
-
-#define LR7_0 /* Nothing */
-#define LR7_1 /* Nothing */
-#define LR7_2 /* Nothing */
-#define LR7_3 /* Nothing */
-#define LR7_4 /* Nothing */
-#define LR7_5 /* Nothing */
-#define LR7_6 lg %r7,56+160(%r15); \
- cfi_restore (%r7);
-
# if IS_IN (libpthread) || IS_IN (libc)
-# ifndef __ASSEMBLER__
extern int __local_multiple_threads attribute_hidden;
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (__local_multiple_threads == 0, 1)
-# else
-# define SINGLE_THREAD_P \
- larl %r1,__local_multiple_threads; \
- icm %r0,15,0(%r1);
-# endif
# else
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P \
- ear %r1,%a0; \
- sllg %r1,%r1,32; \
- ear %r1,%a1; \
- icm %r1,15,MULTIPLE_THREADS_OFFSET(%r1);
-# endif
# endif
-#elif !defined __ASSEMBLER__
+#else
# define SINGLE_THREAD_P (1)
# define NO_CANCELLATION 1
#endif
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
index 5645cad..1ea501b 100644
--- a/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/sh/sysdep-cancel.h
@@ -23,147 +23,17 @@
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-# define _IMM12 #-12
-# define _IMM16 #-16
-# define _IMP16 #16
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
- ENTRY (name); \
- .Lpseudo_start: \
- SINGLE_THREAD_P; \
- bf .Lpseudo_cancel; \
- .type __##syscall_name##_nocancel,@function; \
- .globl __##syscall_name##_nocancel; \
- __##syscall_name##_nocancel: \
- DO_CALL (syscall_name, args); \
- mov r0,r1; \
- mov _IMM12,r2; \
- shad r2,r1; \
- not r1,r1; \
- tst r1,r1; \
- bt .Lsyscall_error; \
- bra .Lpseudo_end; \
- nop; \
- .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
- .Lpseudo_cancel: \
- sts.l pr,@-r15; \
- cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (pr, 0); \
- add _IMM16,r15; \
- cfi_adjust_cfa_offset (16); \
- SAVE_ARGS_##args; \
- CENABLE; \
- LOAD_ARGS_##args; \
- add _IMP16,r15; \
- cfi_adjust_cfa_offset (-16); \
- lds.l @r15+,pr; \
- cfi_adjust_cfa_offset (-4); \
- cfi_restore (pr); \
- DO_CALL(syscall_name, args); \
- SYSCALL_INST_PAD; \
- sts.l pr,@-r15; \
- cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (pr, 0); \
- mov.l r0,@-r15; \
- cfi_adjust_cfa_offset (4); \
- cfi_rel_offset (r0, 0); \
- CDISABLE; \
- mov.l @r15+,r0; \
- cfi_adjust_cfa_offset (-4); \
- cfi_restore (r0); \
- lds.l @r15+,pr; \
- cfi_adjust_cfa_offset (-4); \
- cfi_restore (pr); \
- mov r0,r1; \
- mov _IMM12,r2; \
- shad r2,r1; \
- not r1,r1; \
- tst r1,r1; \
- bf .Lpseudo_end; \
- .Lsyscall_error: \
- SYSCALL_ERROR_HANDLER; \
- .Lpseudo_end:
-
-# undef PSEUDO_END
-# define PSEUDO_END(sym) \
- END (sym)
-
-# define SAVE_ARGS_0 /* Nothing. */
-# define SAVE_ARGS_1 SAVE_ARGS_0; mov.l r4,@(0,r15); cfi_offset (r4,-4)
-# define SAVE_ARGS_2 SAVE_ARGS_1; mov.l r5,@(4,r15); cfi_offset (r5,-8)
-# define SAVE_ARGS_3 SAVE_ARGS_2; mov.l r6,@(8,r15); cfi_offset (r6,-12)
-# define SAVE_ARGS_4 SAVE_ARGS_3; mov.l r7,@(12,r15); cfi_offset (r7,-16)
-# define SAVE_ARGS_5 SAVE_ARGS_4
-# define SAVE_ARGS_6 SAVE_ARGS_5
-
-# define LOAD_ARGS_0 /* Nothing. */
-# define LOAD_ARGS_1 LOAD_ARGS_0; mov.l @(0,r15),r4; cfi_restore (r4)
-# define LOAD_ARGS_2 LOAD_ARGS_1; mov.l @(4,r15),r5; cfi_restore (r5)
-# define LOAD_ARGS_3 LOAD_ARGS_2; mov.l @(8,r15),r6; cfi_restore (r6)
-# define LOAD_ARGS_4 LOAD_ARGS_3; mov.l @(12,r15),r7; cfi_restore (r7)
-# define LOAD_ARGS_5 LOAD_ARGS_4
-# define LOAD_ARGS_6 LOAD_ARGS_5
-
-# if IS_IN (libpthread)
-# define __local_enable_asynccancel __pthread_enable_asynccancel
-# define __local_disable_asynccancel __pthread_disable_asynccancel
-# elif IS_IN (libc)
-# define __local_enable_asynccancel __libc_enable_asynccancel
-# define __local_disable_asynccancel __libc_disable_asynccancel
-# elif IS_IN (librt)
-# define __local_enable_asynccancel __librt_enable_asynccancel
-# define __local_disable_asynccancel __librt_disable_asynccancel
-# else
-# error Unsupported library
-# endif
-
-# define CENABLE \
- mov.l 1f,r0; \
- bsrf r0; \
- nop; \
- 0: bra 2f; \
- mov r0,r2; \
- .align 2; \
- 1: .long __local_enable_asynccancel - 0b; \
- 2:
-
-# define CDISABLE \
- mov.l 1f,r0; \
- bsrf r0; \
- mov r2,r4; \
- 0: bra 2f; \
- nop; \
- .align 2; \
- 1: .long __local_disable_asynccancel - 0b; \
- 2:
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P \
- stc gbr,r0; \
- mov.w 0f,r1; \
- sub r1,r0; \
- mov.l @(MULTIPLE_THREADS_OFFSET,r0),r0; \
- bra 1f; \
- tst r0,r0; \
- 0: .word TLS_PRE_TCB_SIZE; \
- 1:
-
-# endif
-#elif !defined __ASSEMBLER__
+#else
# define SINGLE_THREAD_P (1)
# define NO_CANCELLATION 1
#endif
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
deleted file mode 100644
index c513212..0000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* Copyright (C) 2002-2017 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <nptl/pthreadP.h>
-#endif
-
-#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
- .globl __syscall_error; \
-ENTRY(name) \
- ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;\
- cmp %g1, 0; \
- bne 1f; \
-.type __##syscall_name##_nocancel,@function; \
-.globl __##syscall_name##_nocancel; \
-__##syscall_name##_nocancel: \
- mov SYS_ify(syscall_name), %g1; \
- ta 0x10; \
- bcc 8f; \
- mov %o7, %g1; \
- call __syscall_error; \
- mov %g1, %o7; \
-8: jmpl %o7 + 8, %g0; \
- nop; \
-.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;\
-1: save %sp, -96, %sp; \
- cfi_def_cfa_register(%fp); \
- cfi_window_save; \
- cfi_register(%o7, %i7); \
- CENABLE; \
- nop; \
- mov %o0, %l0; \
- COPY_ARGS_##args \
- mov SYS_ify(syscall_name), %g1; \
- ta 0x10; \
- bcc 1f; \
- mov %o0, %l1; \
- CDISABLE; \
- mov %l0, %o0; \
- call __syscall_error; \
- mov %l1, %o0; \
- b 2f; \
- mov -1, %l1; \
-1: CDISABLE; \
- mov %l0, %o0; \
-2: jmpl %i7 + 8, %g0; \
- restore %g0, %l1, %o0;
-
-
-# if IS_IN (libpthread)
-# define CENABLE call __pthread_enable_asynccancel
-# define CDISABLE call __pthread_disable_asynccancel
-# elif IS_IN (libc)
-# define CENABLE call __libc_enable_asynccancel
-# define CDISABLE call __libc_disable_asynccancel
-# elif IS_IN (librt)
-# define CENABLE call __librt_enable_asynccancel
-# define CDISABLE call __librt_disable_asynccancel
-# else
-# error Unsupported library
-# endif
-
-#define COPY_ARGS_0 /* Nothing */
-#define COPY_ARGS_1 COPY_ARGS_0 mov %i0, %o0;
-#define COPY_ARGS_2 COPY_ARGS_1 mov %i1, %o1;
-#define COPY_ARGS_3 COPY_ARGS_2 mov %i2, %o2;
-#define COPY_ARGS_4 COPY_ARGS_3 mov %i3, %o3;
-#define COPY_ARGS_5 COPY_ARGS_4 mov %i4, %o4;
-#define COPY_ARGS_6 COPY_ARGS_5 mov %i5, %o5;
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1
-# endif
-
-#elif !defined __ASSEMBLER__
-
-# define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
-
-#endif
-
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h
deleted file mode 100644
index 45fbd73..0000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* Copyright (C) 2002-2017 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <nptl/pthreadP.h>
-#endif
-
-#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
- .globl __syscall_error; \
-ENTRY(name) \
- ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1;\
- brnz,pn %g1, 1f; \
-.type __##syscall_name##_nocancel,@function; \
-.globl __##syscall_name##_nocancel; \
-__##syscall_name##_nocancel: \
- mov SYS_ify(syscall_name), %g1; \
- ta 0x6d; \
- bcc,pt %xcc, 8f; \
- mov %o7, %g1; \
- call __syscall_error; \
- mov %g1, %o7; \
-8: jmpl %o7 + 8, %g0; \
- nop; \
-.size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel;\
-1: save %sp, -192, %sp; \
- cfi_def_cfa_register(%fp); \
- cfi_window_save; \
- cfi_register(%o7, %i7); \
- CENABLE; \
- nop; \
- mov %o0, %l0; \
- COPY_ARGS_##args \
- mov SYS_ify(syscall_name), %g1; \
- ta 0x6d; \
- bcc,pt %xcc, 1f; \
- mov %o0, %l1; \
- CDISABLE; \
- mov %l0, %o0; \
- call __syscall_error; \
- mov %l1, %o0; \
- ba,pt %xcc, 2f; \
- mov -1, %l1; \
-1: CDISABLE; \
- mov %l0, %o0; \
-2: jmpl %i7 + 8, %g0; \
- restore %g0, %l1, %o0;
-
-# if IS_IN (libpthread)
-# define CENABLE call __pthread_enable_asynccancel
-# define CDISABLE call __pthread_disable_asynccancel
-# elif IS_IN (libc)
-# define CENABLE call __libc_enable_asynccancel
-# define CDISABLE call __libc_disable_asynccancel
-# elif IS_IN (librt)
-# define CENABLE call __librt_enable_asynccancel
-# define CDISABLE call __librt_disable_asynccancel
-# else
-# error Unsupported library
-# endif
-
-#define COPY_ARGS_0 /* Nothing */
-#define COPY_ARGS_1 COPY_ARGS_0 mov %i0, %o0;
-#define COPY_ARGS_2 COPY_ARGS_1 mov %i1, %o1;
-#define COPY_ARGS_3 COPY_ARGS_2 mov %i2, %o2;
-#define COPY_ARGS_4 COPY_ARGS_3 mov %i3, %o3;
-#define COPY_ARGS_5 COPY_ARGS_4 mov %i4, %o4;
-#define COPY_ARGS_6 COPY_ARGS_5 mov %i5, %o5;
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P ld [%g7 + MULTIPLE_THREADS_OFFSET], %g1
-# endif
-
-#elif !defined __ASSEMBLER__
-
-# define SINGLE_THREAD_P (1)
-# define NO_CANCELLATION 1
-
-#endif
-
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
- __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
- header.multiple_threads) == 0, 1)
-#endif
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h b/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
new file mode 100644
index 0000000..61bfa33
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
@@ -0,0 +1,38 @@
+/* Copyright (C) 2002-2015 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Jakub Jelinek <jakub@redhat.com>, 2002.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <tls.h>
+#include <nptl/pthreadP.h>
+
+#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
+
+# define SINGLE_THREAD_P \
+ __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 \
+ __builtin_expect (THREAD_GETMEM (THREAD_SELF, \
+ header.multiple_threads) == 0, 1)
diff --git a/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h b/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h
index 092a90c..c8994db 100644
--- a/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/tile/sysdep-cancel.h
@@ -18,137 +18,22 @@
#include <sysdep.h>
#include <tls.h>
-#ifndef __ASSEMBLER__
-# include <nptl/pthreadP.h>
-#endif
+#include <nptl/pthreadP.h>
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-/* Allow hacking in some extra code if desired. */
-#ifndef PSEUDO_EXTRA
-#define PSEUDO_EXTRA
-#endif
-
-#undef PSEUDO
-#define PSEUDO(name, syscall_name, args) \
- ENTRY(__##syscall_name##_nocancel); \
- PSEUDO_EXTRA \
- moveli TREG_SYSCALL_NR_NAME, SYS_ify(syscall_name); \
- swint1; \
- BNEZ r1, 0f; \
- jrp lr; \
- END(__##syscall_name##_nocancel); \
- ENTRY (name) \
- SINGLE_THREAD_P(r11); \
- BEQZ r11, L(pseudo_cancel); \
- PSEUDO_EXTRA \
- moveli TREG_SYSCALL_NR_NAME, SYS_ify(syscall_name); \
- swint1; \
- BNEZ r1, 0f; \
- jrp lr; \
- L(pseudo_cancel): \
- { \
- move r11, sp; \
- ST sp, lr; \
- ADDI_PTR sp, sp, -STKSPACE; \
- }; \
- cfi_offset (lr, 0); \
- cfi_def_cfa_offset (STKSPACE); \
- { \
- ADDI_PTR r12, sp, REGSIZE; \
- ADDI_PTR r13, sp, 2 * REGSIZE; /* set up for PUSHARGS_0 */ \
- }; \
- ST r12, r11; \
- PUSHARGS_##args /* save syscall args */ \
- CENABLE; \
- ADDI_PTR r12, sp, 10 * REGSIZE; \
- { \
- ST r12, r0; /* save mask */ \
- ADDI_PTR r13, sp, 2 * REGSIZE; /* set up for POPARGS_0 */ \
- }; \
- POPARGS_##args /* restore syscall args */ \
- PSEUDO_EXTRA \
- moveli TREG_SYSCALL_NR_NAME, SYS_ify(syscall_name); \
- swint1; \
- ADDI_PTR r12, sp, 12 * REGSIZE; \
- { \
- ST r12, r1; /* save syscall result */ \
- ADDI_PTR r12, sp, 11 * REGSIZE; \
- }; \
- { \
- ST r12, r0; \
- ADDI_PTR r13, sp, 10 * REGSIZE; \
- }; \
- LD r0, r13; /* pass mask as arg1 */ \
- CDISABLE; \
- { \
- ADDI_PTR lr, sp, STKSPACE; \
- ADDI_PTR r0, sp, 11 * REGSIZE; \
- }; \
- { \
- LD r0, r0; \
- ADDI_PTR r1, sp, 12 * REGSIZE; \
- }; \
- LD r1, r1; \
- { \
- LD lr, lr; \
- ADDI_PTR sp, sp, STKSPACE; \
- }; \
- cfi_def_cfa_offset (0); \
- BNEZ r1, 0f
-
-# define PUSHARGS_0 /* nothing to do */
-# define PUSHARGS_1 PUSHARGS_0 { ADDI_PTR r14, sp, 3 * REGSIZE; ST r13, r0 };
-# define PUSHARGS_2 PUSHARGS_1 { ADDI_PTR r13, sp, 4 * REGSIZE; ST r14, r1 };
-# define PUSHARGS_3 PUSHARGS_2 { ADDI_PTR r14, sp, 5 * REGSIZE; ST r13, r2 };
-# define PUSHARGS_4 PUSHARGS_3 { ADDI_PTR r13, sp, 6 * REGSIZE; ST r14, r3 };
-# define PUSHARGS_5 PUSHARGS_4 { ADDI_PTR r14, sp, 7 * REGSIZE; ST r13, r4 };
-# define PUSHARGS_6 PUSHARGS_5 { ADDI_PTR r13, sp, 8 * REGSIZE; ST r14, r5 };
-# define PUSHARGS_7 PUSHARGS_6 { ADDI_PTR r14, sp, 9 * REGSIZE; ST r13, r6 };
-
-# define POPARGS_0 /* nothing to do */
-# define POPARGS_1 POPARGS_0 { ADDI_PTR r14, sp, 3 * REGSIZE; LD r0, r13 };
-# define POPARGS_2 POPARGS_1 { ADDI_PTR r13, sp, 4 * REGSIZE; LD r1, r14 };
-# define POPARGS_3 POPARGS_2 { ADDI_PTR r14, sp, 5 * REGSIZE; LD r2, r13 };
-# define POPARGS_4 POPARGS_3 { ADDI_PTR r13, sp, 6 * REGSIZE; LD r3, r14 };
-# define POPARGS_5 POPARGS_4 { ADDI_PTR r14, sp, 7 * REGSIZE; LD r4, r13 };
-# define POPARGS_6 POPARGS_5 { ADDI_PTR r13, sp, 8 * REGSIZE; LD r5, r14 };
-# define POPARGS_7 POPARGS_6 { ADDI_PTR r14, sp, 9 * REGSIZE; LD r6, r13 };
-
-# define STKSPACE (13 * REGSIZE)
-
-# if IS_IN (libpthread)
-# define CENABLE jal __pthread_enable_asynccancel
-# define CDISABLE jal __pthread_disable_asynccancel
-# elif IS_IN (librt)
-# define CENABLE jal __librt_enable_asynccancel
-# define CDISABLE jal __librt_disable_asynccancel
-# else
-# define CENABLE jal __libc_enable_asynccancel
-# define CDISABLE jal __libc_disable_asynccancel
-# endif
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) \
== 0, 1)
-# else
-# define SINGLE_THREAD_P(reg) \
- ADDLI_PTR reg, tp, MULTIPLE_THREADS_OFFSET; \
- LD reg, reg; \
- CMPEQI reg, reg, 0
-#endif
-#elif !defined __ASSEMBLER__
+#else
# define SINGLE_THREAD_P 1
# define NO_CANCELLATION 1
#endif
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 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 6598010..0979bde 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h
@@ -24,86 +24,32 @@
#if IS_IN (libc) || IS_IN (libpthread) || IS_IN (librt)
-/* The code to disable cancellation depends on the fact that the called
- functions are special. They don't modify registers other than %rax
- and %r11 if they return. Therefore we don't have to preserve other
- registers around these calls. */
-# undef PSEUDO
-# define PSEUDO(name, syscall_name, args) \
- .text; \
- ENTRY (name) \
- SINGLE_THREAD_P; \
- jne L(pseudo_cancel); \
- .type __##syscall_name##_nocancel,@function; \
- .globl __##syscall_name##_nocancel; \
- __##syscall_name##_nocancel: \
- DO_CALL (syscall_name, args); \
- cmpq $-4095, %rax; \
- jae SYSCALL_ERROR_LABEL; \
- ret; \
- .size __##syscall_name##_nocancel,.-__##syscall_name##_nocancel; \
- L(pseudo_cancel): \
- /* We always have to align the stack before calling a function. */ \
- subq $8, %rsp; cfi_adjust_cfa_offset (8); \
- CENABLE \
- /* The return value from CENABLE is argument for CDISABLE. */ \
- movq %rax, (%rsp); \
- DO_CALL (syscall_name, args); \
- movq (%rsp), %rdi; \
- /* Save %rax since it's the error code from the syscall. */ \
- movq %rax, %rdx; \
- CDISABLE \
- movq %rdx, %rax; \
- addq $8,%rsp; cfi_adjust_cfa_offset (-8); \
- cmpq $-4095, %rax; \
- jae SYSCALL_ERROR_LABEL
-
-
# if IS_IN (libpthread)
-# define CENABLE call __pthread_enable_asynccancel;
-# define CDISABLE call __pthread_disable_asynccancel;
# define __local_multiple_threads __pthread_multiple_threads
# elif IS_IN (libc)
-# define CENABLE call __libc_enable_asynccancel;
-# define CDISABLE call __libc_disable_asynccancel;
# define __local_multiple_threads __libc_multiple_threads
# elif IS_IN (librt)
-# define CENABLE call __librt_enable_asynccancel;
-# define CDISABLE call __librt_disable_asynccancel;
# else
# error Unsupported library
# endif
# if IS_IN (libpthread) || IS_IN (libc)
-# ifndef __ASSEMBLER__
extern int __local_multiple_threads attribute_hidden;
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (__local_multiple_threads == 0, 1)
-# else
-# define SINGLE_THREAD_P cmpl $0, __local_multiple_threads(%rip)
-# endif
-
# else
-
-# ifndef __ASSEMBLER__
-# define SINGLE_THREAD_P \
+# define SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-# else
-# define SINGLE_THREAD_P cmpl $0, %fs:MULTIPLE_THREADS_OFFSET
-# endif
-
# endif
-#elif !defined __ASSEMBLER__
+#else
# define SINGLE_THREAD_P (1)
# define NO_CANCELLATION 1
#endif
-#ifndef __ASSEMBLER__
-# define RTLD_SINGLE_THREAD_P \
+#define RTLD_SINGLE_THREAD_P \
__builtin_expect (THREAD_GETMEM (THREAD_SELF, \
header.multiple_threads) == 0, 1)
-#endif
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 07/14] Consolidate non cancellable fcntl call
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (10 preceding siblings ...)
2017-07-04 19:54 ` [PATCH 14/14] Remove cancellation support for syscall generation Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 13/14] Remove p{read,write}{v} and fallocate from x86 auto-generation list Adhemerval Zanella
` (2 subsequent siblings)
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
This patch consolidates all the non cancellable fcntl calls to use
the __fcntl_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.
Since its prototype is already defined at internal fcntl.h header, it
is removed from not-cancel.h one.
Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu.
* login/utmp_file.c (timeout_handler): Replace fcntl_not_cancel with
__fcntl_nocancel.
* sysdeps/generic/not-cancel.h (fcntl_not_cancel): Remove macro.
* sysdeps/unix/sysv/linux/not-cancel.h (fcntl_not_cancel): Likewise.
---
ChangeLog | 5 +++++
login/utmp_file.c | 4 ++--
sysdeps/generic/not-cancel.h | 2 --
sysdeps/unix/sysv/linux/not-cancel.h | 4 ----
4 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/login/utmp_file.c b/login/utmp_file.c
index 4dd38dd..7462a13 100644
--- a/login/utmp_file.c
+++ b/login/utmp_file.c
@@ -81,7 +81,7 @@ static void timeout_handler (int signum) {};
memset (&fl, '\0', sizeof (struct flock)); \
fl.l_type = (type); \
fl.l_whence = SEEK_SET; \
- if (fcntl_not_cancel ((fd), F_SETLKW, &fl) < 0)
+ if (__fcntl_nocancel ((fd), F_SETLKW, &fl) < 0)
#define LOCKING_FAILED() \
goto unalarm_return
@@ -89,7 +89,7 @@ static void timeout_handler (int signum) {};
#define UNLOCK_FILE(fd) \
/* Unlock the file. */ \
fl.l_type = F_UNLCK; \
- fcntl_not_cancel ((fd), F_SETLKW, &fl); \
+ __fcntl_nocancel ((fd), F_SETLKW, &fl); \
\
unalarm_return: \
/* Reset the signal handler and alarm. We must reset the alarm \
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index 9959c87..fa7b4d3 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -36,8 +36,6 @@
__write (fd, buf, n)
#define __writev_nocancel_nostatus(fd, iov, n) \
(void) __writev (fd, iov, n)
-#define fcntl_not_cancel(fd, cmd, val) \
- __fcntl (fd, cmd, val)
# define waitpid_not_cancel(pid, stat_loc, options) \
__waitpid (pid, stat_loc, options)
#define pause_not_cancel() \
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 7fd42c2..625bbaa 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -72,10 +72,6 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
return INTERNAL_SYSCALL_CALL (writev, err, fd, iov, iovcnt);
}
-/* Uncancelable fcntl. */
-#define fcntl_not_cancel(fd, cmd, val) \
- __fcntl_nocancel (fd, cmd, val)
-
/* Uncancelable waitpid. */
#define __waitpid_nocancel(pid, stat_loc, options) \
INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 13/14] Remove p{read,write}{v} and fallocate from x86 auto-generation list
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (11 preceding siblings ...)
2017-07-04 19:54 ` [PATCH 07/14] Consolidate non cancellable fcntl call Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-07-04 19:54 ` [PATCH 08/14] Consolidate non cancellable waitpid call Adhemerval Zanella
2017-08-02 14:41 ` [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
With {INLINE,INTERNAL}_SYSCALL macros fixed for 64-bits arguments on x32,
we can remove the p{read,write}{v} from auto-generation list.
Tested on x86_64 and x32.
* sysdeps/unix/sysv/linux/x86_64/syscalls.list (pread64): Remove.
(preadv64): Likewise.
(pwrite64(: Likewise.
(pwritev64): Likewise.
---
ChangeLog | 5 +++++
sysdeps/unix/sysv/linux/x86_64/syscalls.list | 4 ----
sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list | 1 -
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/x86_64/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
index 889193b..d46524e 100644
--- a/sysdeps/unix/sysv/linux/x86_64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/syscalls.list
@@ -2,10 +2,6 @@
arch_prctl EXTRA arch_prctl i:ii __arch_prctl arch_prctl
modify_ldt EXTRA modify_ldt i:ipi __modify_ldt modify_ldt
-pread64 - pread64 Ci:ipii __libc_pread __libc_pread64 __pread64 pread64 __pread pread
-preadv64 - preadv Ci:ipii preadv64 preadv
-pwrite64 - pwrite64 Ci:ipii __libc_pwrite __libc_pwrite64 __pwrite64 pwrite64 __pwrite pwrite
-pwritev64 - pwritev Ci:ipii pwritev64 pwritev
syscall_clock_gettime EXTRA clock_gettime Ei:ip __syscall_clock_gettime
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list
index a41c8ac..b44f6f9 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list
@@ -1,6 +1,5 @@
# File name Caller Syscall name # args Strong name Weak names
-fallocate - fallocate Ci:iiii fallocate fallocate64
gettimeofday - gettimeofday:__vdso_gettimeofday@LINUX_2.6 i:pP __gettimeofday gettimeofday
personality EXTRA personality Ei:i __personality personality
posix_fadvise64 - fadvise64 Vi:iiii posix_fadvise posix_fadvise64
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 08/14] Consolidate non cancellable waitpid call
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (12 preceding siblings ...)
2017-07-04 19:54 ` [PATCH 13/14] Remove p{read,write}{v} and fallocate from x86 auto-generation list Adhemerval Zanella
@ 2017-07-04 19:54 ` Adhemerval Zanella
2017-08-02 14:41 ` [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-07-04 19:54 UTC (permalink / raw)
To: libc-alpha
This patch consolidates all the non cancellable waitpid calls to use
the __waitpid_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.
* login/utmp_file.c (timeout_handler): Replace fcntl_not_cancel with
__fcntl_nocancel.
* sysdeps/generic/not-cancel.h (fcntl_not_cancel): Remove macro.
* sysdeps/unix/sysv/linux/not-cancel.h (fcntl_not_cancel): Likewise.
---
libio/iopopen.c | 2 +-
sysdeps/generic/not-cancel.h | 2 +-
sysdeps/unix/sysv/linux/not-cancel.h | 7 +++----
sysdeps/unix/sysv/linux/waitpid.c | 15 ++++++++++++++-
4 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/libio/iopopen.c b/libio/iopopen.c
index 0c20cbb..a2ddebb 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -61,7 +61,7 @@ extern int _IO_dup2 (int fd, int fd2) __THROW;
#ifndef _IO_waitpid
#ifdef _LIBC
-#define _IO_waitpid waitpid_not_cancel
+#define _IO_waitpid __waitpid_nocancel
#else
#define _IO_waitpid waitpid
#endif
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index fa7b4d3..6c3afc2 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -36,7 +36,7 @@
__write (fd, buf, n)
#define __writev_nocancel_nostatus(fd, iov, n) \
(void) __writev (fd, iov, n)
-# define waitpid_not_cancel(pid, stat_loc, options) \
+# define __waitpid_nocancel(pid, stat_loc, options) \
__waitpid (pid, stat_loc, options)
#define pause_not_cancel() \
__pause ()
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 625bbaa..3047848 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -25,6 +25,7 @@
#include <errno.h>
#include <unistd.h>
#include <sys/syscall.h>
+#include <sys/wait.h>
/* Non cancellable open syscall. */
__typeof (open) __open_nocancel;
@@ -73,10 +74,8 @@ __writev_nocancel_nostatus (int fd, const struct iovec *iov, int iovcnt)
}
/* Uncancelable waitpid. */
-#define __waitpid_nocancel(pid, stat_loc, options) \
- INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
-#define waitpid_not_cancel(pid, stat_loc, options) \
- __waitpid_nocancel(pid, stat_loc, options)
+__typeof (waitpid) __waitpid_nocancel;
+libc_hidden_proto (__waitpid_nocancel)
/* Uncancelable pause. */
#define pause_not_cancel() \
diff --git a/sysdeps/unix/sysv/linux/waitpid.c b/sysdeps/unix/sysv/linux/waitpid.c
index 2fed421..052462d 100644
--- a/sysdeps/unix/sysv/linux/waitpid.c
+++ b/sysdeps/unix/sysv/linux/waitpid.c
@@ -16,10 +16,12 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
-#include <sysdep-cancel.h>
#include <stdlib.h>
#include <sys/wait.h>
+#include <sysdep-cancel.h>
+#include <not-cancel.h>
+
__pid_t
__waitpid (__pid_t pid, int *stat_loc, int options)
{
@@ -31,3 +33,14 @@ __waitpid (__pid_t pid, int *stat_loc, int options)
}
libc_hidden_def (__waitpid)
weak_alias (__waitpid, waitpid)
+
+__pid_t
+__waitpid_nocancel (__pid_t pid, int *stat_loc, int options)
+{
+#ifdef __NR_waitpid
+ return INLINE_SYSCALL_CALL (waitpid, pid, stat_loc, options);
+#else
+ return INLINE_SYSCALL_CALL (wait4, pid, stat_loc, options, NULL);
+#endif
+}
+libc_hidden_def (__waitpid_nocancel)
--
2.7.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [PATCH 00/14] Remove sysdep-cancel assembly macro
2017-07-04 19:54 [PATCH 00/14] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (13 preceding siblings ...)
2017-07-04 19:54 ` [PATCH 08/14] Consolidate non cancellable waitpid call Adhemerval Zanella
@ 2017-08-02 14:41 ` Adhemerval Zanella
14 siblings, 0 replies; 21+ messages in thread
From: Adhemerval Zanella @ 2017-08-02 14:41 UTC (permalink / raw)
To: libc-alpha
With now 2.27 open I would like to push it and remove the syscal-cancel.h
hackery at the start of the window. I have recently rechecked with a build
on all ports and with exceptions of x86_64 (which this patchset addresses)
none of Linux ports are currently using any auto-generated cancelable syscall.
On 04/07/2017 16:53, Adhemerval Zanella wrote:
> - I refactored how internal non cancellable syscalls are implemented
> within glibc. On Linux which support cancellation instead of
> C prepocessor macros, proper function prototypes and implementation
> are used. This allows targets that requires specific handling of
> 64 bits arguments, such as x32, to use the correct kernel abi.
>
> --
>
> This patchset finishes my previous work of Linux syscall consolidation
> and refactor to finally remove the requeriment of sysdeps-cancel.h
> assembly macros for cancellable syscalls. All ports now uses the
> SYSCALL_CANCEL macros with C implementation which in turn calls
> INLINE_SYSCALL macros.
>
> Besides simplify the curent code requirement, it also simplify
> possible future ports to require only the C bindings and the direct
> assembly one for syscalls.list autogeneration (another possible
> work for future would be to use C generate binding to simplify
> even further the syscall requirements).
>
> I checked with a build for mostly supported architecture:
> aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabhi, i686-linux-gnu,
> ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu,
> mips{64,64n32}-linux-gnu, nios2-linux-gnu, powerpc{64,64le}-linux-gnu,
> s390{x}-linux-gnu, sh4-linux-gnu{-soft}, tile{pro,gx}-linux-gnu{-32},
> sparc{v9,64}-linux-gnu, and x86_64-linux-gnu.
>
> I also run a full make check on real hardware on aarch64-linux-gnu,
> arm-linux-gnueabihf, i686-linux-gnu, powerpc{64le}-linux-gnu,
> sparc{v9,64}-linux-gnu, and x86_64-linux-gnu{-x32}.
>
> Adhemerval Zanella (14):
> Consolidate non cancellable open call
> Consolidate non cancellable read call
> Consolidate non cancellable write call
> Consolidate non cancellable openat call
> Consolidate non cancellable close call
> Consolidate non cancellable writev call
> Consolidate non cancellable fcntl call
> Consolidate non cancellable waitpid call
> Consolidate non cancellable pause call
> Consolidate non cancellable nanosleep call
> Remove non cancellable sigsuspend definition
> Fix {INLINE,INTERNAL}_SYSCALL macros for x32
> Remove p{read,write}{v} and fallocate from x86 auto-generation list
> Remove cancellation support for syscall generation
>
> ChangeLog | 462 +++++++++++++++++++++
> catgets/open_catalog.c | 8 +-
> csu/check_fds.c | 2 +-
> gmon/gmon.c | 22 +-
> iconv/gconv_cache.c | 6 +-
> intl/loadmsgcat.c | 6 +-
> io/ftw.c | 8 +-
> libio/fileops.c | 12 +-
> libio/iopopen.c | 4 +-
> locale/loadarchive.c | 10 +-
> locale/loadlocale.c | 12 +-
> login/utmp_file.c | 30 +-
> misc/daemon.c | 6 +-
> nptl/pthread_mutex_lock.c | 2 +-
> nptl/pthread_mutex_timedlock.c | 2 +-
> nscd/nscd_getai.c | 2 +-
> nscd/nscd_getgr_r.c | 2 +-
> nscd/nscd_gethst_r.c | 2 +-
> nscd/nscd_getpw_r.c | 2 +-
> nscd/nscd_getserv_r.c | 2 +-
> nscd/nscd_helper.c | 4 +-
> nscd/nscd_initgroups.c | 2 +-
> nscd/nscd_netgroup.c | 4 +-
> nss/nss_db/db-open.c | 4 +-
> resolv/herror.c | 2 +-
> resolv/res-close.c | 4 +-
> stdio-common/psiginfo.c | 2 +-
> sunrpc/pm_getmaps.c | 2 +-
> sysdeps/generic/not-cancel.h | 40 +-
> sysdeps/mach/hurd/opendir.c | 4 +-
> sysdeps/posix/closedir.c | 2 +-
> sysdeps/posix/getaddrinfo.c | 4 +-
> sysdeps/posix/getcwd.c | 8 +-
> sysdeps/posix/libc_fatal.c | 2 +-
> sysdeps/posix/opendir.c | 12 +-
> sysdeps/posix/spawni.c | 10 +-
> sysdeps/unix/make-syscalls.sh | 4 -
> sysdeps/unix/syscall-template.S | 7 +-
> sysdeps/unix/sysv/linux/Versions | 2 +
> sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h | 87 +---
> sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h | 131 +-----
> sysdeps/unix/sysv/linux/arm/sysdep-cancel.h | 197 +--------
> sysdeps/unix/sysv/linux/check_native.c | 2 +-
> sysdeps/unix/sysv/linux/check_pf.c | 2 +-
> sysdeps/unix/sysv/linux/close.c | 8 +
> sysdeps/unix/sysv/linux/fips-private.h | 6 +-
> sysdeps/unix/sysv/linux/gethostid.c | 12 +-
> sysdeps/unix/sysv/linux/getloadavg.c | 6 +-
> sysdeps/unix/sysv/linux/getlogin_r.c | 6 +-
> sysdeps/unix/sysv/linux/getsysstats.c | 16 +-
> sysdeps/unix/sysv/linux/grantpt.c | 6 +-
> sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h | 236 +----------
> sysdeps/unix/sysv/linux/i386/smp.h | 6 +-
> sysdeps/unix/sysv/linux/i386/sysdep-cancel.h | 119 +-----
> sysdeps/unix/sysv/linux/ia64/has_cpuclock.c | 6 +-
> sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h | 194 +--------
> sysdeps/unix/sysv/linux/if_index.c | 6 +-
> sysdeps/unix/sysv/linux/libc_fatal.c | 10 +-
> sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h | 108 +----
> sysdeps/unix/sysv/linux/malloc-sysdep.h | 8 +-
> sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h | 116 +-----
> .../unix/sysv/linux/mips/mips64/sysdep-cancel.h | 249 -----------
> sysdeps/unix/sysv/linux/mips/sysdep-cancel.h | 159 +------
> sysdeps/unix/sysv/linux/mq_notify.c | 2 +-
> sysdeps/unix/sysv/linux/nanosleep.c | 9 +
> sysdeps/unix/sysv/linux/nios2/sysdep-cancel.h | 110 +----
> sysdeps/unix/sysv/linux/not-cancel.h | 118 +++---
> sysdeps/unix/sysv/linux/open.c | 18 +
> sysdeps/unix/sysv/linux/open64.c | 35 +-
> sysdeps/unix/sysv/linux/openat.c | 16 +
> sysdeps/unix/sysv/linux/openat64.c | 32 +-
> sysdeps/unix/sysv/linux/pause.c | 14 +-
> sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c | 2 +-
> .../sysv/linux/powerpc/powerpc32/sysdep-cancel.h | 118 ------
> .../sysv/linux/powerpc/powerpc64/sysdep-cancel.h | 147 -------
> sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h | 38 ++
> sysdeps/unix/sysv/linux/pthread_getname.c | 6 +-
> sysdeps/unix/sysv/linux/pthread_setname.c | 6 +-
> sysdeps/unix/sysv/linux/read.c | 8 +
> .../unix/sysv/linux/s390/s390-32/sysdep-cancel.h | 105 +----
> .../unix/sysv/linux/s390/s390-64/sysdep-cancel.h | 109 +----
> sysdeps/unix/sysv/linux/sh/sysdep-cancel.h | 136 +-----
> .../unix/sysv/linux/sparc/sparc32/sysdep-cancel.h | 111 -----
> .../unix/sysv/linux/sparc/sparc64/sysdep-cancel.h | 109 -----
> sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h | 38 ++
> sysdeps/unix/sysv/linux/spawni.c | 8 +-
> sysdeps/unix/sysv/linux/sysconf.c | 6 +-
> sysdeps/unix/sysv/linux/tile/sysdep-cancel.h | 123 +-----
> sysdeps/unix/sysv/linux/waitpid.c | 15 +-
> sysdeps/unix/sysv/linux/write.c | 8 +
> sysdeps/unix/sysv/linux/x86_64/syscalls.list | 4 -
> sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h | 62 +--
> sysdeps/unix/sysv/linux/x86_64/sysdep.h | 251 ++++++-----
> sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list | 1 -
> sysdeps/unix/sysv/linux/x86_64/x32/times.c | 24 +-
> 95 files changed, 1129 insertions(+), 3077 deletions(-)
> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
> delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h
> delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h
> create mode 100644 sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h
> delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/sysdep-cancel.h
> delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/sysdep-cancel.h
> create mode 100644 sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h
>
^ permalink raw reply [flat|nested] 21+ messages in thread