platform/upstream/glibc.git
7 years agoRemove unneeded declarations from math_private.h
Gabriel F. T. Gomes [Mon, 27 Mar 2017 19:23:58 +0000 (16:23 -0300)]
Remove unneeded declarations from math_private.h

The declarations of many functions in math_private.h are not required
since __MATHDECL and __MATHDECLX, in math.h, already provide the
declarations for these functions.  This patch removes the declarations
from math_private.h. It also adds the inclusion of math.h to the files
which depended on the declaration of functions in math_private.h.

Tested for powerpc64le and s390x.

* sysdeps/generic/math_private.h: Remove declarations of
many functions that are already declared in math.h.
* sysdeps/ieee754/ldbl-128/e_logl.c: Include math.h to get the
declaration for __frexpl.
* sysdeps/ieee754/ldbl-128ibm/e_logl.c: Include math.h to get
the declarations for __scalbnl and fabsl.

7 years agoCheck for __mprotect failure in _dl_map_segments [BZ #20831]
Dmitry V. Levin [Wed, 16 Nov 2016 22:49:25 +0000 (22:49 +0000)]
Check for __mprotect failure in _dl_map_segments [BZ #20831]

* elf/dl-map-segments.h (_dl_map_segments): Check for failure
of __mprotect to change protection on the excess portion
to disallow all access.

7 years agoCheck if SSE is available with HAS_CPU_FEATURE
H.J. Lu [Fri, 7 Apr 2017 14:44:40 +0000 (07:44 -0700)]
Check if SSE is available with HAS_CPU_FEATURE

Similar to other CPU feature checks, check if SSE is available with
HAS_CPU_FEATURE.

* sysdeps/i386/fpu/fclrexcpt.c (__feclearexcept): Use
HAS_CPU_FEATURE to check for SSE.
* sysdeps/i386/fpu/fedisblxcpt.c (fedisableexcept): Likewise.
* sysdeps/i386/fpu/feenablxcpt.c (feenableexcept): Likewise.
* sysdeps/i386/fpu/fegetenv.c (__fegetenv): Likewise.
* sysdeps/i386/fpu/fegetmode.c (fegetmode): Likewise.
* sysdeps/i386/fpu/feholdexcpt.c (__feholdexcept): Likewise.
* sysdeps/i386/fpu/fesetenv.c (__fesetenv): Likewise.
* sysdeps/i386/fpu/fesetmode.c (fesetmode): Likewise.
* sysdeps/i386/fpu/fesetround.c (__fesetround): Likewise.
* sysdeps/i386/fpu/feupdateenv.c (__feupdateenv): Likewise.
* sysdeps/i386/fpu/fgetexcptflg.c (__fegetexceptflag): Likewise.
* sysdeps/i386/fpu/fsetexcptflg.c (__fesetexceptflag): Likewise.
* sysdeps/i386/fpu/ftestexcept.c (fetestexcept): Likewise.
* sysdeps/i386/setfpucw.c (__setfpucw): Likewise.
* sysdeps/x86/cpu-features.h (bit_cpu_SSE): New.
(index_cpu_SSE): Likewise.
(reg_SSE): Likewise.

7 years agogetopt: merge from gnulib: use angle-bracket includes consistently
Paul Eggert [Fri, 7 Apr 2017 11:54:57 +0000 (07:54 -0400)]
getopt: merge from gnulib: use angle-bracket includes consistently

* posix/getopt1.c: Include <config.h>, not "config.h".

7 years agogetopt: annotate files with relationship to gnulib.
Zack Weinberg [Wed, 5 Apr 2017 15:04:35 +0000 (11:04 -0400)]
getopt: annotate files with relationship to gnulib.

As the final act in this patchset, adjust the "This file is part of
the GNU C Library" message at the top of each file to indicate which
files are synced with gnulib.

* posix/bits/getopt_core.h, posix/bits/getopt_ext.h
* posix/getopt.c, posix/getopt1.c, posix/getopt_int.h:
Mention in top-of-file boilerplate that these files are shared
with gnulib.
* posix/getopt.h, posix/bits/getopt_posix.h:
Mention in top-of-file boilerplate that these files are NOT shared
with gnulib, unlike the rest of the getopt implementation.

7 years agogetopt: eliminate __need_getopt by splitting up getopt.h.
Zack Weinberg [Sat, 25 Mar 2017 15:24:24 +0000 (11:24 -0400)]
getopt: eliminate __need_getopt by splitting up getopt.h.

__need_getopt is misnamed; what it really means is "we want only the
getopt features specified in POSIX, not the GNU extensions".  Because
this code is shared with gnulib, it winds up being cleanest to split
getopt.h into *four* headers.  getopt_core.h and getopt_ext.h will
be shared with gnulib, getopt_posix.h will be just for glibc, and
each project will have its own copy of getopt.h.

* posix/bits/getopt_core.h, posix/bits/getopt_ext.h:
New files, intended to be shared with gnulib.
* posix/bits/getopt_posix.h:
New file, not intended to be shared with gnulib.
* posix/getopt.h: Now just includes features.h,
bits/getopt_core.h, and bits/getopt_ext.h.  Will
no longer be shared with gnulib.
* include/bits/getopt_core.h, include/bits/getopt_ext.h
* include/bits/getopt_posix.h: New wrappers.
* posix/Makefile: Install new headers.
* posix/unistd.h, libio/stdio.h:
Include bits/getopt_posix.h instead of getopt.h.

7 years agogetopt: merge _GL_UNUSED annotations from gnulib
Zack Weinberg [Mon, 3 Apr 2017 12:45:41 +0000 (08:45 -0400)]
getopt: merge _GL_UNUSED annotations from gnulib

gnulib now has annotations on at least some functions to cater to
compilation with -Wunused-parameter.  In order to follow suit cleanly,
I've added to libc-symbols.h some of the _GL_* macros that
gnulib-common.m4 puts into config.h.  (I don't think they belong in
sys/cdefs.h, at least not without further thought.)

At this point all gnulib-side changes to getopt.c have been merged.

* include/libc-symbols.h: For gnulib compatibility, define
_GL_UNUSED, _GL_UNUSED_LABEL, _GL_ATTRIBUTE_PURE, and
_GL_ATTRIBUTE_CONST.
* posix/getopt.c (_getopt_initialize): Mark argc and argv
parameters with _GL_UNUSED.

7 years agogetopt: merge from gnulib: alloca avoidance
Zack Weinberg [Sat, 1 Apr 2017 21:13:45 +0000 (17:13 -0400)]
getopt: merge from gnulib: alloca avoidance

In one place, glibc's getopt uses alloca to construct a linked list of
possibilities for an "ambiguous" long option.  In gnulib, malloc
should be used instead.  Providing for both cases complicates things a
fair bit.  Instead of merging straight across, therefore, I have
chosen to rewrite it using a boolean vector instead of a linked list.
There is then only one allocation that might need freeing; in glibc it
can honor __libc_use_alloca as usual, and in gnulib we define
__libc_use_alloca to always be false, so we don't need ifdefs in the
middle of the function.  This should also be slightly more efficient
in the normal case of long options being fully spelled out -- I think
most people aren't even aware they _can_ sometimes abbreviate long
options.

One interesting consequence is that the list of possibilities is now
printed in exactly the order they appear in the list of long options,
instead of the first possibility being shuffled to the end.  This
shouldn't be a big deal but it did break one test that relied on the
exact text of this error message.

(The reason the previous patch was "in aid of" merging from gnulib is
I didn't want to have to make this change in two places.)

(The patch looks bigger than it really is because there's a fair bit
of reindentation and code rearrangement.)

* posix/getopt.c: When used standalone, define __libc_use_alloca
as always false and alloca to abort if called.
(process_long_option): Rewrite handling of ambiguous long options
to use a single boolean vector, not a linked list; use
__libc_use_alloca to decide whether to allocate this using alloca.

* posix/tst-getopt_long1.c: Adjust text of expected error message.

7 years agogetopt: refactor long-option handling
Zack Weinberg [Sat, 1 Apr 2017 20:19:50 +0000 (16:19 -0400)]
getopt: refactor long-option handling

There were two copies of the bulk of the code to handle long options.
Now there is only one.  (Yes, this is in aid of merging from gnulib.)

The change to bug-getopt4.c clarifies the error messages when the test
fails.

* posix/getopt.c (process_long_option): New function split out
from _getopt_internal_r.
(_getopt_internal_r): Replace both copies of the long-option
processing code with calls to process_long_option.
* posix/bug-getopt4.c (one_test): Print argv[0] in error messages.
(do_test): Differentiate argv[0] in the two subtests.

7 years agogetopt: tidy up _getopt_initialize a bit
Zack Weinberg [Sat, 1 Apr 2017 16:42:41 +0000 (12:42 -0400)]
getopt: tidy up _getopt_initialize a bit

_getopt_data.__posixly_correct is completely redundant to
_getopt_data.__ordering, and some work that logically belongs in
_getopt_initialize was being done by _getopt_internal_r, making the
code harder to understand.

As a side effect, getenv will no longer be called if the first
character of the options string is '+' or '-', which is probably a
Good Thing.  (Perhaps we should have a flag character that
specifically asks for the permutation behavior?)

* posix/getopt_int.h (_getopt_data): Remove __posixly_correct field.
* posix/getopt.c (_getopt_internal_r): Move some initialization code...
(_getopt_initialize): ...here. Don't set d->__posixly_correct.

7 years agogetopt: merge from gnulib: function prototype adjustments
Zack Weinberg [Sat, 1 Apr 2017 16:11:33 +0000 (12:11 -0400)]
getopt: merge from gnulib: function prototype adjustments

For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array.  gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.

Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt.  The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.

At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.

* posix/getopt.h: Add backup definition of __nonnull for
consistency with gnulib.  Define __getopt_argv_const to const
if not already defined.
(getopt): Update doc comment from gnulib.  Prototype
unconditionally.  Add __nonnull annotation.
(__posix_getopt): Add __nonnull annotation.
(getopt_long, getopt_long_only): Use __getopt_argv_const in
prototypes for consistency with gnulib.  Add __nonnull
annotations.
* posix/getopt.c (_getopt_initialize, _getopt_internal_r)
(getopt_internal): Change 'argv' argument to type 'char **'.
Remove now-unnecessary casts.
(getopt, __posix_getopt): Eliminate repetition with a macro.
Cast 'argv' to 'char **' when calling _getopt_internal.
* posix/getopt1.c (getopt_long, getopt_long_only):
Use __getopt_argv_const for consistency with gnulib.
Cast 'argv' to 'char **' when calling _getopt_internal.
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.
(main): Constify 'long_options'.
* posix/getopt_int.h (getopt_internal, _getopt_internal_r)
(_getopt_long_r, _getopt_long_only_r):
Change 'argv' argument to type 'char **'.

7 years agogetopt: clean up error reporting
Zack Weinberg [Sat, 1 Apr 2017 14:17:44 +0000 (10:17 -0400)]
getopt: clean up error reporting

getopt can print a whole bunch of error messages, and when used
standalone (from gnulib) it uses fprintf to do that.  But fprintf is a
cancellation point and getopt isn't, and also applying fprintf to a
stream in wide-character mode is not allowed.

glibc has an internal function called __fxprintf that writes a narrow
format string to a stream regardless of mode, but it only handles
ASCII format strings, and it's still a cancellation point.  getopt's
messages are translated, so they might not be ASCII.  So getopt has an
error message to an asprintf buffer, monkeys with internal flag bits
on stderr to disable cancellation, and then calls
__fxprintf(stderr, "%s", buffer).  There isn't even a helper function,
the code is duplicated every time.

This patch fixes __fxprintf to handle arbitrary multibyte format
strings, and adds a variant __fxprintf_nocancel that does the same
thing but also isn't a cancellation point.  (It still _works_ by
monkeying with internal flag bits on the FILE, but that's not really a
layering violation for code in stdio-common.)  All of the #ifdef _LIBC
blocks can then be reduced to their standalone versions with a little
help from some macros at the top of the file.

I also wrote a test case to verify that getopt really isn't a
cancellation point, and I'm glad I did, because it found two bugs, one
of which wasn't even to do with cancellation (see previous patch).

* stdio-common/fxprintf.c (__fxprintf_nocancel): New function.
(locked_vfxprintf): New helper function. Handle arbitrary
multibyte strings, not just ASCII.
* include/stdio.h: Declare __fxprintf_nocancel.

* posix/getopt.c: When _LIBC is defined, define fprintf to
__fxprintf_nocancel, flockfile to _IO_flockfile, and
funlockfile to _IO_funlockfile.  When neither _LIBC nor
_POSIX_THREAD_SAFE_FUNCTIONS is defined, define flockfile and
funlockfile as no-ops.  (_getopt_internal_r): Remove all
internal #ifdef _LIBC blocks; the standalone error-printing
code can now be used for libc as well.  Add an
flockfile/funlockfile pair around one case where the error
message is printed in several chunks.  Don't use fputc.

* posix/tst-getopt-cancel.c: New test.
* posix/Makefile: Run it.

7 years agogetopt: fix fencepost error in ambiguous-W-option handling
Zack Weinberg [Sat, 1 Apr 2017 14:01:40 +0000 (10:01 -0400)]
getopt: fix fencepost error in ambiguous-W-option handling

getopt_long contains an undocumented (AFAICT) feature in which, if you
put "W;" in the short-options list, then '-W foo' and '-Wfoo' are
treated as equivalent to '--foo'.  This is implemented with a partial
second copy of the code for handling long options, and that code
increments optind one too many times when recovering from an ambiguous
abbreviated option, which can cause the main loop to walk past the end
of argv and crash.

I discovered this while writing a test case that tries to exercise all
of getopt's error reporting paths; I wouldn't be surprised to learn
that this feature is never used by real applications.

* posix/getopt.c (_getopt_internal_r): Don't increment
d->optind a second time when reporting ambiguous -W options.

7 years agogetopt: merge straightforward changes from gnulib
Zack Weinberg [Fri, 31 Mar 2017 11:58:07 +0000 (07:58 -0400)]
getopt: merge straightforward changes from gnulib

This covers changes with little or no consequences when the code is
used in glibc.

* posix/getopt_int.h: Include getopt.h.
Use impl-namespace names for all arguments to _getopt_internal and
_getopt_internal_r.
Declare __ordering enum outside the struct.
Harmonize comments with gnulib.
* posix/getopt1.c: Simplify #ifdeffage at top of file. Remove
ELIDE_CODE logic entirely.  Move inclusion of stdlib.h to
#ifdef TEST block and make unconditional.  Do not define NULL.
* posix/getopt.c: Partial merge from gnulib, covering the
initial includes and global declarations, commentary, and
a couple of semantically-neutral code changes.

7 years agogetopt: merge from gnulib: don't use `...' quotes
Zack Weinberg [Fri, 31 Mar 2017 11:39:55 +0000 (07:39 -0400)]
getopt: merge from gnulib: don't use `...' quotes

I'm not sure whether this is official GNU style now, but `...' quotes
haven't looked properly balanced in most people's terminal fonts since
2001ish? and gnulib has chosen to switch over to '...' quotes.
I'm merging this separately from the other changes in gnulib because
it's very mechanical.

* posix/getopt.c, posix/getopt.h, posix/getopt1.c, posix/getopt_int.h:
Use '...' instead of `...' for quotation marks inside
comments and strings.

7 years agogetopt: remove USE_NONOPTION_FLAGS
Zack Weinberg [Wed, 29 Mar 2017 20:58:58 +0000 (16:58 -0400)]
getopt: remove USE_NONOPTION_FLAGS

glibc's implementation of getopt includes code to parse an environment
variable named _XXX_GNU_nonoption_argv_flags_ (where XXX is the
current process's PID in decimal); but all of it has been #ifdefed out
since 2001, with no official way to turn it back on.

According to commentary in our config.h.in, bash version 2.0 set this
environment variable to indicate argv elements that were the result of
glob expansion and therefore should not be treated as options, but the
feature was "disabled later" because "it caused problems".  According
to bash's CHANGES file, "later" was release 2.01; it gives no more
detail about what the problems were.

Version 2.0 of bash was released on the last day of 1996, and version
2.01 in June of 1997.  Twenty years later, I think it is safe to
assume that this environment variable isn't coming back.

* config.h.in (USE_NONOPTION_FLAGS): Remove.
* csu/init-first.c: Remove all #ifdef USE_NONOPTION_FLAGS blocks.
* sysdeps/mach/hurd/i386/init-first.c: Likewise.
* posix/getopt_int.h: Likewise.
* posix/getopt.c: Likewise. Also remove SWAP_FLAGS and the
__libc_argc and __libc_argv externs, which were only used by
#ifdef USE_NONOPTION_FLAGS blocks.
* posix/getopt_init.c: Remove file.
* posix/Makefile (routines): Remove getopt_init.
* include/getopt.h: Don't declare __getopt_initialize_environment.
* manual/getopt.texi: Remove mention of USE_NONOPTION_FLAGS in
a comment.

7 years agoresolv: Remove IQUERY support
Florian Weimer [Fri, 7 Apr 2017 11:01:21 +0000 (13:01 +0200)]
resolv: Remove IQUERY support

7 years agosparc: Fix .udiv plt on libc
Adhemerval Zanella [Thu, 16 Mar 2017 12:15:57 +0000 (09:15 -0300)]
sparc: Fix .udiv plt on libc

With the removal of divdi3 object from sparcv9-linux-gnu build, its
definition came from libgcc and its functions internall calls .udiv.
Since glibc also exports these symbols for compatibility reasons, it
will end up creating PLT calls internally in libc.so.

To avoid it, this patch uses the linker option --wrap to replace all
the internal libc.so .udiv calls to the wrapper __wrap_.udiv. Along
with strong alias in the udiv implementations, it makes linker do
local calls.

Checked on sparcv9-linux-gnu.

* sysdeps/sparc/sparc32/Makefile (libc.so-gnulib): New rule.
* sysdeps/sparc/sparc32/sparcv8/udiv.S (.udiv): Make a strong_alias
to __wrap_.udiv.
* sysdeps/sparc/sparc32/sparcv9/udiv.S (.udiv): Likewise.
* sysdeps/sparc/sparc32/udiv.S (.udiv): Likewise.

7 years agoBuild divdi3 only for architecture that required it
Adhemerval Zanella [Wed, 15 Mar 2017 18:44:59 +0000 (15:44 -0300)]
Build divdi3 only for architecture that required it

As noted in [1], divdi3 object is only exported in a handful ABIs
(i386, m68k, powerpc32, s390-32, and ia64), however it is built
for all current architectures regardless.

This patch refact the make rules for this object to so only the
aforementioned architectures that actually require it builds it.

Also, to avoid internal PLT calls to the exported symbol from the
module, glibc uses an internal header (symbol-hacks.h) which is
unrequired (and in fact breaks the build for architectures that
intend to get symbol definitions from libgcc.a).  The patch also
changes it to create its own header (divdi3-symbol-hacks.h) and
adjust the architectures that require it accordingly.

I checked the build/check (with run-built-tests=no) on the
following architectures (which I think must cover all supported
ABI/builds) using GCC 6.3:

aarch64-linux-gnu
alpha-linux-gnu
arm-linux-gnueabihf
hppa-linux-gnu
ia64-linux-gnu
m68k-linux-gnu
microblaze-linux-gnu
mips64-n32-linux-gnu
mips-linux-gnu
mips64-linux-gnu
nios2-linux-gnu
powerpc-linux-gnu
powerpc-linux-gnu-power4
powerpc64-linux-gnu
powerpc64le-linux-gnu
s390x-linux-gnu
s390-linux-gnu
sh4-linux-gnu
sh4-linux-gnu-soft
sparc64-linux-gnu
sparcv9-linux-gnu
tilegx-linux-gnu
tilegx-linux-gnu-32
tilepro-linux-gnu
x86_64-linux-gnu
x86_64-linux-gnu-x32
i686-linux-gnu

I only saw one regression on sparcv9-linux-gnu (extra PLT call to
.udiv) which I address in next patch in the set.  It also correctly
build SH with GCC 7.0.1 (without any regression from c89721e25d).

[1] https://sourceware.org/ml/libc-alpha/2017-03/msg00243.html

* sysdeps/i386/symbol-hacks.h: New file.
* sysdeps/m68k/symbol-hacks.h: New file.
* sysdeps/powerpc/powerpc32/symbol-hacks.h: New file.
* sysdeps/s390/s390-32/symbol-hacks.h: New file.
* sysdeps/unix/sysv/linux/i386/Makefile
[$(subdir) = csu] (sysdep_routines): New rule: divdi3 object.
[$(subdir) = csu] (sysdep-only-routines): Likewise.
[$(subdir) = csu] (CFLAGS-divdi3.c): Likewise.
* sysdeps/unix/sysv/linux/m68k/Makefile
[$(subdir) = csu] (sysdep_routines): Likewise.
[$(subdir) = csu] (sysdep-only-routines): Likewise.
[$(subdir) = csu] (CFLAGS-divdi3.c): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
[$(subdir) = csu] (sysdep_routines): Likewise.
[$(subdir) = csu] (sysdep-only-routines): Likewise.
[$(subdir) = csu] (CFLAGS-divdi3.c): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/Makefile
[$(subdir) = csu] (sysdep_routines): Likewise.
[$(subdir) = csu] (sysdep-only-routines): Likewise.
[$(subdir) = csu] (CFLAGS-divdi3.c): Likewise.
* sysdeps/wordsize-32/Makefile: Remove file.
* sysdeps/wordsize-32/symbol-hacks.h: Definitions move to ...
* sysdeps/wordsize-32/divdi3-symbol-hacks.h: ... here.

7 years agoDefine TEST_FUNCTION_ARGV in elf/tst-dlopen-aout.c
H.J. Lu [Wed, 5 Apr 2017 21:09:38 +0000 (14:09 -0700)]
Define TEST_FUNCTION_ARGV in elf/tst-dlopen-aout.c

* elf/tst-dlopen-aout.c (TEST_FUNCTION): Removed.
(TEST_FUNCTION_ARGV): New.

7 years agoUpdate elf tests to use the support test driver.
Wainer dos Santos Moschetta [Wed, 5 Apr 2017 13:34:39 +0000 (10:34 -0300)]
Update elf tests to use the support test driver.

Replaced test-skeleton.c with support/test-driver.c and
adjusted the tests accordinly.

Checked on x86_64.

* elf/next.c: Import support/test-driver.c instead of
test-skeleton.c and delete TEST_FUNCTION macro definition.
* elf/nodelete.c: Likewise.
* elf/order2.c: Likewise.
* elf/tst-_dl_addr_inside_object.c: Likewise.
* elf/tst-addr1.c: Likewise.
* elf/tst-align.c: Likewise.
* elf/tst-align2.c: Likewise.
* elf/tst-audit11.c: Likewise.
* elf/tst-audit12.c: Likewise.
* elf/tst-audit2.c: Likewise.
* elf/tst-audit9.c: Likewise.
* elf/tst-auxv.c: Likewise and define
TEST_FUNCTION_ARGV macro.
* elf/tst-deep1.c: Likewise.
* elf/tst-dl-iter-static.c: Likewise.
* elf/tst-dlmodcount.c: Likewise.
* elf/tst-dlmopen1.c: Likewise.
* elf/tst-dlmopen2.c: Likewise.
* elf/tst-dlmopen3.c: Likewise.
* elf/tst-dlopen-aout.c: Likewise.
* elf/tst-dlopenrpath.c: Likewise.
* elf/tst-dlsym-error.c: Likewise.
* elf/tst-execstack-needed.c: Likewise.
* elf/tst-execstack-prog.c: Likewise.
* elf/tst-execstack.c: Likewise.
* elf/tst-global1.c: Likewise.
* elf/tst-gnu2-tls1.c: Likewise.
* elf/tst-latepthread.c: Likewise.
* elf/tst-leaks1.c: Likewise.
* elf/tst-linkall-static.c: Likewise.
(do_test): New function.
* elf/tst-nodelete-opened.c: Likewise.
* elf/tst-nodelete.cc: Likewise.
* elf/tst-nodelete2.c: Likewise.
* elf/tst-noload.c: Likewise.
* elf/tst-null-argv.c: Likewise and define
TEST_FUNCTION_ARGV marcro.
* elf/tst-order-main.c: Likewise.
* elf/tst-pathopt.c: Likewise.
* elf/tst-pie2.c: Likewise.
* elf/tst-piemod1.c: Likewise.
* elf/tst-prelink.c: Likewise.
* elf/tst-protected1a.c: Likewise.
* elf/tst-protected1b.c: Likewise.
* elf/tst-ptrguard1.c: Likewise, import getopt.h,
and define _GNU_SOURCE macro.
(cmdline_process_function): New function.
* elf/tst-relsort1.c: Likewise.
* elf/tst-stackguard1.c: Likewise, import getopt.h,
and define _GNU_SOURCE macro.
(cmdline_process_function): New function.
* elf/tst-thrlock.c: Likewise.
* elf/tst-tls-dlinfo.c: Likewise.
* elf/tst-tls-manydynamic.c: Likewise and import
support/xthread.h.
* elf/tst-tls1.c: Likewise.
* elf/tst-tls10.c: Likewise.
* elf/tst-tls11.c: Likewise.
* elf/tst-tls12.c: Likewise.
* elf/tst-tls13.c: Likewise.
* elf/tst-tls14.c: Likewise.
* elf/tst-tls15.c: Likewise.
* elf/tst-tls16.c: Likewise.
* elf/tst-tls17.c: Likewise.
* elf/tst-tls18.c: Likewise.
* elf/tst-tls19.c: Likewise.
* elf/tst-tls2.c: Likewise.
* elf/tst-tls3.c: Likewise.
* elf/tst-tls4.c: Likewise.
* elf/tst-tls5.c: Likewise.
* elf/tst-tls6.c: Likewise.
* elf/tst-tls7.c: Likewise.
* elf/tst-tls8.c: Likewise.
* elf/tst-tls9.c: Likewise.
* elf/tst-tlsalign-extern.c: Likewise.
* elf/tst-tlsalign.c: Likewise.
* elf/tst-unique1.c: Likewise.
* elf/tst-unique2.c: Likewise.
* elf/vismain.c: Likewise.

7 years agoAdd page tests to string/test-strnlen.
Wainer dos Santos Moschetta [Wed, 5 Apr 2017 13:28:21 +0000 (10:28 -0300)]
Add page tests to string/test-strnlen.

May be tricky for otimized implementations to handle strings around
page boundary once, for instance, it is performed unaligned loads or
when maxlen is used as a hint for vectorized loops. The test cases
should unveil regression bugs on these cases.

To some extend do_random_tests in string/test-strnlen tests strings
placed at page end but it does not cover all cases. So this change
adds tests which consists of placing strings of varying sizes ending
at the page boundary. It also combines with different values of maxlen.

Tested on ppc64le and x86_64.

* string/test-strnlen.c (do_page_tests): New function
to check length of strings ending at the page boundary.
(test_main): Added call to the do_page_tests function.

7 years agopowerpc64: Add POWER8 strnlen
Wainer dos Santos Moschetta [Wed, 5 Apr 2017 13:24:24 +0000 (10:24 -0300)]
powerpc64: Add POWER8 strnlen

Added strnlen POWER8 otimized for long strings. It delivers
same performance as POWER7 implementation for short strings.

This takes advantage of reasonably performing unaligned loads
and bit permutes to check the first 1-16 bytes until
quadword aligned, then checks in 64 bytes strides until unsafe,
then 16 bytes, truncating the count if need be.

Likewise, the POWER7 code is recycled for less than 32 bytes strings.

Tested on ppc64 and ppc64le.

* sysdeps/powerpc/powerpc64/multiarch/Makefile
(sysdep_routines): Add strnlen-power8.
* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
(strnlen): Add __strnlen_power8 to list of strnlen functions.
* sysdeps/powerpc/powerpc64/multiarch/strnlen-power8.S:
New file.
* sysdeps/powerpc/powerpc64/multiarch/strnlen.c
(__strnlen): Add __strnlen_power8 to ifunc list.
* sysdeps/powerpc/powerpc64/power8/strnlen.S: New file.

7 years agoUpdate wcsmbs tests to use the support test driver
Wainer dos Santos Moschetta [Tue, 4 Apr 2017 21:05:20 +0000 (18:05 -0300)]
Update wcsmbs tests to use the support test driver

Replaced test-skeleton.c with support/test-driver.c and
adjusted the tests accordinly.

Checked on x86_64-linux-gnu.

* wcsmbs/tst-btowc.c: Import support/test-driver.c and remove
the TEST_FUNCTION macro definition.
* wcsmbs/tst-mbrtowc2.c: Likewise.
* wcsmbs/tst-mbsrtowcs.c: Likewise.
* wcsmbs/tst-wchar-h.c: Likewise.
* wcsmbs/tst-wcpncpy.c: Likewise.
* wcsmbs/tst-wcrtomb.c: Likewise.
* wcsmbs/tst-wcsnlen.c: Likewise.
* wcsmbs/tst-wcstof.c: Likewise.

7 years agoRemove CALL_THREAD_FCT macro
Adhemerval Zanella [Tue, 4 Apr 2017 19:00:27 +0000 (16:00 -0300)]
Remove CALL_THREAD_FCT macro

This patch removes CALL_THREAD_FCT macro usage and its defition for
x86.  For 32 bits it usage is only for force 16 stack alignment,
however stack is already explicit aligned in clone syscall.  For
64 bits and x32 it just a function call and there is no need to
code it with inline assembly.

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

* nptl/pthread_create.c (START_THREAD_DEFN): Remove
CALL_THREAD_FCT macro usage.
* sysdeps/i386/nptl/tls.h (CALL_THREAD_FCT): Remove definition.
* sysdeps/x86_64/nptl/tls.h (CALL_THREAD_FCT): Likewise.
* sysdeps/x86_64/32/nptl/tls.h: Remove file.

7 years agoRemove __ASSUME_REQUEUE_PI
Adhemerval Zanella [Tue, 4 Apr 2017 20:23:33 +0000 (17:23 -0300)]
Remove __ASSUME_REQUEUE_PI

The new cond var implementation (ed19993b5b0d) removed all the
__ASSUME_{REQUEUE_PI,FUTEX_LOCK_PI} internal usage so there is no
need to keep defining it.  This patch removes all USE_REQUEUE_PI
and __ASSUME_REQUEUE_PI.  It is as follow up from BZ#18463.

Checked with a build for x86_64-linux-gnu, arm-linux-gnueabhf,
m68-linux-gnu, mips64-linux-gnu, and sparc64-linux-gnu.

* nptl/pthreadP.h (USE_REQUEUE_PI): Remove ununsed macro.
* sysdeps/unix/sysv/linux/arm/kernel-features.h
(__ASSUME_REQUEUE_PI): Likewise.
* sysdeps/unix/sysv/linux/kernel-features.h
(__ASSUME_REQUEUE_PI): Likewise.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
(__ASSUME_REQUEUE_PI): Likewise.
* sysdeps/unix/sysv/linux/mips/kernel-features.h
(__ASSUME_REQUEUE_PI): Likewise.
* sysdeps/unix/sysv/linux/sparc/kernel-features.h
(__ASSUME_REQUEUE_PI): Likewise.

7 years agoresolv: Add tst-resolv-canonname
Florian Weimer [Tue, 4 Apr 2017 15:31:52 +0000 (17:31 +0200)]
resolv: Add tst-resolv-canonname

7 years agonss_dns: Replace local declarations with declarations from a header file
Florian Weimer [Tue, 4 Apr 2017 12:36:02 +0000 (14:36 +0200)]
nss_dns: Replace local declarations with declarations from a header file

7 years agonss_dns: Remove superfluous dn_expand call from network handling
Florian Weimer [Tue, 4 Apr 2017 12:13:03 +0000 (14:13 +0200)]
nss_dns: Remove superfluous dn_expand call from network handling

7 years agoresolv: Add test coverage for ns_name_unpack, ns_name_ntop
Florian Weimer [Tue, 4 Apr 2017 12:09:56 +0000 (14:09 +0200)]
resolv: Add test coverage for ns_name_unpack, ns_name_ntop

7 years agoS390: Clobber also r14 in TLS_LD, TLS_GD macros on 31bit.
Stefan Liebler [Tue, 4 Apr 2017 11:16:28 +0000 (13:16 +0200)]
S390: Clobber also r14 in TLS_LD, TLS_GD macros on 31bit.

This patch also clobbers r14 in TLS_LD, TLS_GD macros on 31bit.
This ensures that r14 isn't used to save and restore r12 while
r14 is clobbered by the bas-instruction.

As note:
r12 can't be added to clobber list as gcc would fail with:
error: PIC register clobbered by â€˜12’ in â€˜asm’

For 64bit this fix was already done in 2004 in the
commit b80af23ac6973e69df6cd23d221fa44fffb21e17.

ChangeLog:

* sysdeps/s390/s390-32/tls-macros.h (TLS_LD, TLS_GD):
Clobber also r14.

7 years agoChangeLog: fix BZ style to be consistent and match majority of existing code
Mike Frysinger [Mon, 3 Apr 2017 19:18:07 +0000 (15:18 -0400)]
ChangeLog: fix BZ style to be consistent and match majority of existing code

7 years agoposix_spawn: use a larger min stack for -fstack-check [BZ #21253]
Mike Frysinger [Thu, 16 Mar 2017 06:59:31 +0000 (23:59 -0700)]
posix_spawn: use a larger min stack for -fstack-check [BZ #21253]

When glibc is built with -fstack-check, trying to use posix_spawn can
lead to segfaults due to gcc internally probing stack memory too far.
The new spawn API will allocate a minimum of 1 page, but the stack
checking logic might probe a couple of pages.  When it tries to walk
them, everything falls apart.

The gcc internal docs [1] state the default interval checking is one
page.  Which means we need two pages (the current one, and the next
probed).  No target currently defines it larger.

Further, it mentions that the default minimum stack size needed to
recover from an overflow is 4/8KiB for sjlj or 8/12KiB for others.
But some Linux targets (like mips and ppc) go up to 16KiB (and some
non-Linux targets go up to 24KiB).

Let's create each child with a minimum of 32KiB slack space to support
them all, and give us future breathing room.

No test is added as existing ones crash.  Even a simple call is
enough to trigger the problem:
char *argv[] = { "/bin/ls", NULL };
posix_spawn(NULL, "/bin/ls", NULL, NULL, argv, NULL);

[1] https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gccint/Stack-Checking.html

7 years agoCall the right helper function when setting mallopt M_ARENA_MAX (BZ #21338)
Wladimir J. van der Laan [Sat, 1 Apr 2017 07:09:09 +0000 (12:39 +0530)]
Call the right helper function when setting mallopt M_ARENA_MAX (BZ #21338)

Fixes a typo introduced in commit
be7991c0705e35b4d70a419d117addcd6c627319. This caused
mallopt(M_ARENA_MAX) as well as the environment variable
MALLOC_ARENA_MAX to not work as intended because it set the
wrong internal parameter.

  [BZ #21338]
* malloc/malloc.c: Call do_set_arena_max for M_ARENA_MAX
instead of incorrect do_set_arena_test

7 years agoFix condition for inclusion of math-finite.h for long double
Gabriel F. T. Gomes [Fri, 31 Mar 2017 12:31:10 +0000 (09:31 -0300)]
Fix condition for inclusion of math-finite.h for long double

The condition for declaration of long double functions in
math-finite.h was #ifdef __MATH_DECLARE_LDOUBLE before the
macroization of this file.  After the macroization, it was incorreclty
changed to #if __MATH_DECLARE_LDOUBLE, which broke the build for arm.

* math/math.h: Fix check for __MATH_DECLARE_LDOUBLE.
* math/bits/math-finite.h: Likewise.

7 years agofts: Fix symbol redirect for fts_set [BZ #21289]
Slava Barinov [Fri, 31 Mar 2017 06:49:25 +0000 (08:49 +0200)]
fts: Fix symbol redirect for fts_set [BZ #21289]

In a 32-bit environment with _FILE_OFFSET_BITS=64, the __REDIRECT macro
combined with __THROW generates an invalid C++ declaration.

7 years agoFix more test-errno issues
Adhemerval Zanella [Tue, 28 Mar 2017 19:44:19 +0000 (16:44 -0300)]
Fix more test-errno issues

This patch fixes some test-errno-linux unexpected returns for the
tested syscalls on some older kernels (I saw it on a Linux 3.8 on
armv7l).  Basically:

   - inotify_add_watch: Linux v3.8 (676a0675c) removed the test to
     check at least one valid bit in flags (to return EINVAL).  It
     was later added back in v3.9 (04df32fa1).

   - quotactl: returns ENOSYS for kernels not configured with
     CONFIG_QUOTA.

Checked on x86_64-linux-gnu and armv7l-linux-gnueabihf.

* sysdeps/unix/sysv/linux/test-errno-linux.c (do_test): Handle
non expected inotify_add_watch and quotactl return.

7 years agoChange return type in the declaration of __ieee754_rem_pio2l
Gabriel F. T. Gomes [Tue, 28 Mar 2017 17:48:57 +0000 (14:48 -0300)]
Change return type in the declaration of __ieee754_rem_pio2l

The implementation of __ieee754_rem_pio2l in ldbl-128, ldbl-128ibm,
and ldbl-96 return the type int32_t, whereas math_private.h declares
it as returning int.  This patch changes the declaration to match the
declaration in thoses directories, as well as it changes the stub
implementation in math/e_rem_pio2l.c, similarly.

* math/e_rem_pio2l.c (__ieee754_rem_pio2l): Change return type
to int32_t.
* sysdeps/generic/math_private.h: Declare __ieee754_rem_pio2l
as returning int32_t.

7 years agoMacroize inclusion of math-finite.h
Gabriel F. T. Gomes [Fri, 10 Mar 2017 12:47:18 +0000 (09:47 -0300)]
Macroize inclusion of math-finite.h

This patch macroizes the declarations in math/bits/math-finite.h
similarly to what math/bits/mathcalls.h does.  For each floating-point
type, the file is included once in math/math.h.  This will reduce the
amount of repetitive boilerplate required when adding float128
versions of these declarations.

Tested for powerpc64le and s390x.

* math/math.h: Include bits/math-finite.h once per
floating-point type.
* math/bits/math-finite.h: Macroize all declarations by
floating-point type.

7 years agoFix i686 memchr overflow calculation (BZ#21182)
Adhemerval Zanella [Tue, 14 Mar 2017 17:16:13 +0000 (14:16 -0300)]
Fix i686 memchr overflow calculation (BZ#21182)

This patch fixes the regression added by 23d2770 for final address
overflow calculation.  The subtraction of the considered size (16)
at line 120 is at wrong place, for sizes less than 16 subsequent
overflow check will not take in consideration an invalid size (since
the subtraction will be negative).  Also, the lea instruction also
does not raise the carry flag (CF) that is used in subsequent jbe
to check for overflow.

The fix is to follow x86_64 logic from 3daef2c where the overflow
is first check and a sub instruction is issued.  In case of resulting
negative size, CF will be set by the sub instruction and a NULL
result will be returned.  The patch also add similar tests reported
in bug report.

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

* string/test-memchr.c (do_test): Add BZ#21182 checks for address
near end of a page.
* sysdeps/i386/i686/multiarch/memchr-sse2.S (__memchr): Fix
overflow calculation.

7 years agoChange TEST_NAME to memcpy to fix IFUNC testing of multiple versions.
Steve Ellcey [Tue, 28 Mar 2017 16:07:03 +0000 (09:07 -0700)]
Change TEST_NAME to memcpy to fix IFUNC testing of multiple versions.

* benchtests/bench-memcpy-random.c (TEST_NAME): Change to memcpy.
(IMPL) Call with 1 instead of 0 as argument.

7 years agoConsolidate set* Linux implementation
Adhemerval Zanella [Fri, 20 Jan 2017 21:01:59 +0000 (19:01 -0200)]
Consolidate set* Linux implementation

This patch consolidates the Linux setegid, seteuid, setgid, setgroups,
setregid, setresgid, setresuid, setreuid, and setuid implementation on
default sysdeps/unix/sysv/linux/set*.c implementation.  It basically
removes all the architecture define implementations and add support for
__NR_set*32 syscall on Linux default implementation.

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

* sysdeps/unix/sysv/linux/arm/setegid.c: Remove file.
* sysdeps/unix/sysv/linux/arm/seteuid.c: Likewise.
* sysdeps/unix/sysv/linux/arm/setgid.c: Likewise.
* sysdeps/unix/sysv/linux/arm/setgroups.c: Likewise.
* sysdeps/unix/sysv/linux/arm/setregid.c: Likewise.
* sysdeps/unix/sysv/linux/arm/setresgid.c: Likewise.
* sysdeps/unix/sysv/linux/arm/setresuid.c: Likewise.
* sysdeps/unix/sysv/linux/arm/setreuid.c: Likewise.
* sysdeps/unix/sysv/linux/arm/setuid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setegid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/seteuid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setgid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setgroups.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setregid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setresgid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setresuid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setreuid.c: Likewise.
* sysdeps/unix/sysv/linux/i386/setuid.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/setegid.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/seteuid.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/setgid.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/setgroups.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/setregid.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/setresgid.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/setresuid.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/setreuid.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/setuid.c: Likewise.
* sysdeps/unix/sysv/linux/microblaze/setgroups.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/setegid.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/seteuid.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/setgid.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/setgroups.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/setregid.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/setresgid.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/setresuid.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/setreuid.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/setuid.c: Likewise.
* sysdeps/unix/sysv/linux/sh/setegid.c: Likewise.
* sysdeps/unix/sysv/linux/sh/seteuid.c: Likewise.
* sysdeps/unix/sysv/linux/sh/setgid.c: Likewise.
* sysdeps/unix/sysv/linux/sh/setgroups.c: Likewise.
* sysdeps/unix/sysv/linux/sh/setregid.c: Likewise.
* sysdeps/unix/sysv/linux/sh/setresgid.c: Likewise.
* sysdeps/unix/sysv/linux/sh/setresuid.c: Likewise.
* sysdeps/unix/sysv/linux/sh/setreuid.c: Likewise.
* sysdeps/unix/sysv/linux/sh/setuid.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/setgid.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/setgroups.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/setregid.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/setresgid.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/setresuid.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/setreuid.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/setuid.c: Likewise.
* sysdeps/unix/sysv/linux/setegid.c (setegid): Use
INLINE_SYSCALL_ERROR_RETURN_VALUE.
* sysdeps/unix/sysv/linux/seteuid.c (seteuid): Likewise.
* sysdeps/unix/sysv/linux/setgid.c (setgid): Use __NR_setgid32 if
defined.
* sysdeps/unix/sysv/linux/setgroups.c (setgroups): Use
__NR_setgroups32 if defined.
* sysdeps/unix/sysv/linux/setregid.c (__setregid): Use __NR_setregid32
if defined.
* sysdeps/unix/sysv/linux/setresgid.c (__setresgid): Use
__NR_setresgid32 is defined.
* sysdeps/unix/sysv/linux/setresuid.c (__setresuid): Use
__NR_setresuid32 if defined.
* sysdeps/unix/sysv/linux/setreuid.c (__setreuid): Use
__NR_setreuid32 if defined.
* sysdeps/unix/sysv/linux/setuid.c (__setuid): Use __NR_setuid32 if
defined.

7 years agolocaledata: hu_HU: fix multiple sorting bugs (bug 18934)
Egmont Koblinger [Thu, 23 Mar 2017 01:27:30 +0000 (21:27 -0400)]
localedata: hu_HU: fix multiple sorting bugs (bug 18934)

Fix the incorrect sorting order of a digraph and its geminated variant,
regression introduced by a faulty fix to bug 13547 in commit
b008d4c85619a753e441d7f473ba8af0db400bd6.

Fix two inconsistencies in sorting unusual capitalization of digraphs
(bug #18587).

Enable DIACRIT_FORWARD to work around bug #17750.

Sort foreign accents after the Hungarian ones.

Add extensive unittests containing all the examples from The Rules of
Hungarian Orthography and many more, including explanatory comments.

7 years agoDefine more termios.h macros unconditionally for alpha (bug 21277).
Joseph Myers [Mon, 27 Mar 2017 15:07:38 +0000 (15:07 +0000)]
Define more termios.h macros unconditionally for alpha (bug 21277).

termios.h should define IUCLC for UNIX98 and older XSI standards.  The
sysdeps/unix/sysv/linux/alpha version defines it only if __USE_MISC,
so causing some conform/ tests to fail.

Other versions define it unconditionally (I* being a reserved
namespace for this header); the API should be consistent between
architectures in the absence of a clear reason for it to differ (and
given that a symbol is part of the API on two architectures, I don't
see any reason for the feature test macros required ever to differ
between those architectures), so this patch makes the alpha version
define it unconditionally as well.  Two non-POSIX macros alongside it,
IMAXBEL and IUTF8, are also defined unconditionally on other
architectures, so this patch makes them consistent by defining them
unconditionally on alpha as well.

Tested (compilation only) with build-many-glibcs.py.

[BZ #21277]
* sysdeps/unix/sysv/linux/alpha/bits/termios.h (IUCLC): Define
unconditionally.
(IMAXBEL): Likewise.
(IUTF8): Likewise.

7 years ago[AArch64] Update libm-test-ulps
Szabolcs Nagy [Mon, 27 Mar 2017 11:01:34 +0000 (12:01 +0100)]
[AArch64] Update libm-test-ulps

* sysdeps/aarch64/libm-test-ulps: Update.

7 years agoActually add bench-memcpy-random
Siddhesh Poyarekar [Sun, 26 Mar 2017 13:31:50 +0000 (19:01 +0530)]
Actually add bench-memcpy-random

git-add and commit the benchmark that Wilco posted on the list.

7 years agoUpdate old tunables framework document/script.
Sunyeop Lee [Fri, 24 Mar 2017 05:38:28 +0000 (11:08 +0530)]
Update old tunables framework document/script.

Since commit 8b9e9c3c0bae497ad5e2d0ae2f333f62feddcc12, security_level replaces
is_secure. There were some old files need to be updated.

2017-03-23  Sunyeop Lee  <sunyeop97@gmail.com>

* README.tunables: Updated descriptions.
* elf/dl-tunables.list: Fixed typo: SXID_NONE -> NONE.
* scripts/gen-tunables.awk: Updated the code related to the commit.

7 years agoAdd a new randomized memcpy test for copies up to 256 bytes. The distribution
Wilco Dijkstra [Thu, 23 Mar 2017 19:00:02 +0000 (19:00 +0000)]
Add a new randomized memcpy test for copies up to 256 bytes.  The distribution
of the size and alignment is based on a trace of SPEC2006.  Instead of
repeating the same copy over and over again like the existing tests, it times
several thousand different copies to more accurately estimate the overhead of
branch prediction.

* benchtests/Makefile (string-benchset): Add memcpy-random.
* benchtests/bench-memcpy-random.c: New file.

7 years agoChange the order of function attributes in printf.h
Tulio Magno Quites Machado Filho [Thu, 23 Mar 2017 18:45:00 +0000 (15:45 -0300)]
Change the order of function attributes in printf.h

ISO C++ section 8.3.5 [dcl.fct] requires exception specifications
to appear before attribute specifiers in function declarations.

This patch fixes issues reported by stdio-common/check-installed-headers-cxx.

* stdio-common/printf.h (register_printf_modifier): Change the
order of __wur and __THROW.
(register_printf_type): Likewise.

7 years agoUpdate string tests to use the support test driver.
Wainer dos Santos Moschetta [Thu, 23 Mar 2017 14:32:17 +0000 (11:32 -0300)]
Update string tests to use the support test driver.

Replaced all imports of test-skeleton.c with support/test-driver.c.

In some cases it was needed to adjust do_test to return int
instead of static int since that is the method's signature expected by
test-driver.c.

Checked on x86_64.

* string/test-string.h (TEST_FUNCTION): Use test_main instead of
test_main ().
(CMDLINE_PROCESS): Use function instead of defined macro.
* debug/test-strcpy_chk.c: Import support/test-driver.c and also
<suppport/support.h> to use set_fortify_handler().
* string/bug-envz1.c: Import support/test-driver.c instead of
test-skeleton.c.
* string/bug-strcoll2.c: Likewise.
* string/bug-strtok1.c: Likewise.
* string/stratcliff.c: Likewise.
* string/test-ffs.c: Likewise.
* string/test-memccpy.c: Likewise.
* string/test-memchr.c: Likewise.
* string/test-memcmp.c: Likewise.
* string/test-memcpy.c: Likewise.
* string/test-memmem.c: Likewise.
* string/test-memmove.c: Likewise.
* string/test-memrchr.c: Likewise.
* string/test-memset.c: Likewise.
* string/test-rawmemchr.c: Likewise.
* string/test-strcasecmp.c: Likewise.
* string/test-strcasestr.c: Likewise.
* string/test-strcat.c: Likewise.
* string/test-strchr.c: Likewise.
* string/test-strcmp.c: Likewise.
* string/test-strcpy.c: Likewise.
* string/test-string.h: Likewise.
* string/test-strlen.c: Likewise.
* string/test-strncasecmp.c: Likewise.
* string/test-strncat.c: Likewise.
* string/test-strncmp.c: Likewise.
* string/test-strncpy.c: Likewise.
* string/test-strnlen.c: Likewise.
* string/test-strpbrk.c: Likewise.
* string/test-strrchr.c: Likewise.
* string/test-strspn.c: Likewise.
* string/test-strstr.c: Likewise.
* string/tst-bswap.c: Likewise.
* string/tst-cmp.c: Likewise.
* string/tst-endian.c: Likewise.
* string/tst-inlcall.c: Likewise.
* string/tst-strcoll-overflow.c: Likewise.
* string/tst-strfry.c: Likewise.
* string/tst-strlen.c: Likewise.
* string/tst-strtok.c: Likewise.
* string/tst-strtok_r.c: Likewise.
* string/tst-strxfrm.c: Likewise.
* string/tst-strxfrm2.c: Likewise.
* string/tst-svc.c: Likewise.
* string/tst-svc2.c: Likewise.

7 years agoAnother round of inclusion fixes for _ISOMAC testsuite.
Zack Weinberg [Wed, 22 Mar 2017 12:39:36 +0000 (08:39 -0400)]
Another round of inclusion fixes for _ISOMAC testsuite.

* stdio-common/bug25.c: Include stdlib.h.
* support/tst-support_format_dns_packet.c: Include stdio.h,
stdlib.h, and string.h.
* support/tst-support_record_failure.c: Include string.h.
* support/tst-support_record_failure-2.sh: Adjust line number
expectations and correct a typo in an error message.

7 years agox86-64: Improve branch predication in _dl_runtime_resolve_avx512_opt [BZ #21258]
H.J. Lu [Tue, 21 Mar 2017 17:59:31 +0000 (10:59 -0700)]
x86-64: Improve branch predication in _dl_runtime_resolve_avx512_opt [BZ #21258]

On Skylake server, _dl_runtime_resolve_avx512_opt is used to preserve
the first 8 vector registers.  The code layout is

  if only %xmm0 - %xmm7 registers are used
     preserve %xmm0 - %xmm7 registers
  if only %ymm0 - %ymm7 registers are used
     preserve %ymm0 - %ymm7 registers
  preserve %zmm0 - %zmm7 registers

Branch predication always executes the fallthrough code path to preserve
%zmm0 - %zmm7 registers speculatively, even though only %xmm0 - %xmm7
registers are used.  This leads to lower CPU frequency on Skylake
server.  This patch changes the fallthrough code path to preserve
%xmm0 - %xmm7 registers instead:

  if whole %zmm0 - %zmm7 registers are used
    preserve %zmm0 - %zmm7 registers
  if only %ymm0 - %ymm7 registers are used
     preserve %ymm0 - %ymm7 registers
  preserve %xmm0 - %xmm7 registers

Tested on Skylake server.

[BZ #21258]
* sysdeps/x86_64/dl-trampoline.S (_dl_runtime_resolve_opt):
Define only if _dl_runtime_resolve is defined to
_dl_runtime_resolve_sse_vex.
* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_opt):
Fallthrough to _dl_runtime_resolve_sse_vex.

7 years agoRegenerate INSTALL.
Joseph Myers [Tue, 21 Mar 2017 16:40:16 +0000 (16:40 +0000)]
Regenerate INSTALL.

7 years agoMerge branch 'master' of ssh://sourceware.org/git/glibc
Thorsten Kukuk [Tue, 21 Mar 2017 15:47:00 +0000 (16:47 +0100)]
Merge branch 'master' of ssh://sourceware.org/git/glibc

Conflicts:
ChangeLog

7 years agoFix failing test malloc/tst-interpose-nothread with GCC 7.
Stefan Liebler [Tue, 21 Mar 2017 15:41:56 +0000 (16:41 +0100)]
Fix failing test malloc/tst-interpose-nothread with GCC 7.

The test malloc/tst-interpose-nothread fails on s390x if built
with GCC 7 and glibc commit "Remove the str(n)dup inlines
from string/bits/string2.h. Although inlining"
(ae65d4f3c3995279ca458c460ebf8bab1885fa03) with output:
error: free: 0x3fffdffa010: invalid allocation index: 0 (not less than 0)

The destructor check_for_allocations in malloc/tst-interpose-aux.c is
called twice.  One time after the test-child-process has finished successfully
and once after the test-parent-process finishes.
During the latter invocation, allocation_index == 0.  GCC 7 is now inlining the
free function and calls unconditionally fail in get_header as
header->allocation_index (type == size_t) is always >= allocation_index (= 0).
Before the mentioned commit above, strdup was replaced by strlen, malloc and
memcpy.  The malloc call was also inlined and allocation_index was set to one.

This patch moves the already existing compiler barrier before the invocation
of free.

ChangeLog:

* malloc/tst-interpose-aux.c (check_for_allocations):
Move compiler barrier before free.

7 years agoDeprecate libnsl by default (only shared library will be
Thorsten Kukuk [Tue, 21 Mar 2017 14:14:27 +0000 (15:14 +0100)]
Deprecate libnsl by default (only shared library will be
build for backward compatibility, no linking possible) and disable building
of libnss_compat, libnss_nis and libnss_nisplus, except --enable-obsolete-nsl
option is given to configure.

        * config.h.in: Add LINK_OBSOLETE_NSL.
        * config.make.in: Add build-obsolete-nsl.
        * configure.ac: Add obsolete-nsl option.
        * include/libc-symbols.h: Define libnsl_hidden_nolink_def.
        * include/rpcsvc/yp.h: Add missing functions as libnsl_hidden_proto.
        * include/rpcsvc/nislib.h: Likewise.
        * include/rpcsvc/ypclnt.h: Likewise.
        * manual/install.texi: Document --enable-obsolete-nsl.
        * nis/Makefile: Build only libnsl by default (add build-obsolete-nsl).
        * nis/nis_add.c: Replace libnsl_hidden_def with
        libnsl_hidden_nolink_def.
        * nis/nis_addmember.c: Likewise.
        * nis/nis_call.c: Likewise.
        * nis/nis_clone_obj.c: Likewise.
        * nis/nis_defaults.c: Likeise.
        * nis/nis_domain_of_r.c: Likewise.
        * nis/nis_error.c: Likewise.
        * nis/nis_file.c: Likewise.
        * nis/nis_free.c: Likewise.
        * nis_local_names.c: Likewise.
        * nis/nis_lookup.c: Likewise.
        * nis/nis_modify.c: Likewise.
        * nis/nis_print.c: Likewise.
        * nis/nis_remove.c: Likewise.
        * nis/nis_table.c: Likewise.
        * nis/nis_util.c: Likewise.
        * nis/nis_xdr.c: Likewise.
        * nis/yp_xdr.c: Likewise.
        * nis/ypclnt.c: Likewise.
        * nis/ypupdate_xdr.c: Likewise.
        * nis/nis_checkpoint.c: Add libnsl_hidden_nolink_def to all functions.
        * nis/nis_clone_dir.c: Likewise.
        * nis/nis_clone_res.c: Likewise.
        * nis/nis_creategroup.c: Likewise.
        * nis/nis_destroygroup.c: Likewise.
        * nis/nis_domain_of.c: Likewise.
        * nis/nis_getservlist.c: Likewise.
        * nis/nis_ismember.c: Likewise.
        * nis/nis_mkdir.c: Likewise.
        * nis/nis_ping.c: Likewise.
        * nis/nis_print_group_entry.c: Likewise.
        * nis/nis_removemember.c: Likewise.
        * nis/nis_rmdir.c: Likewise.
        * nis/nis_server.c: Likewise.
        * nis/nis_subr.c: Likewise.
        * nis/nis_verifygroup.c: Likewise.

Signed-off-by: Thorsten Kukuk <kukuk@suse.com>
7 years agoconformtest: Add x32 XFAILs for mq_attr element types (bug 21279).
Joseph Myers [Mon, 20 Mar 2017 21:30:28 +0000 (21:30 +0000)]
conformtest: Add x32 XFAILs for mq_attr element types (bug 21279).

POSIX specifies long as the type of elements of struct mq_attr.  For
x32, they are __syscall_slong_t (i.e. long long).  This patch XFAILs
the corresponding tests for x32 in the conformtest expectations (the
bug should not be closed without an actual fix).

Tested with build-many-glibcs.py.

[BZ #21279]
* sysdeps/unix/sysv/linux/x86_64/x32/Makefile
[$(subdir) = conform] (conformtest-xfail-conds): Update comment.
* conform/data/mqueue.h-data (mq_attr.mq_flags): XFAIL for
x86_64-x32-linux.
(mq_attr.mq_maxmsg): Likewise.
(mq_attr.mq_msgsize): Likewise.
(mq_attr.mq_curmsgs): Likewise.

7 years agoconformtest: Add mips XFAIL for struct stat st_rdev type (bug 21278).
Joseph Myers [Mon, 20 Mar 2017 21:28:16 +0000 (21:28 +0000)]
conformtest: Add mips XFAIL for struct stat st_rdev type (bug 21278).

MIPS o32 struct stat has the wrong type of st_rdev.  This patch XFAILs
that test in the conformtest expectations for this case (the bug
should not be closed without an actual fix, however).

Tested with build-many-glibcs.py.

[BZ #21278]
* sysdeps/unix/sysv/linux/mips/mips32/Makefile
[$(subdir) = conform] (conformtest-xfail-conds): Update comment.
* conform/data/sys/stat.h-data (stat.st_rdev): XFAIL for
mips-o32-linux.

7 years agoFix alpha termios.h NL2, NL3 namespace (bug 21268).
Joseph Myers [Mon, 20 Mar 2017 17:32:19 +0000 (17:32 +0000)]
Fix alpha termios.h NL2, NL3 namespace (bug 21268).

sysdeps/unix/sysv/linux/alpha/bits/termios.h defines NL2 and NL3 for
__USE_MISC || __USE_XOPEN.  These should only be defined for
__USE_MISC as they are not part of any standard namespace.  This patch
conditions them accordingly, matching the powerpc version of the
header (the only other one in glibc that defines these macros).

Tested (compilation only) with build-many-glibcs.py.

[BZ #21268]
* sysdeps/unix/sysv/linux/alpha/bits/termios.h (NL2): Define only
if [__USE_MISC]
(NL3): Likewise.

7 years agoposix_spawn: fix stack setup on ia64 [BZ #21275]
Mike Frysinger [Mon, 20 Mar 2017 08:47:56 +0000 (04:47 -0400)]
posix_spawn: fix stack setup on ia64 [BZ #21275]

The ia64-specific clone2 call expects the base of the stack mapping and
the stack size as sep arguments, not an initial stack value as on other
stack-grows-down architectures.  Reuse the stack-grows-up macro so we
pass in the right stack base.

Reported-by: Matt Turner <mattst88@gentoo.org>
7 years agolinux ttyname and ttyname_r: do not return wrong results
Christian Brauner [Fri, 27 Jan 2017 14:59:59 +0000 (15:59 +0100)]
linux ttyname and ttyname_r: do not return wrong results

If a link (say /proc/self/fd/0) pointing to a device, say /dev/pts/2, in a
parent mount namespace is passed to ttyname, and a /dev/pts/2 exists (in a
different devpts) in the current namespace, then it returns /dev/pts/2.
But /dev/pts/2 is NOT the current tty, it is a different file and device.

Detect this case and return ENODEV.  Userspace can choose to take this as a hint
that the fd points to a tty device but to act on the fd rather than the link.

Signed-off-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
7 years agoconformtest: XFAIL tv_nsec tests for x32 (bug 16437).
Joseph Myers [Sat, 18 Mar 2017 00:24:13 +0000 (00:24 +0000)]
conformtest: XFAIL tv_nsec tests for x32 (bug 16437).

This patch XFAILs the conformtest tv_nsec tests for x32 so that the
incorrect type does not potentially hide other failures.  As this is
not a fix for the bug, it should remain open in Bugzilla.

Tested (compilation only) with build-many-glibcs.py.

[BZ #16437]
* sysdeps/unix/sysv/linux/x86_64/x32/Makefile
[$(subdir) = conform] (conformtest-xfail-conds): New variable.
* conform/data/signal.h-data (timespec.tv_nsec): XFAIL for
x86_64-x32-linux.
* conform/data/sys/select.h-data (timespec.tv_nsec): Likewise.
* conform/data/sys/stat.h-data (timespec.tv_nsec): Likewise.
* conform/data/time.h-data (timespec.tv_nsec): Likewise.

7 years agoFix sparc64 bits/setjmp.h namespace (bug 21261).
Joseph Myers [Sat, 18 Mar 2017 00:17:25 +0000 (00:17 +0000)]
Fix sparc64 bits/setjmp.h namespace (bug 21261).

sysdeps/unix/sysv/linux/sparc/bits/setjmp.h defines 64-bit __jmp_buf
with a load of identifiers that are not part of any standard
namespace, resulting in conform/ tests failing.  This patch fixes this
by moving those identifiers to the implementation namespace, so
enabling the conform/ tests to pass for sparc64.

Tested (compilation only) for sparc64 with build-many-glibcs.py.

[BZ #21261]
* sysdeps/unix/sysv/linux/sparc/bits/setjmp.h
[__WORDSIZE == 64 && !_ASM] (__sparc64_jmp_buf): Use reserved
names for all fields.
* sysdeps/sparc/sparc64/jmpbuf-unwind.h (_JMPBUF_UNWINDS): Update
for jmp_buf field renaming.
(_JMPBUF_UNWINDS_ADJ): Likewise.

7 years agoconformtest: Handle conditional XFAILs with allow-header.
Joseph Myers [Sat, 18 Mar 2017 00:16:05 +0000 (00:16 +0000)]
conformtest: Handle conditional XFAILs with allow-header.

This patch fixes the conformtest handling of headers listed in
allow-header to process xfail[cond]- in the expectations for those
headers.

Tested with build-many-glibcs.py.

* conform/conformtest.pl: Handle xfail[cond]- in header mentioned
with allow-header.

7 years agoFurther harden glibc malloc metadata against 1-byte overflows.
DJ Delorie [Fri, 17 Mar 2017 19:31:38 +0000 (15:31 -0400)]
Further harden glibc malloc metadata against 1-byte overflows.

Additional check for chunk_size == next->prev->chunk_size in unlink()

2017-03-17  Chris Evans  <scarybeasts@gmail.com>

* malloc/malloc.c (unlink): Add consistency check between size and
next->prev->size, to further harden against 1-byte overflows.

7 years agoUse CPU_FEATURES_CPU_P to check if AVX is available
H.J. Lu [Fri, 17 Mar 2017 18:38:13 +0000 (11:38 -0700)]
Use CPU_FEATURES_CPU_P to check if AVX is available

Don't use bit_cpu_AVX directly.

* sysdeps/x86/cpu-features.c (init_cpu_features): Check AVX with
CPU_FEATURES_CPU_P.

7 years agoMake alpha termios.h define IXANY unconditionally (bug 21259).
Joseph Myers [Fri, 17 Mar 2017 16:27:03 +0000 (16:27 +0000)]
Make alpha termios.h define IXANY unconditionally (bug 21259).

sysdeps/unix/sysv/linux/alpha/bits/termios.h defines IXANY only if
__USE_MISC.  But it's in the base standard for POSIX.1:2008, and
XSI-shaded in previous standards.  This patch makes the header define
it unconditionally, like other versions of this header do (it's always
reserved by standards that don't require it, so defining
unconditionally is OK by the standards).

Tested (compilation only) for alpha with build-many-glibcs.py.  Note
that there are still termios.h conformtest failures after this patch
because of other issues with the alpha version of this header.

[BZ #21259]
* sysdeps/unix/sysv/linux/alpha/bits/termios.h (IXANY): Define
unconditionally, not just for [__USE_MISC].

7 years agoconformtest: Add mips XFAIL for struct stat st_dev type (bug 17786).
Joseph Myers [Fri, 17 Mar 2017 02:54:59 +0000 (02:54 +0000)]
conformtest: Add mips XFAIL for struct stat st_dev type (bug 17786).

As noted in bug 17786, MIPS o32 struct stat has the wrong type of
st_dev.  This patch XFAILs that test in the conformtest expectations
for this case (the test still fails after the patch because there's
also a similar issue for st_rdev that needs reporting and XFAILing
separately, and the bug should not be closed without an actual fix,
not just XFAILing).

Tested for mips with build-many-glibcs.py.

[BZ #17786]
* sysdeps/unix/sysv/linux/mips/mips32/Makefile: New file.
* conform/data/sys/stat.h-data (stat.st_dev): XFAIL for
mips-o32-linux.

7 years agoAdd missing piece to last ChangeLog entry.
Joseph Myers [Fri, 17 Mar 2017 02:50:51 +0000 (02:50 +0000)]
Add missing piece to last ChangeLog entry.

7 years agoconformtest: Add alpha XFAIL for struct netent n_net type (bug 21260).
Joseph Myers [Fri, 17 Mar 2017 02:42:16 +0000 (02:42 +0000)]
conformtest: Add alpha XFAIL for struct netent n_net type (bug 21260).

As noted in bug 21260, sysdeps/unix/sysv/linux/alpha/bits/netdb.h
defines struct netent with n_net of type unsigned long instead of the
correct uint32_t.  This patch XFAILs that test in the conformtest
expectations for alpha.  (This is not a fix for the bug, and it should
not be closed without an actual fix.)

Tested for alpha with build-many-glibcs.py.

[BZ #21260]
* sysdeps/unix/sysv/linux/alpha/Makefile
[$(subdir) = conform] (conformtest-xfail-conds): New variable.

7 years agoconformtest: Skip execution tests when cross-compiling.
Joseph Myers [Fri, 17 Mar 2017 01:21:10 +0000 (01:21 +0000)]
conformtest: Skip execution tests when cross-compiling.

This patch makes conformtest skip execution tests when
cross-compiling, as an interim step towards running most of these
tests (presently disabled) in that case.  It omits the (obvious)
Makefile change to actually enable the conformtest tests when
cross-compiling, as there are still enough failures seen with
build-many-glibcs.py that I'd like to get the results cleaner before
enabling these tests.

Tested for x86_64, and with the tests actually enabled for
cross-compilation with build-many-glibcs.py.

* conform/conformtest.pl ($cross): New variable.
(--cross): New command-line option.
(runtest): Skip test execution when cross-compiling.
* conform/Makefile (conformtest-cross): New variable.
($(conformtest-header-tests)): Pass $(conformtest-cross) to
conformtest.pl.

7 years agoconformtest: Support system-specific XFAILs.
Joseph Myers [Fri, 17 Mar 2017 01:08:27 +0000 (01:08 +0000)]
conformtest: Support system-specific XFAILs.

conformtest has an internal XFAIL mechanism to allow failures of
individual expectations to be ignored, so that known hard-to-fix
failures (e.g. those affecting ABIs or requiring kernel changes) do
not cause the overall tests to FAIL and so hide other failures from
the same (header, standard) pair.

Various such bugs are system-specific, so this patch adds a mechanism
to allow system-specific XFAILs.  A system-independent XFAIL is
achieved by putting "xfail-" at the start of the relevant expectation
in the *-data files.  A system-specific XFAIL instead uses
"xfail[cond]-", where "cond" is a condition listed in
conformtest-xfail-conds in a sysdeps makefile (so one for x32 might
set conformtest-xfail-conds = x86_64-x32-linux, for example, and then
an expectation for tv_nsec's type could use
xfail[x86_64-x32-linux]-).  The actual names are arbitrary, just
needing to match between the makefiles and the expectations, and if
necessary you can use "xfail[cond1|cond2]-" for a test that is
expected to fail under multiple conditions.  As with
system-independent XFAILs, I think system-specific ones should have a
bug filed in Bugzilla and a comment referencing that bug.

Tested for x86_64, including with test expectations and makefiles
changed to use the new facility.

* conform/conformtest.pl ($xfail_str): New variable.
(--xfail=): New command-line option.
(top level): Handle expectations starting xfail[cond]-.
* conform/Makefile (conformtest-xfail): New variable.
($(conformtest-header-tests)): Pass $(conformtest-xfail) to
conformtest.pl.

7 years agoconformtest: Make more tests into compilation tests.
Joseph Myers [Thu, 16 Mar 2017 17:51:23 +0000 (17:51 +0000)]
conformtest: Make more tests into compilation tests.

The conformtest header tests test some things through compilation
tests and others through execution tests.  This patch makes more of
the tests into compilation tests, using _Static_assert (note: for
float.h tests on floating-point values this is depending on a GNU
extension, that those assertions are allowed in the absence of
-pedantic although they aren't strictly integer constant expressions).
The remaining execution tests are for values of things listed as
"symbol" (in fact no such things have a value expectation listed) and
for values of macros defined as string constants (three such values
listed in total).

This is intended as preparation for enabling the vast bulk of the
tests to run for cross compilation.  (Even the few remaining execution
tests ought in principle to run for cross compilation when a test
wrapper is defined, but that's more complicated.  The existing
execution tests for native builds in fact are linked and run with an
existing installed libc that's required to exist to link against,
rather than with the newly built libc; only the new headers are used.)

Tested for x86_64.

* conform/conformtest.pl: Use compilation instead of execution
tests for testing values of constants and usability in #if.

7 years agoXFAIL catan and catanh tests on ibm128
Tulio Magno Quites Machado Filho [Thu, 16 Mar 2017 13:18:46 +0000 (10:18 -0300)]
XFAIL catan and catanh tests on ibm128

Mark 4 catan and catanh tests as xfail-rounding:ibm128-libgcc.
After this patch all catan and catanh tests pass on ibm128.

Regenerated auto-libm-test-out using gmp 6.1.2, mpfr 3.1.5 and upstream
mpc (9ef8030e50),

Tested on powerpc, powerpc64 and powerpc64le.

* math/auto-libm-test-in: Mark some catan and catanh as
xfail-rounding:ibm128-libgcc.
* math/auto-libm-test-out-catan: Regenerate.
* math/auto-libm-test-out-catanh: Likewise.

7 years agoRemove C++ namespace handling from glibc headers.
Joseph Myers [Thu, 16 Mar 2017 13:31:57 +0000 (13:31 +0000)]
Remove C++ namespace handling from glibc headers.

glibc headers include some code (not particularly consistent or
systematic) to put various declarations in C++ namespaces std and
__c99, if _GLIBCPP_USE_NAMESPACES is defined.

As noted in <https://gcc.gnu.org/ml/libstdc++/2017-03/msg00025.html>,
this macro was removed from libstdc++ in 2000.  I don't expect
compilation with such old versions of libstdc++ to work with current
glibc headers anyway (whereas old *binaries* are expected to stay
working with current glibc); this patch (which should be a no-op with
any libstdc++ version postdating that removal) removes all this code
from the glibc headers.

The begin-end-check.pl test, whose comments say it is about checking
these namespace macro calls, is also removed.  The code in that test
would have covered __BEGIN_DECLS / __END_DECLS as well, but if those
weren't properly matched it would show up with the
check-installed-headers-cxx tests, so I don't think there is an actual
use for keeping begin-end-check.pl with the namespace code removed.

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).

* misc/sys/cdefs.h (__BEGIN_NAMESPACE_STD): Remove macro.
(__END_NAMESPACE_STD): Likewise.
(__USING_NAMESPACE_STD): Likewise.
(__BEGIN_NAMESPACE_C99): Likewise.
(__END_NAMESPACE_C99): Likewise.
(__USING_NAMESPACE_C99): Likewise.
* math/math.h (_Mdouble_BEGIN_NAMESPACE): Do not define and
undefine macro.
(_Mdouble_END_NAMESPACE): Likewise.
* ctype/ctype.h: Do not handle C++ namespaces.
* libio/bits/stdio-ldbl.h: Likewise.
* libio/stdio.h: Likewise.
* locale/locale.h: Likewise.
* math/bits/mathcalls.h: Likewise.
* setjmp/setjmp.h: Likewise.
* signal/signal.h: Likewise.
* stdlib/bits/stdlib-float.h: Likewise.
* stdlib/bits/stdlib-ldbl.h: Likewise.
* stdlib/stdlib.h: Likewise.
* string/string.h: Likewise.
* sysdeps/x86/fpu/bits/mathinline.h: Likewise.
* time/bits/types/clock_t.h: Likewise.
* time/bits/types/struct_tm.h: Likewise.
* time/bits/types/time_t.h: Likewise.
* time/time.h: Likewise.
* wcsmbs/bits/wchar-ldbl.h: Likewise.
* wcsmbs/uchar.h: Likewise.
* wcsmbs/wchar.h: Likewise.
[_GLIBCPP_USE_NAMESPACES] (wint_t): Remove conditional definition.
* wctype/wctype.h: Do not handle C++ namespaces.
* scripts/begin-end-check.pl: Remove.
* Makefile (installed-headers): Likewise.
(tests-special): Do not add $(objpfx)begin-end-check.out.
($(objpfx)begin-end-check.out): Remove.

7 years agoAdd ChangeLog entry for aarch64 ifunc support patch.
Steve Ellcey [Wed, 15 Mar 2017 23:48:25 +0000 (16:48 -0700)]
Add ChangeLog entry for aarch64 ifunc support patch.

Forgot to add ChangeLog entry.

7 years agoAdd ifunc support for aarch64.
Steve Ellcey [Wed, 15 Mar 2017 23:46:26 +0000 (16:46 -0700)]
Add ifunc support for aarch64.

* sysdeps/aarch64/dl-machine.h: Include cpu-features.c.
(DL_PLATFORM_INIT): New define.
(dl_platform_init): New function.
* sysdeps/aarch64/ldsodefs.h: Include cpu-features.h.
* sysdeps/unix/sysv/linux/aarch64/cpu-features.c: New file.
* sysdeps/unix/sysv/linux/aarch64/cpu-features.h: Likewise.
* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.c: Likewise.
* sysdeps/unix/sysv/linux/aarch64/libc-start.c: Likewise.

7 years agox86_64: fix static build of __mempcpy_chk for compilers defaulting to PIC/PIE
Mike Frysinger [Sun, 12 Mar 2017 22:12:21 +0000 (15:12 -0700)]
x86_64: fix static build of __mempcpy_chk for compilers defaulting to PIC/PIE

When glibc is compiled with gcc 6.2 that has been configured with
to default to PIC/PIE, the static version of __mempcpy_chk is not built,
as the test is done on PIC instead of SHARED.  Fix the test to check for
SHARED, like it is done for similar functions like __memcpy_chk.

2017-03-12  Mike Frysinger  <vapier@gentoo.org>

* sysdeps/x86_64/mempcpy_chk.S (__mempcpy_chk): Check for SHARED
instead of PIC.

7 years agoImprove float range reduction accuracy near pi/2 (bug 21094).
Joseph Myers [Wed, 15 Mar 2017 22:00:54 +0000 (22:00 +0000)]
Improve float range reduction accuracy near pi/2 (bug 21094).

Bug 21094 reports 3ulp errors of cosf and tanf for certain arguments
near pi/2 arising from the use of an insufficiently accurate range
reduction.  (To be clear, this is a quality-of-implementation issue
relating to the apparent intent of those particular cosf and tanf
implementations; 3ulp is within the general glibc accuracy goals, so
not inherently a bug.)

This patch fixes that error by making a wider range of cases use the
existing more accurate range reduction for arguments close to pi/2.
The wider range of values is still narrow enough for the "z -=
pio2_2;" in the more accurate case to be exact, as the code expects.

Tested for x86_64, x86 and mips64; no ulps updates needed (but at
least on mips64, the larger ulps were seen if the tests were added
without the substantive fix).

[BZ #21094]
* sysdeps/ieee754/flt-32/e_rem_pio2f.c (__ieee754_rem_pio2f): Use
24+24+24-bit pi for wider range of values around pi/2.
* math/auto-libm-test-in: Add more tests of cos and tan.
* math/auto-libm-test-out-cos: Regenerated.
* math/auto-libm-test-out-tan: Likewise.

7 years agohppa: Fix setting of __libc_stack_end
John David Anglin [Tue, 21 Feb 2017 01:31:57 +0000 (20:31 -0500)]
hppa: Fix setting of __libc_stack_end

The binutils package was recently changed to fix -z relro support on hppa.
See ld/21000 for details:
https://sourceware.org/bugzilla/show_bug.cgi?id=21000

This exposed a problem with the _dl_start_user function in the RTLD_START
define.  We need to set __libc_stack_end before it is made read only.  For
this, we need to define DL_STACK_END.  The offset of 0x160 gives the same
stack end as the code in _dl_start_user.

A build log with the attached patch is here:
https://buildd.debian.org/status/fetch.php?pkg=glibc&arch=hppa&ver=2.24-9&stamp=1487639205&raw=0

7 years agoFix build with --enable-static-nss [BZ #21088]
Alexey Neyman [Wed, 25 Jan 2017 20:54:57 +0000 (12:54 -0800)]
Fix build with --enable-static-nss [BZ #21088]

Signed-off-by: Alexey Neyman <stilor@att.net>
7 years agoFix combreloc test with BSD grep
Alexey Neyman [Sun, 12 Mar 2017 20:16:18 +0000 (13:16 -0700)]
Fix combreloc test with BSD grep

The test for "-z combreloc" fails when cross-compiling on a machine
that uses BSD grep (e.g. on macos). grep complains about empty
subexpression and exits with non-zero status, which is interpreted
by configure as "not found". As a result, support for "-z combreloc"
(HAVE_Z_COMBRELOC) is not detected, leading to link failure on SPARC.

While there, replace fgrep with 'grep -F', as fgrep is non-POSIX.

* configure.ac: Avoid empty subexpression in grep.

Signed-off-by: Alexey Neyman <stilor@att.net>
7 years agoFix test-errno issues
Adhemerval Zanella [Mon, 13 Mar 2017 13:20:05 +0000 (10:20 -0300)]
Fix test-errno issues

This patch fixes multiple issues of test-errno.c (9a56f8718341):

  - Rename Linux test-errno.c to test-errno-linux.c to avoid build
    the same source for both tests.

  - Add a mlock check for 32 bits build running on 64 bits kernels.
    Althuough man pages states that mlock fails with EINVAL if final
    address overflows, kernels does not return it for aforementioned
    condition (it returns ENOMEM instead).  Although it seems to be
    a kernel issue for compat syscall handling, I think it is worth
    to still check syscall return and document the behavior.

  - Initialize option lenght for setsockopt check.

  - Change open test from EINVAL to EISDIR.

Checked on x86_64-linux-gnu and i686-linux-gnu (running on 64 bits
kernel).

* posix/test-errno.c (do_test): Initialize setsockopt optlen.
* sysdeps/unix/sysv/linux/test-errno.c: Move to ...
* sysdeps/unix/sysv/linux/test-errno-linux.c: ... here.
(test_wrp_rv): Fix format.
(test_wrp_rv2): New macro.
(do_test): Handle mlock return on 64 bits kernels with 32 bits
binaries.

7 years agoFix test-math-vector-sincos.h aliasing.
Joseph Myers [Wed, 15 Mar 2017 17:32:46 +0000 (17:32 +0000)]
Fix test-math-vector-sincos.h aliasing.

x86_64 libmvec tests have been failing to build lately with GCC
mainline with -Wuninitialized errors, and Markus Trippelsdorf traced
this to an aliasing issue
<https://sourceware.org/ml/libc-alpha/2017-03/msg00169.html>.

This patch fixes the aliasing issue, so that the vectors-of-pointers
are initialized using a union instead of pointer casts.  This also
fixes the testsuite build failures with GCC mainline.

Tested for x86_64 (full testsuite with GCC 6; testsuite build with GCC
mainline with build-many-glibcs.py).

* sysdeps/x86/fpu/test-math-vector-sincos.h (INIT_VEC_PTRS_LOOP):
Use a union when storing pointers.
(VECTOR_WRAPPER_fFF_2): Do not take address of integer vector and
cast result when passing to INIT_VEC_PTRS_LOOP.
(VECTOR_WRAPPER_fFF_3): Likewise.
(VECTOR_WRAPPER_fFF_4): Likewise.

7 years agoSplit helper classification macros from mathcalls.h
Gabriel F. T. Gomes [Mon, 6 Mar 2017 20:02:37 +0000 (17:02 -0300)]
Split helper classification macros from mathcalls.h

The classification macros: finite, fpclassify, iseqsig, isinf, isnan,
issignaling, and signbit are defined by ISO C11 and declared in
mathcalls.h for each of the floating-point types: float, double, and
long double.

TS 18661-3 does not mention these macros for float128, however support
for them must be present when _Float128 is present.  This is true,
even when the feature test macro __STDC_WANT_IEC_60559_TYPES_EXT__ is
false.  Other function declarations in mathcalls.h, on the other hand,
depend on __STDC_WANT_IEC_60559_TYPES_EXT__.

This patch splits the helper functions (__finite, __fpclassify,
__iseqsig, __isinf, __isnan, __issignaling, and __signbit) from
mathcalls.h, so that these helper functions can be declared for
_Float128, even when __STDC_WANT_IEC_60559_TYPES_EXT__ is false.

Tested for powerpc64le, s390x, and x86_64.

* include/bits/mathcalls-helper-functions.h: New file.
* math/Makefile (headers): Add bits/mathcalls-helper-functions.h.
* math/bits/mathcalls.h (__finite, __fpclassify, __iseqsig)
(__isinf, __isnan, __issignaling, __signbit): Move declarations to
math/bits/mathcalls-helper-functions.h.
* math/bits/mathcalls-helper-functions.h: New file.
* math/math.h: Include bits/mathcalls-helper-functions.h for
float, double, and long double.

7 years agoUse internal __feraiseexcept in __iseqsig
Gabriel F. T. Gomes [Tue, 14 Mar 2017 20:36:08 +0000 (17:36 -0300)]
Use internal __feraiseexcept in __iseqsig

Replace the use of feraiseexcept with __feraiseexcept in the helper
function __iseqsig (math/s_iseqsig_template.c).

Tested for powerpc64le, s390x, and x86_64.

* math/s_iseqsig_template.c (__iseqsig): Use __feraiseexcept
instead of feraiseexcept.

7 years agosupport: Explain ignored failures of temporary file removal [BZ #21243]
Florian Weimer [Wed, 15 Mar 2017 12:14:54 +0000 (13:14 +0100)]
support: Explain ignored failures of temporary file removal [BZ #21243]

7 years agosupport: Add error checking to close system calls [BZ #21244]
Florian Weimer [Wed, 15 Mar 2017 12:13:58 +0000 (13:13 +0100)]
support: Add error checking to close system calls [BZ #21244]

7 years agosupport_format_dns_packet: Fix CNAME and multiple RR handling
Florian Weimer [Wed, 15 Mar 2017 11:57:12 +0000 (12:57 +0100)]
support_format_dns_packet: Fix CNAME and multiple RR handling

Before this change, the loop iterating over RRs in the answer
section stopped at the first CNAME record, never printing them.
The CNAME and PTR record contents was extracted from the wrong
buffer (whole packet instead RDATA).  This desynced the parsing
after the first CNAME or PTR record.

Also fix the AAAA record parsing by checking their sizes.

7 years agoFix missing posix_fadvise64 mips64 static build (BZ #21232)
Adhemerval Zanella [Tue, 14 Mar 2017 19:42:08 +0000 (16:42 -0300)]
Fix missing posix_fadvise64 mips64 static build (BZ #21232)

This patch fixes the missing posix_fadvise64 symbol for static build
required for _FILE_OFFSET_BITS=64 on mips64 build.

Checked on a mips64-linux-gnu build with run-built-tests=no.

[BZ #21232]
* sysdeps/unix/sysv/linux/mips/mips64/n64/posix_fadvise64.c: Add
posix_fadvise64 weak_alias for static build.

7 years agoRemove _dl_platform_string
Andreas Schwab [Thu, 15 Dec 2016 11:17:19 +0000 (12:17 +0100)]
Remove _dl_platform_string

There are no non-trivial uses of _dl_platform_string.

7 years agohurd: Make send/recv more posixish
Samuel Thibault [Mon, 13 Mar 2017 19:41:12 +0000 (20:41 +0100)]
hurd: Make send/recv more posixish

Thanks David Michael for the suggestion.

* sysdeps/mach/hurd/send.c (__send): Convert hurdish error code into
posix error code.
* sysdeps/mach/hurd/recv.c (__recv): Likewise.

7 years agobuild-many-glibcs: Remove no_isolate from SH config
Adhemerval Zanella [Mon, 13 Mar 2017 11:04:22 +0000 (08:04 -0300)]
build-many-glibcs: Remove no_isolate from SH config

Now with d40dbe7 SH build does not require more the no_isolate gcc
options to correct build glibc (since SH build now does not generate
a trap anymore).  This patch removes the unrequired options from
SH config.

Checked with a build for sh3-linux-gnu, sh3eb-linux-gnu, sh4-linux-gnu,
and sh4eb-linux-gnu.

* scripts/build-many-glibcs.py (Context.add_all_configs): Remove
no_isolate usage for SH.

7 years ago Remove the str(n)dup inlines from string/bits/string2.h. Although inlining
Wilco Dijkstra [Mon, 13 Mar 2017 18:42:35 +0000 (18:42 +0000)]
 Remove the str(n)dup inlines from string/bits/string2.h.  Although inlining
calls with constant strings shows a small (~10%) performance gain, strdup is
typically used in error reporting code, so not performance critical.
Remove the now unused __need_malloc_and_calloc related defines from stdlib.h.

Rename existing uses of str(n)dup to __str(n)dup so it no longer needs to be
redirected to a builtin.  Also building GLIBC with -Os now no longer shows
localplt or linkname space failures (partial fix for BZ #15105 and BZ #19463).

        [BZ #15105]
        [BZ #19463]
        * elf/dl-cache.c (_dl_load_cache_lookup): Use __strdup.
        * inet/rcmd.c (rcmd_af): Likewise.
        * inet/rexec.c   (rexec_af): Likewise.
        * intl/dcigettext.c (_LIBC): Likewise.
        * intl/finddomain.c (_nl_find_domain): Use strdup expansion.
        * locale/loadarchive.c (_nl_load_locale_from_archive): Use __strdup.
        * locale/setlocale.c (setlocale): Likewise.
        * posix/spawn_faction_addopen.c
        (posix_spawn_file_actions_addopen): Likewise.
        * stdlib/putenv.c (putenv): Use __strndup.
        * sunrpc/svc_simple.c (__registerrpc): Use __strdup.
        * sysdeps/posix/getaddrinfo.c (gaih_inet): Use __strdup/__strndup.
        * include/stdlib.h (__need_malloc_and_calloc): Remove uses.
        (__Need_M_And_C) Remove define/undef.
        * stdlib/stdlib.h (__need_malloc_and_calloc): Remove uses.
        (__malloc_and_calloc_defined): Remove define.
        * string/bits/string2.h (__strdup): Remove define.
        (strdup): Likewise.
        (__strndup): Likewise.
        (strndup): Likewise.

7 years agoAdd more IPV6_* macros to sysdeps/unix/sysv/linux/bits/in.h.
Joseph Myers [Mon, 13 Mar 2017 16:44:19 +0000 (16:44 +0000)]
Add more IPV6_* macros to sysdeps/unix/sysv/linux/bits/in.h.

Linux 4.10 adds IPV6_RECVFRAGSIZE to include/uapi/linux/in6.h, which
shows that several such IPV6_* macros are missing from glibc's
sysdeps/unix/sysv/linux/bits/in.h (while older ones are present).  I
don't know whether any of these might be deliberately omitted, but
this patch adds what appear to be the missing more recent macros to
glibc.

Tested for x86_64.

* sysdeps/unix/sysv/linux/bits/in.h (IPV6_AUTOFLOWLABEL): New
macro.
(IPV6_ADDR_PREFERENCES): Likewise.
(IPV6_MINHOPCOUNT): Likewise.
(IPV6_ORIGDSTADDR): Likewise.
(IPV6_RECVORIGDSTADDR): Likewise.
(IPV6_TRANSPARENT): Likewise.
(IPV6_UNICAST_IF): Likewise.
(IPV6_RECVFRAGSIZE): Likewise.

7 years agoAdd missing ChangeLog entries.
Thorsten Kukuk [Mon, 13 Mar 2017 16:43:10 +0000 (17:43 +0100)]
Add missing ChangeLog entries.

7 years agoThe rpcgen tests should not run if we don't build rpcgen.
Thorsten Kukuk [Mon, 13 Mar 2017 16:26:43 +0000 (17:26 +0100)]
The rpcgen tests should not run if we don't build rpcgen.

* sunrpc/Makefile: only run rpcgen tests if we build rpcgen.

7 years agosh: Fix building with gcc5/6
Alexey Neyman [Wed, 8 Feb 2017 18:00:57 +0000 (16:00 -0200)]
sh: Fix building with gcc5/6

Build glibc for sh4-unknown-linux-gnu currently fails if one's
using GCC5/6: in dl-conflict.c, the elf_machine_rela() function
is called with NULL as its 3rd argument, sym. The implementation
of that function in sysdeps/sh/dl-machine.h dereferences that pointer:

const Elf32_Sym *const refsym = sym;
...
if (map == &GL(dl_rtld_map))
  value -= map->l_addr + refsym->st_value + reloc->r_addend;

GCC discovers a null pointer dereference, and in accordance with
-fdelete-null-pointer-checks (which is enabled in -O2) replaces this
code with a trap - which, as SH does not implement a trap pattern in
GCC, evaluates to an abort() call. This abort() call pulls many more
objects from libc_nonshared.a, eventually resulting in link failure
due to multiple definitions for a number of symbols.

As far as I see, the conditional before this code is always false in
rtld: _dl_resolve_conflicts() is called with main_map as the first
argument, not GL(_dl_rtld_map), but since that call is in yet another
compilation unit, GCC does not know about it. Patch that wraps this
conditional into !defined RESOLVE_CONFLICT_FIND_MAP attached.

* sysdeps/sh/dl-machine.h (elf_machine_rela): The condition
in R_SH_DIR32 case is always false when inlined from
dl-conflict.c. Ifdef out to prevent GCC from insertin an
abort() call.

7 years agoFix send consolidation typo
Marko Myllynen [Sun, 12 Mar 2017 20:23:52 +0000 (17:23 -0300)]
Fix send consolidation typo

Fix 60f9423b type for alpha kernel-features.h definition.

* sysdeps/unix/sysv/linux/alpha/kernel-features.h
        (__ASSUME_RECV_SYSCALL): Replace duplicate by
        __ASSUME_SEND_SYSCALL.

7 years agoIf sunrpc code is disabled, rpcsvc header files, rpcgen and
Thorsten Kukuk [Sat, 11 Mar 2017 10:36:58 +0000 (11:36 +0100)]
If sunrpc code is disabled, rpcsvc header files, rpcgen and
librpcsvc.a should not be installed, too.

* sunrpc/Makefile: don't build and install rpcsvc header
files, rpcgen and librpcsvc.a by default.

Signed-off-by: Thorsten Kukuk <kukuk@suse.com>