diff options
25 files changed, 348 insertions, 2766 deletions
@@ -1,3 +1,179 @@ +2017-08-24 Adhemerval Zanella <adhemerval.zanella@linaro.org> + + * sysdeps/unix/make-syscalls.sh: Remove cancellable tagging for + syscall definitions and replace __builtin_expect with __glibc_likely. + * sysdeps/unix/syscall-template.S: Update comment about cancellable + syscall. + (SYSCALL_CANCELLABLE): Removedefinition + * 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. + 2017-08-24 Szabolcs Nagy <szabolcs.nagy@arm.com> * sysdeps/ieee754/dbl-64/Makefile: Don't override CFLAGS. diff --git a/sysdeps/unix/make-syscalls.sh b/sysdeps/unix/make-syscalls.sh index 123553c1d9..042cfacfd2 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 4993ff562d..00588a9cd1 100644 --- a/sysdeps/unix/syscall-template.S +++ b/sysdeps/unix/syscall-template.S @@ -17,9 +17,8 @@ <http://www.gnu.org/licenses/>. */ /* The real guts of this work are in the macros defined in the - machine- and kernel-specific sysdep.h header file. When we - are defining a cancellable system call, the sysdep-cancel.h - versions of those macros are what we really use. + machine- and kernel-specific sysdep.h header file. Cancellable syscalls + should be implemented using C implementation with SYSCALL_CANCEL macro. Each system call's object is built by a rule in sysd-syscalls generated by make-syscalls.sh that #include's this file after @@ -27,7 +26,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 +39,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 4be2259878..80732f5445 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep-cancel.h @@ -18,108 +18,26 @@ #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) \ - .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 __glibc_likely (__local_multiple_threads == 0) # else /* There is no __local_multiple_threads for librt, so use the TCB. */ -# ifndef __ASSEMBLER__ -# 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 +# define SINGLE_THREAD_P \ + __glibc_likely (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0) # endif -#elif !defined __ASSEMBLER__ +#else /* For rtld, et cetera. */ # define SINGLE_THREAD_P 1 @@ -127,8 +45,5 @@ 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 + __glibc_likely (THREAD_GETMEM (THREAD_SELF, header.multiple_threads) == 0) diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h b/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h index 66d6962b80..72e6c0cb60 100644 --- a/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h +++ b/sysdeps/unix/sysv/linux/alpha/sysdep-cancel.h @@ -17,147 +17,23 @@ #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 |
