* [PATCH 5/5] Remove cancellation support for syscall generation
2017-05-23 18:26 [PATCH 0/5] Remove sysdep-cancel assembly macro Adhemerval Zanella
2017-05-23 18:26 ` [PATCH 4/5] Consolidate Linux fcntl implementation Adhemerval Zanella
@ 2017-05-23 18:26 ` Adhemerval Zanella
2017-05-23 18:26 ` [PATCH 2/5] Remove p{read,write}{v} and fallocate from x86 auto-generation list Adhemerval Zanella
` (3 subsequent siblings)
5 siblings, 0 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2017-05-23 18:26 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] 19+ messages in thread
* [PATCH 4/5] Consolidate Linux fcntl implementation
2017-05-23 18:26 [PATCH 0/5] Remove sysdep-cancel assembly macro Adhemerval Zanella
@ 2017-05-23 18:26 ` Adhemerval Zanella
2017-06-29 14:15 ` Adhemerval Zanella
2017-06-29 15:01 ` Andreas Schwab
2017-05-23 18:26 ` [PATCH 5/5] Remove cancellation support for syscall generation Adhemerval Zanella
` (4 subsequent siblings)
5 siblings, 2 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2017-05-23 18:26 UTC (permalink / raw)
To: libc-alpha
This patch consolidates the fcntl Linux syscall generation on
sysdeps/unix/sysv/linux/fcntl.c. It basically removes all the
architecture define implementations.
Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
aarch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.
I also did a sanity check with fcntl tests from LTP to check for
possible issue on the aforementioned architectures.
* sysdeps/unix/sysv/linux/arm/fcntl.c: Remove file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c: Likewise.
* sysdeps/unix/sysv/linux/hppa/fcntl.c: Likewise.
* sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/fcntl.c: Likewise.
* sysdeps/unix/sysv/linux/microblaze/fcntl.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/fcntl.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c: Likewise.
* sysdeps/unix/sysv/linux/sh/fcntl.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c: Likewise.
* sysdeps/unix/sysv/linux/fcntl.c: New file.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Refactor to
use default implementation.
---
ChangeLog | 16 ++++
sysdeps/unix/sysv/linux/arm/fcntl.c | 1 -
sysdeps/unix/sysv/linux/fcntl.c | 52 ++++++-------
.../unix/sysv/linux/generic/wordsize-32/fcntl.c | 86 ----------------------
sysdeps/unix/sysv/linux/hppa/fcntl.c | 1 -
sysdeps/unix/sysv/linux/i386/fcntl.c | 61 ---------------
sysdeps/unix/sysv/linux/m68k/fcntl.c | 1 -
sysdeps/unix/sysv/linux/microblaze/fcntl.c | 1 -
sysdeps/unix/sysv/linux/mips/mips32/fcntl.c | 1 -
sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c | 1 -
sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c | 1 -
sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c | 49 ++----------
sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c | 1 -
sysdeps/unix/sysv/linux/sh/fcntl.c | 1 -
sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c | 1 -
15 files changed, 50 insertions(+), 224 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/arm/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/hppa/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/i386/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/m68k/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/microblaze/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/sh/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c
diff --git a/ChangeLog b/ChangeLog
index 2928e25..bb5d320 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,21 @@
2017-05-23 Adhemerval Zanella <adhemerval.zanella@linaro.org>
+ * sysdeps/unix/sysv/linux/arm/fcntl.c: Remove file.
+ * sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c: Likewise.
+ * sysdeps/unix/sysv/linux/hppa/fcntl.c: Likewise.
+ * sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise.
+ * sysdeps/unix/sysv/linux/m68k/fcntl.c: Likewise.
+ * sysdeps/unix/sysv/linux/microblaze/fcntl.c: Likewise.
+ * sysdeps/unix/sysv/linux/mips/mips32/fcntl.c: Likewise.
+ * sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c: Likewise.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c: Likewise.
+ * sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c: Likewise.
+ * sysdeps/unix/sysv/linux/sh/fcntl.c: Likewise.
+ * sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c: Likewise.
+ * sysdeps/unix/sysv/linux/fcntl.c: New file.
+ * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Refactor to
+ use default implementation.
+
* io/Makefile (CFLAGS-sync_file_range.c): Remove rule.
* sysdeps/unix/sysv/linux/Makefile (CFLAGS-sync_file_range.c): New
rule.
diff --git a/sysdeps/unix/sysv/linux/arm/fcntl.c b/sysdeps/unix/sysv/linux/arm/fcntl.c
deleted file mode 100644
index ea951bc..0000000
--- a/sysdeps/unix/sysv/linux/arm/fcntl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c
index 02f3252..76e846c 100644
--- a/sysdeps/unix/sysv/linux/fcntl.c
+++ b/sysdeps/unix/sysv/linux/fcntl.c
@@ -15,31 +15,36 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <assert.h>
-#include <errno.h>
-#include <sysdep-cancel.h> /* Must come before <fcntl.h>. */
#include <fcntl.h>
#include <stdarg.h>
+#include <errno.h>
+#include <sysdep-cancel.h>
-#include <sys/syscall.h>
+#ifndef __NR_fcntl64
+# define __NR_fcntl64 __NR_fcntl
+#endif
+#ifndef FCNTL_ADJUST_CMD
+# define FCNTL_ADJUST_CMD(__cmd) __cmd
+#endif
static int
-do_fcntl (int fd, int cmd, void *arg)
+fcntl_common (int fd, int cmd, void *arg)
{
- if (cmd != F_GETOWN)
- return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
-
- INTERNAL_SYSCALL_DECL (err);
- struct f_owner_ex fex;
- int res = INTERNAL_SYSCALL (fcntl, err, 3, fd, F_GETOWN_EX, &fex);
- if (!INTERNAL_SYSCALL_ERROR_P (res, err))
- return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
-
- return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res,
+ if (cmd == F_GETOWN)
+ {
+ INTERNAL_SYSCALL_DECL (err);
+ struct f_owner_ex fex;
+ int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex);
+ if (!INTERNAL_SYSCALL_ERROR_P (res, err))
+ return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
+
+ return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res,
err));
-}
+ }
+ return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg);
+}
#ifndef NO_CANCELLATION
int
@@ -52,11 +57,10 @@ __fcntl_nocancel (int fd, int cmd, ...)
arg = va_arg (ap, void *);
va_end (ap);
- return do_fcntl (fd, cmd, arg);
+ return fcntl_common (fd, cmd, arg);
}
#endif
-
int
__libc_fcntl (int fd, int cmd, ...)
{
@@ -67,16 +71,12 @@ __libc_fcntl (int fd, int cmd, ...)
arg = va_arg (ap, void *);
va_end (ap);
- if (SINGLE_THREAD_P || cmd != F_SETLKW)
- return do_fcntl (fd, cmd, arg);
-
- int oldtype = LIBC_CANCEL_ASYNC ();
-
- int result = do_fcntl (fd, cmd, arg);
+ cmd = FCNTL_ADJUST_CMD (cmd);
- LIBC_CANCEL_RESET (oldtype);
+ if (cmd == F_SETLKW || cmd == F_SETLKW64)
+ return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg);
- return result;
+ return fcntl_common (fd, cmd, arg);
}
libc_hidden_def (__libc_fcntl)
diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c
deleted file mode 100644
index 20399f9..0000000
--- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
-
- 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 <assert.h>
-#include <errno.h>
-#include <sysdep-cancel.h> /* Must come before <fcntl.h>. */
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <sys/syscall.h>
-
-
-static int
-do_fcntl (int fd, int cmd, void *arg)
-{
- if (cmd != F_GETOWN)
- return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
-
- INTERNAL_SYSCALL_DECL (err);
- struct f_owner_ex fex;
- int res = INTERNAL_SYSCALL (fcntl64, err, 3, fd, F_GETOWN_EX, &fex);
- if (!INTERNAL_SYSCALL_ERROR_P (res, err))
- return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
-
- __set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
- return -1;
-}
-
-
-#ifndef NO_CANCELLATION
-int
-__fcntl_nocancel (int fd, int cmd, ...)
-{
- va_list ap;
- void *arg;
-
- va_start (ap, cmd);
- arg = va_arg (ap, void *);
- va_end (ap);
-
- return do_fcntl (fd, cmd, arg);
-}
-#endif
-
-
-int
-__libc_fcntl (int fd, int cmd, ...)
-{
- va_list ap;
- void *arg;
-
- va_start (ap, cmd);
- arg = va_arg (ap, void *);
- va_end (ap);
-
- if (SINGLE_THREAD_P || cmd != F_SETLKW)
- return do_fcntl (fd, cmd, arg);
-
- int oldtype = LIBC_CANCEL_ASYNC ();
-
- int result = do_fcntl (fd, cmd, arg);
-
- LIBC_CANCEL_RESET (oldtype);
-
- return result;
-}
-libc_hidden_def (__libc_fcntl)
-
-weak_alias (__libc_fcntl, __fcntl)
-libc_hidden_weak (__fcntl)
-weak_alias (__libc_fcntl, fcntl)
diff --git a/sysdeps/unix/sysv/linux/hppa/fcntl.c b/sysdeps/unix/sysv/linux/hppa/fcntl.c
deleted file mode 100644
index ea951bc..0000000
--- a/sysdeps/unix/sysv/linux/hppa/fcntl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/sysdeps/unix/sysv/linux/i386/fcntl.c b/sysdeps/unix/sysv/linux/i386/fcntl.c
deleted file mode 100644
index b0a5783..0000000
--- a/sysdeps/unix/sysv/linux/i386/fcntl.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Copyright (C) 2000-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 <assert.h>
-#include <errno.h>
-#include <sysdep-cancel.h> /* Must come before <fcntl.h>. */
-#include <fcntl.h>
-#include <stdarg.h>
-
-#include <sys/syscall.h>
-
-#ifndef NO_CANCELLATION
-int
-__fcntl_nocancel (int fd, int cmd, ...)
-{
- va_list ap;
- void *arg;
-
- va_start (ap, cmd);
- arg = va_arg (ap, void *);
- va_end (ap);
-
- return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
-}
-#endif /* NO_CANCELLATION */
-
-
-int
-__libc_fcntl (int fd, int cmd, ...)
-{
- va_list ap;
- void *arg;
-
- va_start (ap, cmd);
- arg = va_arg (ap, void *);
- va_end (ap);
-
- if ((cmd != F_SETLKW) && (cmd != F_SETLKW64))
- return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
-
- return SYSCALL_CANCEL (fcntl64, fd, cmd, arg);
-}
-libc_hidden_def (__libc_fcntl)
-
-weak_alias (__libc_fcntl, __fcntl)
-libc_hidden_weak (__fcntl)
-weak_alias (__libc_fcntl, fcntl)
diff --git a/sysdeps/unix/sysv/linux/m68k/fcntl.c b/sysdeps/unix/sysv/linux/m68k/fcntl.c
deleted file mode 100644
index ea951bc..0000000
--- a/sysdeps/unix/sysv/linux/m68k/fcntl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/sysdeps/unix/sysv/linux/microblaze/fcntl.c b/sysdeps/unix/sysv/linux/microblaze/fcntl.c
deleted file mode 100644
index ea951bc..0000000
--- a/sysdeps/unix/sysv/linux/microblaze/fcntl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fcntl.c b/sysdeps/unix/sysv/linux/mips/mips32/fcntl.c
deleted file mode 100644
index ea951bc..0000000
--- a/sysdeps/unix/sysv/linux/mips/mips32/fcntl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c b/sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c
deleted file mode 100644
index ea951bc..0000000
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c
deleted file mode 100644
index ea951bc..0000000
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c
index 85ae8a2..d382d08 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c
@@ -15,51 +15,18 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <assert.h>
-#include <errno.h>
-#include <sysdep-cancel.h> /* Must come before <fcntl.h>. */
+#include <unistd.h>
#include <fcntl.h>
-#include <stdarg.h>
-#include <sys/syscall.h>
-
-
-#ifndef NO_CANCELLATION
-int
-__fcntl_nocancel (int fd, int cmd, ...)
+static inline int
+__libc_fcntl_adjust_cmd (int cmd)
{
- va_list ap;
- void *arg;
-
- va_start (ap, cmd);
- arg = va_arg (ap, void *);
- va_end (ap);
-
- return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
-}
-#endif
-
-
-int
-__libc_fcntl (int fd, int cmd, ...)
-{
- va_list ap;
- void *arg;
-
- va_start (ap, cmd);
- arg = va_arg (ap, void *);
- va_end (ap);
-
if (cmd >= F_GETLK64 && cmd <= F_SETLKW64)
cmd -= F_GETLK64 - F_GETLK;
-
- if (cmd != F_SETLKW)
- return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
-
- return SYSCALL_CANCEL (fcntl, fd, cmd, arg);
+ return cmd;
}
-libc_hidden_def (__libc_fcntl)
-weak_alias (__libc_fcntl, __fcntl)
-libc_hidden_weak (__fcntl)
-weak_alias (__libc_fcntl, fcntl)
+#define FCNTL_ADJUST_CMD(__cmd) \
+ __libc_fcntl_adjust_cmd (__cmd)
+
+#include <sysdeps/unix/sysv/linux/fcntl.c>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c b/sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c
deleted file mode 100644
index ea951bc..0000000
--- a/sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/sysdeps/unix/sysv/linux/sh/fcntl.c b/sysdeps/unix/sysv/linux/sh/fcntl.c
deleted file mode 100644
index ea951bc..0000000
--- a/sysdeps/unix/sysv/linux/sh/fcntl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c b/sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c
deleted file mode 100644
index ea951bc..0000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
--
2.7.4
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 3/5] linux: Consolidate sync_file_range implementation
2017-05-23 18:26 [PATCH 0/5] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (3 preceding siblings ...)
2017-05-23 18:26 ` [PATCH 1/5] Fix {INLINE,INTERNAL}_SYSCALL macros for x32 Adhemerval Zanella
@ 2017-05-23 18:26 ` Adhemerval Zanella
2017-06-15 18:46 ` Adhemerval Zanella
2017-06-02 12:51 ` [PATCH 0/5] Remove sysdep-cancel assembly macro Adhemerval Zanella
5 siblings, 1 reply; 19+ messages in thread
From: Adhemerval Zanella @ 2017-05-23 18:26 UTC (permalink / raw)
To: libc-alpha
This patch consolidates Linux sync_file_range at default
sysdeps/unix/sysv/linux/sync_file_range.c implementation. It also
moves the rules flags from generic io/Makefile to Linux one due the
fact it is a Linux-only symbol.
Checked on i686-linux-gnu and x86_64-linux-gnu.
* io/Makefile (CFLAGS-sync_file_range.c): Remove rule.
* sysdeps/unix/sysv/linux/Makefile (CFLAGS-sync_file_range.c): New
rule.
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Remove
sync_file_range.
---
ChangeLog | 6 ++++++
io/Makefile | 1 -
sysdeps/unix/sysv/linux/Makefile | 1 +
sysdeps/unix/sysv/linux/wordsize-64/syscalls.list | 1 -
4 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/io/Makefile b/io/Makefile
index 16365e5..2f26bf5 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -99,7 +99,6 @@ CFLAGS-posix_fallocate.c = -fexceptions
CFLAGS-posix_fallocate64.c = -fexceptions
CFLAGS-fallocate.c = -fexceptions
CFLAGS-fallocate64.c = -fexceptions
-CFLAGS-sync_file_range.c = -fexceptions
CFLAGS-read.c = -fexceptions
CFLAGS-write.c = -fexceptions
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index 99b3f9d..1a170c2 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -25,6 +25,7 @@ CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-vmsplice.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-splice.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-open_by_handle_at.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-sync_file_range.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=(0x80000000-sysconf(_SC_PAGESIZE))"
# Note that bits/mman-linux.h is listed here though the file lives in the
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
index 5c78677..4bb7ebf 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
@@ -4,7 +4,6 @@ fstatfs - fstatfs i:ip __fstatfs fstatfs fstatfs64 __fstatfs64
statfs - statfs i:sp __statfs statfs statfs64
readahead - readahead i:iii __readahead readahead
sendfile - sendfile i:iipi sendfile sendfile64
-sync_file_range - sync_file_range Ci:iiii sync_file_range
prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
--
2.7.4
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 0/5] Remove sysdep-cancel assembly macro
@ 2017-05-23 18:26 Adhemerval Zanella
2017-05-23 18:26 ` [PATCH 4/5] Consolidate Linux fcntl implementation Adhemerval Zanella
` (5 more replies)
0 siblings, 6 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2017-05-23 18:26 UTC (permalink / raw)
To: libc-alpha
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 (5):
Fix {INLINE,INTERNAL}_SYSCALL macros for x32
Remove p{read,write}{v} and fallocate from x86 auto-generation list
linux: Consolidate sync_file_range implementation
Consolidate Linux fcntl implementation
Remove cancellation support for syscall generation
ChangeLog | 250 ++++++++++++++++++++
io/Makefile | 1 -
sysdeps/unix/make-syscalls.sh | 4 -
sysdeps/unix/syscall-template.S | 7 +-
sysdeps/unix/sysv/linux/Makefile | 1 +
sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h | 87 +------
sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h | 131 +----------
sysdeps/unix/sysv/linux/arm/fcntl.c | 1 -
sysdeps/unix/sysv/linux/arm/sysdep-cancel.h | 197 +---------------
sysdeps/unix/sysv/linux/fcntl.c | 52 ++---
.../unix/sysv/linux/generic/wordsize-32/fcntl.c | 86 -------
sysdeps/unix/sysv/linux/hppa/fcntl.c | 1 -
sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h | 236 +------------------
sysdeps/unix/sysv/linux/i386/fcntl.c | 61 -----
sysdeps/unix/sysv/linux/i386/sysdep-cancel.h | 119 +---------
sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h | 194 +---------------
sysdeps/unix/sysv/linux/m68k/fcntl.c | 1 -
sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h | 108 +--------
sysdeps/unix/sysv/linux/microblaze/fcntl.c | 1 -
sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h | 116 +---------
sysdeps/unix/sysv/linux/mips/mips32/fcntl.c | 1 -
sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c | 1 -
.../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 +--------
sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c | 1 -
.../sysv/linux/powerpc/powerpc32/sysdep-cancel.h | 118 ----------
sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c | 49 +---
.../sysv/linux/powerpc/powerpc64/sysdep-cancel.h | 147 ------------
sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h | 38 ++++
sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c | 1 -
.../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/fcntl.c | 1 -
sysdeps/unix/sysv/linux/sh/sysdep-cancel.h | 136 +----------
sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c | 1 -
.../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/wordsize-64/syscalls.list | 1 -
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 +-
46 files changed, 572 insertions(+), 3032 deletions(-)
delete mode 100644 sysdeps/unix/sysv/linux/arm/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/hppa/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/i386/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/m68k/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/microblaze/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c
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/s390/s390-32/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/sh/fcntl.c
delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c
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
--
2.7.4
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/5] Fix {INLINE,INTERNAL}_SYSCALL macros for x32
2017-05-23 18:26 [PATCH 0/5] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (2 preceding siblings ...)
2017-05-23 18:26 ` [PATCH 2/5] Remove p{read,write}{v} and fallocate from x86 auto-generation list Adhemerval Zanella
@ 2017-05-23 18:26 ` Adhemerval Zanella
2017-06-29 14:15 ` Adhemerval Zanella
2017-07-01 16:53 ` H.J. Lu
2017-05-23 18:26 ` [PATCH 3/5] linux: Consolidate sync_file_range implementation Adhemerval Zanella
2017-06-02 12:51 ` [PATCH 0/5] Remove sysdep-cancel assembly macro Adhemerval Zanella
5 siblings, 2 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2017-05-23 18:26 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 | 50 ++++++
sysdeps/unix/sysv/linux/x86_64/sysdep.h | 251 ++++++++++++++++-------------
sysdeps/unix/sysv/linux/x86_64/x32/times.c | 24 +--
3 files changed, 205 insertions(+), 120 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index 7b8bd79..6d0a6f4 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] 19+ messages in thread
* [PATCH 2/5] Remove p{read,write}{v} and fallocate from x86 auto-generation list
2017-05-23 18:26 [PATCH 0/5] Remove sysdep-cancel assembly macro Adhemerval Zanella
2017-05-23 18:26 ` [PATCH 4/5] Consolidate Linux fcntl implementation Adhemerval Zanella
2017-05-23 18:26 ` [PATCH 5/5] Remove cancellation support for syscall generation Adhemerval Zanella
@ 2017-05-23 18:26 ` Adhemerval Zanella
2017-06-29 14:15 ` Adhemerval Zanella
2017-05-23 18:26 ` [PATCH 1/5] Fix {INLINE,INTERNAL}_SYSCALL macros for x32 Adhemerval Zanella
` (2 subsequent siblings)
5 siblings, 1 reply; 19+ messages in thread
From: Adhemerval Zanella @ 2017-05-23 18:26 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] 19+ messages in thread
* Re: [PATCH 0/5] Remove sysdep-cancel assembly macro
2017-05-23 18:26 [PATCH 0/5] Remove sysdep-cancel assembly macro Adhemerval Zanella
` (4 preceding siblings ...)
2017-05-23 18:26 ` [PATCH 3/5] linux: Consolidate sync_file_range implementation Adhemerval Zanella
@ 2017-06-02 12:51 ` Adhemerval Zanella
2017-06-13 14:31 ` Adhemerval Zanella
5 siblings, 1 reply; 19+ messages in thread
From: Adhemerval Zanella @ 2017-06-02 12:51 UTC (permalink / raw)
To: libc-alpha
Ping.
On 23/05/2017 15:25, Adhemerval Zanella wrote:
> 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 (5):
> Fix {INLINE,INTERNAL}_SYSCALL macros for x32
> Remove p{read,write}{v} and fallocate from x86 auto-generation list
> linux: Consolidate sync_file_range implementation
> Consolidate Linux fcntl implementation
> Remove cancellation support for syscall generation
>
> ChangeLog | 250 ++++++++++++++++++++
> io/Makefile | 1 -
> sysdeps/unix/make-syscalls.sh | 4 -
> sysdeps/unix/syscall-template.S | 7 +-
> sysdeps/unix/sysv/linux/Makefile | 1 +
> sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h | 87 +------
> sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h | 131 +----------
> sysdeps/unix/sysv/linux/arm/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/arm/sysdep-cancel.h | 197 +---------------
> sysdeps/unix/sysv/linux/fcntl.c | 52 ++---
> .../unix/sysv/linux/generic/wordsize-32/fcntl.c | 86 -------
> sysdeps/unix/sysv/linux/hppa/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h | 236 +------------------
> sysdeps/unix/sysv/linux/i386/fcntl.c | 61 -----
> sysdeps/unix/sysv/linux/i386/sysdep-cancel.h | 119 +---------
> sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h | 194 +---------------
> sysdeps/unix/sysv/linux/m68k/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h | 108 +--------
> sysdeps/unix/sysv/linux/microblaze/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h | 116 +---------
> sysdeps/unix/sysv/linux/mips/mips32/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c | 1 -
> .../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 +--------
> sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c | 1 -
> .../sysv/linux/powerpc/powerpc32/sysdep-cancel.h | 118 ----------
> sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c | 49 +---
> .../sysv/linux/powerpc/powerpc64/sysdep-cancel.h | 147 ------------
> sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h | 38 ++++
> sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c | 1 -
> .../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/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/sh/sysdep-cancel.h | 136 +----------
> sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c | 1 -
> .../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/wordsize-64/syscalls.list | 1 -
> 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 +-
> 46 files changed, 572 insertions(+), 3032 deletions(-)
> delete mode 100644 sysdeps/unix/sysv/linux/arm/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/hppa/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/i386/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/m68k/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/microblaze/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
> delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c
> 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/s390/s390-32/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/sh/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c
> 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] 19+ messages in thread
* Re: [PATCH 0/5] Remove sysdep-cancel assembly macro
2017-06-02 12:51 ` [PATCH 0/5] Remove sysdep-cancel assembly macro Adhemerval Zanella
@ 2017-06-13 14:31 ` Adhemerval Zanella
2017-06-29 14:16 ` Adhemerval Zanella
0 siblings, 1 reply; 19+ messages in thread
From: Adhemerval Zanella @ 2017-06-13 14:31 UTC (permalink / raw)
To: libc-alpha
Ping (x2).
On 02/06/2017 09:51, Adhemerval Zanella wrote:
> Ping.
>
> On 23/05/2017 15:25, Adhemerval Zanella wrote:
>> 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 (5):
>> Fix {INLINE,INTERNAL}_SYSCALL macros for x32
>> Remove p{read,write}{v} and fallocate from x86 auto-generation list
>> linux: Consolidate sync_file_range implementation
>> Consolidate Linux fcntl implementation
>> Remove cancellation support for syscall generation
>>
>> ChangeLog | 250 ++++++++++++++++++++
>> io/Makefile | 1 -
>> sysdeps/unix/make-syscalls.sh | 4 -
>> sysdeps/unix/syscall-template.S | 7 +-
>> sysdeps/unix/sysv/linux/Makefile | 1 +
>> sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h | 87 +------
>> sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h | 131 +----------
>> sysdeps/unix/sysv/linux/arm/fcntl.c | 1 -
>> sysdeps/unix/sysv/linux/arm/sysdep-cancel.h | 197 +---------------
>> sysdeps/unix/sysv/linux/fcntl.c | 52 ++---
>> .../unix/sysv/linux/generic/wordsize-32/fcntl.c | 86 -------
>> sysdeps/unix/sysv/linux/hppa/fcntl.c | 1 -
>> sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h | 236 +------------------
>> sysdeps/unix/sysv/linux/i386/fcntl.c | 61 -----
>> sysdeps/unix/sysv/linux/i386/sysdep-cancel.h | 119 +---------
>> sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h | 194 +---------------
>> sysdeps/unix/sysv/linux/m68k/fcntl.c | 1 -
>> sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h | 108 +--------
>> sysdeps/unix/sysv/linux/microblaze/fcntl.c | 1 -
>> sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h | 116 +---------
>> sysdeps/unix/sysv/linux/mips/mips32/fcntl.c | 1 -
>> sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c | 1 -
>> .../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 +--------
>> sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c | 1 -
>> .../sysv/linux/powerpc/powerpc32/sysdep-cancel.h | 118 ----------
>> sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c | 49 +---
>> .../sysv/linux/powerpc/powerpc64/sysdep-cancel.h | 147 ------------
>> sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h | 38 ++++
>> sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c | 1 -
>> .../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/fcntl.c | 1 -
>> sysdeps/unix/sysv/linux/sh/sysdep-cancel.h | 136 +----------
>> sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c | 1 -
>> .../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/wordsize-64/syscalls.list | 1 -
>> 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 +-
>> 46 files changed, 572 insertions(+), 3032 deletions(-)
>> delete mode 100644 sysdeps/unix/sysv/linux/arm/fcntl.c
>> delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c
>> delete mode 100644 sysdeps/unix/sysv/linux/hppa/fcntl.c
>> delete mode 100644 sysdeps/unix/sysv/linux/i386/fcntl.c
>> delete mode 100644 sysdeps/unix/sysv/linux/m68k/fcntl.c
>> delete mode 100644 sysdeps/unix/sysv/linux/microblaze/fcntl.c
>> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/fcntl.c
>> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c
>> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
>> delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c
>> 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/s390/s390-32/fcntl.c
>> delete mode 100644 sysdeps/unix/sysv/linux/sh/fcntl.c
>> delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c
>> 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] 19+ messages in thread
* Re: [PATCH 3/5] linux: Consolidate sync_file_range implementation
2017-05-23 18:26 ` [PATCH 3/5] linux: Consolidate sync_file_range implementation Adhemerval Zanella
@ 2017-06-15 18:46 ` Adhemerval Zanella
0 siblings, 0 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2017-06-15 18:46 UTC (permalink / raw)
To: libc-alpha
On 23/05/2017 15:25, Adhemerval Zanella wrote:
> This patch consolidates Linux sync_file_range at default
> sysdeps/unix/sysv/linux/sync_file_range.c implementation. It also
> moves the rules flags from generic io/Makefile to Linux one due the
> fact it is a Linux-only symbol.
>
> Checked on i686-linux-gnu and x86_64-linux-gnu.
>
> * io/Makefile (CFLAGS-sync_file_range.c): Remove rule.
> * sysdeps/unix/sysv/linux/Makefile (CFLAGS-sync_file_range.c): New
> rule.
> * sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Remove
> sync_file_range.
This patch is straightforward and follow the other consolidation I have
done. I will push this soon.
> ---
> ChangeLog | 6 ++++++
> io/Makefile | 1 -
> sysdeps/unix/sysv/linux/Makefile | 1 +
> sysdeps/unix/sysv/linux/wordsize-64/syscalls.list | 1 -
> 4 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/io/Makefile b/io/Makefile
> index 16365e5..2f26bf5 100644
> --- a/io/Makefile
> +++ b/io/Makefile
> @@ -99,7 +99,6 @@ CFLAGS-posix_fallocate.c = -fexceptions
> CFLAGS-posix_fallocate64.c = -fexceptions
> CFLAGS-fallocate.c = -fexceptions
> CFLAGS-fallocate64.c = -fexceptions
> -CFLAGS-sync_file_range.c = -fexceptions
> CFLAGS-read.c = -fexceptions
> CFLAGS-write.c = -fexceptions
>
> diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
> index 99b3f9d..1a170c2 100644
> --- a/sysdeps/unix/sysv/linux/Makefile
> +++ b/sysdeps/unix/sysv/linux/Makefile
> @@ -25,6 +25,7 @@ CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
> CFLAGS-vmsplice.c = -fexceptions -fasynchronous-unwind-tables
> CFLAGS-splice.c = -fexceptions -fasynchronous-unwind-tables
> CFLAGS-open_by_handle_at.c = -fexceptions -fasynchronous-unwind-tables
> +CFLAGS-sync_file_range.c = -fexceptions -fasynchronous-unwind-tables
> CFLAGS-tst-writev.c += "-DARTIFICIAL_LIMIT=(0x80000000-sysconf(_SC_PAGESIZE))"
>
> # Note that bits/mman-linux.h is listed here though the file lives in the
> diff --git a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> index 5c78677..4bb7ebf 100644
> --- a/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list
> @@ -4,7 +4,6 @@ fstatfs - fstatfs i:ip __fstatfs fstatfs fstatfs64 __fstatfs64
> statfs - statfs i:sp __statfs statfs statfs64
> readahead - readahead i:iii __readahead readahead
> sendfile - sendfile i:iipi sendfile sendfile64
> -sync_file_range - sync_file_range Ci:iiii sync_file_range
> prlimit EXTRA prlimit64 i:iipp prlimit prlimit64
>
> fanotify_mark EXTRA fanotify_mark i:iiiis fanotify_mark
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/5] Remove p{read,write}{v} and fallocate from x86 auto-generation list
2017-05-23 18:26 ` [PATCH 2/5] Remove p{read,write}{v} and fallocate from x86 auto-generation list Adhemerval Zanella
@ 2017-06-29 14:15 ` Adhemerval Zanella
0 siblings, 0 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2017-06-29 14:15 UTC (permalink / raw)
To: libc-alpha
Ping, x86 is the only target AFAIK preventing the sysdep-cancel asm
macro removal.
On 23/05/2017 15:25, Adhemerval Zanella wrote:
> 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
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/5] Fix {INLINE,INTERNAL}_SYSCALL macros for x32
2017-05-23 18:26 ` [PATCH 1/5] Fix {INLINE,INTERNAL}_SYSCALL macros for x32 Adhemerval Zanella
@ 2017-06-29 14:15 ` Adhemerval Zanella
2017-06-29 18:51 ` Florian Weimer
2017-07-01 16:53 ` H.J. Lu
1 sibling, 1 reply; 19+ messages in thread
From: Adhemerval Zanella @ 2017-06-29 14:15 UTC (permalink / raw)
To: libc-alpha
Ping, x86 is the only target AFAIK preventing the sysdep-cancel asm
macro removal.
On 23/05/2017 15:25, Adhemerval Zanella 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.
> ---
> ChangeLog | 50 ++++++
> sysdeps/unix/sysv/linux/x86_64/sysdep.h | 251 ++++++++++++++++-------------
> sysdeps/unix/sysv/linux/x86_64/x32/times.c | 24 +--
> 3 files changed, 205 insertions(+), 120 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
> index 7b8bd79..6d0a6f4 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) \
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 4/5] Consolidate Linux fcntl implementation
2017-05-23 18:26 ` [PATCH 4/5] Consolidate Linux fcntl implementation Adhemerval Zanella
@ 2017-06-29 14:15 ` Adhemerval Zanella
2017-06-29 15:01 ` Andreas Schwab
1 sibling, 0 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2017-06-29 14:15 UTC (permalink / raw)
To: libc-alpha
Ping.
On 23/05/2017 15:25, Adhemerval Zanella wrote:
> This patch consolidates the fcntl Linux syscall generation on
> sysdeps/unix/sysv/linux/fcntl.c. It basically removes all the
> architecture define implementations.
>
> Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
> aarch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.
>
> I also did a sanity check with fcntl tests from LTP to check for
> possible issue on the aforementioned architectures.
>
> * sysdeps/unix/sysv/linux/arm/fcntl.c: Remove file.
> * sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/hppa/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/m68k/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/microblaze/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/mips/mips32/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/sh/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/fcntl.c: New file.
> * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Refactor to
> use default implementation.
> ---
> ChangeLog | 16 ++++
> sysdeps/unix/sysv/linux/arm/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/fcntl.c | 52 ++++++-------
> .../unix/sysv/linux/generic/wordsize-32/fcntl.c | 86 ----------------------
> sysdeps/unix/sysv/linux/hppa/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/i386/fcntl.c | 61 ---------------
> sysdeps/unix/sysv/linux/m68k/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/microblaze/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/mips/mips32/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c | 49 ++----------
> sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/sh/fcntl.c | 1 -
> sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c | 1 -
> 15 files changed, 50 insertions(+), 224 deletions(-)
> delete mode 100644 sysdeps/unix/sysv/linux/arm/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/hppa/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/i386/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/m68k/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/microblaze/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/sh/fcntl.c
> delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c
>
> diff --git a/ChangeLog b/ChangeLog
> index 2928e25..bb5d320 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,5 +1,21 @@
> 2017-05-23 Adhemerval Zanella <adhemerval.zanella@linaro.org>
>
> + * sysdeps/unix/sysv/linux/arm/fcntl.c: Remove file.
> + * sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c: Likewise.
> + * sysdeps/unix/sysv/linux/hppa/fcntl.c: Likewise.
> + * sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise.
> + * sysdeps/unix/sysv/linux/m68k/fcntl.c: Likewise.
> + * sysdeps/unix/sysv/linux/microblaze/fcntl.c: Likewise.
> + * sysdeps/unix/sysv/linux/mips/mips32/fcntl.c: Likewise.
> + * sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c: Likewise.
> + * sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c: Likewise.
> + * sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c: Likewise.
> + * sysdeps/unix/sysv/linux/sh/fcntl.c: Likewise.
> + * sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c: Likewise.
> + * sysdeps/unix/sysv/linux/fcntl.c: New file.
> + * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Refactor to
> + use default implementation.
> +
> * io/Makefile (CFLAGS-sync_file_range.c): Remove rule.
> * sysdeps/unix/sysv/linux/Makefile (CFLAGS-sync_file_range.c): New
> rule.
> diff --git a/sysdeps/unix/sysv/linux/arm/fcntl.c b/sysdeps/unix/sysv/linux/arm/fcntl.c
> deleted file mode 100644
> index ea951bc..0000000
> --- a/sysdeps/unix/sysv/linux/arm/fcntl.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
> diff --git a/sysdeps/unix/sysv/linux/fcntl.c b/sysdeps/unix/sysv/linux/fcntl.c
> index 02f3252..76e846c 100644
> --- a/sysdeps/unix/sysv/linux/fcntl.c
> +++ b/sysdeps/unix/sysv/linux/fcntl.c
> @@ -15,31 +15,36 @@
> License along with the GNU C Library; if not, see
> <http://www.gnu.org/licenses/>. */
>
> -#include <assert.h>
> -#include <errno.h>
> -#include <sysdep-cancel.h> /* Must come before <fcntl.h>. */
> #include <fcntl.h>
> #include <stdarg.h>
> +#include <errno.h>
> +#include <sysdep-cancel.h>
>
> -#include <sys/syscall.h>
> +#ifndef __NR_fcntl64
> +# define __NR_fcntl64 __NR_fcntl
> +#endif
>
> +#ifndef FCNTL_ADJUST_CMD
> +# define FCNTL_ADJUST_CMD(__cmd) __cmd
> +#endif
>
> static int
> -do_fcntl (int fd, int cmd, void *arg)
> +fcntl_common (int fd, int cmd, void *arg)
> {
> - if (cmd != F_GETOWN)
> - return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
> -
> - INTERNAL_SYSCALL_DECL (err);
> - struct f_owner_ex fex;
> - int res = INTERNAL_SYSCALL (fcntl, err, 3, fd, F_GETOWN_EX, &fex);
> - if (!INTERNAL_SYSCALL_ERROR_P (res, err))
> - return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
> -
> - return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res,
> + if (cmd == F_GETOWN)
> + {
> + INTERNAL_SYSCALL_DECL (err);
> + struct f_owner_ex fex;
> + int res = INTERNAL_SYSCALL_CALL (fcntl64, err, fd, F_GETOWN_EX, &fex);
> + if (!INTERNAL_SYSCALL_ERROR_P (res, err))
> + return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
> +
> + return INLINE_SYSCALL_ERROR_RETURN_VALUE (INTERNAL_SYSCALL_ERRNO (res,
> err));
> -}
> + }
>
> + return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg);
> +}
>
> #ifndef NO_CANCELLATION
> int
> @@ -52,11 +57,10 @@ __fcntl_nocancel (int fd, int cmd, ...)
> arg = va_arg (ap, void *);
> va_end (ap);
>
> - return do_fcntl (fd, cmd, arg);
> + return fcntl_common (fd, cmd, arg);
> }
> #endif
>
> -
> int
> __libc_fcntl (int fd, int cmd, ...)
> {
> @@ -67,16 +71,12 @@ __libc_fcntl (int fd, int cmd, ...)
> arg = va_arg (ap, void *);
> va_end (ap);
>
> - if (SINGLE_THREAD_P || cmd != F_SETLKW)
> - return do_fcntl (fd, cmd, arg);
> -
> - int oldtype = LIBC_CANCEL_ASYNC ();
> -
> - int result = do_fcntl (fd, cmd, arg);
> + cmd = FCNTL_ADJUST_CMD (cmd);
>
> - LIBC_CANCEL_RESET (oldtype);
> + if (cmd == F_SETLKW || cmd == F_SETLKW64)
> + return SYSCALL_CANCEL (fcntl64, fd, cmd, (void *) arg);
>
> - return result;
> + return fcntl_common (fd, cmd, arg);
> }
> libc_hidden_def (__libc_fcntl)
>
> diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c b/sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c
> deleted file mode 100644
> index 20399f9..0000000
> --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c
> +++ /dev/null
> @@ -1,86 +0,0 @@
> -/* Copyright (C) 2011-2017 Free Software Foundation, Inc.
> - This file is part of the GNU C Library.
> - Contributed by Chris Metcalf <cmetcalf@tilera.com>, 2011.
> -
> - 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 <assert.h>
> -#include <errno.h>
> -#include <sysdep-cancel.h> /* Must come before <fcntl.h>. */
> -#include <fcntl.h>
> -#include <stdarg.h>
> -
> -#include <sys/syscall.h>
> -
> -
> -static int
> -do_fcntl (int fd, int cmd, void *arg)
> -{
> - if (cmd != F_GETOWN)
> - return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
> -
> - INTERNAL_SYSCALL_DECL (err);
> - struct f_owner_ex fex;
> - int res = INTERNAL_SYSCALL (fcntl64, err, 3, fd, F_GETOWN_EX, &fex);
> - if (!INTERNAL_SYSCALL_ERROR_P (res, err))
> - return fex.type == F_OWNER_GID ? -fex.pid : fex.pid;
> -
> - __set_errno (INTERNAL_SYSCALL_ERRNO (res, err));
> - return -1;
> -}
> -
> -
> -#ifndef NO_CANCELLATION
> -int
> -__fcntl_nocancel (int fd, int cmd, ...)
> -{
> - va_list ap;
> - void *arg;
> -
> - va_start (ap, cmd);
> - arg = va_arg (ap, void *);
> - va_end (ap);
> -
> - return do_fcntl (fd, cmd, arg);
> -}
> -#endif
> -
> -
> -int
> -__libc_fcntl (int fd, int cmd, ...)
> -{
> - va_list ap;
> - void *arg;
> -
> - va_start (ap, cmd);
> - arg = va_arg (ap, void *);
> - va_end (ap);
> -
> - if (SINGLE_THREAD_P || cmd != F_SETLKW)
> - return do_fcntl (fd, cmd, arg);
> -
> - int oldtype = LIBC_CANCEL_ASYNC ();
> -
> - int result = do_fcntl (fd, cmd, arg);
> -
> - LIBC_CANCEL_RESET (oldtype);
> -
> - return result;
> -}
> -libc_hidden_def (__libc_fcntl)
> -
> -weak_alias (__libc_fcntl, __fcntl)
> -libc_hidden_weak (__fcntl)
> -weak_alias (__libc_fcntl, fcntl)
> diff --git a/sysdeps/unix/sysv/linux/hppa/fcntl.c b/sysdeps/unix/sysv/linux/hppa/fcntl.c
> deleted file mode 100644
> index ea951bc..0000000
> --- a/sysdeps/unix/sysv/linux/hppa/fcntl.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
> diff --git a/sysdeps/unix/sysv/linux/i386/fcntl.c b/sysdeps/unix/sysv/linux/i386/fcntl.c
> deleted file mode 100644
> index b0a5783..0000000
> --- a/sysdeps/unix/sysv/linux/i386/fcntl.c
> +++ /dev/null
> @@ -1,61 +0,0 @@
> -/* Copyright (C) 2000-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 <assert.h>
> -#include <errno.h>
> -#include <sysdep-cancel.h> /* Must come before <fcntl.h>. */
> -#include <fcntl.h>
> -#include <stdarg.h>
> -
> -#include <sys/syscall.h>
> -
> -#ifndef NO_CANCELLATION
> -int
> -__fcntl_nocancel (int fd, int cmd, ...)
> -{
> - va_list ap;
> - void *arg;
> -
> - va_start (ap, cmd);
> - arg = va_arg (ap, void *);
> - va_end (ap);
> -
> - return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
> -}
> -#endif /* NO_CANCELLATION */
> -
> -
> -int
> -__libc_fcntl (int fd, int cmd, ...)
> -{
> - va_list ap;
> - void *arg;
> -
> - va_start (ap, cmd);
> - arg = va_arg (ap, void *);
> - va_end (ap);
> -
> - if ((cmd != F_SETLKW) && (cmd != F_SETLKW64))
> - return INLINE_SYSCALL (fcntl64, 3, fd, cmd, arg);
> -
> - return SYSCALL_CANCEL (fcntl64, fd, cmd, arg);
> -}
> -libc_hidden_def (__libc_fcntl)
> -
> -weak_alias (__libc_fcntl, __fcntl)
> -libc_hidden_weak (__fcntl)
> -weak_alias (__libc_fcntl, fcntl)
> diff --git a/sysdeps/unix/sysv/linux/m68k/fcntl.c b/sysdeps/unix/sysv/linux/m68k/fcntl.c
> deleted file mode 100644
> index ea951bc..0000000
> --- a/sysdeps/unix/sysv/linux/m68k/fcntl.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
> diff --git a/sysdeps/unix/sysv/linux/microblaze/fcntl.c b/sysdeps/unix/sysv/linux/microblaze/fcntl.c
> deleted file mode 100644
> index ea951bc..0000000
> --- a/sysdeps/unix/sysv/linux/microblaze/fcntl.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fcntl.c b/sysdeps/unix/sysv/linux/mips/mips32/fcntl.c
> deleted file mode 100644
> index ea951bc..0000000
> --- a/sysdeps/unix/sysv/linux/mips/mips32/fcntl.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c b/sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c
> deleted file mode 100644
> index ea951bc..0000000
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c
> deleted file mode 100644
> index ea951bc..0000000
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c
> index 85ae8a2..d382d08 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c
> @@ -15,51 +15,18 @@
> License along with the GNU C Library; if not, see
> <http://www.gnu.org/licenses/>. */
>
> -#include <assert.h>
> -#include <errno.h>
> -#include <sysdep-cancel.h> /* Must come before <fcntl.h>. */
> +#include <unistd.h>
> #include <fcntl.h>
> -#include <stdarg.h>
>
> -#include <sys/syscall.h>
> -
> -
> -#ifndef NO_CANCELLATION
> -int
> -__fcntl_nocancel (int fd, int cmd, ...)
> +static inline int
> +__libc_fcntl_adjust_cmd (int cmd)
> {
> - va_list ap;
> - void *arg;
> -
> - va_start (ap, cmd);
> - arg = va_arg (ap, void *);
> - va_end (ap);
> -
> - return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
> -}
> -#endif
> -
> -
> -int
> -__libc_fcntl (int fd, int cmd, ...)
> -{
> - va_list ap;
> - void *arg;
> -
> - va_start (ap, cmd);
> - arg = va_arg (ap, void *);
> - va_end (ap);
> -
> if (cmd >= F_GETLK64 && cmd <= F_SETLKW64)
> cmd -= F_GETLK64 - F_GETLK;
> -
> - if (cmd != F_SETLKW)
> - return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
> -
> - return SYSCALL_CANCEL (fcntl, fd, cmd, arg);
> + return cmd;
> }
> -libc_hidden_def (__libc_fcntl)
>
> -weak_alias (__libc_fcntl, __fcntl)
> -libc_hidden_weak (__fcntl)
> -weak_alias (__libc_fcntl, fcntl)
> +#define FCNTL_ADJUST_CMD(__cmd) \
> + __libc_fcntl_adjust_cmd (__cmd)
> +
> +#include <sysdeps/unix/sysv/linux/fcntl.c>
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c b/sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c
> deleted file mode 100644
> index ea951bc..0000000
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
> diff --git a/sysdeps/unix/sysv/linux/sh/fcntl.c b/sysdeps/unix/sysv/linux/sh/fcntl.c
> deleted file mode 100644
> index ea951bc..0000000
> --- a/sysdeps/unix/sysv/linux/sh/fcntl.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c b/sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c
> deleted file mode 100644
> index ea951bc..0000000
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c
> +++ /dev/null
> @@ -1 +0,0 @@
> -#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 0/5] Remove sysdep-cancel assembly macro
2017-06-13 14:31 ` Adhemerval Zanella
@ 2017-06-29 14:16 ` Adhemerval Zanella
0 siblings, 0 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2017-06-29 14:16 UTC (permalink / raw)
To: libc-alpha
Ping (x3). The main idea of this patch, apart of cancellation refactor,
is to easier new port additions and we have two new candidates for next
release (ARC and RISCV).
On 13/06/2017 11:31, Adhemerval Zanella wrote:
> Ping (x2).
>
> On 02/06/2017 09:51, Adhemerval Zanella wrote:
>> Ping.
>>
>> On 23/05/2017 15:25, Adhemerval Zanella wrote:
>>> 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 (5):
>>> Fix {INLINE,INTERNAL}_SYSCALL macros for x32
>>> Remove p{read,write}{v} and fallocate from x86 auto-generation list
>>> linux: Consolidate sync_file_range implementation
>>> Consolidate Linux fcntl implementation
>>> Remove cancellation support for syscall generation
>>>
>>> ChangeLog | 250 ++++++++++++++++++++
>>> io/Makefile | 1 -
>>> sysdeps/unix/make-syscalls.sh | 4 -
>>> sysdeps/unix/syscall-template.S | 7 +-
>>> sysdeps/unix/sysv/linux/Makefile | 1 +
>>> sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h | 87 +------
>>> sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h | 131 +----------
>>> sysdeps/unix/sysv/linux/arm/fcntl.c | 1 -
>>> sysdeps/unix/sysv/linux/arm/sysdep-cancel.h | 197 +---------------
>>> sysdeps/unix/sysv/linux/fcntl.c | 52 ++---
>>> .../unix/sysv/linux/generic/wordsize-32/fcntl.c | 86 -------
>>> sysdeps/unix/sysv/linux/hppa/fcntl.c | 1 -
>>> sysdeps/unix/sysv/linux/hppa/sysdep-cancel.h | 236 +------------------
>>> sysdeps/unix/sysv/linux/i386/fcntl.c | 61 -----
>>> sysdeps/unix/sysv/linux/i386/sysdep-cancel.h | 119 +---------
>>> sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h | 194 +---------------
>>> sysdeps/unix/sysv/linux/m68k/fcntl.c | 1 -
>>> sysdeps/unix/sysv/linux/m68k/sysdep-cancel.h | 108 +--------
>>> sysdeps/unix/sysv/linux/microblaze/fcntl.c | 1 -
>>> sysdeps/unix/sysv/linux/microblaze/sysdep-cancel.h | 116 +---------
>>> sysdeps/unix/sysv/linux/mips/mips32/fcntl.c | 1 -
>>> sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c | 1 -
>>> .../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 +--------
>>> sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c | 1 -
>>> .../sysv/linux/powerpc/powerpc32/sysdep-cancel.h | 118 ----------
>>> sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c | 49 +---
>>> .../sysv/linux/powerpc/powerpc64/sysdep-cancel.h | 147 ------------
>>> sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h | 38 ++++
>>> sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c | 1 -
>>> .../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/fcntl.c | 1 -
>>> sysdeps/unix/sysv/linux/sh/sysdep-cancel.h | 136 +----------
>>> sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c | 1 -
>>> .../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/wordsize-64/syscalls.list | 1 -
>>> 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 +-
>>> 46 files changed, 572 insertions(+), 3032 deletions(-)
>>> delete mode 100644 sysdeps/unix/sysv/linux/arm/fcntl.c
>>> delete mode 100644 sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c
>>> delete mode 100644 sysdeps/unix/sysv/linux/hppa/fcntl.c
>>> delete mode 100644 sysdeps/unix/sysv/linux/i386/fcntl.c
>>> delete mode 100644 sysdeps/unix/sysv/linux/m68k/fcntl.c
>>> delete mode 100644 sysdeps/unix/sysv/linux/microblaze/fcntl.c
>>> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips32/fcntl.c
>>> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c
>>> delete mode 100644 sysdeps/unix/sysv/linux/mips/mips64/sysdep-cancel.h
>>> delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c
>>> 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/s390/s390-32/fcntl.c
>>> delete mode 100644 sysdeps/unix/sysv/linux/sh/fcntl.c
>>> delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c
>>> 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] 19+ messages in thread
* Re: [PATCH 4/5] Consolidate Linux fcntl implementation
2017-05-23 18:26 ` [PATCH 4/5] Consolidate Linux fcntl implementation Adhemerval Zanella
2017-06-29 14:15 ` Adhemerval Zanella
@ 2017-06-29 15:01 ` Andreas Schwab
1 sibling, 0 replies; 19+ messages in thread
From: Andreas Schwab @ 2017-06-29 15:01 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On Mai 23 2017, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:
> * sysdeps/unix/sysv/linux/arm/fcntl.c: Remove file.
> * sysdeps/unix/sysv/linux/generic/wordsize-32/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/hppa/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/m68k/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/microblaze/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/mips/mips32/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/mips/mips64/n32/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/powerpc/powerpc32/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/s390/s390-32/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/sh/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/sparc/sparc32/fcntl.c: Likewise.
> * sysdeps/unix/sysv/linux/fcntl.c: New file.
That's not a new file.
> * sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c: Refactor to
> use default implementation.
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c
> index 85ae8a2..d382d08 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/fcntl.c
> @@ -15,51 +15,18 @@
> License along with the GNU C Library; if not, see
> <http://www.gnu.org/licenses/>. */
>
> -#include <assert.h>
> -#include <errno.h>
> -#include <sysdep-cancel.h> /* Must come before <fcntl.h>. */
> +#include <unistd.h>
> #include <fcntl.h>
> -#include <stdarg.h>
>
> -#include <sys/syscall.h>
> -
> -
> -#ifndef NO_CANCELLATION
> -int
> -__fcntl_nocancel (int fd, int cmd, ...)
> +static inline int
> +__libc_fcntl_adjust_cmd (int cmd)
No need for __libc prefix, since this is static.
Ok with those changes.
Andreas.
--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/5] Fix {INLINE,INTERNAL}_SYSCALL macros for x32
2017-06-29 14:15 ` Adhemerval Zanella
@ 2017-06-29 18:51 ` Florian Weimer
2017-06-30 15:03 ` Adhemerval Zanella
0 siblings, 1 reply; 19+ messages in thread
From: Florian Weimer @ 2017-06-29 18:51 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: libc-alpha
On 06/29/2017 04:15 PM, Adhemerval Zanella wrote:
> +/* 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))
I think cast_to_integer was added for this purpose.
Thanks,
Florian
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/5] Fix {INLINE,INTERNAL}_SYSCALL macros for x32
2017-06-29 18:51 ` Florian Weimer
@ 2017-06-30 15:03 ` Adhemerval Zanella
0 siblings, 0 replies; 19+ messages in thread
From: Adhemerval Zanella @ 2017-06-30 15:03 UTC (permalink / raw)
To: Florian Weimer; +Cc: libc-alpha
On 29/06/2017 15:50, Florian Weimer wrote:
> On 06/29/2017 04:15 PM, Adhemerval Zanella wrote:
>> +/* 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))
>
> I think cast_to_integer was added for this purpose.
The 'cast_to_integer' macro was added after my initial (I based the ARGIFY
macro on the mips64n32 one) and checking it by replacing ARGIGY with
'cast_to_integer' I see:
---
gconv_cache.c: In function â__gconv_load_cacheâ:
../include/libc-pointer-arith.h:34:45: error: cast specifies array type
__integer_if_pointer_type_sub(__typeof__ ((__typeof__ (expr)) 0), \
^
../include/libc-pointer-arith.h:29:39: note: in definition of macro â__integer_if_pointer_type_subâ
__typeof__ (*(0 ? (__typeof__ (0 ? (T *) 0 : (void *) (P))) 0 \
^
../include/libc-pointer-arith.h:38:33: note: in expansion of macro â__integer_if_pointer_typeâ
# define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val))
^~~~~~~~~~~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:284:29: note: in expansion of macro âcast_to_integerâ
TYPEFY (arg1, __arg1) = cast_to_integer (arg1); \
^~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:230:2: note: in expansion of macro âinternal_syscall3â
internal_syscall##nr (SYS_ify (name), err, args)
^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/x86_64/sysdep.h:196:35: note: in expansion of macro âINTERNAL_SYSCALLâ
unsigned long int resultvar = INTERNAL_SYSCALL (name, , nr, args); \
^~~~~~~~~~~~~~~~
../sysdeps/unix/sysv/linux/not-cancel.h:31:4: note: in expansion of macro âINLINE_SYSCALLâ
INLINE_SYSCALL (open, 3, name, flags, mode)
---
And I recall this was one the issue I had when creating this patch. Using compound
literal on __typeof__ cast did not help due we build with -Wwrite-strings it and
in turn it enables -Wdiscarded-array-qualifiers. This triggers a 'pointer to
array loses qualifier', because constness type is propagate.
So to actually use cast_to_integer workable on char array (and on other arrays
as well) one solution is to incorporate the arithmetic promotion used on
mips64n32 sysdep and also on this patch:
---
/* Type cast using arithmetic promotion. It also remove l-value-constness
when using char arrays on cast_to_interger (for instance
cast_to_interger ("...") will not trigger a 'pointer to array loses
qualifier' warning due -Wdiscarded-array-qualifiers from -Wwrite-strings.
*/
# define __typeof_arith_promote(T) __typeof__((T) - (T))
/* 1 if 'type' is a pointer type, 0 otherwise. */
# define __pointer_type(type) (__builtin_classify_type ((type) 0) == 5)
/* intptr_t if P is true, or T if P is false. */
# define __integer_if_pointer_type_sub(T, P) \
__typeof__ (*(0 ? (__typeof__ (0 ? (T *) 0: (void *) (P))) 0 \
: (__typeof__ (0 ? (intptr_t *) 0: (void *) (!(P)))) 0))
/* intptr_t if EXPR has a pointer type, or the type of EXPR otherwise. */
# define __integer_if_pointer_type(expr) \
__integer_if_pointer_type_sub(__typeof__ ((__typeof_arith_promote (expr)) 0), \
__pointer_type (__typeof_arith_promote (expr)))
/* Cast an integer or a pointer VAL to integer with proper type. */
# define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val))
---
I am not sure how safe is the arithmetic promotion in the all the possible
cases where one could use cast_to_integer, however current cases on atomic
and syscall usage should be safe (make check shows no regression on
x86_64{-x32} with the pread auto-generate removal applied, so they use the
default Linux implementation. If you think it is worth I can resend with the
libc-pointer-arith.h modification.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/5] Fix {INLINE,INTERNAL}_SYSCALL macros for x32
2017-05-23 18:26 ` [PATCH 1/5] Fix {INLINE,INTERNAL}_SYSCALL macros for x32 Adhemerval Zanella
2017-06-29 14:15 ` Adhemerval Zanella
@ 2017-07-01 16:53 ` H.J. Lu
2017-07-03 11:53 ` Adhemerval Zanella
1 sibling, 1 reply; 19+ messages in thread
From: H.J. Lu @ 2017-07-01 16:53 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: GNU C Library, Adhemerval Zanella
On Tue, May 23, 2017 at 11:25 AM, 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.
> ---
> ChangeLog | 50 ++++++
> sysdeps/unix/sysv/linux/x86_64/sysdep.h | 251 ++++++++++++++++-------------
> sysdeps/unix/sysv/linux/x86_64/x32/times.c | 24 +--
> 3 files changed, 205 insertions(+), 120 deletions(-)
>
> diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
> index 7b8bd79..6d0a6f4 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))
> +
I am a little bit concerned about this. The current macros cast to long int
by default on purpose. 64-bit return and arguments are treated as
special cases. With your change, this code in loadlocale.c:
if (filedata != NULL)
{
off_t to_read = st.st_size;
ssize_t nread;
char *p = (char *) filedata;
while (to_read > 0)
{
nread = read_not_cancel (fd, p, to_read);
if (__builtin_expect (nread, 1) <= 0)
{
free (filedata);
if (nread == 0)
__set_errno (EINVAL); /* Bizarreness going on. */
goto puntfd;
}
p += nread;
is generated differently. On x32, ssize_t is 32 bits and offset is 64 bits.
Before your patch, to_read is passed as 32 bit value. With your change,
__typeof__ ((X) - (X)) turns to_read into 64 bits. It may be OK for this
particular case. But I am not certain that your change is 100% safe in
all cases.
H.J.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/5] Fix {INLINE,INTERNAL}_SYSCALL macros for x32
2017-07-01 16:53 ` H.J. Lu
@ 2017-07-03 11:53 ` Adhemerval Zanella
2017-07-03 19:44 ` H.J. Lu
0 siblings, 1 reply; 19+ messages in thread
From: Adhemerval Zanella @ 2017-07-03 11:53 UTC (permalink / raw)
To: H.J. Lu; +Cc: GNU C Library, Adhemerval Zanella
On 01/07/2017 13:53, H.J. Lu wrote:
> On Tue, May 23, 2017 at 11:25 AM, 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.
>> ---
>> ChangeLog | 50 ++++++
>> sysdeps/unix/sysv/linux/x86_64/sysdep.h | 251 ++++++++++++++++-------------
>> sysdeps/unix/sysv/linux/x86_64/x32/times.c | 24 +--
>> 3 files changed, 205 insertions(+), 120 deletions(-)
>>
>> diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
>> index 7b8bd79..6d0a6f4 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))
>> +
>
> I am a little bit concerned about this. The current macros cast to long int
> by default on purpose. 64-bit return and arguments are treated as
> special cases. With your change, this code in loadlocale.c:
>
> if (filedata != NULL)
> {
> off_t to_read = st.st_size;
> ssize_t nread;
> char *p = (char *) filedata;
> while (to_read > 0)
> {
> nread = read_not_cancel (fd, p, to_read);
> if (__builtin_expect (nread, 1) <= 0)
> {
> free (filedata);
> if (nread == 0)
> __set_errno (EINVAL); /* Bizarreness going on. */
> goto puntfd;
> }
> p += nread;
>
> is generated differently. On x32, ssize_t is 32 bits and offset is 64 bits.
> Before your patch, to_read is passed as 32 bit value. With your change,
> __typeof__ ((X) - (X)) turns to_read into 64 bits. It may be OK for this
> particular case. But I am not certain that your change is 100% safe in
> all cases.
I think the problem is we define 'read_not_cancel' as a macro rather than
an static inline with expected arguments types. For a QoI I think creating
wrappers around it would be better.
I would like to make the syscall internal macros to work seamlessly across
all architectures and avoid to create specialized assembly macros for
specific syscalls (such as lseek{64} for x32 witch I think it is not
avoidable). Also x32 is the only architecture afaik preventing the
syscall-cancel.h cleanup currently.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/5] Fix {INLINE,INTERNAL}_SYSCALL macros for x32
2017-07-03 11:53 ` Adhemerval Zanella
@ 2017-07-03 19:44 ` H.J. Lu
0 siblings, 0 replies; 19+ messages in thread
From: H.J. Lu @ 2017-07-03 19:44 UTC (permalink / raw)
To: Adhemerval Zanella; +Cc: GNU C Library, Adhemerval Zanella
On Mon, Jul 3, 2017 at 4:52 AM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
> On 01/07/2017 13:53, H.J. Lu wrote:
>> On Tue, May 23, 2017 at 11:25 AM, 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.
>>> ---
>>> ChangeLog | 50 ++++++
>>> sysdeps/unix/sysv/linux/x86_64/sysdep.h | 251 ++++++++++++++++-------------
>>> sysdeps/unix/sysv/linux/x86_64/x32/times.c | 24 +--
>>> 3 files changed, 205 insertions(+), 120 deletions(-)
>>>
>>> diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
>>> index 7b8bd79..6d0a6f4 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))
>>> +
>>
>> I am a little bit concerned about this. The current macros cast to long int
>> by default on purpose. 64-bit return and arguments are treated as
>> special cases. With your change, this code in loadlocale.c:
>>
>> if (filedata != NULL)
>> {
>> off_t to_read = st.st_size;
>> ssize_t nread;
>> char *p = (char *) filedata;
>> while (to_read > 0)
>> {
>> nread = read_not_cancel (fd, p, to_read);
>> if (__builtin_expect (nread, 1) <= 0)
>> {
>> free (filedata);
>> if (nread == 0)
>> __set_errno (EINVAL); /* Bizarreness going on. */
>> goto puntfd;
>> }
>> p += nread;
>>
>> is generated differently. On x32, ssize_t is 32 bits and offset is 64 bits.
>> Before your patch, to_read is passed as 32 bit value. With your change,
>> __typeof__ ((X) - (X)) turns to_read into 64 bits. It may be OK for this
>> particular case. But I am not certain that your change is 100% safe in
>> all cases.
>
> I think the problem is we define 'read_not_cancel' as a macro rather than
> an static inline with expected arguments types. For a QoI I think creating
> wrappers around it would be better.
That is fine with me.
> I would like to make the syscall internal macros to work seamlessly across
> all architectures and avoid to create specialized assembly macros for
> specific syscalls (such as lseek{64} for x32 witch I think it is not
> avoidable). Also x32 is the only architecture afaik preventing the
> syscall-cancel.h cleanup currently.
There is fine with me as long as the implementation is correct for
x32. But the current one isn't correct for x32.
Thanks.
--
H.J.
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2017-07-03 19:44 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-23 18:26 [PATCH 0/5] Remove sysdep-cancel assembly macro Adhemerval Zanella
2017-05-23 18:26 ` [PATCH 4/5] Consolidate Linux fcntl implementation Adhemerval Zanella
2017-06-29 14:15 ` Adhemerval Zanella
2017-06-29 15:01 ` Andreas Schwab
2017-05-23 18:26 ` [PATCH 5/5] Remove cancellation support for syscall generation Adhemerval Zanella
2017-05-23 18:26 ` [PATCH 2/5] Remove p{read,write}{v} and fallocate from x86 auto-generation list Adhemerval Zanella
2017-06-29 14:15 ` Adhemerval Zanella
2017-05-23 18:26 ` [PATCH 1/5] Fix {INLINE,INTERNAL}_SYSCALL macros for x32 Adhemerval Zanella
2017-06-29 14:15 ` Adhemerval Zanella
2017-06-29 18:51 ` Florian Weimer
2017-06-30 15:03 ` Adhemerval Zanella
2017-07-01 16:53 ` H.J. Lu
2017-07-03 11:53 ` Adhemerval Zanella
2017-07-03 19:44 ` H.J. Lu
2017-05-23 18:26 ` [PATCH 3/5] linux: Consolidate sync_file_range implementation Adhemerval Zanella
2017-06-15 18:46 ` Adhemerval Zanella
2017-06-02 12:51 ` [PATCH 0/5] Remove sysdep-cancel assembly macro Adhemerval Zanella
2017-06-13 14:31 ` Adhemerval Zanella
2017-06-29 14:16 ` Adhemerval Zanella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).