]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
6 years agopowerpc: refactor strrchr IFUNC
Rajalakshmi Srinivasaraghavan [Fri, 23 Jun 2017 05:54:30 +0000 (11:24 +0530)] 
powerpc: refactor strrchr IFUNC

As done in commit 6d15a5c2e9450a1e926d5b4991759e1cfa50fccf
clean up IFUNC implementation for power8 in order to remove
unneeded macro definitions.

6 years agopowerpc: Add optimized version of [l]lroundf
Rajalakshmi Srinivasaraghavan [Fri, 23 Jun 2017 05:13:31 +0000 (10:43 +0530)] 
powerpc: Add optimized version of [l]lroundf

This patch makes use of optimized double version of llround for single
precision as both the versions return [long] long type.

6 years agoSupport _Float128 in ldbl-96 bits/iscanonical.h.
Joseph Myers [Thu, 22 Jun 2017 23:06:41 +0000 (23:06 +0000)] 
Support _Float128 in ldbl-96 bits/iscanonical.h.

This patch adds _Float128 support to the ldbl-96 bits/iscanonical.h,
as needed for x86_64 / x86 / ia64 support of _Float128.

Tested for x86_64 (in conjunction with float128 patches).

* sysdeps/ieee754/ldbl-96/bits/iscanonical.h
[__HAVE_DISTINCT_FLOAT128] (__iscanonicalf128): New macro.

6 years agoSupport _Float128 in math-tests.h.
Joseph Myers [Thu, 22 Jun 2017 23:03:38 +0000 (23:03 +0000)] 
Support _Float128 in math-tests.h.

This patch makes math-tests.h, as used to describe support of given
floating-point types for sNaNs, rounding modes and exceptions, handle
distinguishing _Float128 from long double.  This is needed for x86_64,
where if building with GCC 6 or earlier there is no __builtin_nansq,
so no way to get a signaling NaN of _Float128 type, so associated
tests cannot be run (although glibc itself works fine, as there is
never any need to create such an sNaN with a built-in function inside
glibc).

Tested for x86_64 (in conjunction with float128 patches).

* sysdeps/generic/math-tests.h: Include <bits/floatn.h>.
(MATH_TESTS_TG): New macro.
(SNAN_TESTS_float128): Likewise.
(ROUNDING_TESTS_float128): Likewise.
(EXCEPTION_TESTS_float128): Likewise.
(SNAN_TESTS): Define using MATH_TESTS_TG.
(ROUNDING_TESTS): Likewise.
(EXCEPTION_TESTS): Likewise.

6 years agoFix float128_private.h redefinition of SET_RESTORE_ROUNDL.
Joseph Myers [Thu, 22 Jun 2017 22:57:28 +0000 (22:57 +0000)] 
Fix float128_private.h redefinition of SET_RESTORE_ROUNDL.

As with other long double identifiers, float128_private.h has a
redefinition of SET_RESTORE_ROUNDL.  However, that redefinition is
broken, since this is a macro with one argument being defined to take
no arguments.  This patch fixes the redefinition.  (x86_64 needs the
redefinition because SET_RESTORE_ROUNDL only changes the x87 rounding
mode, whereas _Float128 arithmetic uses the SSE rounding mode instead
on x86_64.)

Tested for x86_64 (in conjunction with float128 patches).

* sysdeps/ieee754/float128/float128_private.h
[SET_RESTORE_ROUNDF128] (SET_RESTORE_ROUNDL): Take an argument and
pass it to SET_RESTORE_ROUNDF128.

6 years agoMake float128_private.h work with generic ieee754.h.
Joseph Myers [Thu, 22 Jun 2017 22:53:01 +0000 (22:53 +0000)] 
Make float128_private.h work with generic ieee754.h.

float128_private.h redefines ieee754.h identifiers ieee854_long_double
and IEEE854_LONG_DOUBLE_BIAS to map them to identifiers from
ieee754_float128.h.

This causes problems when ieee754.h is included after
float128_private.h and it's a version of ieee754.h that also defines
those identifiers; specifically, sysdeps/ieee754/ieee754.h, which
defines those identifiers for the x86 extended format.  This patch
fixes this by ensuring an include of ieee754.h from float128_private.h
before the redefinitions.

Tested for x86_64 (in conjunction with float128 patches).

* sysdeps/ieee754/float128/float128_private.h: Include
<ieee754.h>.

6 years agoCorrect min_of_type handling of _Float128.
Joseph Myers [Thu, 22 Jun 2017 22:46:27 +0000 (22:46 +0000)] 
Correct min_of_type handling of _Float128.

The math_private.h macro min_of_type has broken _Float128 handling:
instead of passing its type argument to the key __EXPR_FLT128 macro,
it passes x, which is not a macro argument but whatever variable
called x happens to be visible in the calling function.  If that
variable has the wrong type, the wrong one of long double and
_Float128 can get chosen.  In particular, this applies to some
_Complex long double functions (where x happens to have type _Complex
long double, resulting in min_of_type returning a _Float128 value when
it should return a long double value).  For some reason, this only
caused test failures for me on x86_64 with GCC 6 but not GCC 7 (I
suspect it triggers known bugs in conversions from x86 long double to
_Float128 that are present in GCC 6's soft-fp).

Tested for x86_64 (in conjunction with float128 patches).

* sysdeps/generic/math_private.h (__EXPR_FLT128): Do not apply
typeof to argument passed to __builtin_types_compatible_p.
(min_of_type): Pass type argument, not x, to __EXPR_FLT128.

6 years agoMake errno-setting libm templates include errno.h.
Joseph Myers [Thu, 22 Jun 2017 22:39:48 +0000 (22:39 +0000)] 
Make errno-setting libm templates include errno.h.

Various type-generic libm wrapper templates, as used for float128, set
errno but do not include errno.h.  I presume they must get an implicit
include from some internal header on powerpc64le; they don't get such
an implicit include on x86_64.  This patch adds the missing includes
of errno.h to each such wrapper.

Tested for x86_64 (in conjunction with float128 patches).

* math/w_acos_template.c [__USE_WRAPPER_TEMPLATE]: Include
<errno.h>.
* math/w_acosh_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_asin_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_atanh_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_cosh_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_exp10_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_exp2_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_exp_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_fmod_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_hypot_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_j0_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_j1_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_jn_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_lgamma_r_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_lgamma_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_log10_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_log2_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_log_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_pow_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_remainder_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_sinh_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_sqrt_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.
* math/w_tgamma_template.c [__USE_WRAPPER_TEMPLATE]: Likewise.

6 years agoFix float128 uses of xlocale.h.
Joseph Myers [Thu, 22 Jun 2017 22:34:49 +0000 (22:34 +0000)] 
Fix float128 uses of xlocale.h.

Three float128 files still include xlocale.h after it was removed.  I
don't know why this didn't cause problems for powerpc64le float128
testing; it did cause problems for my x86_64 float128 testing.  This
patch changes the includes to use bits/types/locale_t.h.

Tested for x86_64 (in conjunction with float128 patches).

* sysdeps/ieee754/float128/strtof128_l.c: Include
<bits/types/locale_t.h> instead of <xlocale.h>.
* sysdeps/ieee754/float128/wcstof128.c: Likewise.
* sysdeps/ieee754/float128/wcstof128_l.c: Likewise.

6 years agoAdd ChangeLog entries for the last 3 commits
Siddhesh Poyarekar [Thu, 22 Jun 2017 18:19:15 +0000 (23:49 +0530)] 
Add ChangeLog entries for the last 3 commits

I forgot to add ChangeLog entries for my last three commits.

6 years agobenchtests: New script to parse memcpy results
Siddhesh Poyarekar [Thu, 22 Jun 2017 18:14:50 +0000 (23:44 +0530)] 
benchtests: New script to parse memcpy results

Read the memcpy results in json and print out the results in tabular
form, in addition to generating a graph of the results to compare all
of the implementations.

The format of the output is extensible enough to allow this kind of
analysis to be done on other string functions as well.

* benchtests/scripts/benchout_strings.schema.json: New file.
* benchtests/scripts/compare_strings.py: New file.

6 years agobenchtests: Make memcpy benchmarks print results in json
Siddhesh Poyarekar [Thu, 22 Jun 2017 18:14:19 +0000 (23:44 +0530)] 
benchtests: Make memcpy benchmarks print results in json

Print the benchmark output for various memcpy benchmarks in json so
that it can be predictably parsed and analyzed.

* benchtests/bench-memcpy-large.c: Include json-lib.h.
(do_one_test): Print json.
(do_test): Likewise.
(test_main): Likewise.
* benchtests/bench-memcpy-random.c: Include json-lib.h.
(do_one_test): Print json.
(do_test): Likewise.
(test_main): Likewise.
* benchtests/bench-memcpy.c: Include json-lib.h.
(do_one_test): Print json.
(do_test): Likewise.
(test_main): Likewise.

6 years agobenchtests: Print string array elements, int and uint in json
Siddhesh Poyarekar [Thu, 22 Jun 2017 18:14:12 +0000 (23:44 +0530)] 
benchtests: Print string array elements, int and uint in json

Enhance the json module in benchtests to print signed and unsigned
integers and string array elements.

* benchtests/json-lib.h: Include inttypes.h.
(json_attr_int, json_attr_int, json_element_string,
json_element_int, json_element_uint): New functions.
* benchtests/json-lib.c: (json_attr_int, json_attr_int,
json_element_string, json_element_int, json_element_uint): New
functions.

6 years agoDescribe remainder as primary and drem as alternative in the manual
Gabriel F. T. Gomes [Tue, 20 Jun 2017 18:00:16 +0000 (15:00 -0300)] 
Describe remainder as primary and drem as alternative in the manual

In preparation for the documentation of _FloatN and _FloatNx variants of
the remainder function, this patch changes the descriptions of remainder
and drem, so that remainder is described as primary and drem as an
alternative name for the same functionality.

* manual/arith.texi (Remainder Functions): Describe remainder as
primary and drem as an alternative name.  Change the comment on
remainder to ISO, since it is defined in ISO C99.

6 years agoProvide an additional macro expansion for F128 in stdlib/tst-strtod.h
Gabriel F. T. Gomes [Wed, 21 Jun 2017 12:20:39 +0000 (09:20 -0300)] 
Provide an additional macro expansion for F128 in stdlib/tst-strtod.h

The macro F128 in stdlib/tst-strtod.h is defined to provide the literal
suffix for _Float128 constants.  It uses the macro __f128 (), which is
defined in bits/floatn.h to provide the correct literal suffix depending on
what is provided by the compiler.

However, F128 was not being expanded and only worked correctly, when
compiling with GCC 7 (or greater), since F128 is the literal suffix itself.
This patch adds an additional macro expansion so that the macro F128
expands to the correct literal suffix on older compilers.

* stdlib/tst-strtod.h (MMFUNC): New macro to provide an addition
macro expansion.
(GEN_TEST_STRTOD_FOREACH): Use MMFUNC for _Float128.

6 years agolocaledata: fur_IT: Fix spelling of Wednesday (Miercus)
Rafal Luzynski [Thu, 22 Jun 2017 09:53:02 +0000 (11:53 +0200)] 
localedata: fur_IT: Fix spelling of Wednesday (Miercus)

* localedata/locales/fur_IT (day, abday): reworded "Miarcus" to
  "Miercus" and abbreviated "Mia" to "Mie".

6 years agoBug 21533: Update to Unicode 10.0.0
Mike FABIAN [Wed, 31 May 2017 09:10:25 +0000 (11:10 +0200)] 
Bug 21533: Update to Unicode 10.0.0

* Unicode 10.0.0 Support: Character encoding, character type info, and
  transliteration tables are all updated to Unicode 10.0.0, using
  generator scripts contributed by Mike FABIAN (Red Hat).

6 years agoinet: __inet6_scopeid_pton should accept node-local addresses [BZ #21657]
Benjamin Cama [Thu, 22 Jun 2017 13:49:28 +0000 (15:49 +0200)] 
inet: __inet6_scopeid_pton should accept node-local addresses [BZ #21657]

6 years ago_nl_load_domain: Use calloc instead of alloca
Florian Weimer [Wed, 21 Jun 2017 20:59:19 +0000 (22:59 +0200)] 
_nl_load_domain: Use calloc instead of alloca

6 years agoImplement allocation buffers for internal use
Florian Weimer [Wed, 21 Jun 2017 20:43:57 +0000 (22:43 +0200)] 
Implement allocation buffers for internal use

This commit adds fixed-size allocation buffers.  The primary use
case is in NSS modules, where dynamically sized data is stored
in a fixed-size buffer provided by the caller.

Other uses include a replacement of mempcpy cascades (which is
safer due to the size checking inherent to allocation buffers).

6 years agox86-64: Implement strcmp family IFUNC selectors in C
H.J. Lu [Wed, 21 Jun 2017 19:10:50 +0000 (12:10 -0700)] 
x86-64: Implement strcmp family IFUNC selectors in C

Implement strcmp family IFUNC selectors in C.

All internal calls within libc.so can use IFUNC on x86-64 since unlike
x86, x86-64 supports PC-relative addressing to access the GOT entry so
that it can call via PLT without using an extra register.  For libc.a,
we can't use IFUNC for functions which are called before IFUNC has been
initialized.  Use IFUNC internally reduces the icache footprint since
libc.so and other codes in the process use the same implementations.
This patch uses IFUNC for strcmp family functions within libc.

* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
strcmp-sse2, strcmp-sse4_2, strncmp-sse2, strncmp-sse4_2,
strcasecmp_l-sse2, strcasecmp_l-sse4_2, strcasecmp_l-avx,
strncase_l-sse2, strncase_l-sse4_2 and strncase_l-avx.
* sysdeps/x86_64/multiarch/ifunc-strcasecmp.h: New file.
* sysdeps/x86_64/multiarch/strcasecmp.c: Likewise.
* sysdeps/x86_64/multiarch/strcasecmp_l-avx.S: Likewise.
* sysdeps/x86_64/multiarch/strcasecmp_l-sse2.S: Likewise.
* sysdeps/x86_64/multiarch/strcasecmp_l-sse4_2.S: Likewise.
* sysdeps/x86_64/multiarch/strcasecmp_l.c: Likewise.
* sysdeps/x86_64/multiarch/strcmp-sse2.S: Likewise.
* sysdeps/x86_64/multiarch/strcmp-sse4_2.S: Likewise.
* sysdeps/x86_64/multiarch/strcmp.c: Likewise.
* sysdeps/x86_64/multiarch/strncase.c: Likewise.
* sysdeps/x86_64/multiarch/strncase_l-avx.S : Likewise.
* sysdeps/x86_64/multiarch/strncase_l-sse2.S: Likewise.
* sysdeps/x86_64/multiarch/strncase_l-sse4_2.S: Likewise.
* sysdeps/x86_64/multiarch/strncase_l.c: Likewise.
* sysdeps/x86_64/multiarch/strncmp-sse2.S: Likewise.
* sysdeps/x86_64/multiarch/strncmp-sse4_2.S: Likewise.
* sysdeps/x86_64/multiarch/strncmp.c: Likewise.
* sysdeps/x86_64/multiarch/strcasecmp_l.S: Removed.
* sysdeps/x86_64/multiarch/strcmp.S: Likewise.
* sysdeps/x86_64/multiarch/strncase_l.S: Likewise.
* sysdeps/x86_64/multiarch/strncmp.S: Likewise.
* sysdeps/x86_64/multiarch/strcmp-sse42.S: Include <sysdep.h>.
(STRCMP_SSE42): New.  Defined to __strcmp_sse42 if not defined.
[USE_AS_STRCASECMP_L || USE_AS_STRNCASECMP_L]: Include
"locale-defines.h".
(UPDATE_STRNCMP_COUNTER): New.
(SECTION): Likewise.
(GLABEL): Likewise.
(LABEL): Likewise.
* sysdeps/x86_64/multiarch/strncmp-ssse3.S: Rewrite and enable
for libc.a.

6 years agoFix tile SA_* conditions for POSIX.1:2008 (bug 21622).
Joseph Myers [Wed, 21 Jun 2017 17:35:24 +0000 (17:35 +0000)] 
Fix tile SA_* conditions for POSIX.1:2008 (bug 21622).

As shown by conform/ tests once the remaining namespace issues are
fixed, the tile bits/sigaction.h fails to declare SA_RESETHAND,
SA_RESTART and SA_NODEFER for non-XSI POSIX.1:2008 as other versions
do.  Those constants were moved from XSI to Base in the 2008 edition
of POSIX.  This patch fixes the conditions to match other versions of
this header.

Tested (compilation only) for tilegx-linux-gnu with
build-many-glibcs.py.

[BZ #21622]
* sysdeps/unix/sysv/linux/tile/bits/sigaction.h (SA_RESTART):
Define for [__USE_UNIX98 || __USE_XOPEN2K8], not [__USE_UNIX98 ||
__USE_MISC].
(SA_NODEFER): Likewise.
(SA_RESETHAND): Likewise.

6 years agox86: Rename glibc.tune.ifunc to glibc.tune.hwcaps
H.J. Lu [Wed, 21 Jun 2017 17:20:24 +0000 (10:20 -0700)] 
x86: Rename glibc.tune.ifunc to glibc.tune.hwcaps

Rename glibc.tune.ifunc to glibc.tune.hwcaps and move it to
sysdeps/x86/dl-tunables.list since it is x86 specicifc.  Also
change type of data_cache_size, data_cache_size and
non_temporal_threshold to unsigned long int to match size_t.
Remove usage DEFAULT_STRLEN from cpu-tunables.c.

* elf/dl-tunables.list (glibc.tune.ifunc): Removed.
* sysdeps/x86/dl-tunables.list (glibc.tune.hwcaps): New.
Remove security_level on all fields.
* manual/tunables.texi: Replace ifunc with hwcaps.
* sysdeps/x86/cpu-features.c (TUNABLE_CALLBACK (set_ifunc)):
Renamed to ..
(TUNABLE_CALLBACK (set_hwcaps)): This.
(init_cpu_features): Updated.
* sysdeps/x86/cpu-features.h (cpu_features): Change type of
data_cache_size, data_cache_size and non_temporal_threshold to
unsigned long int.
* sysdeps/x86/cpu-tunables.c (DEFAULT_STRLEN): Removed.
(TUNABLE_CALLBACK (set_ifunc)): Renamed to ...
(TUNABLE_CALLBACK (set_hwcaps)): This.  Update comments.  Don't
use DEFAULT_STRLEN.

6 years agoDCIGETTEXT: Use getcwd, asprintf to construct absolute pathname
Florian Weimer [Wed, 21 Jun 2017 14:31:31 +0000 (16:31 +0200)] 
DCIGETTEXT: Use getcwd, asprintf to construct absolute pathname

6 years ago[AArch64] Add more cfi annotations to tlsdesc entry points
Szabolcs Nagy [Wed, 21 Jun 2017 14:01:18 +0000 (15:01 +0100)] 
[AArch64] Add more cfi annotations to tlsdesc entry points

Backtrace through _dl_tlsdesc_resolve_rela was broken because the offset
of x30 from cfa was not in the debug info.

Add enough annotation so backtracing from the dynamic linker through
tlsdesc entry points works and the debugger shows registers correctly.

6 years agoposix: Add invalid flags test for p{write,read}v2
Adhemerval Zanella [Mon, 5 Jun 2017 12:13:49 +0000 (09:13 -0300)] 
posix: Add invalid flags test for p{write,read}v2

This patch add an extra test for passing invalid flags and check its
expected failure.  It shows an invalid LO_HI_LONG macro definition for
x86_64 with leads to passing invalid flags on some configurations.

The new tests fails on i686-linux-gnu and potentially on other 32 bits
architecture that uses the compat syscall definition due a kernel bug.
It is intended to be fixed upstream.

Checked on x86_64-linux-gnu

* misc/tst-preadvwritev2-common.c: New file.
* misc/tst-preadvwritev2.c (do_test): Add test for invalid flag.
* misc/tst-preadvwritev64v2.c (do_test): Likewise.

6 years ago[AArch64] Use hidden __GI__dl_argv in rtld startup code
Szabolcs Nagy [Wed, 21 Jun 2017 12:47:07 +0000 (13:47 +0100)] 
[AArch64] Use hidden __GI__dl_argv in rtld startup code

We rely on the symbol being locally defined so using extern symbol
is not correct and the linker may complain about the relocations.

6 years agogetaddrinfo: Avoid stack copy of IPv6 address
Florian Weimer [Wed, 21 Jun 2017 11:35:37 +0000 (13:35 +0200)] 
getaddrinfo: Avoid stack copy of IPv6 address

6 years ago__inet_pton_length: Implement new internal helper function
Florian Weimer [Wed, 21 Jun 2017 11:09:08 +0000 (13:09 +0200)] 
__inet_pton_length: Implement new internal helper function

6 years agoinet: Add IPv6 getaddrinfo coverage to tst-inet6_scopeid_pton.c
Florian Weimer [Wed, 21 Jun 2017 10:51:54 +0000 (12:51 +0200)] 
inet: Add IPv6 getaddrinfo coverage to tst-inet6_scopeid_pton.c

6 years agopowerpc: Optimize memchr for power8
Rajalakshmi Srinivasaraghavan [Wed, 21 Jun 2017 05:25:12 +0000 (10:55 +0530)] 
powerpc: Optimize memchr for power8

Vectorized loops are used for sizes greater than 32B to improve
performance over power7 optimiztion.

6 years agopowerpc: Add optimized version of [l]lrintf
Rajalakshmi Srinivasaraghavan [Wed, 21 Jun 2017 05:14:18 +0000 (10:44 +0530)] 
powerpc: Add optimized version of [l]lrintf

This patch makes use of optimized double version of llrint for single
precision as both the versions return [long] long type.

6 years agoFactor out shared definitions from bits/signum.h.
Zack Weinberg [Sat, 3 Jun 2017 20:22:24 +0000 (16:22 -0400)] 
Factor out shared definitions from bits/signum.h.

Many of the things defined by bits/signum.h are invariant across all
supported operating systems.  This patch factors out all of them to a
new header bits/signum-generic.h, which each bits/signum.h will include
and then override whichever things need adjustment.  Normally that will
mean, at most, adding or changing a few signal numbers.

A user-visible side effect is that the obsolete signal constant SIGUNUSED
(which is an alias for SIGSYS on all platforms that define it) is no
longer exposed by any version of bits/signum.h.

A side effect only relevant to glibc hackers is that _NSIG is now defined
in terms of __SIGRTMAX, instead of the other way around.  This is because
__SIGRTMAX varies from platform to platform, but _NSIG==__SIGRTMAX+1 is
true universally.  If your platform doesn't support realtime signals,
leave __SIGRTMAX equal to __SIGRTMIN.

I also added a Linux-specific test to make sure that our signal constants
match the ones in <asm/signal.h>, since we can't use that header (it's
not even vaguely namespace-clean).

* bits/signum-generic.h: Renamed from bits/signum.h.
Add proper multiple include guard and misuse check.
Define __SIGRTMIN = __SIGRTMAX = 32, and define _NSIG = __SIGRTMAX+1.
Move definition of SIGIO to "archaic names for compatibility" section.
* bits/signum.h: New file which just includes bits/signum-generic.h.
* sysdeps/unix/bsd/bits/signum.h
* sysdeps/unix/sysv/linux/bits/signum.h
* sysdeps/unix/sysv/linux/alpha/bits/signum.h
* sysdeps/unix/sysv/linux/hppa/bits/signum.h
* sysdeps/unix/sysv/linux/mips/bits/signum.h
* sysdeps/unix/sysv/linux/sparc/bits/signum.h
Just include <bits/signum-generic.h> and then add or adjust
signal constants.  Do not define SIGUNUSED, SIGRTMIN, or SIGRTMAX.

* signal/Makefile: Install bits/signum-generic.h.
* signal/signal.h: Define SIGRTMIN and SIGRTMAX here.

* sysdeps/generic/siglist.h: SIGSYS and SIGWINCH are
universal.  Prefer SIGPOLL to SIGIO. Simplify #ifdeffage.

* sysdeps/unix/sysv/linux/tst-signal-numbers.sh: New test.
* sysdeps/unix/sysv/linux/Makefile: Run it.

6 years agoUse locale_t, not __locale_t, throughout glibc
Zack Weinberg [Tue, 20 Jun 2017 13:26:43 +0000 (09:26 -0400)] 
Use locale_t, not __locale_t, throughout glibc

<locale.h> is specified to define locale_t in POSIX.1-2008, and so are
all of the headers that define functions that take locale_t arguments.
Under _GNU_SOURCE, the additional headers that define such functions
have also always defined locale_t.  Therefore, there is no need to use
__locale_t in public function prototypes, nor in any internal code.

* ctype/ctype-c99_l.c, ctype/ctype.h, ctype/ctype_l.c
* include/monetary.h, include/stdlib.h, include/time.h
* include/wchar.h, locale/duplocale.c, locale/freelocale.c
* locale/global-locale.c, locale/langinfo.h, locale/locale.h
* locale/localeinfo.h, locale/newlocale.c
* locale/nl_langinfo_l.c, locale/uselocale.c
* localedata/bug-usesetlocale.c, localedata/tst-xlocale2.c
* stdio-common/vfscanf.c, stdlib/monetary.h, stdlib/stdlib.h
* stdlib/strfmon_l.c, stdlib/strtod_l.c, stdlib/strtof_l.c
* stdlib/strtol.c, stdlib/strtol_l.c, stdlib/strtold_l.c
* stdlib/strtoll_l.c, stdlib/strtoul_l.c, stdlib/strtoull_l.c
* string/strcasecmp.c, string/strcoll_l.c, string/string.h
* string/strings.h, string/strncase.c, string/strxfrm_l.c
* sysdeps/ieee754/float128/strtof128_l.c
* sysdeps/ieee754/float128/wcstof128.c
* sysdeps/ieee754/float128/wcstof128_l.c
* sysdeps/ieee754/ldbl-128ibm/strtold_l.c
* sysdeps/ieee754/ldbl-64-128/strtold_l.c
* sysdeps/ieee754/ldbl-opt/nldbl-compat.c
* sysdeps/ieee754/ldbl-opt/nldbl-strfmon_l.c
* sysdeps/ieee754/ldbl-opt/nldbl-strtold_l.c
* sysdeps/ieee754/ldbl-opt/nldbl-wcstold_l.c
* sysdeps/powerpc/powerpc32/power7/strcasecmp.S
* sysdeps/powerpc/powerpc64/power7/strcasecmp.S
* sysdeps/x86_64/strcasecmp_l-nonascii.c
* sysdeps/x86_64/strncase_l-nonascii.c, time/strftime_l.c
* time/strptime_l.c, time/time.h, wcsmbs/mbsrtowcs_l.c
* wcsmbs/wchar.h, wcsmbs/wcscasecmp.c, wcsmbs/wcsncase.c
* wcsmbs/wcstod.c, wcsmbs/wcstod_l.c, wcsmbs/wcstof.c
* wcsmbs/wcstof_l.c, wcsmbs/wcstol_l.c, wcsmbs/wcstold.c
* wcsmbs/wcstold_l.c, wcsmbs/wcstoll_l.c, wcsmbs/wcstoul_l.c
* wcsmbs/wcstoull_l.c, wctype/iswctype_l.c
* wctype/towctrans_l.c, wctype/wcfuncs_l.c
* wctype/wctrans_l.c, wctype/wctype.h, wctype/wctype_l.c:
Change all uses of __locale_t to locale_t.

6 years agoRename xlocale.h to bits/types/__locale_t.h.
Zack Weinberg [Fri, 9 Jun 2017 16:02:06 +0000 (12:02 -0400)] 
Rename xlocale.h to bits/types/__locale_t.h.

xlocale.h is already a single-type micro-header, defining struct
__locale_struct and the typedefs __locale_t and locale_t.  This patch
brings it into the bits/types/ scheme: there are now
bits/types/__locale_t.h which defines only __locale_struct and
__locale_t, and bits/types/locale_t.h which defines locale_t as well
as the other two.  None of *our* headers need __locale_t.h, but it
appears to me that libstdc++ could make use of it.

There are a lot of external uses of xlocale.h, but all the uses I
checked had an autoconf test or equivalent for its existence.  It has
never been available from other C libraries, and it has always
contained a comment reading "This file is not standardized, don't rely
on it, it can go away without warning" so I think dropping it is
pretty safe.

I also took the opportunity to clean up comments in various public
header files that still talk about the *_l interfaces as though they
were completely nonstandard.  There are a few of them, notably the
strtoX_l and wcstoX_l families, that haven't been standardized, but
the bulk are in POSIX.1-2008.

        * locale/xlocale.h: Rename to...
* locale/bits/types/__locale_t.h: ...here.  Adjust commentary.
Only define struct __locale_struct and __locale_t, not locale_t.
        * locale/bits/types/locale_t.h: New file; define locale_t here.
        * locale/Makefile (headers): Update to match.

        * include/xlocale.h: Delete wrapper.
        * include/bits/types/__locale_t.h: New wrapper.
        * include/bits/types/locale_t.h: New wrapper.

        * ctype/ctype.h, include/printf.h, include/time.h
        * locale/langinfo.h, locale/locale.h, stdlib/monetary.h
        * stdlib/stdlib.h, string/string.h, string/strings.h, time/time.h
        * wcsmbs/wchar.h, wctype/wctype.h: Use bits/types/locale_t.h.
        Correct outdated comments regarding the standardization status of
        the functions that take locale_t arguments.

        * stdlib/strtod_l.c, stdlib/strtof_l.c, stdlib/strtol_l.c
        * stdlib/strtold_l.c, stdlib/strtoul_l.c, stdlib/strtoull_l.c
        * sysdeps/ieee754/ldbl-128ibm/strtold_l.c
        * sysdeps/ieee754/ldbl-64-128/strtold_l.c
        * wcsmbs/wcstod.c, wcsmbs/wcstod_l.c, wcsmbs/wcstof.c
        * wcsmbs/wcstof_l.c, wcsmbs/wcstold.c, wcsmbs/wcstold_l.c:
        Don't include xlocale.h. If necessary, include locale.h instead.

        * stdlib/strtold_l.c: Unconditionally include wchar.h.

6 years agoConsolidate Linux openat implementation
Adhemerval Zanella [Tue, 20 Jun 2017 18:46:28 +0000 (15:46 -0300)] 
Consolidate Linux openat implementation

This patch consolidates the open Linux syscall implementation on
sysdeps/unix/sysv/linux/open{64}.c.  The changes are:

  1. Remove wordsize-64 openat{64}.
  2. For architetures that define __OFF_T_MATCHES_OFF64_T openat64
     will be default one with alias to required symbols.  Otherwise
     openat64 will pass the required O_LARGEFILE flag on syscall.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

* sysdeps/unix/sysv/linux/openat.c (__libc_openat): Build only
for !__OFF_T_MATCHES_OFF64_T.
* sysdeps/unix/sysv/linux/openat64.c (__libc_openat64): New
implementation based on open64.
* sysdeps/unix/sysv/linux/wordsize-64/openat.c: Remove file.
* sysdeps/unix/sysv/linux/wordsize-64/openat64.c: Likewise.

6 years agoMove x86 specific tunables to x86/dl-tunables.list
H.J. Lu [Tue, 20 Jun 2017 21:03:09 +0000 (14:03 -0700)] 
Move x86 specific tunables to x86/dl-tunables.list

* elf/dl-tunables.list: Move x86 specific tunables to ...
* sysdeps/x86/dl-tunables.list: Here.  New file.

6 years agoconformtest: XFAIL uc_mcontext test for powerpc32 (bug 21635).
Joseph Myers [Tue, 20 Jun 2017 17:51:36 +0000 (17:51 +0000)] 
conformtest: XFAIL uc_mcontext test for powerpc32 (bug 21635).

This patch XFAILs one test where the powerpc32 ucontext_t has the
wrong type of a field, to allow the conform/ tests as a whole to pass
once the namespace issues are fixed.

Tested with build-many-glibcs.py.

[BZ #21635]
* sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
[$(subdir) = conform] (conformtest-xfail-conds): New variable.
* conform/data/signal.h-data (uc_mcontext): XFAIL for
powerpc32-linux.
* conform/data/ucontext.h-data (uc_mcontext): Likewise.

6 years agoconformtest: XFAIL uc_sigmask test for ia64 (bug 21634).
Joseph Myers [Tue, 20 Jun 2017 17:47:32 +0000 (17:47 +0000)] 
conformtest: XFAIL uc_sigmask test for ia64 (bug 21634).

This patch XFAILs one test where the ia64 ucontext_t has the wrong
type of a field, to allow the conform/ tests as a whole to pass once
the namespace issues are fixed.

Tested with build-many-glibcs.py.

[BZ #21634]
* sysdeps/unix/sysv/linux/ia64/Makefile [$(subdir) = conform]
(conformtest-xfail-conds): New variable.
* conform/data/signal.h-data (uc_sigmask): XFAIL for ia64-linux.
* conform/data/ucontext.h-data (uc_sigmask): Likewise.

6 years agoAdd powf trace
Wilco Dijkstra [Tue, 20 Jun 2017 15:46:52 +0000 (16:46 +0100)] 
Add powf trace

Add a workload for powf.  This is a reduced trace based on 2.3 billion
samples extracted from wrf.  The distribution of values, in particular
frequency of commonly used operands is the same as in the full trace.

    * benchtests/powf-inputs: Add reduced trace from wrf.

6 years agotunables: Add IFUNC selection and cache sizes
H.J. Lu [Tue, 20 Jun 2017 15:33:29 +0000 (08:33 -0700)] 
tunables: Add IFUNC selection and cache sizes

The current IFUNC selection is based on microbenchmarks in glibc.  It
should give the best performance for most workloads.  But other choices
may have better performance for a particular workload or on the hardware
which wasn't available at the selection was made.  The environment
variable, GLIBC_TUNABLES=glibc.tune.ifunc=-xxx,yyy,-zzz...., can be used
to enable CPU/ARCH feature yyy, disable CPU/ARCH feature yyy and zzz,
where the feature name is case-sensitive and has to match the ones in
cpu-features.h.  It can be used by glibc developers to override the
IFUNC selection to tune for a new processor or improve performance for
a particular workload.  It isn't intended for normal end users.

NOTE: the IFUNC selection may change over time.  Please check all
multiarch implementations when experimenting.

Also, GLIBC_TUNABLES=glibc.tune.x86_non_temporal_threshold=NUMBER is
provided to set threshold to use non temporal store to NUMBER,
GLIBC_TUNABLES=glibc.tune.x86_data_cache_size=NUMBER to set data cache
size, GLIBC_TUNABLES=glibc.tune.x86_shared_cache_size=NUMBER to set
shared cache size.

* elf/dl-tunables.list (tune): Add ifunc,
x86_non_temporal_threshold,
x86_data_cache_size and x86_shared_cache_size.
* manual/tunables.texi: Document glibc.tune.ifunc,
glibc.tune.x86_data_cache_size, glibc.tune.x86_shared_cache_size
and glibc.tune.x86_non_temporal_threshold.
* sysdeps/unix/sysv/linux/x86/dl-sysdep.c: New file.
* sysdeps/x86/cpu-tunables.c: Likewise.
* sysdeps/x86/cacheinfo.c
(init_cacheinfo): Check and get data cache size, shared cache
size and non temporal threshold from cpu_features.
* sysdeps/x86/cpu-features.c [HAVE_TUNABLES] (TUNABLE_NAMESPACE):
New.
[HAVE_TUNABLES] Include <unistd.h>.
[HAVE_TUNABLES] Include <elf/dl-tunables.h>.
[HAVE_TUNABLES] (TUNABLE_CALLBACK (set_ifunc)): Likewise.
[HAVE_TUNABLES] (init_cpu_features): Use TUNABLE_GET to set
IFUNC selection, data cache size, shared cache size and non
temporal threshold.
* sysdeps/x86/cpu-features.h (cpu_features): Add data_cache_size,
shared_cache_size and non_temporal_threshold.

6 years agoImprove math benchmark infrastructure
Wilco Dijkstra [Tue, 20 Jun 2017 15:26:26 +0000 (16:26 +0100)] 
Improve math benchmark infrastructure

Improve support for math function benchmarking.  This patch adds
a feature that allows accurate benchmarking of traces extracted
from real workloads.  This is done by iterating over all samples
rather than repeating each sample many times (which completely
ignores branch prediction and cache effects).  A trace can be
added to existing math function inputs via
"## name: workload-<name>", followed by the trace.

        * benchtests/README: Describe workload feature.
        * benchtests/bench-skeleton.c (main): Add support for
        benchmarking traces from workloads.

6 years agoFix fallout from bits/string.h removal.
Zack Weinberg [Tue, 20 Jun 2017 13:39:08 +0000 (09:39 -0400)] 
Fix fallout from bits/string.h removal.

Remove one more string inline that was defined directly in string.h;
in the absence of the rest of the inlines, it broke the build.

Like other ifunc shims for these functions,
x86_64/multiarch/{mem,st}pcpy.c need to define __NO_STRING_INLINES and
NO_MEMPCPY_STPCPY_REDIRECT.

* string/string.h (__mempcpy_inline): Delete.
* sysdeps/x86_64/multiarch/mempcpy.c
* sysdeps/x86_64/multiarch/stpcpy.c:
Define NO_MEMPCPY_STPCPY_REDIRECT and __NO_STRING_INLINES
before including string.h.

6 years agoAdd powf bench tests
Paul Clarke [Tue, 20 Jun 2017 13:14:42 +0000 (10:14 -0300)] 
Add powf bench tests

Add powf() bench test with input which covers these cases:
- positive base to positive exponent
- exponent 0
- negative base to even exponent
- exponent 1
- exponent -1
- squared
- squareroot
- 1 to negative exponent
- -1 to negative exponent
- base 0
- -1 to even exponent
- small base
- small exponent

* benchtests/Makefile (bench-math): Add powf.
* benchtests/powf-inputs: New file.

6 years agoMention in NEWS that __(NO|USE)_STRING_INLINES don't do anything anymore.
Zack Weinberg [Tue, 20 Jun 2017 12:31:18 +0000 (08:31 -0400)] 
Mention in NEWS that __(NO|USE)_STRING_INLINES don't do anything anymore.

6 years agoRemove bits/string.h.
Zack Weinberg [Thu, 17 Nov 2016 14:26:27 +0000 (09:26 -0500)] 
Remove bits/string.h.

These machine-dependent inline string functions have never been on by
default, and even if they were a good idea at the time they were
introduced, they haven't really been touched in ten to fifteen years
and probably aren't a good idea on current-gen processors.  Current
thinking is that this class of optimization is best left to the
compiler.

* bits/string.h, string/bits/string.h
* sysdeps/aarch64/bits/string.h
* sysdeps/m68k/m680x0/m68020/bits/string.h
* sysdeps/s390/bits/string.h, sysdeps/sparc/bits/string.h
* sysdeps/x86/bits/string.h: Delete file.

* string/string.h: Don't include bits/string.h.
* string/bits/string3.h: Rename to bits/string_fortified.h.
No need to undef various symbols that the removed headers
might have defined as macros.
* string/Makefile (headers): Remove bits/string.h, change
bits/string3.h to bits/string_fortified.h.
* string/string-inlines.c: Update commentary.  Remove definitions
of various macros that nothing looks at anymore.  Don't directly
include bits/string.h. Set _STRING_INLINE_unaligned here, based on
compiler-predefined macros.
* string/strncat.c: If STRNCAT is not defined, or STRNCAT_PRIMARY
_is_ defined, provide internal hidden alias __strncat.
* include/string.h: Declare internal hidden alias __strncat.
Only forward __stpcpy to __builtin_stpcpy if __NO_STRING_INLINES is
not defined.
* include/bits/string3.h: Rename to bits/string_fortified.h,
update to match above.

* sysdeps/i386/string-inlines.c: Define compat symbols for
everything formerly defined by sysdeps/x86/bits/string.h.
Make existing definitions into compat symbols as well.
Remove some no-longer-necessary messing around with macros.

* sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy.c
* sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
* sysdeps/powerpc/powerpc64/multiarch/stpcpy.c
* sysdeps/s390/multiarch/mempcpy.c
No need to define _HAVE_STRING_ARCH_mempcpy.
Do define __NO_STRING_INLINES and NO_MEMPCPY_STPCPY_REDIRECT.

* sysdeps/i386/i686/multiarch/strncat-c.c
* sysdeps/s390/multiarch/strncat-c.c
* sysdeps/x86_64/multiarch/strncat-c.c
Define STRNCAT_PRIMARY.  Don't change definition of libc_hidden_def.

6 years agomanual: Complete @standards in lang.texi.
Rical Jasan [Tue, 20 Jun 2017 11:29:33 +0000 (04:29 -0700)] 
manual: Complete @standards in lang.texi.

* manual/lang.texi (LDBL_MANT_DIG): Add annotation.
(LDBL_DIG): Likewise.
(LDBL_MIN_EXP): Likewise.
(LDBL_MIN_10_EXP): Likewise.
(LDBL_MAX_EXP): Likewise.
(LDBL_MAX_10_EXP): Likewise.
(LDBL_MAX): Likewise.
(LDBL_MIN): Likewise.
(LDBL_EPSILON): Likewise.
(FLT_ROUNDS): Change standard from ISO to C90.
(FLT_RADIX): Likewise.
(FLT_MANT_DIG, DBL_MANT_DIG): Likewise.
(FLT_DIG, DBL_DIG): Likewise.
(FLT_MIN_EXP, DBL_MIN_EXP): Likewise.
(FLT_MIN_10_EXP, DBL_MIN_10_EXP): Likewise.
(FLT_MAX_EXP, DBL_MAX_EXP): Likewise.
(FLT_MAX_10_EXP, DBL_MAX_10_EXP): Likewise.
(FLT_MAX, DBL_MAX): Likewise.
(FLT_MIN, DBL_MIN): Likewise.
(FLT_EPSILON, DBL_EPSILON): Likewise.

6 years agoRemove pre-GCC-4.9 MIPS code.
Joseph Myers [Mon, 19 Jun 2017 23:24:36 +0000 (23:24 +0000)] 
Remove pre-GCC-4.9 MIPS code.

This patch removes some MIPS code in glibc that was conditional on old
GCC versions no longer supported for building glibc.

Tested with build-many-glibcs.py.

* sysdeps/mips/atomic-machine.h (R10K_BEQZ_INSN): Remove.
[__GNUC_PREREQ (4, 8) || __mips16]: Make code unconditional.
[!__GNUC_PREREQ (4, 8) && !__mips16]: Remove conditional code.
* sysdeps/mips/math-tests.h
[_MIPS_SIM != _ABIO32 && !__GNUC_PREREQ (4, 9)]: Remove
conditional code.

6 years agoDCIGETTEXT: Do not make copy of localename
Florian Weimer [Mon, 19 Jun 2017 12:44:33 +0000 (14:44 +0200)] 
DCIGETTEXT: Do not make copy of localename

6 years agold.so: Reject overly long LD_AUDIT path elements
Florian Weimer [Mon, 19 Jun 2017 20:32:12 +0000 (22:32 +0200)] 
ld.so: Reject overly long LD_AUDIT path elements

Also only process the last LD_AUDIT entry.

6 years agold.so: Reject overly long LD_PRELOAD path elements
Florian Weimer [Mon, 19 Jun 2017 20:31:04 +0000 (22:31 +0200)] 
ld.so: Reject overly long LD_PRELOAD path elements

6 years agoFix wait3 namespace (bug 21625).
Joseph Myers [Mon, 19 Jun 2017 16:39:17 +0000 (16:39 +0000)] 
Fix wait3 namespace (bug 21625).

The wait3 function was removed in the 2001 edition of POSIX.
sys/wait.h wrongly declares it for the 2001 and 2008 editions of POSIX
when XSI features are enabled.  This patch fixes the conditionals.

Tested for x86_64.

[BZ #21625]
* posix/sys/wait.h (strust rusage forward declaration): Change
[__USE_XOPEN_EXTENDED] conditional to [__USE_XOPEN_EXTENDED &&
!__USE_XOPEN2K].
(wait3): Likewise.

6 years agoRequire GCC 4.9 or later for building glibc.
Joseph Myers [Mon, 19 Jun 2017 16:33:00 +0000 (16:33 +0000)] 
Require GCC 4.9 or later for building glibc.

This patch makes configure require GCC 4.9 or later for building
glibc, and documents that requirement.  Requiring GCC 4.9 or later
allows use of _Generic (as in tzcode).  It would allow <stdatomic.h>
and _Atomic to be used as well if desired, although we need to avoid
any libatomic dependencies on any platforms.  This patch is explicitly
the minimum to implement a new version requirement, with any
consequent cleanups of conditional code (not in installed headers or
files shared with gnulib etc.) to be done separately.

Tested for x86_64.

* configure.ac (libc_cv_compiler_ok): Require GCC 4.9 or later.
* configure: Regenerated.
* manual/install.texi (Tools for Compilation): Document
requirement for GCC 4.9 or later.
* INSTALL: Regenerated.

6 years agoCVE-2017-1000366: Ignore LD_LIBRARY_PATH for AT_SECURE=1 programs [BZ #21624]
Florian Weimer [Mon, 19 Jun 2017 15:09:55 +0000 (17:09 +0200)] 
CVE-2017-1000366: Ignore LD_LIBRARY_PATH for AT_SECURE=1 programs [BZ #21624]

LD_LIBRARY_PATH can only be used to reorder system search paths, which
is not useful functionality.

This makes an exploitable unbounded alloca in _dl_init_paths unreachable
for AT_SECURE=1 programs.

6 years agoS390: Sync ptrace.h with kernel. [BZ #21539]
Stefan Liebler [Mon, 19 Jun 2017 14:27:25 +0000 (16:27 +0200)] 
S390: Sync ptrace.h with kernel. [BZ #21539]

This patch removes PTRACE_GETREGS, PTRACE_SETREGS, PTRACE_GETFPREGS
and PTRACE_SETFPREGS as these requests does not exist on s390 kernel.

But the kernel has support for PTRACE_SINGLEBLOCK,
PTRACE_SECCOMP_GET_FILTER, PTRACE_PEEKUSR_AREA, PTRACE_POKEUSR_AREA,
PTRACE_GET_LAST_BREAK, PTRACE_ENABLE_TE, PTRACE_DISABLE_TE and
PTRACE_TE_ABORT_RAND.  Thus those are defined now.

The current kernel s390 specific ptrace.h file also defines
PTRACE_PEEKTEXT_AREA, PTRACE_PEEKDATA_AREA, PTRACE_POKETEXT_AREA,
PTRACE_POKEDATA_AREA, PTRACE_PEEK_SYSTEM_CALL, PTRACE_POKE_SYSTEM_CALL
and PTRACE_PROT, but those requests are not supported.
Thus those defines are skipped in glibc ptrace.h.

There were old includes of ptrace.h in sysdeps/s390/fpu/fesetenv.c.
The ptrace feature isn't used there anymore, thus I removed the includes.

Before this patch, <glibc>/sysdeps/unix/sysv/linux/s390/sys/ptrace.h
uses ptrace-request 12 for PTRACE_GETREGS,
but <kernel>/include/uapi/linux/ptrace.h uses 12 for PTRACE_SINGLEBLOCK.

The s390 kernel has never had support for PTRACE_GETREGS!
Thus glibc ptrace.h is adjusted to match kernel ptrace.h.

The new s390 specific test ensures, that PTRACE_SINGLEBLOCK defined
in glibc works as expected.  If the kernel would interpret it as
PTRACE_GETREGS, then the testcase will not make any progress
and will time out.

ChangeLog:

[BZ #21539]
* NEWS: Mention s390 ptrace request changes.
* sysdeps/unix/sysv/linux/s390/sys/ptrace.h
(PTRACE_GETREGS, PTRACE_SETREGS, PTRACE_GETFPREGS,
PTRACE_SETFPREGS): Remove enum constant.
(PT_GETREGS, PT_SETREGS, PT_GETFPREGS, T_SETFPREGS):
Remove defines.
(PTRACE_SINGLEBLOCK): New enum constant.
(PT_STEPBLOCK): New define.
(PTRACE_PEEKUSR_AREA, PTRACE_POKEUSR_AREA,
PTRACE_GET_LAST_BREAK, PTRACE_ENABLE_TE, PTRACE_DISABLE_TE,
PTRACE_TE_ABORT_RAND): New enum constant and define.
* sysdeps/s390/fpu/fesetenv.c: Remove ptrace.h includes.
* sysdeps/unix/sysv/linux/s390/tst-ptrace-singleblock.c:
New file.
* sysdeps/unix/sysv/linux/s390/Makefile: Add test.

6 years agoresolv: Use getline for configuration file reading in res_vinit_1
Florian Weimer [Fri, 16 Jun 2017 18:54:43 +0000 (20:54 +0200)] 
resolv: Use getline for configuration file reading in res_vinit_1

6 years agoresolv: Report allocation errors in __res_vinit
Florian Weimer [Mon, 19 Jun 2017 12:05:49 +0000 (14:05 +0200)] 
resolv: Report allocation errors in __res_vinit

6 years agoresolv: Reformat res_vinit and related functions to GNU style
Florian Weimer [Mon, 19 Jun 2017 11:20:46 +0000 (13:20 +0200)] 
resolv: Reformat res_vinit and related functions to GNU style

Also remove some obsolete comments.

6 years agoresolv: Introduce is_sort_mask and call it from res_vinit
Florian Weimer [Mon, 19 Jun 2017 11:19:00 +0000 (13:19 +0200)] 
resolv: Introduce is_sort_mask and call it from res_vinit

6 years agoresolv: Remove DEBUG preprocessor conditionals from res_setoptions
Florian Weimer [Mon, 19 Jun 2017 11:18:45 +0000 (13:18 +0200)] 
resolv: Remove DEBUG preprocessor conditionals from res_setoptions

6 years agoresolv: Move _res deallocation functions to their own file
Florian Weimer [Mon, 19 Jun 2017 11:17:49 +0000 (13:17 +0200)] 
resolv: Move _res deallocation functions to their own file

6 years agoresolv: Move res_randomid to its own file
Florian Weimer [Mon, 19 Jun 2017 11:17:03 +0000 (13:17 +0200)] 
resolv: Move res_randomid to its own file

6 years agoresolv: Make __res_vinit hidden
Florian Weimer [Mon, 19 Jun 2017 11:15:11 +0000 (13:15 +0200)] 
resolv: Make __res_vinit hidden

And remove unnecessary separate declarations.

6 years agoFix another x86 sys/ucontext.h namespace issue (bug 21457).
Joseph Myers [Mon, 19 Jun 2017 12:21:35 +0000 (12:21 +0000)] 
Fix another x86 sys/ucontext.h namespace issue (bug 21457).

This patch fixes a namespace issue for one more field in the x86
sys/ucontext.h that I missed in my previous changes.

Tested for x86_64.

[BZ #21457]
* sysdeps/unix/sysv/linux/x86/sys/ucontext.h [__x86_64__] (struct
_libc_xmmreg): Use __ctx in defining field.

6 years agoFix siginterrupt namespace (bug 21597).
Joseph Myers [Mon, 19 Jun 2017 12:18:46 +0000 (12:18 +0000)] 
Fix siginterrupt namespace (bug 21597).

The siginterrupt function is XSI-shaded in POSIX.  glibc wrongly
declares it in <signal.h> for non-XSI POSIX.1:2008.  This patch fixes
the conditionals (moving it into the __USE_XOPEN_EXTENDED ||
__USE_MISC block as the minimum conservative change, although it's not
clear this obsolescent function should be declared by default).

Tested for x86_64.

[BZ #21597]
* signal/signal.h (siginterrupt): Make declaration conditional on
[__USE_XOPEN_EXTENDED || __USE_MISC].

6 years agoFix signal stack namespace (bug 21584).
Joseph Myers [Mon, 19 Jun 2017 12:00:13 +0000 (12:00 +0000)] 
Fix signal stack namespace (bug 21584).

In POSIX.1:2008, various signal stack symbols - sigaltstack, SS_*,
SIGSTKSZ, MINSIGSTKSZ - are all XSI-shaded.  glibc wrongly makes them
visible for non-XSI POSIX.  This patch fixes the conditionals, leaving
the symbols available for __USE_MISC as it seems likely some of them
are widely used and should be visible by default.  (Note that stack_t
is *not* XSI-shaded and so the conditionals on that are correctly
unchanged.)

Tested for x86_64.

[BZ #21584]
* signal/signal.h: Make includes of <bits/sigstack.h> and
<bits/ss_flags.h> conditional on [__USE_XOPEN_EXTENDED ||
__USE_MISC].
(sigaltstack): Make declaration conditional on
[__USE_XOPEN_EXTENDED || __USE_MISC].

6 years agoDefine struct rusage in sys/wait.h when required (bug 21575).
Joseph Myers [Mon, 19 Jun 2017 11:59:19 +0000 (11:59 +0000)] 
Define struct rusage in sys/wait.h when required (bug 21575).

Some older standards (XPG4.2 through POSIX.1:2001, XSI only) require
sys/wait.h to include the definition of struct rusage.  This is
missing in glibc.

This patch adds the required definition.  struct rusage is moved to a
new header bits/types/struct_rusage.h to avoid bringing in the whole
of sys/resource.h (although the standards in question do allow the
whole of sys/resource.h to be brought in).  In the five
bits/resource.h headers, the only variation between the definitions of
struct rusage is that the sysdeps/unix/sysv/linux version is prepared
for x32 (by having anonymous unions with __syscall_slong_t fields) and
the others are not.  Thus, this version is suitable for use
generically (everything other than x32 simply has __syscall_slong_t
the same as long int, so there are no API or ABI changes involved, and
anonymous unions are already a required language feature for glibc
headers elsewhere), and this patch uses it as a base for the single
implementation of bits/types/struct_rusage.h.

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

[BZ #21575]
* resource/bits/types/struct_rusage.h: New file.
* include/bits/types/struct_rusage.h: Likewise.
* bits/resource.h (struct rusage): Include
<bits/types/struct_rusage.h> instead of defining here.
* sysdeps/unix/sysv/linux/bits/resource.h (struct rusage):
Likewise.
* sysdeps/unix/sysv/linux/alpha/bits/resource.h (struct rusage):
Likewise.
* sysdeps/unix/sysv/linux/mips/bits/resource.h (struct rusage):
Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/resource.h (struct rusage):
Likewise.
* resource/Makefile (headers): Add bits/types/struct_rusage.h.
* posix/sys/wait.h [__USE_XOPEN_EXTENDED && !__USE_XOPEN2K8]:
Include <bits/types/struct_rusage.h>

6 years agodynarray: Use libc_hidden_proto only for !_ISOMAC
Florian Weimer [Mon, 19 Jun 2017 10:58:08 +0000 (12:58 +0200)] 
dynarray: Use libc_hidden_proto only for !_ISOMAC

With this change, it is possible to use dynarray from non-internal
tests.

6 years agoFix typo when undefining weak_alias
Siddhesh Poyarekar [Mon, 19 Jun 2017 09:26:40 +0000 (14:56 +0530)] 
Fix typo when undefining weak_alias

The macro directive #undef was miswritten as #undefine.

* sysdeps/x86_64/multiarch/rawmemchr-sse2.S: Fix typo.

6 years agoFix gen-tunables.awk to work with older awk
Adhemerval Zanella [Mon, 19 Jun 2017 09:17:21 +0000 (14:47 +0530)] 
Fix gen-tunables.awk to work with older awk

Awk 3.1.x does not support multi-dimensional arrays, so fix up to make
sure that gen-tunables.awk works on it.

* scripts/gen-tunables.awk: Avoid multi-dimensional arrays.

6 years agoS390: Fix build with gcc configured with --enable-default-pie. [BZ #21537]
Stefan Liebler [Mon, 19 Jun 2017 09:06:49 +0000 (11:06 +0200)] 
S390: Fix build with gcc configured with --enable-default-pie. [BZ #21537]

Building glibc with gcc configured with --enable-default-pie failed on s390
due to assembler messages:
../sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S:44:
Error: junk at end of line, first unrecognized character is `@'

HIDDEN_JUMPTARGET was expanded to exit@PLT@GOTOFF.
If SHARED is not defined, HIDDEN_JUMPTARGET is defined to JUMPTARGET
in sysdeps/s390/s390-32/sysdep.h.  There it expanded to exit@PLT
in non SHARED case as PIC is defined if gcc is configured with
--enable-default-pie. Thus I've changed the "ifdef PIC" to "ifdef SHARED"
as we do not want PLTs in the static obj files.  I've also changed this
in sysdeps/s390/s390-64/sysdep.h.

I've also adjusted sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S.
If glibc is configured with --disable-hidden-plt, then NO_HIDDEN is defined.
In SHARED case HIDDEN_JUMPTARGET would be expanded to exit@PLT@GOTOFF
instead of __GI_exit@GOTOFF.
Now we jump to:
- __GI_exit if SHARED is defined
- exit@PLT if SHARED and NO_HIDDEN is defined
- exit if both are not defined.
On s390 31bit we have to setup GOT pointer in r12 if we use a PLT stub.
Therefore I use SYSCALL_PIC_SETUP from sysdep.h and added the missing semicolons.

ChangeLog:

[BZ #21537]
* sysdeps/s390/s390-32/sysdep.h (JUMPTARGET, SYSCALL_PIC_SETUP):
Check SHARED instead of PIC.
(SYSCALL_PIC_SETUP): Add missing semicolons.
* sysdeps/s390/s390-64/sysdep.h (JUMPTARGET, SYSCALL_PIC_SETUP):
Check SHARED instead of PIC.
* sysdeps/unix/sysv/linux/s390/s390-32/__makecontext_ret.S
(__makecontext_ret): Adjust code to jump to exit.

6 years agos390: optimize syscall function
Christian Borntraeger [Mon, 19 Jun 2017 08:59:40 +0000 (10:59 +0200)] 
s390: optimize syscall function

Since kernel 2.6.0 all Linux version accept the system call number
in register 1 for svc 0. There is no need to have special handling
that uses EX for system calls < 256. This will simplify and speed
up that code.

A microbenchmark doing "syscall(__NR_getpid);" in a loops gets faster
by ~12%.

        * sysdeps/unix/sysv/linux/s390/s390-32/syscall.S: Simplify
        code by always using SVC 0 instead of EX.
        * sysdeps/unix/sysv/linux/s390/s390-64/syscall.S: Likewise.

6 years agoRemove _dl_out_of_memory from elf/Versions
H.J. Lu [Fri, 16 Jun 2017 13:45:55 +0000 (06:45 -0700)] 
Remove _dl_out_of_memory from elf/Versions

Since _dl_out_of_memory is static in elf/dl-error-skeleton.c:

static const char _dl_out_of_memory[] = "out of memory";

remove _dl_out_of_memory from elf/Versions.

* elf/Versions (ld): Remove _dl_out_of_memory.

6 years agoUpdate timezone code from tzcode 2017b.
Joseph Myers [Fri, 16 Jun 2017 11:09:21 +0000 (11:09 +0000)] 
Update timezone code from tzcode 2017b.

This patch updates files coming from tzcode to the versions in tzcode
2017b.  A couple of changes to other glibc code are needed.
time/tzset.c was using the SECSPERDAY macro from tzfile.h, which no
longer defines that macro, so a local definition is added to tzset.c.
Because timezone/private.h now defines the _ macro whenever
HAVE_GETTEXT is true, even if it was previously defined, it is also
necessary to avoid a conflict with the definition in
include/libintl.h.  Defining _ISOMAC is the obvious way to avoid such
internal definitions being visible, together with defining TZ_DOMAIN
so that zic and zdump continue to get the messages from the libc
domain as desired.  However, zic and zdump rely on PKGVERSION and
REPORT_BUGS_TO from config.h, which is not included by default with
_ISOMAC, so -include config.h needs adding to the options for these
programs as well.  Together those changes allow unmodified tzcode
2017b sources to work in glibc.

Tested for x86_64.

* timezone/private.h: Update from tzcode 2017b.
* timezone/tzfile.h: Likewise.
* timezone/tzselect.ksh: Likewise.
* timezone/zdump.c: Likewise.
* timezone/zic.c: Likewise.
* timezone/Makefile (tz-cflags): Add -D_ISOMAC
-DTZ_DOMAIN='"libc"' -include $(common-objpfx)config.h.
* time/tzset.c (SECSPERDAY): New macro.

6 years agomanual: Complete @standards in string.texi.
Rical Jasan [Fri, 16 Jun 2017 08:06:51 +0000 (01:06 -0700)] 
manual: Complete @standards in string.texi.

* manual/string.texi (strdup): Complete header and standards
annotation.
(strncpy): Likewise.

6 years agomanual: Complete @standards in arith.texi.
Rical Jasan [Fri, 16 Jun 2017 07:27:09 +0000 (00:27 -0700)] 
manual: Complete @standards in arith.texi.

* manual/arith.texi (FP_NAN): Add or complete header and
standard annotations.
(FP_INFINITE): Likewise.
(FP_ZERO): Likewise.
(FP_SUBNORMAL): Likewise.
(FP_NORMAL): Likewise.
(SNAN): Likewise.
(SNANL): Likewise.
(totalorderf): Likewise.
(totalorderl): Likewise.
(totalordermagf): Likewise.
(totalordermagl): Likewise.
(_Complex_I): Likewise.
(I): Likewise.

6 years agomanual: Complete @standards in argp.texi.
Rical Jasan [Fri, 26 May 2017 10:59:15 +0000 (03:59 -0700)] 
manual: Complete @standards in argp.texi.

* manual/argp.texi (ARGP_HELP_USAGE): Add missing header and
standard annotation.
(ARGP_HELP_SHORT_USAGE): Likewise.
(ARGP_HELP_SEE): Likewise.
(ARGP_HELP_LONG): Likewise.
(ARGP_HELP_PRE_DOC): Likewise.
(ARGP_HELP_POST_DOC): Likewise.
(ARGP_HELP_DOC): Likewise.
(ARGP_HELP_BUG_ADDR): Likewise.
(ARGP_HELP_LONG_ONLY): Likewise.
(ARGP_HELP_EXIT_ERR): Likewise.
(ARGP_HELP_EXIT_OK): Likewise.
(ARGP_HELP_STD_ERR): Likewise.
(ARGP_HELP_STD_USAGE): Likewise.
(ARGP_HELP_STD_HELP): Likewise.

6 years agomanual: Replace summary.awk with summary.pl.
Rical Jasan [Fri, 16 Jun 2017 04:12:39 +0000 (21:12 -0700)] 
manual: Replace summary.awk with summary.pl.

The Summary is now generated from @standards, and syntax-checking is
performed.  If invalid @standards syntax is detected, summary.pl will
fail, reporting all errors.  Failure and error reporting is disabled
for now, however, since much of the manual is still incomplete
wrt. header and standards annotations.

Note that the sorting order of the Summary has changed; summary.pl
respects the locale, like summary.awk did, but the use of LC_ALL=C is
introduced in the Makefile.  Other notable deviations are improved
detection of the annotated elements' names, which are used for
sorting, and improved detection of the @node used to reference into
the manual.  The most noticeable difference in the rendered Summary is
that entries may now contain multiple lines, one for each header and
standard combination.

summary.pl accepts a `--help' option, which details the expected
syntax of @standards.  If errors are reported, the user is directed to
this feature for further information.

* manual/Makefile: Generate summary.texi with summary.pl.
Force use of the C locale.  Update Perl dependency comment.
* manual/header.texi: Update reference to summary.awk.
* manual/macros.texi: Refer authors to `summary.pl --help'.
* manual/summary.awk: Remove file.
* manual/summary.pl: New file.  Generate summary.texi, and
check for @standards-related syntax errors.
* manual/argp.texi: Convert header and standards @comments to
@standards.
* manual/arith.texi: Likewise.
* manual/charset.texi: Likewise.
* manual/conf.texi: Likewise.
* manual/creature.texi: Likewise.
* manual/crypt.texi: Likewise.
* manual/ctype.texi: Likewise.
* manual/debug.texi: Likewise.
* manual/errno.texi: Likewise.
* manual/filesys.texi: Likewise.
* manual/getopt.texi: Likewise.
* manual/job.texi: Likewise.
* manual/lang.texi: Likewise.
* manual/llio.texi: Likewise.
* manual/locale.texi: Likewise.
* manual/math.texi: Likewise.
* manual/memory.texi: Likewise.
* manual/message.texi: Likewise.
* manual/pattern.texi: Likewise.
* manual/pipe.texi: Likewise.
* manual/process.texi: Likewise.
* manual/resource.texi: Likewise.
* manual/search.texi: Likewise.
* manual/setjmp.texi: Likewise.
* manual/signal.texi: Likewise.
* manual/socket.texi: Likewise.
* manual/startup.texi: Likewise.
* manual/stdio.texi: Likewise.
* manual/string.texi: Likewise.
* manual/sysinfo.texi: Likewise.
* manual/syslog.texi: Likewise.
* manual/terminal.texi: Likewise.
* manual/threads.texi: Likewise.
* manual/time.texi: Likewise.
* manual/users.texi: Likewise.

6 years agomanual: Create empty placeholder macros for @standards.
Rical Jasan [Mon, 13 Mar 2017 05:30:41 +0000 (22:30 -0700)] 
manual: Create empty placeholder macros for @standards.

Header and standards annotations are slated for standardization,
including being rendered in the description of functions, variables,
etc. (elements), and eventually required.  This commit adds @standards
dummy macros so we can convert all existing annotations to the new
framework while maintaining the rendered status quo.

There needs to be a way to disambiguate annotations in lists of @*x
elements, where a common description is shared but some elements may
have different headers or standards.  The @standardsx macro fills this
role by accepting an additional parameter: the name of the annotated
element.

* manual/macros.texi (@standards): New macro.  Provide
placeholder for header and standards annotations.
(@standardsx): New macro.  Likewise, for lists of @*x
elements.

6 years agolinux: Consolidate sync_file_range implementation
Adhemerval Zanella [Fri, 19 May 2017 13:33:58 +0000 (10:33 -0300)] 
linux: Consolidate sync_file_range implementation

This patch consolidates Linux sync_file_range at default
sysdeps/unix/sysv/linux/sync_file_range.c implementation.  It also
moves the rules flags from generic io/Makefile to Linux one due the
fact it is a Linux-only symbol.

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

* io/Makefile (CFLAGS-sync_file_range.c): Remove rule.
* sysdeps/unix/sysv/linux/Makefile (CFLAGS-sync_file_range.c): New
rule.
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Remove
sync_file_range.

6 years agosupport: Add optstring support
Adhemerval Zanella [Wed, 24 May 2017 12:17:34 +0000 (09:17 -0300)] 
support: Add optstring support

This patch adds an option to test to add small command line option
through CMDLINE_OPTSTRING define.  For instance:

  #define CMDLINE_OPTSTRING "vd"

  static void
  cmdline_process_function (int c)
  {
    switch (c):
      'v':
        /* process '-v' option.  */
      break;
      'd':
        /* process '-d' option.  */
      break;
  }
  #define CMDLINE_PROCESS cmdline_process_function

It will add both '-v' and '-d' along with already default long options.

* support/support_test_main.c (support_test_main):  Use optstring
member for option string in getopt_long.
* support/test-driver.c: Add comment about CMDLINE_OPTSTRING.
(CMDLINE_OPTSTRING): New define.
* support/test-driver.h (test_config): Add optstring member.

6 years agox86-64: Implement strcspn/strpbrk/strspn IFUNC selectors in C
H.J. Lu [Thu, 15 Jun 2017 15:58:56 +0000 (08:58 -0700)] 
x86-64: Implement strcspn/strpbrk/strspn IFUNC selectors in C

Implement strcspn/strpbrk/strspn IFUNC selectors in C

All internal calls within libc.so can use IFUNC on x86-64 since unlike
x86, x86-64 supports PC-relative addressing to access the GOT entry so
that it can call via PLT without using an extra register.  For libc.a,
we can't use IFUNC for functions which are called before IFUNC has been
initialized.  Use IFUNC internally reduces the icache footprint since
libc.so and other codes in the process use the same implementations.
This patch uses IFUNC for strcspn/strpbrk/strspn functions within libc.

* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
strcspn-sse2, strpbrk-sse2 and strspn-sse2.
* sysdeps/x86_64/strcspn.S (STRPBRK_P): Removed.
Check USE_AS_STRPBRK instead of STRPBRK_P.
* sysdeps/x86_64/strpbrk.S (USE_AS_STRPBRK): New.
* sysdeps/x86_64/multiarch/ifunc-sse4_2.h: New file.
* sysdeps/x86_64/multiarch/strcspn-sse2.S: Likewise.
* sysdeps/x86_64/multiarch/strcspn.c: Likewise.
* sysdeps/x86_64/multiarch/strpbrk-sse2.S: Likewise.
* sysdeps/x86_64/multiarch/strpbrk.c: Likewise.
* sysdeps/x86_64/multiarch/strspn-sse2.S: Likewise.
* sysdeps/x86_64/multiarch/strspn.c: Likewise.
* sysdeps/x86_64/multiarch/strcspn.S: Removed.
* sysdeps/x86_64/multiarch/strpbrk.S: Likewise.
* sysdeps/x86_64/multiarch/strspn.S: Likewise.
* sysdeps/x86_64/multiarch/strpbrk-c.c: Remove "#ifdef SHARED"
and "#endif".

6 years agox86-64: Implement wcscpy IFUNC selector in C
H.J. Lu [Thu, 15 Jun 2017 15:57:39 +0000 (08:57 -0700)] 
x86-64: Implement wcscpy IFUNC selector in C

* sysdeps/x86_64/multiarch/wcscpy.S: Removed.
* sysdeps/x86_64/multiarch/wcscpy.c: New file.

6 years agox86-64: Implement strcat family IFUNC selectors in C
H.J. Lu [Thu, 15 Jun 2017 15:56:48 +0000 (08:56 -0700)] 
x86-64: Implement strcat family IFUNC selectors in C

Implement strcat family IFUNC selectors in C.

All internal calls within libc.so can use IFUNC on x86-64 since unlike
x86, x86-64 supports PC-relative addressing to access the GOT entry so
that it can call via PLT without using an extra register.  For libc.a,
we can't use IFUNC for functions which are called before IFUNC has been
initialized.  Use IFUNC internally reduces the icache footprint since
libc.so and other codes in the process use the same implementations.
This patch uses IFUNC for strcat family functions within libc.

* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
strcat-sse2.
* sysdeps/x86_64/multiarch/strcat-sse2.S: New file.
* sysdeps/x86_64/multiarch/strcat.c: Likewise.
* sysdeps/x86_64/multiarch/strncat.c: Likewise.
* sysdeps/x86_64/multiarch/strcat.S: Removed.
* sysdeps/x86_64/multiarch/strncat.S: Likewise.

6 years agox86-64: Implement memcmp family IFUNC selectors in C
H.J. Lu [Thu, 15 Jun 2017 15:49:43 +0000 (08:49 -0700)] 
x86-64: Implement memcmp family IFUNC selectors in C

Implement memcmp family IFUNC selectors in C.

All internal calls within libc.so can use IFUNC on x86-64 since unlike
x86, x86-64 supports PC-relative addressing to access the GOT entry so
that it can call via PLT without using an extra register.  For libc.a,
we can't use IFUNC for functions which are called before IFUNC has been
initialized.  Use IFUNC internally reduces the icache footprint since
libc.so and other codes in the process use the same implementations.
This patch uses IFUNC for memcmp family functions within libc.

* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
memcmp-sse2.
* sysdeps/x86_64/multiarch/ifunc-memcmp.h: New file.
* sysdeps/x86_64/multiarch/memcmp-sse2.S: Likewise.
* sysdeps/x86_64/multiarch/memcmp.c: Likewise.
* sysdeps/x86_64/multiarch/wmemcmp.c: Likewise.
* sysdeps/x86_64/multiarch/memcmp.S: Removed.
* sysdeps/x86_64/multiarch/wmemcmp.S: Likewise.

6 years agox86-64: Implement memset family IFUNC selectors in C
H.J. Lu [Thu, 15 Jun 2017 15:33:25 +0000 (08:33 -0700)] 
x86-64: Implement memset family IFUNC selectors in C

Implement memset family IFUNC selectors in C.

All internal calls within libc.so can use IFUNC on x86-64 since unlike
x86, x86-64 supports PC-relative addressing to access the GOT entry so
that it can call via PLT without using an extra register.  For libc.a,
we can't use IFUNC for functions which are called before IFUNC has been
initialized.  Use IFUNC internally reduces the icache footprint since
libc.so and other codes in the process use the same implementations.
This patch uses IFUNC for memset functions within libc.

2017-06-07  H.J. Lu  <hongjiu.lu@intel.com>
    Erich Elsen  <eriche@google.com>

* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
memset-sse2-unaligned-erms, and memset_chk-nonshared.
* sysdeps/x86_64/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Add test for __memset_chk_erms.
Update comments.
* sysdeps/x86_64/multiarch/ifunc-memset.h: New file.
* sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S: Likewise.
* sysdeps/x86_64/multiarch/memset.c: Likewise.
* sysdeps/x86_64/multiarch/memset_chk-nonshared.S: Likewise.
* sysdeps/x86_64/multiarch/memset_chk.c: Likewise.
* sysdeps/x86_64/multiarch/memset.S: Removed.
* sysdeps/x86_64/multiarch/memset_chk.S: Likewise.
* sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
(__memset_chk_erms): New function.

6 years agoEnable tunables by default
Siddhesh Poyarekar [Thu, 15 Jun 2017 09:42:54 +0000 (15:12 +0530)] 
Enable tunables by default

All of the major architectures are adopting tunables as a way to add
tuning to the library, from hwcap_mask for aarch64 to HLE for s390 and
ifunc and cache geometry for x86.  Given this adoption and the fact
that we don't want additional tuning knobs to be added outside of
tunables, it makes sense to enable tunables by default using this
trivial patch.

Smoke tested on x86 to ensure that tunables code was built without
specifying it as a configure flag.  I have kept it as --enabled and
not changed it to --disable since we want to still keep the option of
different kinds of front-ends for tunables.

* configure.ac(--enable-tunables): Enable by default.
* configure: Regenerate.
* NEWS: Mention change.
* manual/install.texi (enable-tunables): Adjust documentation.
* INSTALL: Regenerate.

6 years agonptl: Invert the mmap/mprotect logic on allocated stacks (BZ#18988)
Adhemerval Zanella [Tue, 31 Jan 2017 20:01:59 +0000 (18:01 -0200)] 
nptl: Invert the mmap/mprotect logic on allocated stacks (BZ#18988)

Current allocate_stack logic for create stacks is to first mmap all
the required memory with the desirable memory and then mprotect the
guard area with PROT_NONE if required.  Although it works as expected,
it pessimizes the allocation because it requires the kernel to actually
increase commit charge (it counts against the available physical/swap
memory available for the system).

The only issue is to actually check this change since side-effects are
really Linux specific and to actually account them it would require a
kernel specific tests to parse the system wide information.  On the kernel
I checked /proc/self/statm does not show any meaningful difference for
vmm and/or rss before and after thread creation.  I could only see
really meaningful information checking on system wide /proc/meminfo
between thread creation: MemFree, MemAvailable, and Committed_AS shows
large difference without the patch.  I think trying to use these
kind of information on a testcase is fragile.

The BZ#18988 reports shows that the commit pages are easily seen with
mlockall (MCL_FUTURE) (with lock all pages that become mapped in the
process) however a more straighfoward testcase shows that pthread_create
could be faster using this patch:

--
static const int inner_count = 256;
static const int outer_count = 128;

static
void *thread1(void *arg)
{
  return NULL;
}

static
void *sleeper(void *arg)
{
  pthread_t ts[inner_count];
  for (int i = 0; i < inner_count; i++)
    pthread_create (&ts[i], &a, thread1, NULL);
  for (int i = 0; i < inner_count; i++)
    pthread_join (ts[i], NULL);

  return NULL;
}

int main(void)
{
  pthread_attr_init(&a);
  pthread_attr_setguardsize(&a, 1<<20);
  pthread_attr_setstacksize(&a, 1134592);

  pthread_t ts[outer_count];
  for (int i = 0; i < outer_count; i++)
    pthread_create(&ts[i], &a, sleeper, NULL);
  for (int i = 0; i < outer_count; i++)
    pthread_join(ts[i], NULL);
    assert(r == 0);
  }
  return 0;
}

--

On x86_64 (4.4.0-45-generic, gcc 5.4.0) running the small benchtests
I see:

$ time ./test

real 0m3.647s
user 0m0.080s
sys 0m11.836s

While with the patch I see:

$ time ./test

real 0m0.696s
user 0m0.040s
sys 0m1.152s

So I added a pthread_create benchtest (thread_create) which check
the thread creation latency.  As for the simple benchtests, I saw
improvements in thread creation on all architectures I tested the
change.

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
arm-linux-gnueabihf, powerpc64le-linux-gnu, sparc64-linux-gnu,
and sparcv9-linux-gnu.

[BZ #18988]
* benchtests/thread_create-inputs: New file.
* benchtests/thread_create-source.c: Likewise.
* support/xpthread_attr_setguardsize.c: Likewise.
* support/Makefile (libsupport-routines): Add
xpthread_attr_setguardsize object.
* support/xthread.h: Add xpthread_attr_setguardsize prototype.
* benchtests/Makefile (bench-pthread): Add thread_create.
* nptl/allocatestack.c (allocate_stack): Call mmap with PROT_NONE and
then mprotect the required area.

6 years agox86-64: Implement memmove family IFUNC selectors in C
H.J. Lu [Wed, 14 Jun 2017 19:10:57 +0000 (12:10 -0700)] 
x86-64: Implement memmove family IFUNC selectors in C

Implement memmove family IFUNC selectors in C.

All internal calls within libc.so can use IFUNC on x86-64 since unlike
x86, x86-64 supports PC-relative addressing to access the GOT entry so
that it can call via PLT without using an extra register.  For libc.a,
we can't use IFUNC for functions which are called before IFUNC has been
initialized.  Use IFUNC internally reduces the icache footprint since
libc.so and other codes in the process use the same implementations.
This patch uses IFUNC for memmove family functions within libc.

* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
memmove-sse2-unaligned-erms, memcpy_chk-nonshared,
mempcpy_chk-nonshared and memmove_chk-nonshared.
* sysdeps/x86_64/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Add tests for __memmove_chk_erms,
__memcpy_chk_erms and __mempcpy_chk_erms.  Update comments.
* sysdeps/x86_64/multiarch/ifunc-memmove.h: New file.
* sysdeps/x86_64/multiarch/memcpy.c: Likewise.
* sysdeps/x86_64/multiarch/memcpy_chk-nonshared.S: Likewise.
* sysdeps/x86_64/multiarch/memcpy_chk.c: Likewise.
* sysdeps/x86_64/multiarch/memmove-sse2-unaligned-erms.S: Likewise.
* sysdeps/x86_64/multiarch/memmove.c: Likewise.
* sysdeps/x86_64/multiarch/memmove_chk-nonshared.S: Likewise.
* sysdeps/x86_64/multiarch/memmove_chk.c: Likewise.
* sysdeps/x86_64/multiarch/mempcpy.c: Likewise.
* sysdeps/x86_64/multiarch/mempcpy_chk-nonshared.S: Likewise.
* sysdeps/x86_64/multiarch/mempcpy_chk.c: Likewise.
* sysdeps/x86_64/multiarch/memcpy.S: Removed.
* sysdeps/x86_64/multiarch/memcpy_chk.S: Likewise.
* sysdeps/x86_64/multiarch/memmove.S: Likewise.
* sysdeps/x86_64/multiarch/memmove_chk.S: Likewise.
* sysdeps/x86_64/multiarch/mempcpy.S: Likewise.
* sysdeps/x86_64/multiarch/mempcpy_chk.S: Likewise.
* sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S
(__mempcpy_chk_erms): New function.
(__memmove_chk_erms): Likewise.
(__memcpy_chk_erms): New alias.

6 years agoi686: Add missing IS_IN (libc) guards to vectorized strcspn
Florian Weimer [Wed, 14 Jun 2017 06:11:22 +0000 (08:11 +0200)] 
i686: Add missing IS_IN (libc) guards to vectorized strcspn

Since commit d957c4d3fa48d685ff2726c605c988127ef99395 (i386: Compile
rtld-*.os with -mno-sse -mno-mmx -mfpmath=387), vector intrinsics can
no longer be used in ld.so, even if the compiled code never makes it
into the final ld.so link.  This commit adds the missing IS_IN (libc)
guard to the SSE 4.2 strcspn implementation, so that it can be used from
ld.so in the future.

6 years agoRemove __need macros from errno.h (__need_Emath, __need_error_t).
Zack Weinberg [Tue, 21 Mar 2017 20:30:53 +0000 (16:30 -0400)] 
Remove __need macros from errno.h (__need_Emath, __need_error_t).

This is fairly complicated, not because the users of __need_Emath and
__need_error_t have complicated requirements, but because the core
changes had a lot of fallout.

__need_error_t exists for gnulib compatibility in argz.h and argp.h.
error_t itself is a Hurdism, an enum containing all the E-constants,
so you can do 'p (error_t) errno' in gdb and get a symbolic value.
argz.h and argp.h use it for function return values, and they want to
fall back to 'int' when that's not available.  There is no reason why
these nonstandard headers cannot just go ahead and include all of
errno.h; so we do that.

__need_Emath is defined only by .S files; what they _really_ need is
for errno.h to avoid declaring anything other than the E-constants
(e.g. 'extern int __errno_location(void);' is a syntax error in
assembly language). This is replaced with a check for __ASSEMBLER__ in
errno.h, plus a carefully documented requirement for bits/errno.h not
to define anything other than macros.  That in turn has the
consequence that bits/errno.h must not define errno - fortunately, all
live ports use the same definition of errno, so I've moved it to
errno.h.  The Hurd bits/errno.h must also take care not to define
error_t when __ASSEMBLER__ is defined, which involves repeating all of
the definitions twice, but it's a generated file so that's okay.

* stdlib/errno.h: Remove __need_Emath and __need_error_t logic.
Reorganize file.  Declare errno here.  When __ASSEMBLER__ is
defined, don't declare anything other than the E-constants.

* include/errno.h: Change conditional for exposing internal
declarations to (not _ISOMAC and not __ASSEMBLER__).
* bits/errno.h: Remove logic for __need_Emath.  Document
requirements for a port-specific bits/errno.h.

* sysdeps/unix/sysv/linux/bits/errno.h
* sysdeps/unix/sysv/linux/alpha/bits/errno.h
* sysdeps/unix/sysv/linux/hppa/bits/errno.h
* sysdeps/unix/sysv/linux/mips/bits/errno.h
* sysdeps/unix/sysv/linux/sparc/bits/errno.h:
Add multiple-include guard and check against improper inclusion.
Remove __need_Emath logic.  Don't declare errno here.  Ensure all
constants are defined as simple integer literals.  Consistent
formatting.
* sysdeps/mach/hurd/errnos.awk: Likewise.  Only define error_t and
enum __error_t_codes if __ASSEMBLER__ is not defined.
* sysdeps/mach/hurd/bits/errno.h: Regenerate.

* argp/argp.h, string/argz.h: Don't define __need_error_t before
including errno.h.
* sysdeps/i386/i686/fpu/multiarch/s_cosf-sse2.S
* sysdeps/i386/i686/fpu/multiarch/s_sincosf-sse2.S
* sysdeps/i386/i686/fpu/multiarch/s_sinf-sse2.S
* sysdeps/x86_64/fpu/s_cosf.S
* sysdeps/x86_64/fpu/s_sincosf.S
* sysdeps/x86_64/fpu/s_sinf.S:
Just include errno.h; don't define __need_Emath or include
bits/errno.h directly.

6 years agoRemove __need_IOV_MAX and __need_FOPEN_MAX.
Zack Weinberg [Wed, 22 Mar 2017 14:55:38 +0000 (10:55 -0400)] 
Remove __need_IOV_MAX and __need_FOPEN_MAX.

__need_FOPEN_MAX wasn't being used anywhere.  __need_IOV_MAX was more
complicated; the basic deal is that sys/uio.h wants to define a
constant named UIO_MAXIOV and bits/xopen_lim.h wants to define a
constant named IOV_MAX, with the same meaning.  For no apparent reason
this was being handled via bits/stdio_lim.h -- stdio.h is NOT supposed
to define IOV_MAX -- and some mess in Makerules.  Also, bits/uio.h on
Linux was being used as a dumping ground for extension functions.

So now we have bits/uio_lim.h, which defines __IOV_MAX.
bits/xopen_lim.h and sys/uio.h use that to define their respective
constants.  We also now have bits/uio-ext.h, which is the official
Proper Home for extensions to sys/uio.h.  bits/uio.h is removed, and
stdio_lim.h doesn't define IOV_MAX at all.

* bits/uio_lim.h, sysdeps/unix/sysv/linux/bits/uio_lim.h
* bits/uio-ext.h, sysdeps/unix/sysv/linux/bits/uio-ext.h: New file.
* bits/uio.h, sysdeps/unix/sysv/linux/bits/uio.h: Delete file.

* include/bits/xopen_lim.h: Use bits/uio_lim.h to get the value
for IOV_MAX.
* misc/Makefile: Install bits/uio-ext.h and bits/uio_lim.h.
Don't install bits/uio.h.
* misc/sys/uio.h: Don't include bits/uio.h.  Do include
bits/types/struct_iovec.h and bits/uio_lim.h.  Set UIO_MAXIOV
based on __IOV_MAX. Under __USE_GNU, also include bits/uio-ext.h.

* stdio-common/stdio_lim.h.in: Remove logic for __need_FOPEN_MAX
and __need_IOV_MAX.  Don't define IOV_MAX at all.
* Makerules (stdio_lim.h): Remove logic for setting IOV_MAX.

* sysdeps/unix/sysv/linux/bits/fcntl-linux.h:
Include bits/types/struct_iovec.h, not bits/uio.h.
Use __ssize_t, not ssize_t, in function prototypes.
Don't use hard TAB for double space after period in comments.

6 years agoPowerPC64 ELFv2 PPC64_OPT_LOCALENTRY
Alan Modra [Wed, 14 Jun 2017 01:17:25 +0000 (10:47 +0930)] 
PowerPC64 ELFv2 PPC64_OPT_LOCALENTRY

ELFv2 functions with localentry:0 are those with a single entry point,
ie. global entry == local entry, that have no requirement on r2 or
r12 and guarantee r2 is unchanged on return.  Such an external
function can be called via the PLT without saving r2 or restoring it
on return, avoiding a common load-hit-store for small functions.

This patch implements the ld.so changes necessary for this
optimization.  ld.so needs to check that an optimized plt call
sequence is in fact calling a function implemented with localentry:0,
end emit a fatal error otherwise.

The elf/testobj6.c change is to stop "error while loading shared
libraries: expected localentry:0 `preload'" when running
elf/preloadtest, which we'd get otherwise.

* elf/elf.h (PPC64_OPT_LOCALENTRY): Define.
* sysdeps/alpha/dl-machine.h (elf_machine_fixup_plt): Add
refsym and sym parameters.  Adjust callers.
* sysdeps/aarch64/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/arm/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/generic/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/hppa/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/i386/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/ia64/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/m68k/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/microblaze/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/mips/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/nios2/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_fixup_plt):
Likewise.
* sysdeps/s390/s390-32/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/s390/s390-64/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/sh/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/sparc/sparc32/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/sparc/sparc64/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/tile/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/x86_64/dl-machine.h (elf_machine_fixup_plt): Likewise.
* sysdeps/powerpc/powerpc64/dl-machine.c (_dl_error_localentry): New.
(_dl_reloc_overflow): Increase buffser size.  Formatting.
* sysdeps/powerpc/powerpc64/dl-machine.h (ppc64_local_entry_offset):
Delete reloc param, add refsym and sym.  Check optimized plt
call stubs for localentry:0 functions.  Adjust callers.
(elf_machine_fixup_plt, elf_machine_plt_conflict): Add refsym
and sym parameters.  Adjust callers.
(_dl_reloc_overflow): Move attribute.
(_dl_error_localentry): Declare.
* elf/dl-runtime.c (_dl_fixup): Save original sym.  Pass
refsym and sym to elf_machine_fixup_plt.
* elf/testobj6.c (preload): Call printf.

6 years agoPowerPC64 ENTRY_TOCLESS
Alan Modra [Wed, 14 Jun 2017 01:15:50 +0000 (10:45 +0930)] 
PowerPC64 ENTRY_TOCLESS

A number of functions in the sysdeps/powerpc/powerpc64/ tree don't use
or change r2, yet declare a global entry that sets up r2.  This patch
fixes that problem, and consolidates the ENTRY and EALIGN macros.

* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(NOPS, ENTRY_3): New macros.
(ENTRY): Rewrite.
(ENTRY_TOCLESS): Define.
(EALIGN, EALIGN_W_0, EALIGN_W_1, EALIGN_W_2, EALIGN_W_4, EALIGN_W_5,
EALIGN_W_6, EALIGN_W_7, EALIGN_W_8): Delete.
* sysdeps/powerpc/powerpc64/a2/memcpy.S: Replace EALIGN with ENTRY.
* sysdeps/powerpc/powerpc64/dl-trampoline.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_ceil.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_ceilf.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_floor.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_floorf.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_rint.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_rintf.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_round.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_roundf.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_trunc.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_truncf.S: Likewise.
* sysdeps/powerpc/powerpc64/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/fpu/s_finite.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/fpu/s_isinf.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/fpu/s_isnan.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strstr.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/e_expf.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_cosf.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_sinf.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strcasestr.S: Likewise.
* sysdeps/powerpc/powerpc64/addmul_1.S: Use ENTRY_TOCLESS.
* sysdeps/powerpc/powerpc64/cell/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_copysign.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_copysignl.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_fabsl.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_isnan.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_llrint.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_llrintf.S: Likewise.
* sysdeps/powerpc/powerpc64/lshift.S: Likewise.
* sysdeps/powerpc/powerpc64/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/mul_1.S: Likewise.
* sysdeps/powerpc/powerpc64/power4/memcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power4/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power4/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power4/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_ceil.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_ceilf.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_floor.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_floorf.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_llround.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_round.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_roundf.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_trunc.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_truncf.S: Likewise.
* sysdeps/powerpc/powerpc64/power5/fpu/s_isnan.S: Likewise.
* sysdeps/powerpc/powerpc64/power6/fpu/s_copysign.S: Likewise.
* sysdeps/powerpc/powerpc64/power6/fpu/s_isnan.S: Likewise.
* sysdeps/powerpc/powerpc64/power6/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power6/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power6x/fpu/s_isnan.S: Likewise.
* sysdeps/powerpc/powerpc64/power6x/fpu/s_llrint.S: Likewise.
* sysdeps/powerpc/powerpc64/power6x/fpu/s_llround.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/add_n.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memmove.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/mempcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memrchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/rawmemchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strcasecmp.S (strcasecmp_l):
Likewise.
* sysdeps/powerpc/powerpc64/power7/strchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strchrnul.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strlen.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strncpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strnlen.S: Likewise.
* sysdeps/powerpc/powerpc64/power7/strrchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_finite.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_isinf.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_isnan.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_llrint.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/fpu/s_llround.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/memcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/memset.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strcpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strlen.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strncpy.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strnlen.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strrchr.S: Likewise.
* sysdeps/powerpc/powerpc64/power8/strspn.S: Likewise.
* sysdeps/powerpc/powerpc64/power9/strcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/power9/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc64/strchr.S: Likewise.
* sysdeps/powerpc/powerpc64/strcmp.S: Likewise.
* sysdeps/powerpc/powerpc64/strlen.S: Likewise.
* sysdeps/powerpc/powerpc64/strncmp.S: Likewise.
* sysdeps/powerpc/powerpc64/ppc-mcount.S: Store LR earlier.  Don't
add nop when SHARED.
* sysdeps/powerpc/powerpc64/start.S: Fix comment.
* sysdeps/powerpc/powerpc64/multiarch/strrchr-power8.S (ENTRY): Don't
define.
(ENTRY_TOCLESS): Define.
* sysdeps/powerpc/powerpc32/sysdep.h (ENTRY_TOCLESS): Define.
* sysdeps/powerpc/fpu/s_fma.S: Use ENTRY_TOCLESS.
* sysdeps/powerpc/fpu/s_fmaf.S: Likewise.

6 years agoPowerPC64 strncpy, stpncpy and strstr fixes
Alan Modra [Wed, 14 Jun 2017 01:14:59 +0000 (10:44 +0930)] 
PowerPC64 strncpy, stpncpy and strstr fixes

Makes __stpncpy_power8 call __memset_power8 directly rather than via an
IFUNC.  Fixes a missing _mcount, and removes some redundant NOPS.  The
*_is_local defines are also used in a followup patch.

* sysdeps/powerpc/powerpc64/multiarch/strncpy-power7.S: Define
MEMSET_is_local.
* sysdeps/powerpc/powerpc64/multiarch/strncpy-power8.S: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/stpncpy-power7.S: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/stpncpy-power8.S: Likewise.
Define MEMSET.
* sysdeps/powerpc/powerpc64/multiarch/strstr-power7.S: Define
STRLEN_is_local, STRNLEN_is_local, and STRCHR_is_local.
* sysdeps/powerpc/powerpc64/power7/strstr.S: Likewise.  Don't add
nop after local calls.
* sysdeps/powerpc/powerpc64/power7/strncpy.S: Define MEMSET_is_local.
Don't add nop after local call.
* sysdeps/powerpc/powerpc64/power8/strncpy.S: Likewise.  Add missing
CALL_MCOUNT.

6 years agoPowerPC64 sysdep.h tidy
Alan Modra [Wed, 14 Jun 2017 01:14:03 +0000 (10:44 +0930)] 
PowerPC64 sysdep.h tidy

.align on some targets takes a byte alignment, on others like powerpc,
log2 of the byte alignment.  It's a good idea to avoid .align,
particularly since x86 and powerpc are different.  This patch fixes
the occurrences of .align in powerpc64/sysdep.h, renames DOT_LABEL
since the macro doesn't have anything to do with adding dots, removes
extraneous semicolons, and fixes some formatting.

* sysdeps/powerpc/powerpc64/sysdep.h: Formatting.
(FUNC_LABEL): Rename from DOT_LABEL.
(ENTRY_1): Use FUNC_LABEL and remove leading space from label.
Use .p2align rather than .align.
(TRACEBACK, TRACEBACK_MASK): Use .p2align rather than .align.
(ABORT_TRANSACTION): Likewise.
(ENTRY_1, ENTRY_2, END_2, LOCALENTRY): Remove unnecessary semicolons,
particularly at end.  Add semicolon at invocation as necessary.
(TRACEBACK, TRACEBACK_MASK, PSEUDO, PSEUDO_NOERRNO): Likewise.
(PSEUDO_ERRVAL, PPC64_LOAD_FUNCPTR, OPD_ENT): Likewise.
* sysdeps/powerpc/powerpc64/multiarch/strrchr-power8.S (ENTRY,
END): Adjust to suit.

6 years agoPowerPC64 FRAME_PARM_SAVE
Alan Modra [Wed, 14 Jun 2017 01:13:33 +0000 (10:43 +0930)] 
PowerPC64 FRAME_PARM_SAVE

I think FRAME_PARM[1-9]_SAVE confuse the code, particularly
FRAME_PARM9_SAVE.  There are only 8 parameter save slots!

* sysdeps/powerpc/powerpc64/sysdep.h: (FRAME_BACKCHAIN,
FRAME_CR_SAVE, FRAME_LR_SAVE): Move out of conditional.
(FRAME_PARM1_SAVE, FRAME_PARM2_SAVE, FRAME_PARM3_SAVE,
FRAME_PARM4_SAVE, FRAME_PARM5_SAVE, FRAME_PARM6_SAVE,
FRAME_PARM7_SAVE, FRAME_PARM8_SAVE, FRAME_PARM9_SAVE): Delete.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/makecontext.S: Replace
uses of FRAME_PARM[1-9]_SAVE with FRAME_PARM_SAVE plus offset.

6 years agoPowerPC64, fix calls to _mcount
Alan Modra [Wed, 14 Jun 2017 01:12:42 +0000 (10:42 +0930)] 
PowerPC64, fix calls to _mcount

The macros used in assembly were broken on powerpc64 ELFv1.

* sysdeps/powerpc/powerpc64/sysdep.h: (call_mcount_parm_offset): Delete.
(SAVE_ARG, REST_ARG, CFI_SAVE_ARG): Correct.

6 years agomips: Fix store/load gp registers to/from ucontext_t
Gordana Cmiljanovic [Tue, 13 Jun 2017 21:34:45 +0000 (21:34 +0000)] 
mips: Fix store/load gp registers to/from ucontext_t

General purpose registers in mcontext_t structure
are 8 bytes long for both MIPS32/MIPS64.

get/set/make/swap context implementations for MIPS O32
incorrectly assume that general purpose registers
in this structure are 4 bytes long.

This patch is fixing that.

Tested for MIPS O32 LE and BE.
Compared objdump of modified functions for mips n32 and mips n64.

[BZ #21548]
* sysdeps/unix/sysv/linux/mips/getcontext.S: Define MCONTEXT_SZGREG as
8 and use it when copying general purpose registers.
* sysdeps/unix/sysv/linux/mips/makecontext.S: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/Makefile: Include new test for
mips o32.
* sysdeps/unix/sysv/linux/mips/mips32/bug-getcontext-mips-gp.c: Added
new test for mips o32.
* sysdeps/unix/sysv/linux/mips/setcontext.S: Define MCONTEXT_SZGREG as
8 and use it when copying general purpose registers.
* sysdeps/unix/sysv/linux/mips/swapcontext.S: Likewise.

6 years agoconfigure: Suppress expected compiler error message
Florian Weimer [Tue, 13 Jun 2017 20:09:59 +0000 (22:09 +0200)] 
configure: Suppress expected compiler error message