platform/upstream/glibc.git
6 years agoClean up bits/math-finite.h for aliasing types.
Joseph Myers [Fri, 25 Aug 2017 16:11:13 +0000 (16:11 +0000)]
Clean up bits/math-finite.h for aliasing types.

This patch cleans up how bits/math-finite.h handles types that are
ABI-aliases of other types.

For such types, no __*_finite functions exist; instead,
bits/math-finite.h must redirect calls to a the functions for a
canonical choice of type for each floating-point format.  (For the
actual public interfaces, symbols need exporting for each type, even
those that are ABI-aliases, because of standard requirements that
programs can declare the functions themselves without including
<math.h>, but that does not apply to __*_finite.)

At present, there is a special-case conditional in bits/math-finite.h
on __MATH_DECLARING_LDOUBLE && defined __NO_LONG_DOUBLE_MATH to handle
redirecting long double function calls to double __*_finite.  This
patch replaces this by a more general mechanism.  math.h, before each
inclusion of bits/math-finite.h, defines _MSUFTO_ as the suffix to use
on the target of redirection, in addition to the existing _MSUF_.
This way, __MATH_DECLARING_LDOUBLE can go away, as can the special
conditional in bits/math-finite.h.  With this patch, math.h is now
prepared for the case of supporting float128 functions as aliases of
long double ones on platforms where long double is binary128, with
_MSUFTO_ appropriately defined for that case, and appropriate _MSUFTO_
definitions can easily be included when supporting _Float32 / _Float64
/ _Float32x / _Float64x (which will always be ABI-aliases of another
type when supported).

Tested for x86_64, and did a compilation test for ARM with
build-many-glibcs.py to cover the long double = double case.

* math/math.h (_MSUFTO_): Define and undefine for each inclusion
of <bits/math-finite.h>.
(__MATH_DECLARING_LDOUBLE): Do not define and undefine for each
inclusion of <bits/math-finite.h>.
* math/bits/math-finite.h (__REDIRTO_X): Do not define
conditionally on [__MATH_DECLARING_LDOUBLE && defined
__NO_LONG_DOUBLE_MATH].
(__MATH_REDIRCALL): Use _MSUFTO_ in __REDIRTO call.
(__MATH_REDIRCALL_2): Likewise.
(__MATH_REDIRCALL_INTERNAL): Likewise.
(__REDIRFROM (lgamma, , _MSUF_)): Likewise.
(__REDIRFROM (gamma, , _MSUF_)): Likewise.
(__REDIRFROM (tgamma, , _MSUF_)): Likewise.

6 years agoRemove powerpc32 sqrt wrappers.
Joseph Myers [Fri, 25 Aug 2017 11:33:04 +0000 (11:33 +0000)]
Remove powerpc32 sqrt wrappers.

This patch removes the powerpc32-specific wrappers for sqrt and sqrtf.

These wrappers, by adding architecture-specific uses of _LIB_VERSION
and __kernel_standard, unnecessarily complicate cleanups of libm error
handling.  They also do not serve a useful optimization purpose.  GCC
knows about sqrt as a built-in function, and can generate direct calls
to a hardware square root instruction, either on its own, in the
-fno-math-errno case, or together with an inline check for the
argument being negative and a call to the out-of-line sqrt function
for error handling only in that case (and has been able to do so for a
long time).  Thus in practice the wrapper will only be called only in
the case of negative arguments, which is not a case it is useful to
optimize for.

Tested with build-many-glibcs.py for powerpc-linux-gnu-power4.

* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/w_sqrt_compat-power5.S:
Remove file.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/w_sqrt_compat-ppc32.S:
Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/w_sqrt_compat.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/w_sqrtf_compat-power5.S:
Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/w_sqrtf_compat-ppc32.S:
Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/w_sqrtf_compat.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/w_sqrt_compat.S: Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/w_sqrtf_compat.S: Likewise.
* sysdeps/powerpc/powerpc32/power5/fpu/w_sqrt_compat.S: Likewise.
* sysdeps/powerpc/powerpc32/power5/fpu/w_sqrtf_compat.S: Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
(libm-sysdep-routines): Remove w_sqrt_compat-power5,
w_sqrt_compat-ppc32, w_sqrtf_compat-power5 and
w_sqrtf_compat-ppc32.

6 years agoFix the C++ version of issignaling when __NO_LONG_DOUBLE_MATH is defined
Gabriel F. T. Gomes [Wed, 23 Aug 2017 13:16:54 +0000 (10:16 -0300)]
Fix the C++ version of issignaling when __NO_LONG_DOUBLE_MATH is defined

When __NO_LONG_DOUBLE_MATH is defined, __issignalingl is not available,
thus issignaling with long double argument should call __issignaling,
instead.

Tested for powerpc64le.

* math/math.h [defined __cplusplus] (issignaling): In the long
double case, call __issignalingl only if __NO_LONG_DOUBLE_MATH
is not defined.  Call __issignaling, otherwise.

6 years agoRemove cancellation support for syscall generation
Adhemerval Zanella [Thu, 12 Nov 2015 16:01:36 +0000 (14:01 -0200)]
Remove cancellation support for syscall generation

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.A
Also with build-many-glibc.py with remaning touched architectures.

* 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.

6 years agoFix CFLAGS override in sysdeps/ieee754/dbl-64
Szabolcs Nagy [Thu, 24 Aug 2017 14:56:11 +0000 (15:56 +0100)]
Fix CFLAGS override in sysdeps/ieee754/dbl-64

Use += instead of = to avoid overriding target specific CFLAGS settings.
Ideally the settings in target Makefiles would have precedence, but the
Makefile inclusion order does not allow that, with this fix at least the
target settings are not dropped.

6 years agox86-64: Regenerate libm-test-ulps for AVX512 mathvec tests
H.J. Lu [Wed, 23 Aug 2017 16:11:41 +0000 (09:11 -0700)]
x86-64: Regenerate libm-test-ulps for AVX512 mathvec tests

Update libm-test-ulps for AVX512 mathvec tests by running
“make regen-ulps” on Intel Xeon processor with AVX512.

* sysdeps/x86_64/fpu/libm-test-ulps: Regenerated.

6 years agostring/stratcliff.c: Replace int with size_t [BZ #21982]
H.J. Lu [Wed, 23 Aug 2017 15:22:52 +0000 (08:22 -0700)]
string/stratcliff.c: Replace int with size_t [BZ #21982]

Fix GCC 7 errors when string/stratcliff.c is compiled with -O3:

stratcliff.c: In function ‘do_test’:
cc1: error: assuming signed overflow does not occur when assuming that (X - c) <= X is always true [-Werror=strict-overflow]

[BZ #21982]
* string/stratcliff.c (do_test): Declare size, nchars, inner,
middle and outer with size_t instead of int.  Repleace %d and
%Zd with %zu in printf.  Update "MAX (0, nchars - 128)" and
"MAX (outer, nchars - 64)" to support unsigned outer and
nchars.  Also exit loop when outer == 0.

6 years agoConsolidate remaning non cancellable definitions
Adhemerval Zanella [Wed, 23 Aug 2017 13:40:14 +0000 (10:40 -0300)]
Consolidate remaning non cancellable definitions

This patch consolidate the remaning non cancellable syscall definitions
on not-cancel.h header.  They are:

  * __fcntl_nocancel: Moved from fcntl.h to not-cancel.h.
  * __sigsuspend_nocancel: Removed since 988f991b50 it is not used or
    defined anymore.
  * __nanosleep_nocancel: Removed since 6f33fd046b it is defined on
    not-cancel.h.

Now all non-cancellable syscall definition are defined on not-cancel
(the only exceptions is the stdio symbol __fxprintf_nocancel which
uses non cancellable open and it is used on getopt implementation).

Checked on x86_64-linux-gnu and with build-many-glibc.py.

* include/fcntl.h (__fcntl_nocancel): Remove definition.
* include/signal.h (__sigsuspend_nocancel): Likewise.
* include/time.h (__nanosleep_nocancel): Likewise.
* sysdeps/generic/not-cancel.h (__fcntl_nocancel): New macro.
* login/utmp_file.c: Include non cancellable syscall header.
* sysdeps/unix/sysv/linux/not-cancel.h (__fcntl_nocancel): New
prototype.

6 years agox86_64: Replace AVX512F .byte sequences with instructions
H.J. Lu [Wed, 23 Aug 2017 13:16:12 +0000 (06:16 -0700)]
x86_64: Replace AVX512F .byte sequences with instructions

Since binutils 2.25 or later is required to build glibc, we can replace
AVX512F .byte sequences with AVX512F instructions.

Tested on x86-64 and x32.  There are no code differences in libmvec.so
and libmvec.a.

* sysdeps/x86_64/fpu/svml_d_sincos8_core.S: Replace AVX512F
.byte sequences with AVX512F instructions.
* sysdeps/x86_64/fpu/svml_d_wrapper_impl.h: Likewise.
* sysdeps/x86_64/fpu/svml_s_sincosf16_core.S: Likewise.
* sysdeps/x86_64/fpu/svml_s_wrapper_impl.h: Likewise.
* sysdeps/x86_64/fpu/multiarch/svml_d_sincos8_core_avx512.S:
Likewise.
* sysdeps/x86_64/fpu/multiarch/svml_s_sincosf16_core_avx512.S:
Likewise.

6 years agoaarch64: Use PTR_REG macro to fix ILP32 bug and make code consistent
Steve Ellcey [Tue, 22 Aug 2017 23:22:05 +0000 (16:22 -0700)]
aarch64: Use PTR_REG macro to fix ILP32 bug and make code consistent

* sysdeps/aarch64/dl-tlsdesc.S (_dl_tlsdesc_dynamic):
Use PTR_REG macro in cmp instruction.

6 years agoFix remaining return type of ifunc resolver declaration
Gabriel F. T. Gomes [Tue, 22 Aug 2017 17:01:07 +0000 (14:01 -0300)]
Fix remaining return type of ifunc resolver declaration

Since Martin Sebor's commit

commit ee4e992ebe5f9712faedeefe8958b67d61eaa0f2
Author: Martin Sebor <msebor@redhat.com>
Date:   Tue Aug 22 09:35:23 2017 -0600

    Declare ifunc resolver to return a pointer to the same type as the target
    function to help GCC detect incompatibilities between the two when it's
    enhanced to do so.

builds for powerpc64le fail in the declaration of some ifunc resolvers,
because the ifunc is declared with unmatching return types.  One of the
declarations comes from the __ifunc_resolver macro, which was patched by
the aforementioned commit:

    /* Helper / base  macros for indirect function symbols.  */
    #define __ifunc_resolver(type_name, name, expr, arg, init, classifier) \
      classifier inhibit_stack_protector                                   \
      __typeof (type_name) *name##_ifunc (arg)                             \

whereas the other comes from the unpatched __ifunc macro when
HAVE_GCC_IFUNC is not defined:

    # define __ifunc(type_name, name, expr, arg, init)                     \
      extern __typeof (type_name) name;                                    \
      void *name##_ifunc (arg) __asm__ (#name);                            \

This patch changes the return type of the ifunc resolver in the __ifunc
macro, so that it matches the return type of the target function,
similarly to what the aforementioned commit does.

Tested for powerpc64le and s390x with unpatched GCC.

* include/libc-symbols.h: [!defined HAVE_GCC_IFUNC] (__ifunc):
Change the return type of the ifunc resolver to match the return
type of the target function.

6 years agoRemove p{read,write}{v} and fallocate from x86 auto-generation list
Adhemerval Zanella [Tue, 19 Jul 2016 13:23:49 +0000 (10:23 -0300)]
Remove p{read,write}{v} and fallocate from x86 auto-generation list

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.

6 years agoFix {INLINE,INTERNAL}_SYSCALL macros for x32
Adhemerval Zanella [Wed, 13 Jul 2016 09:50:05 +0000 (10:50 +0100)]
Fix {INLINE,INTERNAL}_SYSCALL macros for x32

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.

6 years agoRemove duplicate inclusion of header math-svid-compat.h
Gabriel F. T. Gomes [Tue, 22 Aug 2017 14:14:15 +0000 (11:14 -0300)]
Remove duplicate inclusion of header math-svid-compat.h

The header math-svid-compat.h has been unintentionally included twice in
the wrappers for the remainder functions.  This patch removes the
duplicate inclusions.

* math/w_remainder_compat.c: Remove duplicate inclusion of
math-svid-compat.h.
* math/w_remainderf_compat.c: Likewise.
* math/w_remainderl_compat.c: Likewise.

6 years agopowerpc: Shrink ULPs for float128
Gabriel F. T. Gomes [Tue, 8 Aug 2017 21:52:03 +0000 (18:52 -0300)]
powerpc: Shrink ULPs for float128

During the development of float128 on powerpc64le, the ulps have been
generated since early versions of the patches.  On those versions, the
functions gamma and pow10 were mistakenly thought to be part of the API.
After review, the functions were removed, however the ulps for them were
carried in the ulps file.

This patch removes such entries from the ulps file, as well as it
shrinks the ulps for the cpow and lgamma functions.

Tested for powerpc64le.

* sysdeps/powerpc/fpu/libm-test-ulps: Update.

6 years agoFix tgmath.h handling of complex integers (bug 21684).
Joseph Myers [Tue, 22 Aug 2017 17:55:42 +0000 (17:55 +0000)]
Fix tgmath.h handling of complex integers (bug 21684).

The tgmath.h macros return a real type not a complex type when an
argument is of complex integer type (a GNU extension) and there are no
arguments of complex floating type.  It seems clear that just as real
integers are mapped to double for tgmath.h, so complex integers should
be mapped to _Complex double.

This patch implements such a mapping.  The main complication in fixing
this bug is that the tgmath.h macros expand their arguments a large
number of times, resulting in exponential blowup of the size of the
expansion when calls to tgmath.h macros are used in the arguments of
such macros; it would be unfortunate for fixing a bug with a fairly
obscure extension to make the macros expand their arguments even more
times.  Thus, this patch optimizes the definitions of the relevant
macros.  __tgmath_real_type previously expanded its argument 7 times
and now expands it 3 times.  __tgmath_complex_type, used in place of
__tgmath_real_type only for functions that might return either real or
complex types, not for complex functions that always return real types
or always return complex types, expands its argument 5 times.  So the
sizes of the macro expansions from nested macro calls are
correspondingly reduced (remembering that each tgmath.h macro expands
__tgmath_real_type, or sometimes now __tgmath_complex_type, several
times).

Sometimes the real return type resulted from calling a complex
function and converting the result to a real type; sometimes it
resulted from calling a real function, because the logic for
determining whether arguments were real or complex, based on sizeof,
was confused by integer promotions applying to e.g. short int but not
_Complex short int.  The relevant tests are converted to use a new
macro __expr_is_real, which, by calling __builtin_classify_type rather
than comparing the results of two calls to sizeof, also reduces the
number of times macros expand their arguments.

Although there are reductions in the number of times macros expand
their arguments, I do not consider this to fix bug 21660, since a
proper fix means each macro expanding its arguments only once (via
using new compiler features designed for that purpose).

Tested for x86_64.

[BZ #21684]
* math/tgmath.h (__floating_type): Simplify definitions.
(__real_integer_type): New macro.
(__complex_integer_type): Likewise.
(__expr_is_real): Likewise.
(__tgmath_real_type_sub): Update comment to describe handling of
complex types.
(__tgmath_complex_type_sub): New macro.
(__tgmath_complex_type): Likewise.
[__HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)]
(__TGMATH_CF128): Use __expr_is_real.
(__TGMATH_UNARY_REAL_IMAG): Use __tgmath_complex_type and
__expr_is_real.
(__TGMATH_BINARY_REAL_IMAG): Likewise.
(__TGMATH_UNARY_REAL_IMAG_RET_REAL): Use __expr_is_real.
* math/gen-tgmath-tests.py (Type.create_type): Create complex
integer types.

6 years agoRemove non cancellable sigsuspend definition
Adhemerval Zanella [Tue, 22 Aug 2017 13:09:52 +0000 (10:09 -0300)]
Remove non cancellable sigsuspend definition

There is no current internal usage for non cancellable sigsuspend calls.

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

* sysdeps/generic/not-cancel.h (sigsuspend_not_cancel): remove
macro.
* sysdeps/mach/hurd/sigsuspend.c (sigsuspend_not_cancel): remove
alias.
* sysdeps/unix/sysv/linux/not-cancel.h (sigsuspend_not_cancel):
likewise.

6 years agoConsolidate non cancellable nanosleep call
Adhemerval Zanella [Mon, 3 Jul 2017 18:54:02 +0000 (15:54 -0300)]
Consolidate non cancellable nanosleep call

This patch consolidates all the non cancellable nanosleep calls to use
the __nanosleep_nocancel identifier.  For non cancellable targets it will
be just a macro to call the default respective symbol while on Linux
will be a internal one.

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

* nptl/pthread_mutex_timedlock.c (__pthread_mutex_timedlock): Replace
nanosleep_not_cancel with __nanosleep_nocancel.
* sysdeps/generic/not-cancel.h (nanosleep_not_cancel): Remove macro.
(__nanosleep_nocancel): New macro.
* sysdeps/unix/sysv/linux/nanosleep.c (__nanosleep_nocancel): New
function.
* sysdeps/unix/sysv/linux/not-cancel.h (nanosleep_not_cancel): Remove
macro.
(__nanosleep_nocancel): New prototype.

6 years agoConsolidate non cancellable pause call
Adhemerval Zanella [Mon, 21 Aug 2017 20:23:56 +0000 (17:23 -0300)]
Consolidate non cancellable pause call

This patch consolidates all the non cancellable pause calls to use
the __pause_nocancel identifier.  For non cancellable targets it will
be just a macro to call the default respective symbol while on Linux
will be a internal one.

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

* nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Replace
pause_not_cancel with __pause_nocancel.
* sysdeps/generic/not-cancel.h (pause_not_cancel): Remove macro.
(__pause_nocancel): New macro.
* sysdeps/unix/sysv/linux/not-cancel.h (pause_not_cancel): Remove
macro.
(__pause_nocancel): New prototype.
* sysdeps/unix/sysv/linux/pause.c (__pause_nocancel): New function.

6 years agoDeclare ifunc resolver to return a pointer to the same type as the target
Martin Sebor [Tue, 22 Aug 2017 15:35:23 +0000 (09:35 -0600)]
Declare ifunc resolver to return a pointer to the same type as the target
function to help GCC detect incompatibilities between the two when it's
enhanced to do so.

6 years agoHide internal printf functions [BZ #18822/21986]
H.J. Lu [Tue, 22 Aug 2017 14:47:34 +0000 (07:47 -0700)]
Hide internal printf functions [BZ #18822/21986]

Hide internal printf functions to allow direct access within libc.so and
libc.a without using GOT nor PLT.

Since __guess_grouping has been changed to take 2 arguments by

commit a1d84548c8aa7023cd039c85f81b831eef6d4a4c
Author: Ulrich Drepper <drepper@redhat.com>
Date:   Fri Feb 11 18:50:36 2000 +0000

the third argument passed to __guess_grouping is removed.

[BZ #18822]
[BZ #21986]
* include/printf.h (__printf_fphex): Add attribute_hidden.
(__guess_grouping): New prototype.
* stdio-common/printf_fp.c (__guess_grouping): Removed.
* stdio-common/reg-printf.c (__register_printf_specifier): Add
libc_hidden_proto and libc_hidden_def.
* stdlib/strfmon_l.c (__guess_grouping): Removed.
(__vstrfmon_l): Remove the third argument passed to
__guess_grouping.

6 years agoProvide a C++ version of issignaling that does not use __MATH_TG
Gabriel F. T. Gomes [Mon, 14 Aug 2017 16:46:15 +0000 (13:46 -0300)]
Provide a C++ version of issignaling that does not use __MATH_TG

The macro __MATH_TG contains the logic to select between long double and
_Float128, when these types are ABI-distinct.  This logic relies on
__builtin_types_compatible_p, which is not available in C++ mode.

On the other hand, C++ function overloading provides the means to
distinguish between the floating-point types.  The overloading
resolution will match the correct parameter regardless of type
qualifiers, i.e.: const and volatile.

Tested for powerpc64le, s390x, and x86_64.

* math/math.h [defined __cplusplus] (issignaling): Provide a C++
definition for issignaling that does not rely on __MATH_TG,
since __MATH_TG uses __builtin_types_compatible_p, which is only
available in C mode.
(CFLAGS-test-math-issignaling.cc): New variable.
* math/Makefile [CXX] (tests): Add test-math-issignaling.
* math/test-math-issignaling.cc: New test for C++ implementation
of type-generic issignaling.
* sysdeps/powerpc/powerpc64le/Makefile [subdir == math]
(CXXFLAGS-test-math-issignaling.cc): Add -mfloat128 to the build
options of test-math-issignaling on powerpc64le.

6 years agoAdd hidden visibility to internal function prototypes
H.J. Lu [Tue, 22 Aug 2017 11:49:14 +0000 (13:49 +0200)]
Add hidden visibility to internal function prototypes

Add hidden visibility to internal function prototypes to allow direct
access to internal functions within libc.a without using GOT when the
compiler defaults to -fPIE.

Size comparison of elf/ldconfig when the compiler defaults to -fPIE:

On x86-64:
        text    data     bss     dec     hex
Before: 619646   20132    5488  645266   9d892
After : 619502   20132    5488  645122   9d802
On i686:
        text    data     bss     dec     hex
Before: 550333   10748    3060  564141   89bad
After : 546453   10732    3060  560245   88c75

* include/libc-symbols.h (__hidden_proto_hiddenattr): New for
building libc.a.
(hidden_proto): Likewise.
(hidden_tls_proto): Likewise.
(__hidden_proto): Likewise.

(Reapplied after the revert in df1deda60050cc8a68156cf6c81ad42363647a29.)

6 years agomath: Statically link tests of internal functionality
Florian Weimer [Tue, 22 Aug 2017 10:45:16 +0000 (12:45 +0200)]
math: Statically link tests of internal functionality

6 years agoFix sparc32 bits/long-double.h (bug 21987).
Joseph Myers [Tue, 22 Aug 2017 00:59:43 +0000 (00:59 +0000)]
Fix sparc32 bits/long-double.h (bug 21987).

My refactoring of long double information

commit 0acb8a2a855395c25b1feef2470f4d7ca4bed589
Author: Joseph Myers <joseph@codesourcery.com>
Date:   Wed Dec 14 18:27:56 2016 +0000

    Refactor long double information into bits/long-double.h.

resulted in sparc32 configurations installing the ldbl-opt version of
bits/long-double.h instead of the intended
sysdeps/unix/sysv/linux/sparc version.

For sparc32 by itself, this is not a problem, since the ldbl-opt
version is correct for sparc32.  However, both sparc32 and sparc64 are
supposed to install sets of headers that work for both of them, so
that a single sysroot, whichever order the libraries are built and
installed in, works for both.  The effect of having the wrong version
installed is that you end up with a miscompiled sparc64 libstdc++
which fails glibc's configure tests for the C++ compiler.

This patch moves the header from sysdeps/unix/sysv/linux/sparc to
separate copies of the same file for sparc32 and sparc64, to ensure it
comes before ldbl-opt in the sysdeps directory ordering.

Tested with build-many-glibcs.py for sparc64-linux-gnu and
sparcv9-linux-gnu.

[BZ #21987]
* sysdeps/unix/sysv/linux/sparc/bits/long-double.h: Remove file
and copy to ...
* sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h:
... here.
* sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h:
... and here.

6 years agoFix position of tests-unsupported definition in assert/Makefile.
Joseph Myers [Tue, 22 Aug 2017 00:30:51 +0000 (00:30 +0000)]
Fix position of tests-unsupported definition in assert/Makefile.

tests-unsupported has to be defined before the inclusion of Rules in a
subdirectory Makefile; otherwise it is ineffective.  This patch fixes
the ordering in assert/Makefile, where a recent test addition put
tests-unsupported too late (resulting in build failures when the C++
compiler was missing or broken, and thereby showing up the unrelated
bug 21987).

Incidentally, I don't see why these tests depend on
$(have-cxx-thread_local) rather than just a working C++ compiler.

Tested in such a configuration (broken compiler/libstdc++) with
build-many-glibcs.py.

* assert/Makefile [$(have-cxx-thread_local)]: Move conditional
variable definitions above inclusion of ../Rules.

6 years agoFix GCC 7 build of k_standard.c.
Joseph Myers [Mon, 21 Aug 2017 21:43:32 +0000 (21:43 +0000)]
Fix GCC 7 build of k_standard.c.

This patch adds a default case to k_standard.c that calls
__builtin_unreachable, to avoid an uninitialized variable error from
GCC 7 (reported in
<https://sourceware.org/ml/libc-alpha/2017-08/msg01012.html>).

Tested for x86_64 (with GCC 7).

* sysdeps/ieee754/k_standard.c (__kernel_standard): Add default
case calling __builtin_unreachable.

6 years agoConsolidate non cancellable waitpid call
Adhemerval Zanella [Mon, 3 Jul 2017 18:43:51 +0000 (15:43 -0300)]
Consolidate non cancellable waitpid call

This patch consolidates all the non cancellable waitpid calls to use
the __waitpid_nocancel identifier.  For non cancellable targets it will
be just a macro to call the default respective symbol while on Linux
will be a internal one.

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

* libio/ioopen.c (_IO_waitpid): Replace waitpid_not_cancel with
__waitpid_nocancel.
* sysdeps/generic/not-cancel.h (waitpid_not_cancel): Remove macro.
(__waitpid_nocancel): New macro.
* sysdeps/unix/sysv/linux/not-cancel.h (waitpid_not_cancel): Remove
macro.
(__waitpid_nocancel): Replace macro with a function.
* sysdeps/unix/sysv/linux/waitpid.c (__waitpid_nocancel): New
function.

6 years agoConsolidate non cancellable fcntl call
Adhemerval Zanella [Mon, 3 Jul 2017 18:37:16 +0000 (15:37 -0300)]
Consolidate non cancellable fcntl call

This patch consolidates all the non cancellable fcntl calls to use
the __fcntl_nocancel identifier.  For non cancellable targets it will
be just a macro to call the default respective symbol while on Linux
will be a internal one.

Since its prototype is already defined at internal fcntl.h header, it
is removed from not-cancel.h one.

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

* login/utmp_file.c (timeout_handler): Replace fcntl_not_cancel with
__fcntl_nocancel.
* sysdeps/generic/not-cancel.h (fcntl_not_cancel): Remove macro.
* sysdeps/unix/sysv/linux/not-cancel.h (fcntl_not_cancel): Likewise.

6 years agoConsolidate non cancellable writev call
Adhemerval Zanella [Mon, 3 Jul 2017 18:33:23 +0000 (15:33 -0300)]
Consolidate non cancellable writev call

This patch consolidates all the non cancellable writev calls to use
the __writev_nocancel identifier.  For non cancellable targets it will
be just a macro to call the default respective symbol while on Linux
will be a internal one.

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

* gmon/gmon.c (write_hist): Replace writev_not_cancel_no_status with
__writev_nocancel_nostatus.
(write_call_graph): Likewise.
(write_bb_counts): Likewise.
* resolv/herror.c (herror): Likewise.
* sysdeps/generic/not-cancel.h (writev_not_cancel_no_status): Remove
macro.
(__writev_nocancel_nostatus): New macro.
* sysdeps/unix/sysv/linux/not-cancel.h (writev_not_cancel_no_status):
Remove macro.
(__writev_nocancel_nostatus): New function.

6 years agoRevert "Add hidden visibility to internal function prototypes".
Joseph Myers [Mon, 21 Aug 2017 17:52:05 +0000 (17:52 +0000)]
Revert "Add hidden visibility to internal function prototypes".

The commit

commit 568ff4296c72534e49c8d9c83c33f3a0069cccc7
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Aug 21 05:50:38 2017 -0700

    Add hidden visibility to internal function prototypes

breaks the build of the testsuite for many platforms:

https://sourceware.org/ml/libc-testresults/2017-q3/msg00300.html

The errors are of the following form, building math/atest-exp:

[...]
/scratch/jmyers/glibc-bot/build/glibcs/aarch64-linux-gnu/glibc/stdlib/rshift.o: In function `__mpn_rshift':
/scratch/jmyers/glibc-bot/build/glibcs/aarch64-linux-gnu/glibc-src/stdlib/rshift.c:45: undefined reference to `__assert_fail'
/scratch/jmyers/glibc-bot/install/compilers/aarch64-linux-gnu/lib/gcc/aarch64-glibc-linux-gnu/7.2.1/../../../../aarch64-glibc-linux-gnu/bin/ld: /scratch/jmyers/glibc-bot/build/glibcs/aarch64-linux-gnu/glibc/math/atest-exp: hidden symbol `__assert_fail' isn't defined
/scratch/jmyers/glibc-bot/install/compilers/aarch64-linux-gnu/lib/gcc/aarch64-glibc-linux-gnu/7.2.1/../../../../aarch64-glibc-linux-gnu/bin/ld: final link failed: Bad value

This test is using various objects from the build of libc.  Some of
those objects contain references to __assert_fail.  Because those
references are hidden, they cannot refer to __assert_fail from
libc.so.  Given the tests using internal objects those symbols in
libc.a can't safely be made hidden, so this patch reverts the problem
commit until any alternative approach that doesn't break the build can
be found.

6 years agoRemove SPARC sqrt wrappers (bug 21973).
Joseph Myers [Mon, 21 Aug 2017 17:46:34 +0000 (17:46 +0000)]
Remove SPARC sqrt wrappers (bug 21973).

This patch removes the SPARC-specific wrappers for sqrt and sqrtf.

These wrappers, by adding architecture-specific uses of _LIB_VERSION
and __kernel_standard, unnecessarily complicate cleanups of libm error
handling.  They also do not serve a useful optimization purpose.  GCC
knows about sqrt as a built-in function, and can generate direct calls
to a hardware square root instruction, either on its own, in the
-fno-math-errno case, or together with an inline check for the
argument being negative and a call to the out-of-line sqrt function
for error handling only in that case (and has been able to do so for a
long time).  Thus in practice the wrapper will only be called only in
the case of negative arguments, which is not a case it is useful to
optimize for.

The removal of the wrappers also uncovers, and fixes, an old bug.
32-bit SPARC libm used (checked with glibc 2.8 binaries) to have a
sqrtl compat symbol, version GLIBC_2.0, for old binaries when sqrtl
was an alias of sqrt (I don't have pre-glibc-2.4 binaries for SPARC to
hand to check for the sqrtl symbol in those).  This disappeared,
probably with:

commit 8847f0377003fbfe9cbe951ce9f8717d74f26247
Author: David S. Miller <davem@davemloft.net>
Date:   Tue Feb 28 22:37:58 2012 -0800

    Add sparc optimized sqrt{,f}.

Removing the wrappers brings back the generic ldbl-opt logic for
creating such compat symbols, and so restores the compat symbol that
should be there.  This could of course also be fixed in the wrappers -
but as noted above, the wrappers are optimizing a case it's not useful
to optimize, so the bug of the missing compat symbol serves to
illustrate the risks involved with the extra complexity of
architecture-specific function versions where not needed.

Tested with build-many-glibcs.py.

[BZ #21973]
* sysdeps/sparc/sparc32/fpu/w_sqrt_compat.S: Remove file.
* sysdeps/sparc/sparc32/fpu/w_sqrtf_compat.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat-vis3.S:
Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat.S:
Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat-vis3.S:
Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat.S:
Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrt_compat.S : Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrtf_compat.S: Likewise.
* sysdeps/sparc/sparc64/fpu/w_sqrt_compat.S: Likewise.
* sysdeps/sparc/sparc64/fpu/w_sqrtf_compat.S: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Add
GLIBC_2.0 sqrtl symbol.

6 years agoObsolete matherr, _LIB_VERSION, libieee.a.
Joseph Myers [Mon, 21 Aug 2017 17:45:10 +0000 (17:45 +0000)]
Obsolete matherr, _LIB_VERSION, libieee.a.

This patch obsoletes support for SVID libm error handling (the system
where a user-defined function matherr is called on a libm function
error; only enabled if you also set _LIB_VERSION = _SVID_ or
_LIB_VERSION = _XOPEN_) and the use of the _LIB_VERSION global
variable to control libm error handling.  matherr and _LIB_VERSION are
made into compat symbols, not supported for new ports or for static
linking.  The libieee.a object file (which sets _LIB_VERSION = _IEEE_,
so disabling errno setting for some functions) is also removed, and
all the related definitions are removed from math.h.

The manual already recommends against using matherr, and it's already
not supported for _Float128 functions (those use new wrappers that
don't support matherr, only errno) - this patch means that it becomes
possible to e.g. add sinf32 as an alias to sinf without that resulting
in undesired matherr support in sinf32 for existing glibc ports.
matherr support is not part of any standard supported by glibc (it was
removed in XPG4).

Because matherr is a function to be defined by the user, of course
user programs defining such a function will still continue to link; it
just quietly won't be used.  If they try to write to the library's
copy of _LIB_VERSION to enable SVID error handling, however, they will
get a link error (but if they define their own _LIB_VERSION variable,
they won't).

I expect the most likely case of build failures from this patch to be
programs with unconditional cargo-culted uses of -lieee (based on a
notion of "I want IEEE floating point", not any actual requirement for
that library).

Ideally, the new-port-or-static-linking case would use the new
wrappers used for _Float128.  This is not implemented in this patch,
because of the complication of architecture-specific (powerpc32 and
sparc) sqrt wrappers that use _LIB_VERSION and __kernel_standard
directly.  Thus, the old wrappers and __kernel_standard are still
built unconditionally, and _LIB_VERSION still exists in static libm.
But when the old wrappers and __kernel_standard are built in the
non-compat case, _LIB_VERSION and matherr are defined as macros so
code to support those features isn't actually built into static libm
or new ports' shared libm after this patch.

I intend to move to the new wrappers for static libm and new ports in
followup patches.  I believe the sqrt wrappers for powerpc32 and sparc
can reasonably be removed.  GCC already optimizes the normal case of
sqrt by generating code that uses a hardware instruction and only
calls the sqrt function if the argument was negative (if
-fno-math-errno, of course, it just uses the hardware instruction
without any check for negative argument being needed).  Thus those
wrappers will only actually get called in the case of negative
arguments, which is not a case it makes sense to optimize for.  But
even without removing the powerpc32 and sparc wrappers it should still
be possible to move to the new wrappers for static libm and new ports,
just without having those dubious architecture-specific optimizations
in static libm.

Everything said about matherr equally applies to matherrf and matherrl
(IA64-specific, undocumented), except that the structure of IA64 libm
means it won't be converted to using the new wrappers (it doesn't use
the old ones either, but its own error-handling code instead).

As with other tests of compat symbols, I expect test-matherr and
test-matherr-2 to need to become appropriately conditional once we
have a system for disabling such tests for ports too new to have the
relevant symbols.

Tested for x86_64 and x86, and with build-many-glibcs.py.

* math/math.h [__USE_MISC] (_LIB_VERSION_TYPE): Remove.
[__USE_MISC] (_LIB_VERSION): Likewise.
[__USE_MISC] (struct exception): Likewise.
[__USE_MISC] (matherr): Likewise.
[__USE_MISC] (DOMAIN): Likewise.
[__USE_MISC] (SING): Likewise.
[__USE_MISC] (OVERFLOW): Likewise.
[__USE_MISC] (UNDERFLOW): Likewise.
[__USE_MISC] (TLOSS): Likewise.
[__USE_MISC] (PLOSS): Likewise.
[__USE_MISC] (HUGE): Likewise.
[__USE_XOPEN] (MAXFLOAT): Define even if [__USE_MISC].
* math/math-svid-compat.h: New file.
* conform/linknamespace.pl (@whitelist): Remove matherr, matherrf
and matherrl.
* include/math.h [!_ISOMAC] (__matherr): Remove.
* manual/arith.texi (FP Exceptions): Do not document matherr.
* math/Makefile (tests): Change test-matherr to test-matherr-3.
(tests-internal): New variable.
(install-lib): Do not add libieee.a.
(non-lib.a): Likewise.
(extra-objs): Do not add libieee.a and ieee-math.o.
(CPPFLAGS-s_lib_version.c): Remove variable.
($(objpfx)libieee.a): Remove rule.
($(addprefix $(objpfx), $(tests-internal)): Depend on $(libm).
* math/ieee-math.c: Remove.
* math/libm-test-support.c (matherr): Remove.
* math/test-matherr.c: Use <support/test-driver.c>.  Add copyright
and license notices.  Include <math-svid-compat.h> and
<shlib-compat.h>.
(matherr): Undefine as macro.  Use compat_symbol_reference.
(_LIB_VERSION): Likewise.
* math/test-matherr-2.c: New file.
* math/test-matherr-3.c: Likewise.
* sysdeps/generic/math_private.h (__kernel_standard): Remove
declaration.
(__kernel_standard_f): Likewise.
(__kernel_standard_l): Likewise.
* sysdeps/ieee754/s_lib_version.c: Do not include <math.h> or
<math_private.h>.  Include <math-svid-compat.h>.
(_LIB_VERSION): Undefine as macro.
(_LIB_VERSION_INTERNAL): Always initialize to _POSIX_.  Define
only if [LIBM_SVID_COMPAT || !defined SHARED].  If
[LIBM_SVID_COMPAT], use compat_symbol.
* sysdeps/ieee754/s_matherr.c: Do not include <math.h> or
<math_private.h>.  Include <math-svid-compat.h>.
(matherr): Undefine as macro.
(__matherr): Define only if [LIBM_SVID_COMPAT].  Use
compat_symbol.
* sysdeps/ia64/fpu/libm_error.c: Include <math-svid-compat.h>.
[_LIBC && LIBM_SVID_COMPAT] (matherrf): Use
compat_symbol_reference.
[_LIBC && LIBM_SVID_COMPAT] (matherrl): Likewise.
[_LIBC && !LIBM_SVID_COMPAT] (matherrf): Define as macro.
[_LIBC && !LIBM_SVID_COMPAT] (matherrl): Likewise.
* sysdeps/ia64/fpu/libm_support.h: Include <math-svid-compat.h>.
(MATHERR_D): Remove declaration.
[!_LIBC] (_LIB_VERSION_TYPE): Likewise
[!LIBM_BUILD] (_LIB_VERSIONIMF): Likewise.
[LIBM_BUILD] (pmatherrf): Likewise.
[LIBM_BUILD] (pmatherr): Likewise.
[LIBM_BUILD] (pmatherrl): Likewise.
(DOMAIN): Likewise.
(SING): Likewise.
(OVERFLOW): Likewise.
(UNDERFLOW): Likewise.
(TLOSS): Likewise.
(PLOSS): Likewise.
* sysdeps/ia64/fpu/s_matherrf.c: Include <math-svid-compat.h>.
(__matherrf): Define only if [LIBM_SVID_COMPAT].  Use
compat_symbol.
* sysdeps/ia64/fpu/s_matherrl.c: Include <math-svid-compat.h>.
(__matherrl): Define only if [LIBM_SVID_COMPAT].  Use
compat_symbol.
* math/lgamma-compat.h: Include <math-svid-compat.h>.
* math/w_acos_compat.c: Likewise.
* math/w_acosf_compat.c: Likewise.
* math/w_acosh_compat.c: Likewise.
* math/w_acoshf_compat.c: Likewise.
* math/w_acoshl_compat.c: Likewise.
* math/w_acosl_compat.c: Likewise.
* math/w_asin_compat.c: Likewise.
* math/w_asinf_compat.c: Likewise.
* math/w_asinl_compat.c: Likewise.
* math/w_atan2_compat.c: Likewise.
* math/w_atan2f_compat.c: Likewise.
* math/w_atan2l_compat.c: Likewise.
* math/w_atanh_compat.c: Likewise.
* math/w_atanhf_compat.c: Likewise.
* math/w_atanhl_compat.c: Likewise.
* math/w_cosh_compat.c: Likewise.
* math/w_coshf_compat.c: Likewise.
* math/w_coshl_compat.c: Likewise.
* math/w_exp10_compat.c: Likewise.
* math/w_exp10f_compat.c: Likewise.
* math/w_exp10l_compat.c: Likewise.
* math/w_exp2_compat.c: Likewise.
* math/w_exp2f_compat.c: Likewise.
* math/w_exp2l_compat.c: Likewise.
* math/w_fmod_compat.c: Likewise.
* math/w_fmodf_compat.c: Likewise.
* math/w_fmodl_compat.c: Likewise.
* math/w_hypot_compat.c: Likewise.
* math/w_hypotf_compat.c: Likewise.
* math/w_hypotl_compat.c: Likewise.
* math/w_j0_compat.c: Likewise.
* math/w_j0f_compat.c: Likewise.
* math/w_j0l_compat.c: Likewise.
* math/w_j1_compat.c: Likewise.
* math/w_j1f_compat.c: Likewise.
* math/w_j1l_compat.c: Likewise.
* math/w_jn_compat.c: Likewise.
* math/w_jnf_compat.c: Likewise.
* math/w_jnl_compat.c: Likewise.
* math/w_lgamma_main.c: Likewise.
* math/w_lgamma_r_compat.c: Likewise.
* math/w_lgammaf_main.c: Likewise.
* math/w_lgammaf_r_compat.c: Likewise.
* math/w_lgammal_main.c: Likewise.
* math/w_lgammal_r_compat.c: Likewise.
* math/w_log10_compat.c: Likewise.
* math/w_log10f_compat.c: Likewise.
* math/w_log10l_compat.c: Likewise.
* math/w_log2_compat.c: Likewise.
* math/w_log2f_compat.c: Likewise.
* math/w_log2l_compat.c: Likewise.
* math/w_log_compat.c: Likewise.
* math/w_logf_compat.c: Likewise.
* math/w_logl_compat.c: Likewise.
* math/w_pow_compat.c: Likewise.
* math/w_powf_compat.c: Likewise.
* math/w_powl_compat.c: Likewise.
* math/w_remainder_compat.c: Likewise.
* math/w_remainderf_compat.c: Likewise.
* math/w_remainderl_compat.c: Likewise.
* math/w_scalb_compat.c: Likewise.
* math/w_scalbf_compat.c: Likewise.
* math/w_scalbl_compat.c: Likewise.
* math/w_sinh_compat.c: Likewise.
* math/w_sinhf_compat.c: Likewise.
* math/w_sinhl_compat.c: Likewise.
* math/w_sqrt_compat.c: Likewise.
* math/w_sqrtf_compat.c: Likewise.
* math/w_sqrtl_compat.c: Likewise.
* math/w_tgamma_compat.c: Likewise.
* math/w_tgammaf_compat.c: Likewise.
* math/w_tgammal_compat.c: Likewise.
* sysdeps/ieee754/dbl-64/w_exp_compat.c: Likewise.
* sysdeps/ieee754/flt-32/w_expf_compat.c: Likewise.
* sysdeps/ieee754/k_standard.c: Likewise.
* sysdeps/ieee754/k_standardf.c: Likewise.
* sysdeps/ieee754/k_standardl.c: Likewise.
* sysdeps/ieee754/ldbl-128/w_expl_compat.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/w_expl_compat.c: Likewise.
* sysdeps/ieee754/ldbl-96/w_expl_compat.c: Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/w_sqrt_compat.S: Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/w_sqrtf_compat.S: Likewise.
* sysdeps/powerpc/powerpc32/power5/fpu/w_sqrt_compat.S: Likewise.
* sysdeps/powerpc/powerpc32/power5/fpu/w_sqrtf_compat.S: Likewise.
* sysdeps/sparc/sparc32/fpu/w_sqrt_compat.S: Likewise.
* sysdeps/sparc/sparc32/fpu/w_sqrtf_compat.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat-vis3.S:
Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat-vis3.S:
Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrt_compat.S: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrtf_compat.S: Likewise.
* sysdeps/sparc/sparc64/fpu/w_sqrt_compat.S: Likewise.
* sysdeps/sparc/sparc64/fpu/w_sqrtf_compat.S: Likewise.

6 years agobenchtests: Do not compile benchmark objects as libc modules [BZ #21864]
Florian Weimer [Mon, 21 Aug 2017 17:28:54 +0000 (19:28 +0200)]
benchtests: Do not compile benchmark objects as libc modules [BZ #21864]

Otherwise, this will lead to link failures due to hidden symbol
references.

6 years agoassert: Support types without operator== (int) [BZ #21972]
Florian Weimer [Mon, 21 Aug 2017 11:03:29 +0000 (13:03 +0200)]
assert: Support types without operator== (int) [BZ #21972]

6 years agox86-64: Mark internal symbols with attribute_hidden [BZ #18822]
H.J. Lu [Mon, 21 Aug 2017 12:58:39 +0000 (05:58 -0700)]
x86-64: Mark internal symbols with attribute_hidden [BZ #18822]

Since __syscall_clock_gettime and __start_context are internal symbols
for Linux/x86-64, mark them with attribute_hidden.

[BZ #18822]
* sysdeps/unix/sysv/linux/x86_64/init-first.c
(__syscall_clock_gettime): Add attribute_hidden.
* sysdeps/unix/sysv/linux/x86_64/makecontext.c
(__start_context): Likewise.

6 years agoAdd hidden visibility to internal function prototypes
H.J. Lu [Mon, 21 Aug 2017 12:50:38 +0000 (05:50 -0700)]
Add hidden visibility to internal function prototypes

Add hidden visibility to internal function prototypes to allow direct
access to internal functions within libc.a without using GOT when the
compiler defaults to -fPIE.

Size comparison of elf/ldconfig when the compiler defaults to -fPIE:

On x86-64:
        text    data     bss     dec     hex
Before: 619646   20132    5488  645266   9d892
After : 619502   20132    5488  645122   9d802
On i686:
        text    data     bss     dec     hex
Before: 550333   10748    3060  564141   89bad
After : 546453   10732    3060  560245   88c75

* include/libc-symbols.h (__hidden_proto_hiddenattr): New for
building libc.a.
(hidden_proto): Likewise.
(hidden_tls_proto): Likewise.
(__hidden_proto): Likewise.

6 years agoEnable hidden visibility in libc.a compiled with PIE
H.J. Lu [Mon, 21 Aug 2017 12:47:10 +0000 (05:47 -0700)]
Enable hidden visibility in libc.a compiled with PIE

When building libc.a with PIE, enable hidden visibility to allow direct
access to definitions within libc.a without using GOT.

Size comparison of elf/ldconfig when the compiler defaults to -fPIE:

On x86-64:
        text    data     bss     dec     hex
Before: 619206   20132    5488  644826   9d6da
After : 619062   20132    5488  644682   9d64a
On i686:
        text    data     bss     dec     hex
Before: 556305   10816    3056  570177   8b341
After : 553688   10756    3056  567500   8a8cc

* include/libc-symbols.h (attribute_hidden): Enable hidden
visibility in libc.a compiled with PIE.

6 years agox86: Mark VDSO_SYMBOL(getcpu) with attribute_hidden [BZ #18822]
H.J. Lu [Mon, 21 Aug 2017 12:40:33 +0000 (05:40 -0700)]
x86: Mark VDSO_SYMBOL(getcpu) with attribute_hidden [BZ #18822]

VDSO_SYMBOL(getcpu) is defined as hidden in Linux/x86_64 init-first.c
and unused for Linux/i386.

[BZ #18822]
* sysdeps/unix/sysv/linux/x86/libc-vdso.h (VDSO_SYMBOL(getcpu)):
Add attribute_hidden.

6 years agoDon't compile non-lib modules as lib modules [BZ #21864]
H.J. Lu [Sun, 30 Jul 2017 04:04:09 +0000 (21:04 -0700)]
Don't compile non-lib modules as lib modules [BZ #21864]

Some programs have more than one source files.  These non-lib modules
should not be compiled with -DMODULE_NAME=libc.  This patch puts these
non-lib modules in $(others-extras) and adds $(others-extras) to
all-nonlib.

[BZ #21864]
* Makerules (all-nonlib): Add $(others-extras).
* catgets/Makefile (others-extras): New.
* elf/Makefile (others-extras): Likewise.
* nss/Makefile (others-extras): Likewise.

6 years agoMark __libc_multiple_libcs with attribute_hidden [BZ #18822]
H.J. Lu [Mon, 21 Aug 2017 12:32:21 +0000 (05:32 -0700)]
Mark __libc_multiple_libcs with attribute_hidden [BZ #18822]

Since __libc_multiple_libcs is defined as hidden symbol in init-first.c,
it should be always marked with attribute_hidden.

[BZ #18822]
* csu/libc-start.c (__libc_multiple_libcs): Removed.
* elf/dl-open.c: Include <libc-internal.h>.
(__libc_multiple_libcs): Removed.
* elf/dl-sysdep.c: Include <libc-internal.h> instead of
<hp-timing.h>.
* include/libc-internal.h (__libc_multiple_libcs): New.
* misc/sbrk.c: Include <libc-internal.h>.
(__libc_multiple_libcs): Removed.

6 years agoMark internal nss symbols with attribute_hidden [BZ #18822]
H.J. Lu [Mon, 21 Aug 2017 12:31:02 +0000 (05:31 -0700)]
Mark internal nss symbols with attribute_hidden [BZ #18822]

Mark internal nss symbols with attribute_hidden to allow direct access
within libc.so and libc.a without using GOT nor PLT.

Tested on x86-64 with and without --disable-nscd.

[BZ #18822]
* grp/initgroups.c (__nss_group_database): Removed.
(__nss_initgroups_database): Likewise.
* nscd/gai.c (__nss_hosts_database): Likewise.
* nss/XXX-lookup.c (DATABASE_NAME_SYMBOL): Likewise.
* posix/tst-rfc3484-2.c (__nss_hosts_database): Likewise.
* posix/tst-rfc3484-3.c (__nss_hosts_database): Likewise.
* posix/tst-rfc3484.c (__nss_hosts_database): Likewise.
* sysdeps/posix/getaddrinfo.c (__nss_hosts_database): Likewise.
* nss/getXXent.c (INTERNAL (REENTRANT_GETNAME)): Add
attribute_hidden.
* nss/nsswitch.c (__nss_database_custom): Define only if
USE_NSCD is defined.
(__nss_configure_lookup): Use __nss_database_custom only if
USE_NSCD is defined.
* nss/nsswitch.h (__nss_database_custom): Declare only if
USE_NSCD is defined.  Add attribute_hidden.
(__nss_setent): Add attribute_hidden.
(__nss_endent): Likewise.
(__nss_getent_r): Likewise.
(__nss_getent): Likewise.
(DEFINE_DATABASE): Declare __nss_##arg##_database.

6 years agoi386: Hide __old_glob64 [BZ #18822]
H.J. Lu [Sun, 20 Aug 2017 17:46:47 +0000 (10:46 -0700)]
i386: Hide __old_glob64 [BZ #18822]

Hide internal __old_glob64 function to allow direct access within
libc.so and libc.a without using GOT nor PLT.

[BZ #18822]
* sysdeps/unix/sysv/linux/i386/glob64.c (__old_glob64): Add
libc_hidden_proto and libc_hidden_def.

6 years agoi386: Hide __old_readdir64 [BZ #18822]
H.J. Lu [Sun, 20 Aug 2017 17:45:58 +0000 (10:45 -0700)]
i386: Hide __old_readdir64 [BZ #18822]

Hide internal __old_readdir64 function to allow direct access within
libc.so and libc.a without using GOT nor PLT.

[BZ #18822]
* sysdeps/unix/sysv/linux/i386/olddirent.h (__old_readdir64):
Add libc_hidden_proto.
* sysdeps/unix/sysv/linux/i386/readdir64.c (__old_readdir64):
Add libc_hidden_def.

6 years agoRemove sysdeps/alpha/bb_init_func.S
H.J. Lu [Sun, 20 Aug 2017 13:50:59 +0000 (06:50 -0700)]
Remove sysdeps/alpha/bb_init_func.S

Since the generic __bb_init_func has been removed by commit 7ed87317c7fb,
there is no need for sysdeps/alpha/bb_init_func.S.

[BZ #21974]
* sysdeps/alpha/bb_init_func.S: Removed.

6 years agoUpdate ChangeLog
H.J. Lu [Sun, 20 Aug 2017 13:45:25 +0000 (06:45 -0700)]
Update ChangeLog

6 years agoRemove __bb_init_func and __bb_exit_func [BZ #21974]
H.J. Lu [Sun, 20 Aug 2017 13:39:10 +0000 (06:39 -0700)]
Remove __bb_init_func and __bb_exit_func [BZ #21974]

__bb_init_func and __bb_exit_func have been removed from GCC 3.3 in
2002 by

https://gcc.gnu.org/ml/gcc-patches/2002-09/msg00499.html

which also recommended that they should also be removed from glibc. These
functions exist only in libc.a and are used for gcov from versions of GCC
older than GCC 3.3.

[BZ #21974]
* gmon/Makefile (routines): Remove bb_init_func and
bb_exit_func.
(elide-routines.os): Removed.
* include/sys/gmon.h (__bb): Likewise.
(__bb_init_func): Likewise.
(__bb_exit_func): Likewise.

6 years agoMove ____longjmp_chk prototype to include/setjmp.h
H.J. Lu [Sun, 20 Aug 2017 13:30:29 +0000 (06:30 -0700)]
Move ____longjmp_chk prototype to include/setjmp.h

Move ____longjmp_chk prototype to include/setjmp.h and add
attribute_hidden.

* debug/longjmp_chk.c (____longjmp_chk): Moved to ...
* include/setjmp.h (____longjmp_chk): Here.  Add
attribute_hidden.

6 years agoMark internal SSE2 functions with attribute_hidden [BZ #18822]
H.J. Lu [Sat, 19 Aug 2017 23:46:33 +0000 (16:46 -0700)]
Mark internal SSE2 functions with attribute_hidden [BZ #18822]

Mark internal SSE2 functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.

[BZ #18822]
* sysdeps/x86_64/multiarch/strcspn-c.c (STRCSPN_SSE2): Add
attribute_hidden.
(__strspn_sse2): Likewise.

6 years agoConsolidate non cancellable close call
Adhemerval Zanella [Mon, 3 Jul 2017 18:22:58 +0000 (15:22 -0300)]
Consolidate non cancellable close call

This patch consolidates all the non cancellable close calls to use
the __close_nocancel{_nostatus} identifier.  For non cancellable targets
it will be just a macro to call the default respective symbol while on Linux
will be a internal one.

Also, since it is used on libcrypto it is also exported in GLIBC_PRIVATE
namespace.

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

* sysdeps/generic/not-cancel.h (close_not_cancel): Remove macro.
(close_not_cancel_no_status): Likewise.
(__close_nocancel): New macro.
(__close_nocancel_no_status): Likewise.
* sysdeps/unix/sysv/linux/not-cancel.h (__close_nocancel): Remove
macro.
(close_not_cancel): Likewise.
(close_not_cancel_no_status): Likewise.
(__close_nocancel): New prototype.
(__close_nocancel_no_status): New function.
* sysdeps/unix/sysv/linux/close.c (__close_nocancel): New function.
* catgets/open_catalog.c (__open_catalog): Replace
close_not_cancel{_no_status) with __close_nocancel{_nostatus}.
* gmon/gmon.c (write_gmon): Likewise.
* iconv/gconv_cache.c (__gconv_load_cache): Likewise.
* intl/loadmsgcat.c (close): Likewise.
* io/ftw.c (open_dir_stream): Likewise.
(ftw_startup): Likewise.
* libio/fileops.c (_IO_file_open): Likewise.
(_IO_file_close_mmap): Likewise.
(_IO_file_close): Likewise.
* libio/iopopen.c (_IO_dup2): Likewise.
* locale/loadarchive.c (_nl_load_locale_from_archive): Likewise.
* locale/loadlocale.c (_nl_load_locale): Likewise.
* login/utmp_file.c (pututline_file): Likewise.
(endutent_file): Likewise.
* misc/daemon.c (daemon): Likewise.
* nscd/nscd_getai.c (__nscd_getai): Likewise.
* nscd/nscd_getgr_r.c (nscd_getgr_r): Likewise.
* nscd/nscd_gethst_r.c (nscd_gethst_r): Likewise.
* nscd/nscd_getpw_r.c (nscd_getpw_r): Likewise.
* nscd/nscd_getserv_r.c (nscd_getserv_r): Likewise.
* nscd/nscd_helper.c (open_socket): Likewise.
(__nscd_open_socket): Likewise.
* nscd/nscd_initgroups.c (__nscd_getgrouplist): Likewise.
* nscd/nscd_netgroup.c (__nscd_setnetgrent): Likewise.
(__nscd_innetgr): Likewise.
* nss/nss_db/db-open.c (internal_setent): Likewise.
* resolv/res-close.c (__res_iclose): Likewise.
* sunrpc/pm_getmaps.c (pmap_getmaps): Likewise.
* sysdeps/posix/closedir.c (__closedir): Likewise.
* sysdeps/posix/getaddrinfo.c (getaddrinfo): Likewise.
* sysdeps/posix/getcwd.c (__getcwd): Likewise.
* sysdeps/posix/opendir.c (tryopen_o_directory): Likewise.
(opendir_tail): Likewise.
* sysdeps/posix/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/check_native.c (__check_native): Likewise.
* sysdeps/unix/sysv/linux/check_pf.c (__check_pf): Likewise.
* sysdeps/unix/sysv/linux/fips-private.h (fips_enabled_p): Likewise.
* sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise.
(gethostid): Likewise.
* sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise.
* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
Likewise.
* sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Likewise.
* sysdeps/unix/sysv/linux/grantpt.c (close_all_fds): Likewise.
* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
* sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock):
Likewise.
* sysdeps/unix/sysv/linux/if_index.c (__if_nametoindex): Likewise.
* sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps): Likewise.
* sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap):
Likewise.
* sysdeps/unix/sysv/linux/mq_notify.c (init_mq_netlink): Likewise.
* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np):
Likewise.
* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
Likewise.
* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise.

6 years agoConsolidate non cancellable openat call
Adhemerval Zanella [Mon, 3 Jul 2017 18:00:26 +0000 (15:00 -0300)]
Consolidate non cancellable openat call

This patch consolidates all the non cancellable openat{64} calls to use
the __openat{64}_nocancel identifier.  For non cancellable targets it will
be just a macro to call the default respective symbol while on Linux
will be a internal one.

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

* sysdeps/generic/not-cancel.h (openat_not_cancel): Remove macro.
(openat_not_cancel_3): Likewise.
(openat64_not_cancel_3): Likewise).
(openat_not_cancel_3): Likewise).
* sysdeps/unix/sysv/linux/not-cancel.h (openat_not_cancel): Remove
macro.
(openat_not_cancel_3): Likewise.
(openat64_not_cancel): Likewise.
(openat64_not_cancel_3): Likewise.
* sysdeps/unix/sysv/linux/openat.c (__openat_nocancel): New function.
* sysdeps/unix/sysv/linux/openat64.c (__openat64_nocancel): Likewise.
* io/ftw.c (open_dir_stream): Replace openat{64}_not_cancel{_3} with
__open{64}_nocancel.
* sysdeps/mach/hurd/opendir.c (__opendirat): Likewise.
* sysdeps/posix/getcwd.c (__getcwd): Likewise.
* sysdeps/posix/opendir.c (__opendirat): Likewise.

6 years agoMark internal argz functions with attribute_hidden [BZ #18822]
H.J. Lu [Fri, 18 Aug 2017 16:31:19 +0000 (09:31 -0700)]
Mark internal argz functions with attribute_hidden [BZ #18822]

Move internal argz function prototypes to include/argz.h and mark them
with attribute_hidden to allow direct access within libc.so and libc.a
without using GOT nor PLT.  This also brings string/argz.h closer to the
gnulib version.

[BZ #18822]
* include/argz.h (__argz_create_sep): New function prototype.
(__argz_append): Likewise.
(__argz_add): Likewise.
(__argz_add_sep): Likewise.
(__argz_delete): Likewise.
(__argz_insert): Likewise.
(__argz_replace): Likewise.
* string/argz.h (__argz_create_sep): Removed.
(__argz_append): Likewise.
(__argz_add): Likewise.
(__argz_add_sep): Likewise.
(__argz_delete): Likewise.
(__argz_insert): Likewise.
(__argz_replace): Likewise.

6 years agoAdd NT_GNU_PROPERTY_TYPE_0 macros
H.J. Lu [Fri, 18 Aug 2017 15:49:07 +0000 (08:49 -0700)]
Add NT_GNU_PROPERTY_TYPE_0 macros

Add macros used in GNU .note.gnu.property notes (NT_GNU_PROPERTY_TYPE_0).

* elf/elf.h (NT_GNU_PROPERTY_TYPE_0): New.
(NOTE_GNU_PROPERTY_SECTION_NAME): Likewise.
(GNU_PROPERTY_STACK_SIZE): Likewie.
(GNU_PROPERTY_NO_COPY_ON_PROTECTED): Likewie.
(GNU_PROPERTY_LOPROC): Likewise.
(GNU_PROPERTY_HIPROC): Likewise.
(GNU_PROPERTY_LOUSER): Likewise.
(GNU_PROPERTY_HIUSER): Likewise.
(GNU_PROPERTY_X86_ISA_1_USED): Likwise.
(GNU_PROPERTY_X86_ISA_1_NEEDED): Likwise.
(GNU_PROPERTY_X86_FEATURE_1_AND): Likwise.
(GNU_PROPERTY_X86_ISA_1_486): Likwise.
(GNU_PROPERTY_X86_ISA_1_586): Likwise.
(GNU_PROPERTY_X86_ISA_1_686): Likwise.
(GNU_PROPERTY_X86_ISA_1_SSE): Likwise.
(GNU_PROPERTY_X86_ISA_1_SSE2): Likwise.
(GNU_PROPERTY_X86_ISA_1_SSE3): Likwise.
(GNU_PROPERTY_X86_ISA_1_SSSE3): Likwise.
(GNU_PROPERTY_X86_ISA_1_SSE4_1): Likwise.
(GNU_PROPERTY_X86_ISA_1_SSE4_2): Likwise.
(GNU_PROPERTY_X86_ISA_1_AVX): Likwise.
(GNU_PROPERTY_X86_ISA_1_AVX2): Likwise.
(GNU_PROPERTY_X86_ISA_1_AVX512F): Likwise.
(GNU_PROPERTY_X86_ISA_1_AVX512CD): Likwise.
(GNU_PROPERTY_X86_ISA_1_AVX512ER): Likwise.
(GNU_PROPERTY_X86_ISA_1_AVX512PF): Likwise.
(GNU_PROPERTY_X86_ISA_1_AVX512VL): Likwise.
(GNU_PROPERTY_X86_ISA_1_AVX512DQ): Likwise.
(GNU_PROPERTY_X86_ISA_1_AVX512BW): Likwise.
(GNU_PROPERTY_X86_FEATURE_1_IBT): Likwise.
(GNU_PROPERTY_X86_FEATURE_1_SHSTK): Likwise.

6 years agoDo not use generic selection in C++ mode
Gabriel F. T. Gomes [Mon, 14 Aug 2017 20:51:51 +0000 (17:51 -0300)]
Do not use generic selection in C++ mode

The logic to protect the use of generic selection (_Generic) does not
check for C or C++ mode, however, generic selection is a C-only
feature.

Tested for powerpc64le.

* misc/sys/cdefs.h (__HAVE_GENERIC_SELECTION): Define to 0, if
in C++ mode.

6 years agoDo not use __builtin_types_compatible_p in C++ mode (bug 21930)
Gabriel F. T. Gomes [Fri, 11 Aug 2017 17:29:06 +0000 (14:29 -0300)]
Do not use __builtin_types_compatible_p in C++ mode (bug 21930)

The logic to define isinf for float128 depends on the availability of
__builtin_types_compatible_p, which is only available in C mode,
however, the conditionals do not check for C or C++ mode.  This lead to
an error in libstdc++ configure, as reported by bug 21930.

This patch adds a conditional for C mode in the definition of isinf for
float128.  No definition is provided in C++ mode, since libstdc++
headers undefine isinf.

Tested for powerpc64le (glibc test suite and libstdc++-v3 configure).

[BZ #21930]
* math/math.h (isinf): Check if in C or C++ mode before using
__builtin_types_compatible_p, since this is a C mode feature.

6 years agoConsolidate non cancellable write call
Adhemerval Zanella [Mon, 3 Jul 2017 17:39:52 +0000 (14:39 -0300)]
Consolidate non cancellable write call

This patch consolidates all the non cancellable write calls to use
the __write_nocancel identifier.  For non cancellable targets it will
be just a macro to call the default respective symbol while on Linux
will be a internal one.

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

* sysdeps/generic/not-cancel.h (write_not_cancel): Remove macro.
(__write_nocancel): New macro.
* sysdeps/unix/sysv/linux/not-cancel.h (__write_nocancel):
Rewrite as a function prototype.
(write_not_cancel): Remove macro.
* sysdeps/unix/sysv/linux/write.c (__write_nocancel): New function.
* gmon/gmon.c (ERR): Replace write_not_cancel with __write_nocancel.
(write_gmon): Likewise.
* libio/fileops.c (_IO_new_file_write): Likewise.
* login/utmp_file.c (pututline_file): Likewise.
(updwtmp_file): Likewise.
* stdio-common/psiginfo.c (psiginfo): Likewise.
* sysdeps/posix/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise.
* sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps):
Likewise.
* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
Likewise.

6 years agoConsolidate non cancellable read call
Adhemerval Zanella [Mon, 3 Jul 2017 17:20:46 +0000 (14:20 -0300)]
Consolidate non cancellable read call

This patch consolidates all the non cancellable read calls to use
the __read_nocancel identifier.  For non cancellable targets it will
be just a macro to call the default respective symbol while on Linux
will be a internal one.

Also, since it is used on libcrypto it is also exported in GLIBC_PRIVATE
namespace.

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

* sysdeps/generic/not-cancel.h (read_not_cancel): Remove macro.
(__read_nocancel): New macro.
* sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add
__read_nocancel.
* sysdeps/unix/sysv/linux/not-cancel.h (__read_nocancel): Remove
macro.
(__read_nocancel): New prototype.
* sysdeps/unix/sysv/linux/read.c (__read_nocancel): New function.
* catgets/open_catalog.c (__open_catalog): Replace read_not_cancel
with __read_nocancel.
* intl/loadmsgcat.c (read): Likewise.
* libio/fileops.c (_IO_file_read): Likewise.
* locale/loadlocale.c (_nl_load_locale): Likewise.
* login/utmp_file.c (getutent_r_file): Likewise.
(internal_getut_r): Likewise.
(getutline_r_file): Likewise.
* sysdeps/unix/sysv/linux/fips-private.h (fips_enable_p): Likewise.
* sysdeps/unix/sysv/linux/gethostid.c (gethostid): Likewise.
* sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise.
* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
Likewise.
* sysdeps/unix/sysv/linux/getsysstats.c (next_line): Likewise.
* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
* sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock):
Likewise.
* sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps):
Likewise.
* sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap):
Likewise.
* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np):
Likewise.
* sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise.

6 years agox86-64: Check FMA_Usable in ifunc-mathvec-avx2.h [BZ #21966]
H.J. Lu [Fri, 18 Aug 2017 13:18:55 +0000 (06:18 -0700)]
x86-64: Check FMA_Usable in ifunc-mathvec-avx2.h [BZ #21966]

Since the AVX2 version of mathvec functions uses FMA, it can only be
used when FMA is usable.

[BZ #21966]
* sysdeps/x86_64/fpu/multiarch/ifunc-mathvec-avx2.h
(IFUNC_SELECTOR): Don't use the AVX2 version if FMA isn't
usable.

6 years agoUse the range notation in charmaps/UTF-8 for all ranges of neighbouring characters...
Mike FABIAN [Fri, 18 Aug 2017 11:41:34 +0000 (13:41 +0200)]
Use the range notation in charmaps/UTF-8 for all ranges of neighbouring characters with the same width

[BZ #21750]
* charmaps/UTF-8: Use the range notation for all ranges
of neighbouring characters with the same width.

6 years agoUpdate nss tests to new skeleton
DJ Delorie [Thu, 17 Aug 2017 21:58:25 +0000 (17:58 -0400)]
Update nss tests to new skeleton

* bug17079.c: Update to new test harness.
* test-digits-dots.c: Likewise.
* test-netdb.c: Likewise.
* tst-field.c: Likewise.
* tst-nss-getpwent.c: Likewise.
* tst-nss-static.c: Likewise.
* tst-nss-test1.c: Likewise.
* tst-nss-test2.c: Likewise.
* tst-nss-test3.c: Likewise.
* tst-nss-test4.c: Likewise.
* tst-nss-test5.c: Likewise.

6 years agoConsolidate non cancellable open call
Adhemerval Zanella [Mon, 3 Jul 2017 14:11:24 +0000 (11:11 -0300)]
Consolidate non cancellable open call

This patch consolidates all the non cancellable open calls to use
the __open_nocancel identifier.  For non cancellable targets it will
be just a macro to call the default respective symbol while on Linux
will be a internal one.

To be consistent with the following non cancellable openat call, a
new __open64_nocancel is also added (although not currently used).

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

* sysdeps/generic/not-cancel.h (open_not_cancel): Remove macro.
(open_not_cancel_2): Likewise.
(open_nocancel): New macro.
(open64_nocancel): Likewise.
* sysdeps/unix/sysv/linux/not-cancel.h (open_not_cancel): Remove macro.
(open_not_cancel_2): Likewise.
(__open_nocancel): New prototype.
(__open64_nocancel): Likewise.
* sysdeps/unix/sysv/linux/Versions (libc) [GLIBC_PRIVATE]: Add
__open_nocancel.
* sysdeps/unix/sysv/linux/open.c (__open_nocancel): New function.
* sysdeps/unix/sysv/linux/open64.c (__open64_nocancel): Likewise.
* catgets/open_catalog.c (__open_catalog): Replace open_not_cancel{_2}
with __open_nocancel.
* csu/check_fds.c (check_one_fd): Likewise.
* gmon/gmon.c (write_gmon): Likewise.
* iconv/gconv_cache.c (__gconv_load_cached): Likewise.
* intl/loadmsgcat.c (open): Likewise.
* libio/fileops.c (_IO_file_open): Likewise.
* locale/loadarchive.c (_nl_load_locale_from_archive): Likewise.
* locale/loadlocale.c (_nl_load_locale): Likewise.
* login/utmp_file.c (setutent_file): Likewise.
* misc/daemon.c (daemon): Likewise.
* nss/nss_db/db-open.c (internal_setent): Likewise.
* sysdeps/mach/hurd/opendir.c (__opendirat): Likewise.
* sysdeps/posix/libc_fatal.c (__libc_message): Likewise.
* sysdeps/posix/opendir.c (tryopen_o_directory): Likewise.
(__opendir): Likewise.
* sysdeps/posix/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/fips-private.h (fips_enable_p): Likewise.
* sysdeps/unix/sysv/linux/gethostid.c (sethostid): Likewise.
(gethostid): Likewise.
* sysdeps/unix/sysv/linux/getloadavg.c (getloadavg): Likewise.
* sysdeps/unix/sysv/linux/getlogin_r.c (__getlogin_r_loginuid):
Likewise.
* sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Likewise.
* sysdeps/unix/sysv/linux/grantpt.c (__close_all_fds): Likewise.
* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
* sysdeps/unix/sysv/linux/ia64/has_cpuclock.c (has_cpuclock):
Likewise.
* sysdeps/unix/sysv/linux/libc_fatal.c (backtrace_and_maps):
Likewise.
* sysdeps/unix/sysv/linux/malloc-sysdep.h (check_may_shrink_heap):
Likewise.
* sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c (__get_clockfreq):
Likewise.
* sysdeps/unix/sysv/linux/pthread_getname.c (pthread_getname_np):
Likewise.
* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
Likewise.
* sysdeps/unix/sysv/linux/spawni.c (__spawni_child): Likewise.
* sysdeps/unix/sysv/linux/sysconf.c (__sysconf): Likewise.

6 years agoAdd math benchmark latency test
Wilco Dijkstra [Thu, 17 Aug 2017 15:27:20 +0000 (16:27 +0100)]
Add math benchmark latency test

This patch further improves math function benchmarking by adding a latency
test in addition to throughput.  This enables more accurate comparisons of the
math functions. The latency test works by creating a dependency on the previous
iteration: func_res = F (func_res * zero + input[i]). The multiply by zero
avoids changing the input.

It reports reciprocal throughput and latency in nanoseconds (depending on the
timing header used) and max/min throughput in iterations per second:

   "workload-spec2006.wrf": {
    "reciprocal-throughput": 100,
    "latency": 200,
    "max-throughput": 1.0e+07,
    "min-throughput": 5.0e+06
   }

* benchtests/bench-skeleton.c (main): Add support for
latency benchmarking.
* benchtests/scripts/bench.py: Add support for latency benchmarking.

6 years agoSupport mcount/gprof test with GCC defaulting to PIE
H.J. Lu [Thu, 17 Aug 2017 11:55:44 +0000 (04:55 -0700)]
Support mcount/gprof test with GCC defaulting to PIE

The mcount/gprof test should be linked with gcrt1.o, not Scrt1.o.

* Makeconfig (+link-pie-before-libc): Add CRT-* hook to override
the startup object.

6 years agoFix abmon for bem_ZM
Akhilesh Kumar [Wed, 16 Aug 2017 10:03:58 +0000 (15:33 +0530)]
Fix abmon for bem_ZM

Until now the abbreviated month names were in English.

[BZ #21960]
* locales/bem_ZM (LC_TIME): Fix abmon, make it agree with CLDR.

6 years agoFix country name for xh_ZA
Akhilesh Kumar [Wed, 16 Aug 2017 12:31:53 +0000 (18:01 +0530)]
Fix country name for xh_ZA

[BZ #21959]
* locales/xh_ZA (LC_ADDRESS): Fix country name.

6 years agoRefresh generated charmap data and ChangeLog
Thorsten Glaser [Fri, 14 Jul 2017 12:02:50 +0000 (14:02 +0200)]
Refresh generated charmap data and ChangeLog

[BZ #21750]
* charmaps/UTF-8: Refresh.

6 years agoResolve some historically special cases of ambiguous width
Thorsten Glaser [Fri, 14 Jul 2017 12:02:46 +0000 (14:02 +0200)]
Resolve some historically special cases of ambiguous width

[BZ #21750]
* unicode-gen/utf8_gen.py (U+00AD): Set width to 1.
* unicode-gen/utf8_gen.py (U+1160..U+11FF): Set width to 0.
* unicode-gen/utf8_gen.py (U+3248..U+324F): Set width to 2.
* unicode-gen/utf8_gen.py (U+4DC0..U+4DFF): Likewise.

6 years agoHandle more cases of combining characters
Thorsten Glaser [Fri, 14 Jul 2017 12:02:44 +0000 (14:02 +0200)]
Handle more cases of combining characters

[BZ #21750]
* unicode-gen/utf8_gen.py: Treat category Me and Mn as combining.

6 years agoUnicodeData has precedence over EastAsianWidth
Thorsten Glaser [Fri, 14 Jul 2017 12:02:37 +0000 (14:02 +0200)]
UnicodeData has precedence over EastAsianWidth

[BZ #19852]
[BZ #21750]
* unicode-gen/utf8_gen.py: Process EastAsianWidth lines before
  UnicodeData lines so the latter have precedence; remove hack
  to group output by EastAsianWidth ranges.

6 years ago__opensock: Remove internal_function attribute
Florian Weimer [Thu, 17 Aug 2017 08:18:04 +0000 (10:18 +0200)]
__opensock: Remove internal_function attribute

6 years agoFix sigval namespace (bug 21944).
Joseph Myers [Wed, 16 Aug 2017 20:33:59 +0000 (20:33 +0000)]
Fix sigval namespace (bug 21944).

XPG4.2 defines the siginfo_t type, but not union sigval or its
contents (which were added in the 1993 edition of POSIX.1), resulting
in namespace violations for sigval, sival_int and sival_ptr for
signal.h and sys/wait.h for that standard because those headers
incorrectly expose those names in that case.

This patch fixes this problem.  The public type in this case is union
sigval, but various places in the headers use the sigval_t name for
it; direct uses of union sigval are already properly guarded or in
headers not in XPG4.2.  Now, sigval_t, although not a standard name,
does seem to be widely used outside glibc.  The approach taken by this
patch is to make installed headers use the name __sigval_t instead.
__sigval_t is then defined to either union sigval or union __sigval
(where union __sigval has __-prefixed member names as well), depending
on whether there are any namespace issues with the union sigval name
and its members.  In the case where union __sigval is used, sigval_t
is not defined at all, to avoid the problem of sigval_t having a C++
mangled name that depends on feature test macros.  sigval_t is still
defined by signal.h if __USE_MISC (reflecting the nonstandard nature
of that name).

Tested for x86_64.

[BZ #21944]
* signal/bits/types/__sigval_t.h: New file.
* signal/Makefile (headers): Add bits/types/__sigval_t.h.
* signal/bits/types/sigval_t.h: Include <bits/types/__sigval_t.h>
and define sigval_t using __sigval_t.
* include/bits/types/__sigval_t.h: New file.
* bits/types/sigevent_t.h: Include <bits/types/__sigval_t.h>
instead of <bits/types/__sigval_t.h>.
(struct sigevent): Use __sigval_t instead of sigval_t.
* bits/types/siginfo_t.h: Include <bits/types/__sigval_t.h>
instead of <bits/types/__sigval_t.h>.
(siginfo_t): Use __sigval_t instead of sigval_t.
* sysdeps/unix/sysv/linux/bits/types/sigevent_t.h: Include
<bits/types/__sigval_t.h> instead of <bits/types/__sigval_t.h>.
(struct sigevent): Use __sigval_t instead of sigval_t.
* sysdeps/unix/sysv/linux/bits/types/siginfo_t.h: Include
<bits/types/__sigval_t.h> instead of <bits/types/__sigval_t.h>.
(siginfo_t): Use __sigval_t instead of sigval_t.
* signal/signal.h [__USE_MISC]: Include <bits/types/sigval_t.h>.

6 years agoRemove "[Add new features here]" for 2.27
H.J. Lu [Wed, 16 Aug 2017 18:05:55 +0000 (11:05 -0700)]
Remove "[Add new features here]" for 2.27

* NEWS: Remove "[Add new features here]" for 2.27.

6 years agoAllow abort PLT references in libc.so for SH.
Joseph Myers [Wed, 16 Aug 2017 17:01:27 +0000 (17:01 +0000)]
Allow abort PLT references in libc.so for SH.

Given my patch
<https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00965.html> for the
ICEs building a glibc string function test for SH, the testsuite can
build completely for SH with GCC 7 and mainline.  However, there is a
test failure that does not appear for GCC 6: check-localplt fails
because of an abort PLT reference in libc.so.

Given the lack of a trap insn pattern for SH, it seems unavoidable
that the compiler might sometimes generate abort calls, and such abort
calls (generated from __builtin_trap when there is no trap insn
pattern) will be unaffected by the normal mapping to __GI_abort for
calls within glibc.  Thus, this patch allows (but does not require) an
abort PLT reference in libc.so for SH.

Tested for sh4-linux-gnu with build-many-glibcs.py (GCC 7, with my
patch applied).

* sysdeps/unix/sysv/linux/sh/localplt.data: Allow abort in
libc.so.

6 years agoMention x86-64 FMA optimization in NEWS
H.J. Lu [Wed, 16 Aug 2017 16:17:34 +0000 (09:17 -0700)]
Mention x86-64 FMA optimization in NEWS

* NEWS: Mention x86-64 FMA optimization.

6 years agox86-64: Optimize e_expf with FMA [BZ #21912]
H.J. Lu [Wed, 16 Aug 2017 15:43:35 +0000 (08:43 -0700)]
x86-64: Optimize e_expf with FMA [BZ #21912]

FMA optimized e_expf improves performance by more than 50% on Skylake.

[BZ #21912]
* sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
Add e_expf-fma.
* sysdeps/x86_64/fpu/multiarch/e_expf-fma.S: New file.
* sysdeps/x86_64/fpu/multiarch/e_expf.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/ifunc-fma.h: Likewise.

6 years agoAdd ChangeLog reference to bug 16750/CVE-2009-5064
Florian Weimer [Wed, 16 Aug 2017 14:47:20 +0000 (16:47 +0200)]
Add ChangeLog reference to bug 16750/CVE-2009-5064

6 years agoldd: never run file directly
Andreas Schwab [Wed, 16 Aug 2017 13:59:55 +0000 (15:59 +0200)]
ldd: never run file directly

6 years agox86-64: Align L(SP_RANGE)/L(SP_INF_0) to 8 bytes [BZ #21955]
H.J. Lu [Tue, 15 Aug 2017 21:04:59 +0000 (14:04 -0700)]
x86-64: Align L(SP_RANGE)/L(SP_INF_0) to 8 bytes [BZ #21955]

sysdeps/x86_64/fpu/e_expf.S has

        lea     L(SP_RANGE)(%rip), %rdx /* load over/underflow bound */
        cmpl    (%rdx,%rax,4), %ecx     /* |x|<under/overflow bound ? */
...
        /* Here if |x| is Inf */
        lea     L(SP_INF_0)(%rip), %rdx /* depending on sign of x: */
        movss   (%rdx,%rax,4), %xmm0    /* return zero or Inf */
        ret
...
         .section .rodata.cst8,"aM",@progbits,8
...
        .p2align 2
L(SP_RANGE): /* single precision overflow/underflow bounds */
        .long   0x42b17217      /* if x>this bound, then result overflows */
        .long   0x42cff1b4      /* if x<this bound, then result underflows */
        .type L(SP_RANGE), @object
        ASM_SIZE_DIRECTIVE(L(SP_RANGE))

        .p2align 2
L(SP_INF_0):
        .long   0x7f800000      /* single precision Inf */
        .long   0               /* single precision zero */
        .type L(SP_INF_0), @object
        ASM_SIZE_DIRECTIVE(L(SP_INF_0))

Since L(SP_RANGE) and L(SP_INF_0) are in .rodata.cst8 section, they must
be aligned to 8 bytes.

[BZ #21955]
* sysdeps/x86_64/fpu/e_expf.S (L(SP_RANGE)): Aligned to 8 bytes.
(L(SP_INF_0)): Likewise.

6 years agogmon: Run tst-gmon-prof only for run-built-tests=yes
Florian Weimer [Tue, 15 Aug 2017 16:35:42 +0000 (18:35 +0200)]
gmon: Run tst-gmon-prof only for run-built-tests=yes

6 years agoaio: Remove support for BROKEN_THREAD_SIGNALS
Florian Weimer [Tue, 15 Aug 2017 15:28:37 +0000 (17:28 +0200)]
aio: Remove support for BROKEN_THREAD_SIGNALS

This was originally added to support LinuxThreads and is not needed for
NPTL.

6 years agogmon: Add test for basic mcount/gprof functionality
Florian Weimer [Tue, 15 Aug 2017 13:49:40 +0000 (15:49 +0200)]
gmon: Add test for basic mcount/gprof functionality

6 years agopowerpc: Add values from Linux 4.8 to <elf.h>
Gustavo Romero [Tue, 15 Aug 2017 13:17:30 +0000 (10:17 -0300)]
powerpc: Add values from Linux 4.8 to <elf.h>

Add powerpc specific note sections available since Linux v4.8.

* elf/elf.h A (NT_PPC_TAR): New macro.
(NT_PPC_PPR): Likewise.
(NT_PPC_DSCR): Likewise.
(NT_PPC_EBB): Likewise.
(NT_PPC_PMU): Likewise.
(NT_PPC_TM_CGPR): Likewise.
(NT_PPC_TM_CFPR): Likewise.
(NT_PPC_TM_CVMX): Likewise.
(NT_PPC_TM_CVSX): Likewise.
(NT_PPC_TM_SPR): Likewise.
(NT_PPC_TM_CTAR): Likewise.
(NT_PPC_TM_CPPR): Likewise.
(NT_PPC_TM_CDSCR): Likewise.

6 years agoi386: Replace internal_function attribute for __mcount_internal
Florian Weimer [Tue, 15 Aug 2017 12:46:19 +0000 (14:46 +0200)]
i386: Replace internal_function attribute for __mcount_internal

__mcount_internal is called from assembler code.  Use an explicit
regparm attribute to pass both arguments in registers, to match what
used to happen with internal_function before commit
fbdc1e3e8de7f49e439b6e274d3e7e07da78416e (i386: Do not set
internal_function).

6 years agoS390: Add new s390 platform z14.
Stefan Liebler [Tue, 15 Aug 2017 12:00:07 +0000 (14:00 +0200)]
S390: Add new s390 platform z14.

The new IBM z14 is added to platform string array.
The macro _DL_PLATFORMS_COUNT is incremented.

ChangeLog:

* sysdeps/s390/dl-procinfo.c (_dl_s390_cap_flags): Add z14.
* sysdeps/s390/dl-procinfo.h (_DL_PLATFORMS_COUNT): Increased.

6 years agoChange language name in LC_IDENTIFICATION of bn_BD and bn_IN from “Bengali” to “Bangla”
Mike FABIAN [Mon, 14 Aug 2017 17:48:27 +0000 (19:48 +0200)]
Change language name in LC_IDENTIFICATION of bn_BD and bn_IN from “Bengali” to “Bangla”

[BZ #14925]
* locales/bn_BD (LC_IDENTIFICATION): Change language name in
“title” and “language” from Bengali to Bangla.
* locales/bn_IN (LC_IDENTIFICATION): Likewise.

6 years agoUse “copy "i18n"” in km_KH locale
Mike FABIAN [Mon, 14 Aug 2017 17:05:17 +0000 (19:05 +0200)]
Use “copy "i18n"” in km_KH locale

The custom stuff which was in LC_CTYPE of the km_KH locale seems
to be a very incomplete subset of what one gets by using
“copy "i18n"”. I cannot find anything special there which is not
in “copy "i18n"”, only lots of stuff which is missing.

[BZ #20008]
* locales/km_KH (LC_CTYPE): Use “copy "i18n"”.

6 years agoconformtest: Disable si_value expectation for XPG42.
Joseph Myers [Mon, 14 Aug 2017 17:05:55 +0000 (17:05 +0000)]
conformtest: Disable si_value expectation for XPG42.

This patch corrects the conform/ expectations for sys/wait.h not to
expect si_value for XPG4.2.

Tested for x86_64.

* conform/data/sys/wait.h-data (si_value): Do not expect for
XPG42.

6 years agoNSS: Replace exported NSS lookup functions with stubs [BZ #21962]
Florian Weimer [Mon, 14 Aug 2017 15:12:05 +0000 (17:12 +0200)]
NSS: Replace exported NSS lookup functions with stubs [BZ #21962]

Commit 384ca551743318bd9c9e24a496d6397f2e3f2a49 from 2007 added this to
nss/XXX-lookup.c:

+#ifndef NO_COMPAT
+int
+internal_function attribute_compat_text_section
+DB_COMPAT_FCT (service_user **ni, const char *fct_name, void **fctp)
+{
+  return DB_LOOKUP_FCT (ni, fct_name, NULL, fctp);
+}
+#endif

That is, it adds a pseudo-compat function with an internal_function
attribute.  The function it was supposed to replace did not have the
attribute:

 extern int DB_LOOKUP_FCT (service_user **ni, const char *fct_name,
-   void **fctp) internal_function;
+   const char *fct2_name, void **fctp)
+  internal_function;

This changed the calling convention on i386 for the following
functions in the public ABI:

  __nss_passwd_lookup
  __nss_group_lookup
  __nss_hosts_lookup

This commit replaces the functions with always-failing stubs,
with true compat symbols.  Due to a happy accident, the calling
convention of the stub is identical for the internal_function
and non-internal_function case on i386.

In addition, this commit auto-generates the __nss_*_lookup2
function declarations as part of <nsswitch.h>.

6 years agoUse two letter abbreviations in abday in all German locales.
Mike FABIAN [Mon, 14 Aug 2017 15:12:37 +0000 (17:12 +0200)]
Use two letter abbreviations in abday in all German locales.

[BZ #20482]
* locales/de_AT (LC_TIME): Use 2 letter abbreviations in abday.
* locales/de_BE (LC_TIME): Use 2 letter abbreviations in abday.
* locales/de_CH (LC_TIME): Use 2 letter abbreviations in abday.
* locales/de_DE (LC_TIME): Use readable ASCII in abday.
* locales/de_IT (LC_TIME): Use readable ASCII in abday.
* locales/de_LU (LC_TIME): Use 2 letter abbreviations in abday.

6 years agoFix thousands_sep and grouping and use readable ASCII for decimal_point in eu_ES...
Julen Ruiz Aizpuru [Mon, 14 Aug 2017 13:56:00 +0000 (15:56 +0200)]
Fix thousands_sep and grouping and use readable ASCII for decimal_point in eu_ES locale

[BZ #12349]
* locales/eu_ES (LC_NUMERIC): Fix thousands_sep and grouping
and use readable ASCII for decimal_point.

6 years agoposix: Fix mmap for m68k and ia64 (BZ#21908)
Adhemerval Zanella [Sun, 6 Aug 2017 14:14:32 +0000 (11:14 -0300)]
posix: Fix mmap for m68k and ia64 (BZ#21908)

Default semantic for mmap2 syscall is to take the offset in 4096-byte
units.  However m68k and ia64 mmap2 implementation take in the
configured pageunit units and for both architecture it can be
different values.

This patch fixes the m68k runtime discover of mmap2 offset unit
and adds the ia64 definition to find it at runtime.

Checked the basic tst-mmap and tst-mmap-offset on m68k (the system
is configured with 4k, so current code is already passing on this
system) and a sanity check on x86_64-linux-gnu (which should not be
affected by this change).  Sergei also states that ia64 loader now
work correctly with this change.

Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Sergei Trofimovich  <slyfox@inbox.ru>

* sysdeps/unix/sysv/linux/m68k/mmap_internal.h (MMAP2_PAGE_SHIFT):
Rename to MMAP2_PAGE_UNIT.
* sysdeps/unix/sysv/linux/mmap.c: Include mmap_internal iff
__OFF_T_MATCHES_OFF64_T is not defined.
* sysdeps/unix/sysv/linux/mmap_internal.h (page_unit): Declare as
uint64_t.
(MMAP2_PAGE_UNIT) [MMAP2_PAGE_UNIT == -1]: Redefine to page_unit.
(page_unit) [MMAP2_PAGE_UNIT != -1]: Remove definition.

6 years agoi386: Do not set internal_function
Florian Weimer [Mon, 14 Aug 2017 11:03:34 +0000 (13:03 +0200)]
i386: Do not set internal_function

All calls to functions with the internal_function attribute
have been removed from assembler implementations, which means that
the definition of internal_function can be changed at the C level
without causing ABI issues with assembler code.

_dl_fixup still uses a regparm calling convention on i386, but this
is controlled through ARCH_FIXUP_ATTRIBUTE, not internal_function.

6 years ago_dl_init: Remove internal_function attribute
Florian Weimer [Mon, 14 Aug 2017 10:57:50 +0000 (12:57 +0200)]
_dl_init: Remove internal_function attribute

The function is called from the i386 startup code, which needs minor
adjustments due to the changed ABI.

6 years ago_dl_start: Remove internal_function attribute
Florian Weimer [Mon, 14 Aug 2017 10:29:21 +0000 (12:29 +0200)]
_dl_start: Remove internal_function attribute

The i386 startup code needs adjusting because it calls the function
and the ABI has changed.

6 years ago_dl_fini: Remove internal_function attribute
Florian Weimer [Mon, 14 Aug 2017 09:44:24 +0000 (11:44 +0200)]
_dl_fini: Remove internal_function attribute

Assembler code passes the address of _dl_fini to __libc_start_main,
whose function pointer argument lacks the attribute.  This means
that calls could use the wrong ABI.  Fortunately, for zero-parameter
void-returning functions, internal_function does not change ABI
on i386 (the only architecture which uses internal_function), so
this inconsistency was harmless (which is why it had not been
noticed so far).

6 years agox86: Add IBT/SHSTK bits to cpu-features
H.J. Lu [Mon, 14 Aug 2017 12:54:25 +0000 (05:54 -0700)]
x86: Add IBT/SHSTK bits to cpu-features

Add IBT/SHSTK bits to cpu-features for Shadow Stack in Intel Control-flow
Enforcement Technology (CET) instructions:

https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf

* sysdeps/x86/cpu-features.h (bit_cpu_BIT): New.
(bit_cpu_SHSTK): Likewise.
(index_cpu_IBT): Likewise.
(index_cpu_SHSTK): Likewise.
(reg_IBT): Likewise.
(reg_SHSTK): Likewise.
* sysdeps/x86/cpu-tunables.c (TUNABLE_CALLBACK (set_hwcaps)):
Handle index_cpu_IBT and index_cpu_SHSTK.

6 years agoFix spelling mistake in fr.po
Mike FABIAN [Mon, 14 Aug 2017 07:25:56 +0000 (09:25 +0200)]
Fix spelling mistake in fr.po

[BZ #19982]
* po/fr.po: Fix spelling mistake.

6 years agold.so: Remove internal_function attribute from various functions
Florian Weimer [Sun, 13 Aug 2017 19:11:54 +0000 (21:11 +0200)]
ld.so: Remove internal_function attribute from various functions

These functions are invoked from other DSOs and should therefore
use the standard calling convention.

6 years agoRemove internal_function attribute from string-to-float functions
Florian Weimer [Sun, 13 Aug 2017 19:11:47 +0000 (21:11 +0200)]
Remove internal_function attribute from string-to-float functions

These are called across DSO boundaries and should therefore use
the standard calling convention.

6 years agoNPTL: Remove internal_function from stack marking functions
Florian Weimer [Sun, 13 Aug 2017 19:11:38 +0000 (21:11 +0200)]
NPTL: Remove internal_function from stack marking functions

These are called across DSO boundaries and therefore should use
the ABI calling convention.