]> sourceware.org Git - glibc.git/log
glibc.git
7 years agoNew internal function __access_noerrno
Adhemerval Zanella [Thu, 10 Nov 2016 11:28:00 +0000 (09:28 -0200)]
New internal function __access_noerrno

Implement an internal version of __access called __access_noerrno that
avoids setting errno.  This is useful to check accessibility of files
very early on in process startup i.e. before TLS setup.  This allows
tunables to replace MALLOC_CHECK_ safely (i.e. check existence of
/etc/suid-debug to enable/disable MALLOC_CHECK) and at the same time
initialize very early so that it can override IFUNCs.

Checked on x86_64.

* hurd/hurd.h (__hurd_fail_noerrno): New function.
* include/unistd.h [IS_IN (rtld) || !defined SHARED]: Declare
__access_noerrno.
* io/access.c (__access_noerrno): New function.
* sysdeps/mach/hurd/access.c (hurd_fail_seterrno): New function.
(hurd_fail_seterrno): Likewise.
(access_common): Likewise.
(__access_noerrno): Likewise.
* sysdeps/nacl/access.c (__access_noerrno): Likewise.
* sysdeps/unix/sysv/linux/access.c (__access_noerrno): Likewise.
* sysdeps/nacl/nacl-interfaces.h (NACL_CALL_NOERRNO): New
macro.

7 years agoFix SH4 register-dump.h for soft-float.
Joseph Myers [Wed, 16 Nov 2016 03:45:49 +0000 (03:45 +0000)]
Fix SH4 register-dump.h for soft-float.

This patch fixes SH4 register-dump.h to declare a variable inside the
the build for soft-float.

Tested (compilation only) for SH4 soft-float.

* sysdeps/unix/sysv/linux/sh/sh4/register-dump.h (register_dump):
Only declare fpregs if [__SH_FPU_ANY__].

7 years agoMake SH ucontext always match current kernels.
Joseph Myers [Tue, 15 Nov 2016 21:44:36 +0000 (21:44 +0000)]
Make SH ucontext always match current kernels.

As discussed in the thread starting at
<https://sourceware.org/ml/libc-alpha/2015-06/msg00657.html>, there
are various problems with the sigcontext / mcontext / ucontext
structures on SH.  The soft-float SH4 case in fact does not build at
present, with errors processing
sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym with gen-as-const.awk
("error: 'mcontext_t {aka struct <anonymous>}' has no member named
'fpregs'").

Linux 4.8 (commit bbe6c77857c38f4acbdc4fc70399515226d1859a) moved to
always using the same sigcontext structure on SH, with room for
floating-point registers whether or not present on the processor.
This patch makes the glibc header match.

Tested (compilation only) for sh4-linux-gnu hard float, and in
conjunction with other fixes for soft float.

* sysdeps/unix/sysv/linux/sh/sys/ucontext.h [__SH4__ || __SH4A__]:
Make code unconditional.
[!(__SH4__ || __SH4A__)]: Remove conditional code.

7 years agomanual: Remove non-existent mount options S_IMMUTABLE and S_APPEND [BZ #11235]
Rical Jasan [Sun, 13 Nov 2016 08:29:27 +0000 (00:29 -0800)]
manual: Remove non-existent mount options S_IMMUTABLE and S_APPEND [BZ #11235]

These were removed in 2010, while addressing [BZ #11235].
This commit removes their documentation from the manual.

7 years agoChangeLog: fix date
Mike Frysinger [Tue, 15 Nov 2016 19:30:03 +0000 (14:30 -0500)]
ChangeLog: fix date

7 years agoconfigure: accept __stack_chk_fail_local for ssp support too [BZ #20662]
Denis Kaganovich [Thu, 20 Oct 2016 20:01:39 +0000 (22:01 +0200)]
configure: accept __stack_chk_fail_local for ssp support too [BZ #20662]

When glibc is compiled with gcc 6.2 that has been configured with
--enable-default-pie and --enable-default-ssp, the configure script
fails to detect that the compiler has ssp turned on by default when
being built for i686-linux-gnu.

This is because gcc is emitting __stack_chk_fail_local but the
script is only looking for __stack_chk_fail.  Support both.

Example output:
checking whether x86_64-pc-linux-gnu-gcc -m32 -Wl,-O1 -Wl,--as-needed
implicitly enables -fstack-protector... no

7 years agos390x: Add hidden definition for __sigsetjmp
Florian Weimer [Tue, 15 Nov 2016 14:51:01 +0000 (15:51 +0100)]
s390x: Add hidden definition for __sigsetjmp

7 years agoFix build-many-glibcs.py style issues.
Joseph Myers [Mon, 14 Nov 2016 23:48:50 +0000 (23:48 +0000)]
Fix build-many-glibcs.py style issues.

* scripts/build-many-glibcs.py (os.path): Do not import.
(Context): Inherit explicitly from object.  Remove blank line
between class and docstring.
(Config): Likewise.
(Glibc): Likewise.
(Command): Likewise.
(CommandList): Likewise.
(Context.write_files): Store chmod mode in a variable.

7 years agoMake tilegx32 install libraries in lib32 directories.
Joseph Myers [Mon, 14 Nov 2016 23:34:54 +0000 (23:34 +0000)]
Make tilegx32 install libraries in lib32 directories.

This patch makes tilegx32 install libraries in lib32 directories,
matching what GCC expects and avoiding conflict with 64-bit libraries
installed in lib directories.

Tested (compilation only) for tilegx (32-bit and 64-bit, BE and LE,
GCC 5).

* sysdeps/unix/sysv/linux/tile/tilegx/configure.ac: Use
LIBC_SLIBDIR_RTLDDIR for tilegx32.
* sysdeps/unix/sysv/linux/tile/tilegx/configure: Regenerated.

7 years agoForgot to add the ChangeLog to the previous commit, doh.
Zack Weinberg [Mon, 14 Nov 2016 19:29:22 +0000 (14:29 -0500)]
Forgot to add the ChangeLog to the previous commit, doh.

7 years agoFix build-and-build-again bug in sunrpc tests.
Zack Weinberg [Mon, 14 Nov 2016 19:25:11 +0000 (14:25 -0500)]
Fix build-and-build-again bug in sunrpc tests.

rpcgen will error out if the file it's asked to create already exists.
Several other rules in sunrpc/Makefile take care to delete rpcgen-
generated files before creating them, but rpcgen-tests doesn't, which
can lead to spurious test failures in an incremental rebuild.

* sunrpc/Makefile (rpcgen-tests): Delete the .out file before
creating or re-creating it.

7 years agoFix typo in string/bits/string2.h.
Zack Weinberg [Mon, 14 Nov 2016 17:35:10 +0000 (12:35 -0500)]
Fix typo in string/bits/string2.h.

The comment above the bzero() macro in this file appears to have been
copied verbatim from the comment above the memset() prototype in
string.h proper.  bzero() has no 'c' argument and can only set memory
contents to 0.  (The comment above the prototype of bzero() in
string.h proper does not make the same mistake.)

* string/bits/string2.h: Fix typo in comment.

7 years ago[BZ #19239] Issue deprecation warnings on macro expansion.
Zack Weinberg [Mon, 14 Nov 2016 13:34:59 +0000 (08:34 -0500)]
[BZ #19239] Issue deprecation warnings on macro expansion.

By using __glibc_macro_warning instead of __attribute_deprecated__,
we get the deprecation warnings whenever the macros are expanded,
not just when they compile to a function call.  This is important
for unintentional uses like the test case in #19239 (C++ var(value)
initialization syntax, with a variable named "major").  It's also
simpler, because __REDIRECT is no longer required.

* misc/sys/sysmacros.h (__SYSMACROS_DM, __SYSMACROS_DM1): New macros.
(__SYSMACROS_DEPRECATION_MSG, __SYSMACROS_FST_DECL_TEMPL)
(__SYSMACROS_FST_IMPL_TEMPL): Delete.
(major, minor, makedev): Use __SYSMACROS_DM in definition, instead
of redirected function names.

* misc/sys/cdefs.h (__glibc_macro_warning): Activate for clang >= 3.5
as well.  Document that MESSAGE must be a single string literal.

7 years agoAdd script to build many glibc configurations.
Joseph Myers [Fri, 11 Nov 2016 21:07:08 +0000 (21:07 +0000)]
Add script to build many glibc configurations.

This patch adds a Python (3.5 or later) script to build many different
configurations of glibc, including building the required cross
compilers first.  It's not intended to change any patch testing
requirements, although some people may wish to use it for high-risk
patches such as adding warning options (and it can also be used to
test building, including compiling tests, for an individual
configuration, if e.g. you wish to do such a compilation test of a
patch for an architecture it touches).

The configurations include all the GNU/Linux ABI variants in
<https://sourceware.org/glibc/wiki/ABIList> (although some do not yet
build cleanly) and it would be desirable to cover enough other
variants e.g. for CPUs using different sysdeps directories to test
building each piece of code in glibc at least once.  It would also be
desirable to extend it to cover Hurd and NaCl, which might best be
done by people familiar with those configurations.

You call the script as

build-many-glibcs.py /some/where thing-to-do <other-arguments>

where /some/where is a working directory for the script.  It will
create and use subdirectories build, install, logs therein.  You can
use it with thing-to-do being "checkout" to create a subdirectory src
therein, with subdirectories binutils, gcc, glibc, gmp, linux, mpc,
mpfr with the sources of those components, or create those directories
manually (all except glibc can be symlinks to sources elsewhere).  In
the checkout case, by default it checks out GCC 6 branch, binutils
2.27 branch, glibc mainline and releases of other components.  You can
specify <component>-<version> to choose a version to check out, where
<version> is "vcs-mainline" or "vcs-<branch>" to check out from
version control (only supported for gcc, binutils, glibc) and
otherwise a release version number to download and use a tarball;
components not specified on the command line have default versions
checked out.  If you rerun "checkout" (with the same version
specifications) it will update checkouts from version control, but
will not detect cases where the location something is expected to be
checked out from has changed.

Other than "checkout", thing-to-do is one of host-libraries,
compilers, glibcs.  So you run, in that order:

build-many-glibcs.py /some/where host-libraries
build-many-glibcs.py /some/where compilers
build-many-glibcs.py /some/where glibcs

host-libraries is run once and then those libraries are used for all
the compilers.  compilers can be run once and then used many times for
testing different glibc versions (so a bot only needs to update glibc
and rerun the glibcs task, if using stable GCC / binutils; if testing
the latest versions of the whole toolchain together including mainline
GCC, it would probably want to update everything and rerun both
compilers and glibcs).  You can also name particular variants after
"compilers" or "glibcs" to build just those variants (the possible
variants are hardcoded in the script).

I may add support for allowing the set of configurations to depend on
the GCC version (to get cleaner default results), and optionally
looping over architecture-independent glibc variants of CFLAGS and
configure options as well, for every glibc configuration listed
(e.g. -Os).

GCC versions before 4.9 are not expected to work (the code uses
--with-glibc-version to get the bootstrap GCC appropriately
configured).  There are various problems for particular configurations
as well.

Command-line options to the script: -jN to run N jobs in parallel
(default the number of CPU cores reported by the system); --keep=all
or --keep=failed to control keeping around build directories (default
--keep=none).

* scripts/build-many-glibcs.py: New file.

7 years agoIgnore -Wmaybe-uninitialized in stdlib/bug-getcontext.c.
Joseph Myers [Fri, 11 Nov 2016 21:05:51 +0000 (21:05 +0000)]
Ignore -Wmaybe-uninitialized in stdlib/bug-getcontext.c.

Doing all-ABIs compile testing produces a compiler warning in
stdlib/bug-getcontext.c on nios2 and tilepro (with GCC 5 branch):

bug-getcontext.c: In function 'do_test':
bug-getcontext.c:53:6: error: 'except_mask' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   if (mask != except_mask)
      ^

This warning appears nonsensical; except_mask is initialized where
it's declared.  I think what must be happening here is that the
compiler is confused by the returns-twice nature of getcontext: if
there were a call to setcontext, local variables could indeed have
lost their values on the second return from getcontext.  This patch
duly uses the DIAG_* macros to disable the warning here.

Tested for nios2 and tilepro (compilation only; after this patch all
the tests compile, though there are other failures) and x86_64 (full
testsuite run).

* stdlib/bug-getcontext.c: Include <libc-internal.h>.
(do_test): Disable -Wmaybe-uninitialized around uses of
except_mask.

7 years agoMake SH <sys/user.h> self-contained.
Joseph Myers [Fri, 11 Nov 2016 21:04:28 +0000 (21:04 +0000)]
Make SH <sys/user.h> self-contained.

The check-installed-headers tests show up that the SH <sys/user.h> is
not self-contained, using size_t without including any header that
defines it.  This patch fixes it by including <stddef.h>, as done for
other architectures' versions of this header.

Tested for SH3 and SH4 (compilation only).

* sysdeps/unix/sysv/linux/sh/sys/user.h: Include <stddef.h>.

7 years agoMake sure tilepro uses kernel atomics fo atomic_store
Chris Metcalf [Fri, 11 Nov 2016 01:08:24 +0000 (20:08 -0500)]
Make sure tilepro uses kernel atomics fo atomic_store

It's not legal for raw stores to be mixed with atomic operations
on tilepro, since the atomics are managed by kernel fast syscalls.
It's possible for a hardware store and a kernel fast atomic to race
with each other in such a way that the hardware store is lost.

Suppose you have an initial zero value, and you race with a store
of 2 and a kernel cmpxchg from 0 to 1.  The legal output is only 2:
either the store hit first and the cmpxchg failed, or the cmpxchg
hit first and succeeded, then was overwritten by the 2.  But if
the kernel cmpxchg starts first and loads the zero, then the store
hits and sets the value to 2, the cmpxchg will still decide it was
successful and write the 1, leaving the value illegally set to 1.

Using atomic_exchange variants to implement atomic_store fixes this
problem for tilepro.

7 years agoRefactor some libm type-generic macros.
Joseph Myers [Thu, 10 Nov 2016 21:41:56 +0000 (21:41 +0000)]
Refactor some libm type-generic macros.

This patch refactors some type-generic libm macros, in both math.h and
math_private.h, to be based on a common __MATH_TG macro rather than
all replicating similar logic to choose a function to call based on
the type of the argument.

This should serve to illustrate what I think float128 support for such
macros should look like: common macros such as __MATH_TG may need
different definitions depending on whether float128 is supported in
glibc, so that the individual macros themselves do not need
conditionals on float128 support.

Tested for x86_64, x86, mips64 and powerpc.

* math/math.h (__MATH_TG): New macro.
[__USE_ISOC99] (fpclassify): Define using __MATH_TG.
[__USE_ISOC99] (signbit): Likewise.
[__USE_ISOC99] (isfinite): Likewise.
[__USE_ISOC99] (isnan): Likewise.
[__USE_ISOC99] (isinf): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (issignaling): Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (__MATH_EVAL_FMT2): New macro.
[__GLIBC_USE (IEC_60559_BFP_EXT)] (iseqsig): Define using
__MATH_TG and __MATH_EVAL_FMT2.
* sysdeps/generic/math_private.h (fabs_tg): Define using
__MATH_TG.
* sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
[!__NO_LONG_DOUBLE_MATH] (__iscanonicalf): New macro.
[!__NO_LONG_DOUBLE_MATH] (__iscanonical): Likewise.
[!__NO_LONG_DOUBLE_MATH] (iscanonical): Define using __MATH_TG.
* sysdeps/ieee754/ldbl-96/bits/iscanonical.h (__iscanonicalf): New
macro.
(__iscanonical): Likewise.
(iscanonical): Define using __MATH_TG.

7 years agoFix sh4 build with __ASSUME_ST_INO_64_BIT redefinition
Adhemerval Zanella [Wed, 9 Nov 2016 12:33:34 +0000 (10:33 -0200)]
Fix sh4 build with __ASSUME_ST_INO_64_BIT redefinition

Since 327792c sh4 builds fails with:

../sysdeps/unix/sysv/linux/kernel-features.h:49:0: error: "__ASSUME_ST_INO_64_BIT" redefined [-Werror]
 #define __ASSUME_ST_INO_64_BIT  1
 ^
In file included from ../sysdeps/unix/sysv/linux/sysdep.h:19:0,
                 from ../sysdeps/unix/sysv/linux/sh/sysdep.h:24,
                 from ../sysdeps/unix/sysv/linux/sh/sh4/sysdep.h:4,
                 from <stdin>:1:
../sysdeps/unix/sysv/linux/sh/kernel-features.h:47:0: note: this is the location of the previous definition
 #define __ASSUME_ST_INO_64_BIT 0

It is because sh4 kernel-features.sh is included multiple times
without guards and this patch fixes by adding them.

Tested on a sh4-linux-gnu build.

* sysdeps/unix/sysv/linux/sh/kernel-features.h: Add include
guards.

7 years agoConsolidate Linux access implementation
Adhemerval Zanella [Thu, 10 Nov 2016 11:24:34 +0000 (09:24 -0200)]
Consolidate Linux access implementation

This patch consolidates the Linux access implementation on
sysdeps/unix/sysv/linux/access.c.  Similar to auto-generation through
syscalls.list, __NR_access is check and __NR_faccessat is used only
for newer architectures (where __NR_access is not defined).

Checked on x86_64.

* sysdeps/unix/sysv/linux/access.c: New file.
* sysdeps/unix/sysv/linux/generic/access.c: Remove file.

7 years agoAdd definitions to sysdeps/tile/tilepro/bits/wordsize.h.
Steve Ellcey [Thu, 10 Nov 2016 15:46:18 +0000 (07:46 -0800)]
Add definitions to sysdeps/tile/tilepro/bits/wordsize.h.

* sysdeps/tile/tilepro/bits/wordsize.h: Define __WORDSIZE32_SIZE_ULONG
and __WORDSIZE32_PTRDIFF_LONG.

7 years agoRegenerate ULPs for aarch64
Siddhesh Poyarekar [Thu, 10 Nov 2016 11:22:35 +0000 (16:52 +0530)]
Regenerate ULPs for aarch64

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

7 years agoConsolidate Linux truncate implementations
Adhemerval Zanella [Fri, 26 Aug 2016 15:19:18 +0000 (12:19 -0300)]
Consolidate Linux truncate implementations

This patch consolidates all Linux truncate implementation on
sysdeps/unix/sysv/linux/truncate{64}.c.  It is based on
{INTERNAL,INLINE}_SYSCALL patch [1] to simplify the syscall
construction.

General idea is to build ftruncate iff __OFF_T_MATCHES_OFF64_T is not
defined, otherwise ftruncate64 will be build and ftruncate will be an
alias.  The fallocate will use old compat syscall and pass 32-bit off_t
argument, while fallocate64 will handle the correct off64_t passing using
__ALIGNMENT_ARG and SYSCALL_LL64 macros.

Tested on x86_64, i386, aarch64, and armhf.

* sysdeps/unix/sysv/linux/arm/truncate64.c: Remove file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/truncate.c: Likewise.
* sysdeps/sysv/linux/generic/wordsize-32/truncate64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/truncate64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/truncate64.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/truncate64.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/truncate64.c: Likewise.
* sysdeps/unix/sysv/linux/truncate.c: New file.
* sysdeps/unix/sysv/linux/truncate64.c (truncate64): Use
INLINE_SYSCALL_CALL, __ALIGNMENT_ARG and SYSCALL_LL64 macros.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (truncate):
Remove.
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list (truncate):
Likewise.

[1] https://sourceware.org/ml/libc-alpha/2016-08/msg00646.html

7 years agoConsolidate Linux ftruncate implementations
Adhemerval Zanella [Fri, 26 Aug 2016 13:42:58 +0000 (10:42 -0300)]
Consolidate Linux ftruncate implementations

THis patch consolidates all Linux ftruncate implementation on
sysdeps/unix/sysv/linux/ftruncate{64}.c.  It is based on
{INTERNAL,INLINE}_SYSCALL patch [1] to simplify the syscall construction.

General idea is to build ftruncate iff __OFF_T_MATCHES_OFF64_T is not
defined, otherwise ftruncate64 will be build and ftruncate will be an
alias.  The fallocate will use old compat syscall and pass 32-bit off_t
argument, while fallocate64 will handle the correct off64_t passing using
__ALIGNMENT_ARG and SYSCALL_LL64 macros.

Tested on x86_64, i386, aarch64, and armhf.

* posix/tst-truncate-common.c: New file.
* posix/tst-truncate.c: Use tst-truncate-common.c.
* posix/tst-truncate64.c: Likewise and add LFS tests.
* sysdeps/unix/sysv/linux/arm/ftruncate64.c: Remove file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/ftruncate.c: Likewise.
* sysdeps/unix/sysv/linux/generic/wordsize-32/ftruncate64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/ftruncate64.c: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/ftruncate64.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/ftruncate64.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/ftruncate64.c: Likewise.
* sysdeps/unix/sysv/linux/ftruncate.c: New file.
* sysdeps/unix/sysv/linux/ftruncate64.c (__ftruncate64): Use
INLINE_SYSCALL_CALL, __ALIGNMENT_ARG and SYSCALL_LL64 macros.
[__OFF_T_MATCHES_OFF64_T] (ftruncate): Add alias.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list (ftruncate):
Remove.
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list (ftruncate):
Likewise.

[1] https://sourceware.org/ml/libc-alpha/2016-08/msg00646.html

7 years agoFix rpcgen buffer overrun (bug 20790).
Joseph Myers [Tue, 8 Nov 2016 23:44:51 +0000 (23:44 +0000)]
Fix rpcgen buffer overrun (bug 20790).

Building with GCC 7 produces an error building rpcgen:

rpc_parse.c: In function 'get_prog_declaration':
rpc_parse.c:543:25: error: may write a terminating nul past the end of the destination [-Werror=format-length=]
     sprintf (name, "%s%d", ARGNAME, num); /* default name of argument */
                     ~~~~^
rpc_parse.c:543:5: note: format output between 5 and 14 bytes into a destination of size 10
     sprintf (name, "%s%d", ARGNAME, num); /* default name of argument */
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

That buffer overrun is for the case where the .x file declares a
program with a million arguments.  The strcpy two lines above can
generate a buffer overrun much more simply for a long argument name.

The limit on length of line read by rpcgen (MAXLINESIZE == 1024)
provides a bound on the buffer size needed, so this patch just changes
the buffer size to MAXLINESIZE to avoid both possible buffer
overruns.  A testcase is added that rpcgen does not crash with a
500-character argument name, where it previously crashed.

It would not at all surprise me if there are many other ways of
crashing rpcgen with either valid or invalid input; fuzz testing would
likely find various such bugs, though I don't think they are that
important to fix (rpcgen is not that likely to be used with untrusted
.x files as input).  (As well as fuzz-findable bugs there are probably
also issues when various int variables get overflowed on very large
input.)  The test infrastructure for rpcgen-not-crashing tests would
need extending if tests are to be added for cases where rpcgen should
produce an error, as opposed to cases where it should succeed.

Tested for x86_64 and x86.

[BZ #20790]
* sunrpc/rpc_parse.c (get_prog_declaration): Increase buffer size
to MAXLINESIZE.
* sunrpc/bug20790.x: New file.
* sunrpc/Makefile [$(run-built-tests) = yes] (rpcgen-tests): New
variable.
[$(run-built-tests) = yes] (tests-special): Add $(rpcgen-tests).
[$(run-built-tests) = yes] ($(rpcgen-tests)): New rule.

7 years agoAdd localplt.data for sh.
Joseph Myers [Tue, 8 Nov 2016 23:43:17 +0000 (23:43 +0000)]
Add localplt.data for sh.

This patch adds a localplt.data file for sh so that test passes.  The
architecture-specific entries are for _Unwind_Find_FDE, _exit and
__errno_location.

Tested for sh3 and sh4.

* sysdeps/unix/sysv/linux/sh/localplt.data: New file.

7 years agoAdd localplt.data for hppa.
Joseph Myers [Tue, 8 Nov 2016 23:42:36 +0000 (23:42 +0000)]
Add localplt.data for hppa.

This patch adds a localplt.data file for hppa so that test passes.
Architecture maintainers should feel free to clean up the sysdeps code
so that some or all of the system-specific entries

libc.so: _exit
libc.so: __sigsetjmp
libc.so: _IO_funlockfile
libc.so: sigprocmask
libc.so: __errno_location
libpthread.so: __errno_location

are no longer needed.

Tested for hppa.  Note: check-execstack and check-textrel still fail;
you may wish to look at those to get to a clean baseline there (they
are less obvious for people not familiar with the architecture).

* sysdeps/unix/sysv/linux/hppa/localplt.data: New file.

7 years agoUpdate alpha localplt.data.
Joseph Myers [Tue, 8 Nov 2016 23:41:51 +0000 (23:41 +0000)]
Update alpha localplt.data.

This patch updates alpha localplt.data so the localplt test passes in
my compile-only all-ABIs glibc testing.  The failures I see without
this patch are:

Missing required PLT reference: ld.so: __tls_get_addr
Missing required PLT reference: ld.so: free

Now, __tls_get_addr can be made optional.  For free, rather than
making it optional as in libc.so it seems better to mark all the
malloc-related symbols in both libc.so and ld.so as allowing an
R_ALPHA_GLOB_DAT relocation as an alternative to using a PLT entry, so
this patch does so.

Tested for alpha.

* sysdeps/unix/sysv/linux/alpha/localplt.data: Make __tls_get_addr
optional in ld.so.  Allow R_ALPHA_GLOB_DAT relocation for malloc,
calloc, realloc, free, memalign and __libc_memalign rather than
making them optional.

7 years agoUpdate nios2 localplt.data.
Joseph Myers [Tue, 8 Nov 2016 23:41:05 +0000 (23:41 +0000)]
Update nios2 localplt.data.

This patch updates nios2 localplt.data so the localplt test passes in
my compile-only all-ABIs glibc testing.  A new PLT entry for
__extendsfdf2 is added.

Tested for nios2.

* sysdeps/unix/sysv/linux/nios2/localplt.data: Add __extendsfdf2
for libc.so.

7 years agoConsolidate lseek/lseek64/llseek implementations
Adhemerval Zanella [Thu, 25 Aug 2016 20:42:44 +0000 (17:42 -0300)]
Consolidate lseek/lseek64/llseek implementations

This patch consolidates all Linux lseek/lseek64/llseek implementation
in on on sysdeps/unix/sysv/linux/lseek{64}.c.  It also removes the llseek
file and instead consolidate the LFS lseek implementation on lseek64.c
as for other LFS symbols implementations.

The general idea is:

  - lseek: ABIs that not define __OFF_T_MATCHES_OFF64_T will preferable
  use __NR__llseek if kernel supports it, otherwise they will use __NR_lseek.
  ABIs that defines __OFF_T_MATCHES_OFF64_T won't produce any symbol.

  - lseek64: ABIs with __OFF_T_MATCHES_OFF64_T will preferable use __NR_lseek
  (since it will use 64-bit arguments without low/high splitting) and
  __NR__llseek if __NR_lseek is not defined (for some ILP32 ports).

  - llseek: files will be removed and symbols will be aliased ot lseek64.

ABI without __OFF_T_MATCHES_OFF64_T and without __NR_llseek (basically MIPS64n32
so far) are covered by building lseek with off_t as expected and lseek64
using __NR_lseek (as expected for off64_t being passed using 64-bit registers).

For this consolidation I mantained the x32 assembly specific implementation
because to correctly fix this it would required both the x32 fix for
{INLINE,INTERNAL}_SYSCALL [1] and a wrapper to correctly subscribe it to
return 64 bits instead of default 32 bits (as for times).  It could a future
cleanup.

It is based on my previous {INTERNAL,INLINE}_SYSCALL_CALL macro [2],
although it is mainly for simplification.

Tested on x86_64, i686, aarch64, armhf, and powerpc64le.

* nptl/Makefile (libpthread-routines): Remove ptw-llseek and add
ptw-lseek64.
* sysdeps/unix/sysv/linux/Makefile (sysdeps_routines): Remove llseek.
* sysdeps/unix/sysv/linux/alpha/Makefile  (sysdeps_routines):
Likewise.
* sysdeps/unix/sysv/linux/generic/wordsize-32/llseek.c: Remove file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/lseek.c: Remove file.
* sysdeps/unix/sysv/linux/mips/mips64/llseek.c: Likewise.
* sysdeps/unix/sysv/linux/llseek.c: Remove file.
* sysdeps/unix/sysv/linux/lseek.c: New file.
* sysdeps/unix/sysv/linux/lseek64.c: Add default Linux implementation.
* sysdeps/unix/sysv/linux/mips/mips64/syscalls.list: Remove lseek and
__libc_lseek64 from auto-generation.
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/lseek64.S: New file.

[1] https://sourceware.org/ml/libc-alpha/2016-08/msg00443.html
[2] https://sourceware.org/ml/libc-alpha/2016-08/msg00646.html

7 years agoWrite messages to stdout and use write_message instead of write
Gabriel F. T. Gomes [Tue, 1 Nov 2016 00:09:12 +0000 (22:09 -0200)]
Write messages to stdout and use write_message instead of write

Replaces calls to write on file descriptor 2 with calls to write_message,
which writes to STDOUT_FILENO (1) and properly deals with the return of
write.

7 years agoUse write_message instead of write
Gabriel F. T. Gomes [Mon, 31 Oct 2016 01:51:27 +0000 (23:51 -0200)]
Use write_message instead of write

In the test cases, there are writes to stdout which do not check the result
value.  This patch replaces such occurrences with calls to write_message,
which properly deals with the unused result.

Tested for powerpc64le.

7 years agoMake check-installed-headers.sh ignore sys/sysctl.h for x32.
Joseph Myers [Mon, 7 Nov 2016 23:32:17 +0000 (23:32 +0000)]
Make check-installed-headers.sh ignore sys/sysctl.h for x32.

check-installed-headers tests were failing for x32 because of the x86
bits/sysctl.h containing a #error for x32.  This patch makes the tests
ignore sys/sysctl.h for x32, similar to the other special-casing of
particular headers.

Tested for x86_64 (full testing for -m64, compile-only for x32).

* scripts/check-installed-headers.sh: Ignore sys/sysctl.h for x32.

7 years agoDefine __ASSUME_ST_INO_64_BIT on all platforms.
Steve Ellcey [Mon, 7 Nov 2016 21:26:27 +0000 (13:26 -0800)]
Define __ASSUME_ST_INO_64_BIT on all platforms.

* sysdeps/unix/sysv/linux/alpha/kernel-features.h: #define
  __ASSUME_ST_INO_64_BIT as 0
* sysdeps/unix/sysv/linux/sh/kernel-features.h: Likewise.
* sysdeps/unix/sysv/linux/fxstat64.c: Replace #ifdef with #if
  over the code where __ASSUME_ST_INO_64_BIT is used.
* sysdeps/unix/sysv/linux/lxstat64.c: Likewise.
* sysdeps/unix/sysv/linux/xstat64.c: Likewise.
* sysdeps/unix/sysv/linux/xstatconv.c: Likewise.

7 years agonptl: Document the reason why __kind in pthread_mutex_t is part of the ABI
Florian Weimer [Mon, 7 Nov 2016 13:38:12 +0000 (14:38 +0100)]
nptl: Document the reason why __kind in pthread_mutex_t is part of the ABI

7 years agoDocument do_test in test-skeleton.c
Steve Ellcey [Mon, 7 Nov 2016 16:28:52 +0000 (08:28 -0800)]
Document do_test in test-skeleton.c

* test-skeleton.c: Document do_test usage.

7 years agogconv.h: fix build with GCC 7
Aurelien Jarno [Sun, 6 Nov 2016 20:33:10 +0000 (21:33 +0100)]
gconv.h: fix build with GCC 7

gconv.h is using a flex array to define the __gconv_info member in an
invalid way, causing GCC 7 to issue an error:

| In file included from ../include/gconv.h:1:0,
|                  from ../sysdeps/unix/sysv/linux/_G_config.h:32,
|                  from ../libio/libio.h:31,
|                  from ../include/libio.h:4,
|                  from ../libio/stdio.h:74,
|                  from ../include/stdio.h:5,
|                  from test-math-isinff.cc:22:
| ../iconv/gconv.h:142:50: error: flexible array member '__gconv_info::__data' not at end of 'struct _IO_codecvt'
| In file included from ../include/libio.h:4:0,
|                  from ../libio/stdio.h:74,
|                  from ../include/stdio.h:5,
|                  from test-math-isinff.cc:22:
| ../libio/libio.h:211:14: note: next member '_G_iconv_t _IO_codecvt::__cd_out' declared here
| ../libio/libio.h:187:8: note: in the definition of 'struct _IO_codecvt'
| In file included from ../include/gconv.h:1:0,
|                  from ../sysdeps/unix/sysv/linux/_G_config.h:32,
|                  from ../libio/libio.h:31,
|                  from ../include/libio.h:4,
|                  from ../libio/stdio.h:74,
|                  from ../include/stdio.h:5,
|                  from test-math-isinff.cc:22:
| ../iconv/gconv.h:142:50: error: flexible array member '__gconv_info::__data' not at end of 'struct _IO_wide_data'
| In file included from ../include/libio.h:4:0,
|                  from ../libio/stdio.h:74,
|                  from ../include/stdio.h:5,
|                  from test-math-isinff.cc:22:
| ../libio/libio.h:211:14: note: next member '_G_iconv_t _IO_codecvt::__cd_out' declared here
| ../libio/libio.h:215:8: note: in the definition of 'struct _IO_wide_data'

This is basically a revert to the code from 15 years ago. More details
are available in the GCC bug:
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78039

Changelog:
* iconv/gconv.h (__gconv_info): Define __data element using a
zero-length array.

7 years agoSpeed up math/test-tgmath2.c
Steve Ellcey [Fri, 4 Nov 2016 22:59:22 +0000 (15:59 -0700)]
Speed up math/test-tgmath2.c

* math/test-tgmath2.c: Split up test function.

7 years agoDo not generate UNRESOLVED results for run-built-tests = no.
Joseph Myers [Fri, 4 Nov 2016 21:29:00 +0000 (21:29 +0000)]
Do not generate UNRESOLVED results for run-built-tests = no.

Testing with run-built-tests = no generates many UNRESOLVED results in
tests.sum (and so in the output of "make check"), for all the tests
that are only compiled and not run in such a configuration.  This
doesn't seem useful in the "make check" output, and also causes "make
check" to exist with error status even when all tests that can be run
in such a configuration passed.

This patch changes it not to consider those tests when generating
subdir-tests.sum, and so tests.sum, so that you get a smaller number
of tests considered in the final results rather than a huge pile of
UNRESOLVED.

Tested with a cross-compiler to ARM in a run-built-tests = no
configuration.

* Rules (tests-expected): New variable, depending on
$(run-built-tests).
(tests): Pass $(tests-expected) to merge-test-results.sh, not
$(tests).

7 years agoHandle tests-unsupported if run-built-tests = no.
Joseph Myers [Fri, 4 Nov 2016 21:28:03 +0000 (21:28 +0000)]
Handle tests-unsupported if run-built-tests = no.

The tests-unsupported variable lists tests that should neither be
compiled nor run, because some support needed to compile them is
missing.

The implementation of this feature involves having a rule to create
.out files for these tests that takes precedence over the default
rule.  This does not work in the run-built-tests = no case (cross
compiling without use of a wrapper to run the tests on a separate
system, in which cases most tests are compiled only) because in that
case the tests target depends on $(tests) to ensure all tests get
compiled.  This patch changes that dependency to filter out
$(tests-unsupported).

Tested with cross-compilation to ARM with GCC 5, where libstdc++ is
missing some C++11 support because of the bug I fixed in
<https://gcc.gnu.org/ml/gcc-patches/2015-10/msg01040.html> and so
tests-unsupported is nonempty and the tests in question fail to
compile.  (When I originally observed the bug, it was with a native
build / test simply using an x86_64 compiler that had been configured
as a cross compiler to isolate it from the system headers / libraries,
so the configuration issue applied to the compiler but run-built-tests
was yes, so I don't observe the issue with tests-unsupported with that
compiler.)

* Rules [$(run-built-tests) = no] (tests): Do not depend on
$(tests-unsupported).

7 years agoFix sparc build due missing __WORDSIZE_TIME64_COMPAT32 definition
Adhemerval Zanella [Fri, 4 Nov 2016 20:10:42 +0000 (18:10 -0200)]
Fix sparc build due missing __WORDSIZE_TIME64_COMPAT32 definition

This patch adds the missing Linux sparc definitions from d060cd0.
Both value are copied from default sparc value [1] and with this
fix now both sparc 32 and 64 bits builds on Linux.

* sysdeps/unix/sysv/linux/sparc/bits/wordsize.h
(__WORDSIZE_TIME64_COMPAT32): Define for both 32 and  64 bits.

[1] sysdeps/sparc/sparc{32,64}/bits/wordsize.h

7 years agoFix alpha sqrt fegetenv namespace (bug 20768).
Joseph Myers [Fri, 4 Nov 2016 17:19:13 +0000 (17:19 +0000)]
Fix alpha sqrt fegetenv namespace (bug 20768).

On alpha, sqrt (a C90 function) brings in references to fegetenv
(C99), resulting in linknamespace test failures:

[initial] __sqrt -> [libm.a(w_sqrt.o)] __ieee754_sqrt ->
[libm.a(e_sqrt.o)] __feholdexcept -> [libm.a(feholdexcpt.o)] fegetenv

This patch fixes this by making __feholdexcept call __fegetenv instead
of fegetenv.

Tested for Alpha (compilation only).

[BZ #20768]
* sysdeps/alpha/fpu/feholdexcpt.c (__feholdexcept): Call
__fegetenv instead of fegetenv.

7 years agoDo not hardcode platform names in manual/libm-err-tab.pl (bug 14139).
Joseph Myers [Fri, 4 Nov 2016 16:49:06 +0000 (16:49 +0000)]
Do not hardcode platform names in manual/libm-err-tab.pl (bug 14139).

manual/libm-err-tab.pl hardcodes a list of names for particular
platforms (mapping from sysdeps directory name to friendly name for
the manual).  This goes against the principle of keeping information
about individual platforms in their corresponding sysdeps directory,
and the list is also very out-of-date regarding supported platforms
and their corresponding sysdeps directories.

This patch fixes this by adding a libm-test-ulps-name file alongside
each libm-test-ulps file.  The script then gets the friendly name from
that file, which is required to exist, so it no longer needs to allow
for the mapping being missing.

Tested for x86_64.

[BZ #14139]
* manual/libm-err-tab.pl (%pplatforms): Initialize to empty.
(find_files): Obtain platform name from libm-test-ulps-name and
store in %pplatforms.
(canonicalize_platform): Remove.
(print_platforms): Use $pplatforms directly.
(by_platforms): Do not allow for platforms missing from
%pplatforms.
* sysdeps/aarch64/libm-test-ulps-name: New file.
* sysdeps/alpha/fpu/libm-test-ulps-name: Likewise.
* sysdeps/arm/libm-test-ulps-name: Likewise.
* sysdeps/generic/libm-test-ulps-name: Likewise.
* sysdeps/hppa/fpu/libm-test-ulps-name: Likewise.
* sysdeps/i386/fpu/libm-test-ulps-name: Likewise.
* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps-name: Likewise.
* sysdeps/ia64/fpu/libm-test-ulps-name: Likewise.
* sysdeps/m68k/coldfire/fpu/libm-test-ulps-name: Likewise.
* sysdeps/m68k/m680x0/fpu/libm-test-ulps-name: Likewise.
* sysdeps/microblaze/libm-test-ulps-name: Likewise.
* sysdeps/mips/mips32/libm-test-ulps-name: Likewise.
* sysdeps/mips/mips64/libm-test-ulps-name: Likewise.
* sysdeps/nios2/libm-test-ulps-name: Likewise.
* sysdeps/powerpc/fpu/libm-test-ulps-name: Likewise.
* sysdeps/powerpc/nofpu/libm-test-ulps-name: Likewise.
* sysdeps/s390/fpu/libm-test-ulps-name: Likewise.
* sysdeps/sh/libm-test-ulps-name: Likewise.
* sysdeps/sparc/fpu/libm-test-ulps-name: Likewise.
* sysdeps/tile/libm-test-ulps-name: Likewise.
* sysdeps/x86_64/fpu/libm-test-ulps-name: Likewise.

7 years agoMake MIPS <sys/user.h> self-contained.
Joseph Myers [Fri, 4 Nov 2016 16:44:23 +0000 (16:44 +0000)]
Make MIPS <sys/user.h> self-contained.

The check-installed-headers tests show up that the MIPS <sys/user.h>
is not self-contained, using size_t without including any header that
defines it.  This patch fixes it by including <stddef.h>, as done for
other architectures' versions of this header.

Tested for MIPS (all 24 ABIs, compilation only).

* sysdeps/unix/sysv/linux/mips/sys/user.h: Include <stddef.h>.

7 years agoXFAIL check-execstack for MIPS.
Joseph Myers [Fri, 4 Nov 2016 16:42:37 +0000 (16:42 +0000)]
XFAIL check-execstack for MIPS.

This patch marks the check-execstack test as expected to fail for
MIPS, with a comment referencing previous RFC discussion of the
changes that would be needed to support non-executable stacks on MIPS.

Tested for MIPS (all 24 ABIs).

* sysdeps/unix/sysv/linux/mips/Makefile [$(subdir) = elf]
(test-xfail-check-execstack): New variable.

7 years agoAdd localplt.data for MIPS.
Joseph Myers [Fri, 4 Nov 2016 16:40:54 +0000 (16:40 +0000)]
Add localplt.data for MIPS.

This patch adds a localplt.data file for MIPS, reflecting the
peculiarities of MIPS ELF that mean this test cannot detect PLT
entries (there aren't any in shared libraries), not GOT entries
(because of the implicit relocation).

Tested for MIPS (all 24 ABIs).

* sysdeps/mips/localplt.data: New file.

7 years agoDefine wordsize.h macros everywhere
Steve Ellcey [Fri, 4 Nov 2016 16:37:44 +0000 (09:37 -0700)]
Define wordsize.h macros everywhere

* bits/wordsize.h: Add documentation.
* sysdeps/aarch64/bits/wordsize.h : New file
* sysdeps/generic/stdint.h (PTRDIFF_MIN, PTRDIFF_MAX): Update
definitions.
(SIZE_MAX): Change ifdef to if in __WORDSIZE32_SIZE_ULONG check.
* sysdeps/gnu/bits/utmp.h (__WORDSIZE_TIME64_COMPAT32): Check
with #if instead of #ifdef.
* sysdeps/gnu/bits/utmpx.h (__WORDSIZE_TIME64_COMPAT32): Ditto.
* sysdeps/mips/bits/wordsize.h (__WORDSIZE32_SIZE_ULONG,
__WORDSIZE32_PTRDIFF_LONG, __WORDSIZE_TIME64_COMPAT32):
Add or change defines.
* sysdeps/powerpc/powerpc32/bits/wordsize.h: Likewise.
* sysdeps/powerpc/powerpc64/bits/wordsize.h: Likewise.
* sysdeps/s390/s390-32/bits/wordsize.h: Likewise.
* sysdeps/s390/s390-64/bits/wordsize.h: Likewise.
* sysdeps/sparc/sparc32/bits/wordsize.h: Likewise.
* sysdeps/sparc/sparc64/bits/wordsize.h: Likewise.
* sysdeps/tile/tilegx/bits/wordsize.h: Likewise.
* sysdeps/tile/tilepro/bits/wordsize.h: Likewise.
* sysdeps/unix/sysv/linux/alpha/bits/wordsize.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/wordsize.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/wordsize.h: Likewise.
* sysdeps/wordsize-32/bits/wordsize.h: Likewise.
* sysdeps/wordsize-64/bits/wordsize.h: Likewise.
* sysdeps/x86/bits/wordsize.h: Likewise.

7 years agoAn optimized memchr was missing for AArch64. This version is similar to
Wilco Dijkstra [Fri, 4 Nov 2016 14:37:10 +0000 (14:37 +0000)]
An optimized memchr was missing for AArch64.  This version is similar to
strchr and is significantly faster than the C version.

2016-11-04  Wilco Dijkstra  <wdijkstr@arm.com>
    Kevin Petit  <kevin.petit@arm.com>

* sysdeps/aarch64/memchr.S (__memchr): New file.

7 years agoHandle tilegx* machine names.
Joseph Myers [Fri, 4 Nov 2016 13:32:06 +0000 (13:32 +0000)]
Handle tilegx* machine names.

This patch makes sysdeps/tile/preconfigure handle tilegx* machine
names instead of just plain tilegx.  That matches GCC, and in
particular allows a big-endian toolchain to use the tilegxbe-linux-gnu
name when configuring both GCC and glibc.

Tested with compilation for tilegxbe-linux-gnu, both 32-bit and 64-bit
(building a subsequent GCC against that glibc still falls over because
of both 32-bit and 64-bit libraries going in the lib directory, as
noted at
<https://sourceware.org/ml/libc-alpha/2016-11/msg00129.html>).

* sysdeps/tile/preconfigure: Accept tilegx* instead of tilegx.

7 years agoFix linknamespace parallel test failures.
Joseph Myers [Thu, 3 Nov 2016 22:47:02 +0000 (22:47 +0000)]
Fix linknamespace parallel test failures.

Having found that with my script to build many glibc variants I could
reproduce the linknamespace test failures in parallel builds (that
various people had previously reported but I hadn't seen myself), I
investigated those failures further.  This patch adds a missing
dependency to those tests.

Tested for x86_64, including the configuration where I saw those
failures and where I don't see them with this patch.

* conform/Makefile ($(linknamespace-header-tests)): Also depend on
$(linknamespace-symlists-tests).

7 years agoFix -Wformat-length warning in time/tst-strptime2.c
Steve Ellcey [Wed, 2 Nov 2016 23:00:39 +0000 (16:00 -0700)]
Fix -Wformat-length warning in time/tst-strptime2.c

* time/tst-strptime2.c: Ignore -Wformat-length warning.

7 years agoBug 20729: Fix build failures on ppc64 and other arches.
Carlos O'Donell [Wed, 2 Nov 2016 17:01:36 +0000 (13:01 -0400)]
Bug 20729: Fix build failures on ppc64 and other arches.

The changes to fix bug 20729 introduced an error which removed an
ignore diagnostic from -O2 by using the new -Os related macro.
This broke ppc64 builds. This commit fixes the mistake.

Tested on x86, x86_64, ppc64, ppc64le, arm, aarch64, and s390x.

7 years agoFix warning from latest GCC in tst-printf.c
Steve Ellcey [Tue, 1 Nov 2016 23:00:09 +0000 (16:00 -0700)]
Fix warning from latest GCC in tst-printf.c

* stdio-common/tst-printf.c: Ignore -Wformat-length warning.

7 years agoCorrect clog10 documentation (bug 19673).
Joseph Myers [Tue, 1 Nov 2016 18:38:52 +0000 (18:38 +0000)]
Correct clog10 documentation (bug 19673).

Bug 19673 reports that the documentation of clog10 is incorrect, both
failing to include the division by log (10) in the imaginary part and,
in the non-TeX version of the equation only, describing the LHS as log
rather than log10.

This patch fixes both issues.  Note: I think it's appropriate that the
LHS says log10 not clog10, and that the cexp and clog descriptions
referred to in a comment in that bug report similarly say exp and log;
this is a mathematical description not a literal C one.

Tested for x86_64.

[BZ #19673]
* manual/math.texi (Exponents and Logarithms): Correct description
of clog10.

7 years agoBug 20729: Include libc-internal.h where required.
Carlos O'Donell [Mon, 31 Oct 2016 20:46:57 +0000 (16:46 -0400)]
Bug 20729: Include libc-internal.h where required.

The original fix for bug 20729 failed to include
libc-internal.h in the files that needed them and
this caused build failures on machines that don't
implicitly include this header. This commit fixes
that by following the consensus rule that a header,
if needed, should always be directly included.

7 years agohurd: Fix spurious port deallocation
Brent W. Baccala [Mon, 31 Oct 2016 16:31:56 +0000 (17:31 +0100)]
hurd: Fix spurious port deallocation

* sysdeps/mach/hurd/dl-sysdep.c (__mmap): Do not deallocate memobj_wr
when it is MACH_PORT_NULL.

7 years agoProperly initialize glob structure with GLOB_BRACE|GLOB_DOOFFS (bug 20707)
Andreas Schwab [Thu, 20 Oct 2016 08:04:41 +0000 (10:04 +0200)]
Properly initialize glob structure with GLOB_BRACE|GLOB_DOOFFS (bug 20707)

7 years agoBug 20729: Fix building with -Os.
Carlos O'Donell [Sun, 30 Oct 2016 03:45:40 +0000 (23:45 -0400)]
Bug 20729: Fix building with -Os.

This commit adds a new DIAG_IGNORE_Os_NEEDS_COMMENT which is only
enabled when compiling with -Os. This allows developers working on
-Os enabled builds to mark false-positive warnings without impacting the
warnings emitted at -O2.

Then using the new DIAG_IGNORE_Os_NEEDS_COMMENT we fix 6 warnings
generated with GCC 5 to get -Os builds working again.

7 years agoAdd include/crypt.h.
Carlos O'Donell [Fri, 28 Oct 2016 20:17:30 +0000 (16:17 -0400)]
Add include/crypt.h.

To support tests that include crypt.h we add a wrapper.

7 years agoFix warning caused by unused-result in bug-atexit3-lib.cc
Gabriel F T Gomes [Fri, 28 Oct 2016 17:57:15 +0000 (15:57 -0200)]
Fix warning caused by unused-result in bug-atexit3-lib.cc

The test case dlfcn/bug-atexit3-lib.cc calls write and doesn't check the
result.  When building with GCC 6.2, this generates a warning in 'make
check', which is treated as an error.  This patch replaces the call to
write with a call to write_message.

Tested for powerpc64le.

7 years agoAdd SNAN, SNANF, SNANL macros.
Joseph Myers [Fri, 28 Oct 2016 21:15:26 +0000 (21:15 +0000)]
Add SNAN, SNANF, SNANL macros.

TS 18661-1 defines SNAN macros for signaling NaN values, suitable for
use in static initializers.  This patch adds them to glibc's <math.h>
(provided you are building with GCC 3.3 or later; no attempt is made
to provide any kind of nonconforming fallback for older compilers
without the __builtin_nans functions).

Tested for x86_64 and x86.

* math/math.h
[__GLIBC_USE (IEC_60559_BFP_EXT) && __GNUC_PREREQ (3, 3)] (SNANF):
New macro.
[__GLIBC_USE (IEC_60559_BFP_EXT) && __GNUC_PREREQ (3, 3)] (SNAN):
Likewise.
[__GLIBC_USE (IEC_60559_BFP_EXT) && __GNUC_PREREQ (3, 3)] (SNANL):
Likewise.
* manual/arith.texi (Infinity and NaN): Document SNANF, SNAN and
SNANL.
* math/test-double.h (snan_value_MACRO): New macro.
* math/test-float.h (snan_value_MACRO): Likewise.
* math/test-ldouble.h (snan_value_MACRO): Likewise.
* math/libm-test.inc (issignaling_test_data): Add tests of
snan_value_MACRO.

7 years agoDocument a behavior of an elided pthread_rwlock_unlock
Tulio Magno Quites Machado Filho [Fri, 28 Oct 2016 20:31:24 +0000 (18:31 -0200)]
Document a behavior of an elided pthread_rwlock_unlock

Explain that pthread_rwlock_unlock may crash if called on a lock not
held by the current thread.

7 years agopowerpc: Fix TOC stub on powerpc64 clone()
Tulio Magno Quites Machado Filho [Fri, 21 Oct 2016 17:19:10 +0000 (15:19 -0200)]
powerpc: Fix TOC stub on powerpc64 clone()

Use a function call to _exit() so that the linker can create a TOC stub
instead of just a branch.

Tested on powerpc64.

7 years agomalloc: Update comments about chunk layout
Florian Weimer [Fri, 28 Oct 2016 20:36:58 +0000 (22:36 +0200)]
malloc: Update comments about chunk layout

7 years agocrypt: Use internal names for the SHA-2 block functions
Florian Weimer [Fri, 28 Oct 2016 19:47:44 +0000 (21:47 +0200)]
crypt: Use internal names for the SHA-2 block functions

These functions are externally visible with a static libcrypt
library.

7 years agoFix building tst-linkall-static.
Carlos O'Donell [Fri, 28 Oct 2016 18:27:52 +0000 (14:27 -0400)]
Fix building tst-linkall-static.

The crypt/ directory is not added as part of the sysdep directories.
Add it when building tst-linkall-static to include crypt.h.

7 years agoAdd missing include for stdlib.h.
Carlos O'Donell [Fri, 28 Oct 2016 16:43:15 +0000 (12:43 -0400)]
Add missing include for stdlib.h.

The test math/test-nan-overflow uses malloc without including
stdlib.h. On -Os builds for i486 the header inclusion order
is altered enough that the test fails to build because of the
warning which is turned into an error.

The obvious fix is to include stdlib.h since malloc is being
used directly.

7 years agoCheck IFUNC definition in unrelocated shared library [BZ #20019]
H.J. Lu [Fri, 28 Oct 2016 16:11:55 +0000 (09:11 -0700)]
Check IFUNC definition in unrelocated shared library [BZ #20019]

Calling an IFUNC function defined in unrelocated shared library may
lead to segfault.  This patch issues an error message to request
relinking the shared library if it references IFUNC function defined
in the unrelocated shared library.

[BZ #20019]
* sysdeps/i386/dl-machine.h (elf_machine_rel): Check IFUNC
definition in unrelocated shared library.
* sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.

7 years agoi386: Support CFLAGS which imply -fno-omit-frame-pointer [BZ #20729]
Florian Weimer [Fri, 28 Oct 2016 15:04:57 +0000 (17:04 +0200)]
i386: Support CFLAGS which imply -fno-omit-frame-pointer [BZ #20729]

7 years agoAdd test for linking against most static libraries
Florian Weimer [Fri, 28 Oct 2016 12:03:57 +0000 (14:03 +0200)]
Add test for linking against most static libraries

7 years agosysmalloc: Initialize previous size field of mmaped chunks
Florian Weimer [Thu, 27 Oct 2016 17:45:19 +0000 (19:45 +0200)]
sysmalloc: Initialize previous size field of mmaped chunks

With different encodings of the header, the previous zero initialization
may be insufficient and produce an invalid encoding.

7 years agomalloc: Use accessors for chunk metadata access
Florian Weimer [Fri, 28 Oct 2016 14:26:57 +0000 (16:26 +0200)]
malloc: Use accessors for chunk metadata access

This change allows us to change the encoding of these struct members
in a centralized fashion.

7 years agoMake strtod raise "inexact" exceptions (bug 19380).
Joseph Myers [Fri, 28 Oct 2016 00:40:23 +0000 (00:40 +0000)]
Make strtod raise "inexact" exceptions (bug 19380).

The strtod function should raise the "inexact" exception when its
result is inexact, but fails to do so except in the case of underflow
or overflow.  This patch fixes it to do so for all inexact results.

tst-strtod-round is extended to test for this exception; the generator
is fixed to properly mark inexact results as such in the case where
the inexactness is from the mpfr_subnormalize step.

Tested for x86_64, x86 and powerpc.

[BZ #19380]
* stdlib/strtod_l.c (round_and_return): Force "inexact" exception
for inexact results.
* stdlib/gen-tst-strtod-round.c (string_to_fp): Return indication
of inexact result where mpfr_subnormalize is the only inexact
step.
* stdlib/tst-strtod-round-data.h: Regenerated.
* stdlib/tst-strtod-round-skeleton.c [!FE_INEXACT] (FE_INEXACT):
Define to 0.
(GEN_ONE_TEST): Test inexact exceptions raised are as expected.

7 years agoFix a sparc header conformtest failure.
David S. Miller [Thu, 27 Oct 2016 14:57:49 +0000 (07:57 -0700)]
Fix a sparc header conformtest failure.

* sysdeps/unix/sysv/linux/sparc/sys/user.h: Include stddef.h

7 years agoStatic inline functions for mallopt helpers
Siddhesh Poyarekar [Thu, 27 Oct 2016 03:04:55 +0000 (08:34 +0530)]
Static inline functions for mallopt helpers

Make mallopt helper functions for each mallopt parameter so that it
can be called consistently in other areas, like setting tunables.

* malloc/malloc.c (do_set_mallopt_check): New function.
(do_set_mmap_threshold): Likewise.
(do_set_mmaps_max): Likewise.
(do_set_top_pad): Likewise.
(do_set_perturb_byte): Likewise.
(do_set_trim_threshold): Likewise.
(do_set_arena_max): Likewise.
(do_set_arena_test): Likewise.
(__libc_mallopt): Use them.

7 years agoAdd canonicalize, canonicalizef, canonicalizel.
Joseph Myers [Wed, 26 Oct 2016 23:14:31 +0000 (23:14 +0000)]
Add canonicalize, canonicalizef, canonicalizel.

TS 18661-1 defines canonicalize functions to produce a canonical
version of a floating-point representation.  This patch implements
these functions for glibc.

As with the iscanonical macro, these functions are oriented to the
decimal floating-point case, where some values have both canonical and
noncanonical representations.  However, the functions have a return
value that says whether they succeeded in storing a canonical result;
thus, they can fail for the case of an invalid representation (while
still not making any particular choice from among multiple equally
canonical valid representations of the same value).  Since no
floating-point formats in glibc actually have noncanonical valid
representations, a type-generic implementation of these functions can
be used that expects iscanonical to return 0 only for invalid
representations.  Now that iscanonical is used within libm.so,
libm_hidden_proto / libm_hidden_def are added for __iscanonicall.

The definition of these functions is intended to correspond to a
convertFormat operation to the same floating-point format.  Thus, they
convert signaling NaNs to quiet NaNs, raising the "invalid" exception.
Such a conversion "should" produce "the canonical version of that
signaling NaN made quiet".

libm-test.inc is made to check NaN payloads for the output of these
functions, a new feature (at some point manipulation functions such as
fabs and copysign should have tests added that verify payload
preservation for them).  As however some architectures may not follow
the recommended practice of preserving NaN payloads when converting a
signaling NaN to quiet, a new math-tests.h macro
SNAN_TESTS_PRESERVE_PAYLOAD is added, and defined to 0 for non-NAN2008
MIPS; any other architectures seeing test failures for lack of payload
preservation in this case should also define this macro to 0.  (If any
cases arise where the sign isn't preserved either, those should have a
similar macro added.)

The ldbl-96 and ldbl-128ibm tests of iscanonical are renamed and
adapted to test canonicalizel as well on the same representations.

Tested for x86_64, x86, mips64 and powerpc.

* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(canonicalize): New declaration.
* math/Versions (canonicalize): New libm symbol at version
GLIBC_2.25.
(canonicalizef): Likewise.
(canonicalizel): Likewise.
* math/Makefile (gen-libm-calls): Add s_canonicalizeF.
* math/s_canonicalize_template.c: New file.
* math/libm-test.inc: Update comment on functions tested and
testing of NaN payloads.
(TEST_NAN_PAYLOAD): New macro.
(NO_TEST_INLINE): Update value.
(XFAIL_TEST): Likewise.
(ERRNO_UNCHANGED): Likewise.
(ERRNO_EDOM): Likewise.
(ERRNO_ERANGE): Likewise.
(IGNORE_RESULT): Likewise.
(NON_FINITE): Likewise.
(TEST_SNAN): Likewise.
(NO_TEST_MATHVEC): Likewise.
(TEST_NAN_PAYLOAD_CANONICALIZE): New macro.
(check_float_internal): Check NaN payloads if TEST_NAN_PAYLOAD.
(struct test_Ffp_b1_data): New type.
(RUN_TEST_Ffp_b1): New macro.
(RUN_TEST_LOOP_Ffp_b1): Likewise.
(canonicalize_test_data): New array.
(canonicalize_test): New function.
(main): Call canonicalize_test.
* manual/arith.texi (FP Bit Twiddling): Document canonicalize,
canonicalizef and canonicalizel.
* manual/libm-err-tab.pl: Update comment on interfaces without
ulps tabulated.
* sysdeps/ieee754/ldbl-opt/nldbl-canonicalize.c: New file.
* sysdeps/ieee754/ldbl-opt/s_canonicalizel.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add
canonicalize.
(CFLAGS-nldbl-canonicalize.c): New variable.
* sysdeps/ieee754/ldbl-128ibm/test-iscanonical-ldbl-128ibm.c: Move
to ...
* sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c:
... here.
(do_test): Also test canonicalizel.
* sysdeps/ieee754/ldbl-128ibm/Makefile (tests): Change
test-iscanonical-ldbl-128ibm to test-canonical-ldbl-128ibm.
* sysdeps/ieee754/ldbl-128ibm/include/bits/iscanonical.h: New
file.
* sysdeps/ieee754/ldbl-128ibm/s_iscanonicall.c (__iscanonicall):
Use libm_hidden_def.
* sysdeps/ieee754/ldbl-96/test-iscanonical-ldbl-96.c: Move to ...
* sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c: ... here.
(do_test): Also test canonicalizel.
* sysdeps/ieee754/ldbl-96/Makefile (tests): Change
test-iscanonical-ldbl-96 to test-canonical-ldbl-96.
* sysdeps/ieee754/ldbl-96/include/bits/iscanonical.h: New file.
* sysdeps/ieee754/ldbl-96/s_iscanonicall.c (__iscanonicall): Use
libm_hidden_def.
* sysdeps/generic/math-tests.h (SNAN_TESTS_PRESERVE_PAYLOAD): New
macro.
* sysdeps/mips/math-tests.h [__mips_hard_float && !__mips_nan2008]
(SNAN_TESTS_PRESERVE_PAYLOAD): Likewise.
* sysdeps/nacl/libm.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.

7 years agoAdd getpayloadl to libnldbl.
Joseph Myers [Wed, 26 Oct 2016 17:10:00 +0000 (17:10 +0000)]
Add getpayloadl to libnldbl.

This patch adds getpayloadl to libnldbl, missed in my patch that
originally implemented getpayload functions.

Tested for powerpc.

* sysdeps/ieee754/ldbl-opt/nldbl-getpayload.c: New file.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add
getpayload.
(CFLAGS-nldbl-getpayload.c): New variable.

7 years agoUse read_int in vfscanf
Gabriel F. T. Gomes [Tue, 20 Sep 2016 17:19:27 +0000 (14:19 -0300)]
Use read_int in vfscanf

The function read_int, from printf-parse.h, parses an integer from a string
while avoiding overflows.  It is used by other functions, such as vfprintf,
to avoid undefined behavior.

The function vfscanf (_IO_vfwscanf) parses an integer from the format
string, and can use read_int.

7 years agomalloc: Remove malloc_get_state, malloc_set_state [BZ #19473]
Florian Weimer [Wed, 26 Oct 2016 11:28:28 +0000 (13:28 +0200)]
malloc: Remove malloc_get_state, malloc_set_state [BZ #19473]

After the removal of __malloc_initialize_hook, newly compiled
Emacs binaries are no longer able to use these interfaces.
malloc_get_state is only used during the Emacs build process,
so we provide a stub implementation only.  Existing Emacs binaries
will not call this stub function, but still reference the symbol.

The rewritten tst-mallocstate test constructs a dumped heap
which should approximates what existing Emacs binaries pass
to glibc malloc.

7 years agoiconv: Avoid writable data and relocations in ISO646
Florian Weimer [Wed, 26 Oct 2016 09:43:21 +0000 (11:43 +0200)]
iconv: Avoid writable data and relocations in ISO646

7 years agoiconv: Avoid writable data and relocations in IBM charsets
Florian Weimer [Wed, 26 Oct 2016 08:44:50 +0000 (10:44 +0200)]
iconv: Avoid writable data and relocations in IBM charsets

The IBM930, IBM933, IBM935 and IBM939 converters defined lookup
tables which were not constant.  They also contained an
unnecessary pointer indirection.

7 years agoRemove redundant definitions of M_ARENA_* macros
Siddhesh Poyarekar [Wed, 26 Oct 2016 09:37:33 +0000 (15:07 +0530)]
Remove redundant definitions of M_ARENA_* macros

The M_ARENA_MAX and M_ARENA_TEST macros are defined in malloc.c as
well as malloc.h, and the former is unnecessary.  This patch removes
the duplicate.  Tested on x86_64 to verify that the generated code
remains unchanged barring changed line numbers to __malloc_assert.

* malloc/malloc.c (M_ARENA_TEST, M_ARENA_MAX): Remove.

7 years agoRemove references to sbrk to grow/shrink arenas
Siddhesh Poyarekar [Wed, 26 Oct 2016 09:37:07 +0000 (15:07 +0530)]
Remove references to sbrk to grow/shrink arenas

The manual incorrectly references sbrk as the method used to grow and
shrink heaps and the fact that M_TRIM_THRESHOLD and M_TOP_PAD control
that behavior.  In reality, a heap may be grown or shrunk through
multiple methods depending on whether it is the main arena (in which
case sbrk is correct) or not (in which case, there are a number of
strategies including allocating an additional heap to grow an arena
and/or 'mprotect' a region to make it available for allocation).

Remove references to sbrk so that it covers the behavior more
accurately.

* manual/memory.texi (M_TOP_PAD): Remove reference to sbrk.
(M_TRIM_THRESHOLD): Likewise.

7 years agoDocument the M_ARENA_* mallopt parameters
Siddhesh Poyarekar [Wed, 26 Oct 2016 09:36:21 +0000 (15:06 +0530)]
Document the M_ARENA_* mallopt parameters

The M_ARENA_* mallopt parameters are in wide use in production to
control the number of arenas that a long lived process creates and
hence there is no point in stating that this interface is non-public.
Document this interface and remove the obsolete comment.

* manual/memory.texi (M_ARENA_TEST): Add documentation.
(M_ARENA_MAX): Likewise.
* malloc/malloc.c: Remove obsolete comment.

7 years agoAdd note on MALLOC_MMAP_* environment variables
Siddhesh Poyarekar [Wed, 26 Oct 2016 09:35:37 +0000 (15:05 +0530)]
Add note on MALLOC_MMAP_* environment variables

The mallopt parameters manual does not mention the environment
variables that can be used to set these parameters at program startup.
Mention those environment variables for completeness.

* manual/memory.texi: Add environment variable alternatives to
setting mallopt parameters.

7 years agoFix atomic_fetch_xor_release.
Carlos O'Donell [Wed, 26 Oct 2016 04:00:13 +0000 (00:00 -0400)]
Fix atomic_fetch_xor_release.

No code uses atomic_fetch_xor_release except for the upcoming
conditional variable rewrite. Therefore there is no user
visible bug here. The use of atomic_compare_and_exchange_bool_rel
is removed (since it doesn't exist anymore), and is replaced
by atomic_compare_exchange_weak_release.

We use weak_release because it provides better performance in
the loop (the weak semantic) and because the xor is release MO
(the release semantic). We don't reload expected in the loop
because atomic_compare_and_exchange_weak_release does this for
us as part of the CAS failure.

It is otherwise a fairly plain conversion that fixes building
the new condvar for 32-bit x86. Passes all regression tests
for x86.

7 years agoAdd tests for strfrom functions
Rajalakshmi Srinivasaraghavan [Sat, 22 Oct 2016 13:39:46 +0000 (19:09 +0530)]
Add tests for strfrom functions

7 years agoRefactor strtod tests
Rajalakshmi Srinivasaraghavan [Tue, 30 Aug 2016 06:13:21 +0000 (11:43 +0530)]
Refactor strtod tests

This patch changes strtod* tests to use strfrom* functions.

7 years agoAdd strfromd, strfromf, and strfroml functions
Gabriel F. T. Gomes [Tue, 28 Jun 2016 20:30:42 +0000 (17:30 -0300)]
Add strfromd, strfromf, and strfroml functions

ISO/IEC TS 18661-1 adds several functions in the strfrom family to stdlib.
This patch adds strfromd, strfromf, and strfroml.  This is being done in
preparation for the new floating-point type, float128.  The added functions
convert a floating-point value into a string, with configurable format.

7 years agoFix cmpli usage in power6 memset.
Joseph Myers [Tue, 25 Oct 2016 15:54:16 +0000 (15:54 +0000)]
Fix cmpli usage in power6 memset.

Building glibc for powerpc64 with recent (2.27.51.20161012) binutils,
with multi-arch enabled, I get the error:

../sysdeps/powerpc/powerpc64/power6/memset.S: Assembler messages:
../sysdeps/powerpc/powerpc64/power6/memset.S:254: Error: operand out of range (5 is not between 0 and 1)
../sysdeps/powerpc/powerpc64/power6/memset.S:254: Error: operand out of range (128 is not between 0 and 31)
../sysdeps/powerpc/powerpc64/power6/memset.S:254: Error: missing operand

Indeed, cmpli is documented as a four-operand instruction, and looking
at nearby code it seems likely cmpldi was intended.  This patch fixes
this powerpc64 code accordingly, and makes a corresponding change to
the powerpc32 code.

Tested for powerpc, powerpc64 and powerpc64le by Tulio Magno Quites
Machado Filho

* sysdeps/powerpc/powerpc32/power6/memset.S (memset): Use cmplwi
instead of cmpli.
* sysdeps/powerpc/powerpc64/power6/memset.S (memset): Use cmpldi
instead of cmpli.

7 years ago * sysdeps/unix/sysv/linux/fxstat.c: Remove useless cast.
Yury Norov [Mon, 24 Oct 2016 21:36:53 +0000 (14:36 -0700)]
* sysdeps/unix/sysv/linux/fxstat.c: Remove useless cast.
* sysdeps/unix/sysv/linux/lxstat.c: Likewise.
* sysdeps/unix/sysv/linux/xstat.c: Likewise.
* sysdeps/unix/sysv/linux/i386/fxstat.c: Likewise.
* sysdeps/unix/sysv/linux/i386/lxstat.c: Likewise.
* sysdeps/unix/sysv/linux/i386/xstat.c: Likewise.

7 years agoFix Linux sh4 pread/pwrite argument passing
Adhemerval Zanella [Fri, 21 Oct 2016 21:29:18 +0000 (19:29 -0200)]
Fix Linux sh4 pread/pwrite argument passing

Although conceptually correct for p{read,write}{64} offset argument passing,
sh4 implementation does not generate the correct expected code.  The
__ALIGNMENT_ARG redefinition is incorrect for two reasons: 1. the
kernel-features.h header is included multiple times (since it contains no
guards) and 2. the value it redefines is also incorrect (should be '0, '
instead of empty definition).

This patch fixes it by adding another macro, SYSCALL_LL_PRW{64}, meant to be
used to pass the offset argument on p{read,write}64.  It is basically the
already define SYSCALL_LL{64} plus __ALIGNMENT_ARG unless __ASSUME_PRW_DUMMY_ARG
is define.  In this case an empty dummy argument is used regardless how
__ALIGNMENT_ARG is defined (sh4 case).

Checked on x86_64, i686, aarch64, armhf, and powerpc64le (basically a sanity
check).  Also, John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> and
James Clarke <jrtc27@jrtc27.com> help me check on a debian sh4 bootstrap using
2.24 plus this patch to verify it also corrected fixed the regression issue.

I also verified the generated object for a 2.24 build and master with this
patch for sh4 and both look identical.

* sysdeps/unix/sysv/linux/pread.c (__libc_pread): Use SYSCALL_LL_PRW.
* sysdeps/unix/sysv/linux/pwrite.c (__libc_pwrite): Likewise.
* sysdeps/unix/sysv/linux/pread64.c (__libc_pread64): Use
SYSCALL_LL64_PRW.
* sysdeps/unix/sysv/linux/pwrite64.c (__libc_pwrite64): Likewise.
* sysdeps/unix/sysv/linux/sh/kernel-features.h: Define
__ASSUME_PRW_DUMMY_ARG.
* sysdeps/unix/sysv/linux/sh/pread.c: Remove file.
* sysdeps/unix/sysv/linux/sh/pread64.c: Likewise.
* sysdeps/unix/sysv/linux/sh/pwrite.c: Likewise.
* sysdeps/unix/sysv/linux/sh/pwrite64.c: Likewise.
* sysdeps/unix/sysv/linux/sysdep.h: Define SYSCALL_LL_PRW and
SYSCALL_LL_PRW64 based on __ASSUME_PRW_DUMMY_ARG.

7 years agoFix -Wformat-length warning in tst-setgetname.c
Steve Ellcey [Mon, 24 Oct 2016 16:43:54 +0000 (09:43 -0700)]
Fix -Wformat-length warning in tst-setgetname.c

* sysdeps/unix/sysv/linux/tst-setgetname.c: Increase buffer size.

7 years agomath.h: Wrap C++ bits in extern "C++"
Florian Weimer [Sat, 22 Oct 2016 15:33:26 +0000 (17:33 +0200)]
math.h: Wrap C++ bits in extern "C++"

It is still common to include system header files in an extern "C"
block.  This means that exiting <math.h>'s own extern "C" block
is not sufficient to get back to C++ mode.  Use an extern "C++"
wrapper instead.

7 years agoUse -fno-builtin for sqrt benchmark.
Joseph Myers [Fri, 21 Oct 2016 21:18:03 +0000 (21:18 +0000)]
Use -fno-builtin for sqrt benchmark.

This patch makes the sqrt benchmark use -fno-builtin, as already done
for benchmarks of ffs and ffsll, so that it actually benchmarks the
glibc function as (presumably) intended even in the presence of the
compiler inlining sqrt.

Tested for x86_64 and also used for benchmarking my ARM sqrt patch.

* benchtests/Makefile (CFLAGS-bench-sqrt.c): New variable.

7 years agopowerpc: Cleanup fenv_private.h
Paul Murphy [Fri, 10 Jun 2016 19:50:32 +0000 (14:50 -0500)]
powerpc: Cleanup fenv_private.h

Some of the masks are wrong, and the naming is confusing.

There are two basic cases we really care about:

1. Stacking a new rounding mode when running certain
   sections of code, and pausing exception handling.

2. Likewise, but discarding any exceptions which occur
   while running under the new rounding mode.

libc_feholdexcept_setround_ppc_ctx has been removed as it basically
does the same thing as libc_feholdsetround_ppc_ctx but also clearing
any sticky bits.  The restore behavior is what differentiates these
two cases as the SET_RESTORE_ROUND{,_NOEX} macros will either merge
or discard all exceptions occurring during scope of their usage.

Likewise, there are a number of routines to swap, replace,
or merge FP environments.  This change reduces much of
the common and sometimes wrong code.

Tested on ppc64le, with results before and after.

7 years agomath: Define iszero as a function template for C++ [BZ #20715]
Florian Weimer [Fri, 21 Oct 2016 16:26:53 +0000 (18:26 +0200)]
math: Define iszero as a function template for C++ [BZ #20715]

This increases compatibility with C++ code which is forced to
compile with _GNU_SOURCE.

7 years agoUse VSQRT instruction for ARM sqrt (bug 20660).
Joseph Myers [Thu, 20 Oct 2016 23:24:44 +0000 (23:24 +0000)]
Use VSQRT instruction for ARM sqrt (bug 20660).

This patch makes ARM sqrt and sqrtf use the VSQRT VFP square root
instruction when available, instead of much larger generic code for
computing square roots.

Now, GCC will normally inline sqrt calls except for negative arguments
where errno needs to be set, and because the benchtests fail to use
-fno-builtin that means no significant difference in benchmark results
for sqrt (note, however, there are lots of __ieee754_sqrt calls
internally in libm, which are *not* inlined - although some
architectures define __ieee754_sqrt in their math_private.h for that
purpose, ARM doesn't - so improving out-of-line sqrt performance is
still relevant to those other functions, if not for most ordinary
direct users of sqrt).  With the benchtests changed to use
-fno-builtin for sqrt tests, typical performance results before the
change are ("max" is wildly varying in any case):

    "duration": 9.88358e+09,
    "iterations": 4.8783e+07,
    "max": 457.764,
    "min": 183.105,
    "mean": 202.603

and after it are:

    "duration": 9.45663e+09,
    "iterations": 2.24385e+08,
    "max": 274.659,
    "min": 30.517,
    "mean": 42.1447

Tested for ARM (hard-float and soft-float).

[BZ #20660]
* sysdeps/arm/e_sqrt.c: New file.
* sysdeps/arm/e_sqrtf.c: Likewise.

7 years agoStop powerpc copysignl raising "invalid" for sNaN argument (bug 20718).
Joseph Myers [Wed, 19 Oct 2016 22:58:34 +0000 (22:58 +0000)]
Stop powerpc copysignl raising "invalid" for sNaN argument (bug 20718).

The powerpc (hard-float) implementations of copysignl, both 32-bit and
64-bit, raise spurious "invalid" exceptions when the first argument is
a signaling NaN.  copysign functions should never raise exceptions
even for signaling NaNs.

The problem is the use of an fcmpu instruction to test the sign of the
high part of the long double argument.  This patch fixes the functions
to use fsel instead (as used for fabsl following my fixes for a
similar bug there), or to examine the integer representation for older
32-bit processors without fsel.

Tested for powerpc64 and powerpc32 (configurations with and without
fsel used).

[BZ #20718]
* sysdeps/powerpc/powerpc32/fpu/s_copysignl.S (__copysignl): Do
not use floating-point comparisons to test sign.
* sysdeps/powerpc/powerpc64/fpu/s_copysignl.S (__copysignl):
Likewise.

7 years agoAdd getpayload, getpayloadf, getpayloadl.
Joseph Myers [Wed, 19 Oct 2016 01:49:09 +0000 (01:49 +0000)]
Add getpayload, getpayloadf, getpayloadl.

TS 18661-1 defines functions for manipulating the payloads of NaNs.
This patch implements the getpayload functions for glibc; these
extract the NaN payload (from an argument passed as a pointer, for
which corresponding libm-test support is added) and return it in the
same floating-point type.  The return value of these functions is
unspecified for non-NaN arguments; the patch does the simplest thing
to implement, which is that the functions do not check whether the
argument is a NaN and just treat the relevant bits of the
representation as a payload regardless.  A conversion from integer to
floating-point is used to produce the required return value, except in
the ldbl-128 case; as 128-bit integers are not supported for all
configurations using ldbl-128, the code constructs the required
floating-point representation of the return value directly instead.

Tested for x86_64, x86, mips64 and powerpc.

* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(getpayload): New declaration.
* math/Versions (getpayload): New libm symbol at version
GLIBC_2.25.
(getpayloadf): Likewise.
(getpayloadl): Likewise.
* math/Makefile (libm-calls): Add s_getpayloadF.
* math/libm-test.inc: Include <nan-high-order-bit.h>.
(struct test_f_f_data): Add comment.
(RUN_TEST_fp_f): New macro.
(RUN_TEST_LOOP_fp_f): Likewise.
(getpayload_test_data): New array.
(getpayload_test): New function.
(main): Call getpayload_test.
* math/gen-libm-test.pl (parse_args): Handle 'p' in argument
descriptor.
* manual/arith.texi (FP Bit Twiddling): Document getpayload,
getpayloadf and getpayloadl.
* manual/libm-err-tab.pl: Update comment on interfaces without
ulps tabulated.
* sysdeps/ieee754/dbl-64/s_getpayload.c: New file.
* sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c: Likewise.
* sysdeps/ieee754/flt-32/s_getpayloadf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_getpayloadl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_getpayloadl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_getpayloadl.c: Likewise.
* sysdeps/nacl/libm.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.

This page took 0.098255 seconds and 5 git commands to generate.