Commit Graph

20407 Commits

Author SHA1 Message Date
Wilco Dijkstra 8d2030d659 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.
2017-03-23 19:00:02 +00:00
Tulio Magno Quites Machado Filho ca4dc74659 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.
2017-03-23 15:48:59 -03:00
Wainer dos Santos Moschetta fb82116f24 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.
2017-03-23 11:32:29 -03:00
Zack Weinberg b9e8c90875 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.
2017-03-22 08:44:32 -04:00
H.J. Lu c15f8eb50c 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.
2017-03-21 11:00:12 -07:00
Joseph Myers a640393a18 Regenerate INSTALL. 2017-03-21 16:40:16 +00:00
Thorsten Kukuk 261d0141b3 Merge branch 'master' of ssh://sourceware.org/git/glibc
Conflicts:
	ChangeLog
2017-03-21 16:47:00 +01:00
Stefan Liebler e4e26210c3 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"
(ae65d4f3c3) 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.
2017-03-21 16:41:56 +01:00
Thorsten Kukuk 1e4d83f6fe 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>
2017-03-21 15:14:27 +01:00
Joseph Myers 76b2c32a16 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.
2017-03-20 21:30:28 +00:00
Joseph Myers 112039611c 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.
2017-03-20 21:28:16 +00:00
Joseph Myers ba7fe6906d 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.
2017-03-20 17:32:19 +00:00
Mike Frysinger ddc3fb3334 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>
2017-03-20 10:42:34 -04:00
Christian Brauner 15e9a4f378 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>
2017-03-19 17:36:13 +00:00
Joseph Myers 345118d7f5 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.
2017-03-18 00:24:13 +00:00
Joseph Myers 19641dbd61 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.
2017-03-18 00:17:25 +00:00
Joseph Myers 22b72f356d 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.
2017-03-18 00:16:05 +00:00
DJ Delorie 17f487b7af 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.
2017-03-17 15:31:38 -04:00
H.J. Lu b170d2e7ab 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.
2017-03-17 11:38:13 -07:00
Joseph Myers 20409ce5e8 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].
2017-03-17 16:27:03 +00:00
Joseph Myers 0cb521871b 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.
2017-03-17 02:54:59 +00:00
Joseph Myers d19887f8bb Add missing piece to last ChangeLog entry. 2017-03-17 02:50:51 +00:00
Joseph Myers bb5cc234e1 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.
2017-03-17 02:42:16 +00:00
Joseph Myers c33eac51f4 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.
2017-03-17 01:21:10 +00:00
Joseph Myers 33c02810c5 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.
2017-03-17 01:08:27 +00:00
Joseph Myers 0fbca26c39 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.
2017-03-16 17:51:23 +00:00
Tulio Magno Quites Machado Filho 598fe6d9f4 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.
2017-03-16 10:36:37 -03:00
Joseph Myers 2072f5c34e 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.
2017-03-16 13:31:57 +00:00
Steve Ellcey d6fc3f6516 Add ChangeLog entry for aarch64 ifunc support patch.
Forgot to add ChangeLog entry.
2017-03-15 16:48:25 -07:00
Mike Frysinger fbe355fbd1 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.
2017-03-15 16:10:05 -07:00
Joseph Myers e4e52ff059 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.
2017-03-15 22:00:54 +00:00
John David Anglin 5d20a49aac 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
2017-03-15 13:37:16 -07:00
Alexey Neyman 3ab2021fea Fix build with --enable-static-nss [BZ #21088]
Signed-off-by: Alexey Neyman <stilor@att.net>
2017-03-15 13:32:23 -07:00
Alexey Neyman e37fc4aa68 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>
2017-03-15 13:26:13 -07:00
Adhemerval Zanella b36a65e5ca Fix test-errno issues
This patch fixes multiple issues of test-errno.c (9a56f87183):

  - 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.
2017-03-15 17:05:34 -03:00
Joseph Myers ffe308e4fc 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.
2017-03-15 17:32:46 +00:00
Gabriel F. T. Gomes ff80ec4283 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.
2017-03-15 09:39:16 -03:00
Gabriel F. T. Gomes 826aa1346f 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.
2017-03-15 09:39:16 -03:00
Florian Weimer 2bda2d820d support: Explain ignored failures of temporary file removal [BZ #21243] 2017-03-15 13:33:40 +01:00
Florian Weimer ed3ea040ba support: Add error checking to close system calls [BZ #21244] 2017-03-15 13:33:40 +01:00
Florian Weimer f889e73f60 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.
2017-03-15 13:33:40 +01:00
Adhemerval Zanella ed7d6072f2 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.
2017-03-14 16:42:08 -03:00
Andreas Schwab 605c5ef4fb Remove _dl_platform_string
There are no non-trivial uses of _dl_platform_string.
2017-03-14 17:18:52 +01:00
Samuel Thibault 9d067269f5 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.
2017-03-13 20:41:12 +01:00
Adhemerval Zanella c89721e25d 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.
2017-03-13 16:23:25 -03:00
Wilco Dijkstra ae65d4f3c3 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.
2017-03-13 18:45:42 +00:00
Joseph Myers 53a4608f8d 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.
2017-03-13 16:45:23 +00:00
Thorsten Kukuk d50a2c094c Add missing ChangeLog entries. 2017-03-13 17:43:10 +01:00
Alexey Neyman d40dbe722f 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.
2017-03-12 17:29:32 -03:00
Marko Myllynen cb09a3d497 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.
2017-03-12 17:25:00 -03:00
Stefan Liebler 93adfe2d79 Update auto-libm-test-out for catan / catanh.
I've used gmp 6.1.2, mpfr 3.1.5 and upstream mpc with fix in mpc_atan
(https://scm.gforge.inria.fr/anonscm/gitweb?p=mpc/mpc.git;a=commit;h=958aac9b15a659d6fb5edcb11778123f8a35b14f)
to build gen-auto-libm-tests and regenerated  catan / catanh out files.
Regenerated ULPs for s390 from scratch.  Now the catan / catanh tests
are passing.

ChangeLog:

	* math/auto-libm-test-out-catan: Regenerated.
	* math/auto-libm-test-out-catanh: Likewise.
	* sysdeps/s390/fpu/libm-test-ulps: Likewise.
2017-03-10 08:45:29 +01:00
Joseph Myers b24d6d1550 Regenerate MIPS catan, catanh long double ulps.
This patch regenerates MIPS catan and catanh ulps for long double with
fixed expected results for the tests of those functions.  ulps for
other types (which may see variation depending on whether glibc is
built for a processor with fused multiply-add support) are
deliberately not reduced.  ulps are not regenerated for powerpc-nofpu
as such regeneration does not result in any changes for long double.

	* sysdeps/mips/mips64/libm-test-ulps: Update catan and catanh ulps
	for long double with corrected test expectations.
2017-03-09 22:37:47 +00:00
Adhemerval Zanella 60f9423b6b Consolidate Linux send implementation
This patch consolidates the send Linux syscall implementation on
sysdeps/unix/sysv/linux/send{to}.c.  The changes are:

  1. Remove send from auto-generation syscalls.list on the architecture
     that uses __NR_send.
  2. Define __NR_send for architectures that supports it. It was done instead
     of defining in default kernel-features.h because current Linux practice
     for new ports are to implement only __NR_sendto [1] and it will
     require adding new kernel-features for ports that do not require it
     (aarch64 for instance).
  3. Remove __ASSUME_SENDTO_FOR_SEND_SYSCALL and decide to use
     __NR_sendto for send generation based on __ASSUME_SENDTO_SYSCALL.

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/sysdep.h (HAVE_INTERNAL_SEND_SYMBOL):
	Define.
	* sysdeps/unix/sysv/linux/aarch64/sysdep.h
	(HAVE_INTERNAL_SEND_SYMBOL): Undefine.
	* sysdeps/unix/sysv/linux/nios2/sysdep.h
	(HAVE_INTERNAL_SEND_SYMBOL): Likewise.
	* sysdeps/unix/sysv/linux/tile/sysdep.h
	(HAVE_INTERNAL_SEND_SYMBOL): Likewise.
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h
	(__ASSUME_RECV_SYSCALL): Define.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	(__ASSUME_RECV_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/hppa/kernel-features.h
	(__ASSUME_RECV_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/ia64/kernel-features.h
	(__ASSUME_RECV_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	(__ASSUME_RECV_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	(__ASSUME_SENDTO_FOR_SEND_SYSCALL): Remove define.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_SENDTO_FOR_SEND_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h
	(__ASSUME_SENDTO_FOR_SEND_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/alpha/syscalls.list: Remove send from
	auto-generation list.
	* sysdeps/unix/sysv/linux/arm/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewike.
	* sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/send.c: Simplify includes.
	(__ASSUME_SENDTO_FOR_SEND_SYSCALL): Replace by
	__ASSUME_SENDTO_SYSCALL.
	* sysdeps/unix/sysv/linux/x86_64/send.c: Remove file.
	* sysdeps/unix/sysv/linux/mips/mips64/send.c: Likewise.
	* sysdeps/unix/sysv/linux/generic/send.c: Likewise.
2017-03-09 15:22:06 +01:00
Adhemerval Zanella 06cf371e97 Consolidate Linux sendto implementation
This patch consolidates the sendto Linux syscall implementation on
sysdeps/unix/sysv/linux/sendto.c.  The changes are:

   1. Define __ASSUME_SENDTO_SYSCALL by default.
   2. Undef it for architectures that do not support __NR_sendto.

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/alpha/syscalls.list: Remove sendto from
	auto-generation list.
	* sysdeps/unix/sysv/linux/arm/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_SENDTO_SYSCALL): Define by default.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	(__ASSUME_SENDTO_SYSCALL): Undef it is kernel does not support
	__NR_sendto.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_SENDTO_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h
	(__ASSUME_SENDTO_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_SENDTO_SYSCALL): Remove definition.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	(__ASSUME_SENDTO_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h:
	(__ASSUME_SENDTO_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sendto.c: Simplify includes.
2017-03-09 15:22:06 +01:00
Adhemerval Zanella df799d9eb3 Consolidate Linux recv implementation
This patch consolidates the recv Linux syscall implementation on
sysdeps/unix/sysv/linux/recv.c.  The changes are:

  1. Remove recv from auto-generation syscalls.list on the architecture
     that uses __NR_recv.
  2. Define __NR_recv for architectures that supports it.  It was done
     instead of defining in default kernel-features.h because current Linux
     practice for new ports is to implement only __NR_recvfrom [1] and it will
     require adding new kernel-features for ports that do not require it
     (aarch64 for instance).
  3. Remove __ASSUME_RECVFROM_FOR_RECV_SYSCALL and decide to use
     __NR_recvfrom for recv generation based on __ASSUME_RECVFROM_SYSCALL.

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/alpha/syscalls.list: Remove recv from
	auto-generation list.
	* sysdeps/unix/sysv/linux/arm/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h
	(__ASSUME_RECV_SYSCALL): New define.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	(__ASSUME_RECV_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/hppa/kernel-features.h
	(__ASSUME_RECV_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/ia64/kernel-features.h
	(__ASSUME_RECV_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	(__ASSUME_RECV_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	(__ASSUME_RECVFROM_FOR_RECV_SYSCALL): Remove define.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_RECVFROM_FOR_RECV_SYSCALL): Remove define.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h
	(__ASSUME_RECVFROM_FOR_RECV_SYSCALL): Remove define.
	* sysdeps/unix/sysv/linux/generic/recv.c: Remove file.
	* sysdeps/unix/sysv/linux/mips/mips64/recv.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/recv.c: Likewise.
	* sysdeps/unix/sysv/linux/recv.c: Simplify includes.
	(__libc_recv): Use __ASSUME_RECVFROM_SYSCALL instead of
	__ASSUME_RECVFROM_FOR_RECV_SYSCALL to issue recvfrom syscall.

[1] include/asm-generic/unistd.h (__ARCH_WANT_SYSCALL_DEPRECATED)
2017-03-09 15:22:06 +01:00
Adhemerval Zanella 1f8161a801 Consolidate Linux recvfrom implementation
This patch consolidates the recvfrom Linux syscall implementation on
sysdeps/unix/sysv/linux/recvfrom.c.  The changes are:

  1. Define __ASSUME_RECVFROM_SYSCALL by default
  2. Undef it for  architectures that do not support __NR_recvfrom.

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/alpha/syscalls.list: Remove recvfrom from
	auto-generation list.
	* sysdeps/unix/sysv/linux/arm/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_RECVFROM_SYSCALL): Define by default.
	(__ASSUME_RECVFROM_SYSCALL): Undef it if kernel does not support
	__NR_recvfrom.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_RECVFROM_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h
	(__ASSUME_RECVFROM_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_RECVFROM_SYSCALL): Remove definition.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	(__ASSUME_RECVFROM_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	(__ASSUME_RECVFROM_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h
	(__ASSUME_RECVFROM_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/recvfrom.c: Simplify includes.
2017-03-09 15:22:06 +01:00
Adhemerval Zanella 3e9ff426cb Consolidate Linux connect implementation
This patch consolidates the connect Linux syscall implementation on
sysdeps/unix/sysv/linux/accept.c.  The changes are:

  1. Remove connect from auto-generation syscalls.list on the architecture
     that uses __NR_connect.
  2. Define __NR_connect as default (__ASSUME_CONNECT_SYSCALL) and undef for
     architectures that do not support it.

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/alpha/syscalls.list: Remove connect from
	auto-generation list.
	* sysdeps/unix/sysv/linux/arm/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/connect.c: Simplify include list.
	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_CONNECT_SYSCALL): Define.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	(__ASSUME_CONNECT_SYSCALL): Undef if kernel does not support it.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_CONNECT_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h
	(__ASSUME_CONNECT_SYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h
	(__ASSUME_CONNECT_SYSCALL): Likewise.
2017-03-09 15:22:06 +01:00
Adhemerval Zanella 01061a7cab Consolidate Linux accept implementation
This patch consolidates the accept Linux syscall implementation on
sysdeps/unix/sysv/linux/accept.c.  The changes are:

  1. Remove accept from auto-generation syscalls.list on the architecture
     that uses __NR_accept.
  2. Define __NR_accept as default (__ASSUME_ACCEPT_SYSCALL) and undef for
     architectures that do not support it.
  3. Remove __ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL and decide to use
     __NR_accept4 for accept generation based on __ASSUME_ACCEPT4_SYSCALL.

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/accept.c (__libc_accept): Replace
	__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL by __ASSUME_ACCEPT4_SYSCALL.
	* sysdeps/unix/sysv/linux/alpha/syscalls.list: Remove accept from
	auto-generation list.
	* sysdeps/unix/sysv/linux/arm/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/generic/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/i386/kernel-features.h
	(__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL): Remove define.
	(__ASSUME_ACCEPT_SYSCALL): Undefine.
	* sysdeps/unix/sysv/linux/kernel-features.h
	(__ASSUME_ACCEPT_SYSCALL): New define.
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL): Remove define.
	(__ASSUME_ACCEPT_SYSCALL): Define wheter kernel version supports.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_ACCEPT_SYSCALL): Define.
	* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
	(__ASSUME_ACCEPT_SYSCALL): Undefine.
	* sysdeps/unix/sysv/linux/s390/kernel-features.h
	(__ASSUME_ACCEPT4_FOR_ACCEPT_SYSCALL): Remove define.
	(__ASSUME_ACCEPT_SYSCALL): Undefine.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	(__ASSUME_ACCEPT_SYSCALL): Undefine.
	* sysdeps/unix/sysv/linux/sparc/kernel-features.h
	(__ASSUME_ACCEPT_SYSCALL): Undefine for 32 bits.
2017-03-09 15:22:06 +01:00
Yury Norov 9a56f87183 Test for correct setting of errno.
This patch adds tests for POSIX and Linux specific syscalls
that implemented with syscall templates machinery. The reason
of tests is to receive the expected error code and test if
it's handled properly by glibc.

2017-03-08  Yury Norov <ynorov@caviumnetworks.com>
	    Zack Weinberg  <zackw@panix.com>

	* posix/test-errno.c: New file.
	* posix/Makefile (tests): Add test-errno.
	* sysdeps/unix/sysv/linux/test-errno.c: New file.
	* sysdeps/unix/sysv/linux/Makefile (tests): Add test-errno.
2017-03-08 11:19:47 -05:00
Stefan Liebler 72280a9e55 S390: Regenerate ULPs
Updated ulps file.
There are still fails for long double catan / catanh
due to MPC bug.  See post from Joseph Myers:
https://www.sourceware.org/ml/libc-alpha/2017-03/msg00099.html

ChangeLog:

	* sysdeps/s390/fpu/libm-test-ulps: Regenerated.
2017-03-08 08:34:58 +01:00
Florian Weimer 596d547f50 Fix auto-merge issue in ChangeLog 2017-03-07 17:47:17 +01:00
Florian Weimer 6e3b52292a tzset: Clean up preprocessor macros min, max, sign 2017-03-07 17:45:39 +01:00
Florian Weimer 8492c4dd69 timezone: Remove TZNAME_MAX limit from sysconf [BZ #15576]
glibc does not impose a limit, and POSIX does not allow a
sysconf limit which changes during the lifetime of a process.
2017-03-07 17:45:38 +01:00
Siddhesh Poyarekar 1c1243b6fc Ignore and remove LD_HWCAP_MASK for AT_SECURE programs (bug #21209)
The LD_HWCAP_MASK environment variable may alter the selection of
function variants for some architectures.  For AT_SECURE process it
means that if an outdated routine has a bug that would otherwise not
affect newer platforms by default, LD_HWCAP_MASK will allow that bug
to be exploited.

To be on the safe side, ignore and disable LD_HWCAP_MASK for setuid
binaries.

	[BZ #21209]
	* elf/rtld.c (process_envvars): Ignore LD_HWCAP_MASK for
	AT_SECURE processes.
	* sysdeps/generic/unsecvars.h: Add LD_HWCAP_MASK.
	* elf/tst-env-setuid.c (test_parent): Test LD_HWCAP_MASK.
	(test_child): Likewise.
	* elf/Makefile (tst-env-setuid-ENV): Add LD_HWCAP_MASK.
2017-03-07 20:52:04 +05:30
Adhemerval Zanella a7055e5935 hppa: set __IPC_64 as zero for SysV IPC calls
In 1e5834c38a ("Refactor Linux ipc_priv header") a different
approach to passing __IPC_64 as zero was created.  Hppa kernel ABI
requires to oass __IPC_64 as zero since it does not set
CONFIG_ARCH_WANT_IPC_PARSE_VERSION in the kernel.

Checked on hppa-linux-gnu with some adjustments to avoid BZ#21016
(basically by removing hppa compat implementations and adjusting
required headers).

	* sysdeps/unix/sysv/linux/hppa/ipc_priv.h: New file.
2017-03-07 09:12:48 +01:00
Stefan Liebler 022c9fec9b S390: Optimize atomic macros.
This patch activates C11 atomic builtins by defining
USE_ATOMIC_COMPILER_BUILTINS to 1.
Note:
E.g. in nptl/pthread_key_delete.c if compiled with GCCs 6 and before,
an extra stack-frame is generated and the old value is stored on stack
before cs instruction but it never loads this value from stack.
An unreleased GCC 7 omit those stack operations.

E.g. in nptl/pthread_once.c the condition code of cs instruction is
evaluated by a sequence of ipm, sra, compare and jump instructions instead
of one conditional jump instruction.  This also occurs with an unreleased
GCC 7.

These shortcomings does not really hurt.  Nevertheless, the gcc guys are
investigating those ones and plan to fix them before GCC 7 release.

The atomic_fetch_abc_def C11 builtins are now using load-and-abc instructions
on z196 zarch and higher cpus instead of a loop with compare-and-swap
instruction.

Some of the non-C11 atomic macros from include/atomic.h are now implemented
with help of the C11 atomic builtins.  The other non-C11 atomic macros
are using the macros defined here.

ChangeLog:

	* sysdeps/s390/atomic-machine.h
	(USE_ATOMIC_COMPILER_BUILTINS): Define to 1.
	(__arch_compare_and_exchange_val_8_acq,
	__arch_compare_and_exchange_val_16_acq,
	__arch_compare_and_exchange_val_32_acq,
	__arch_compare_and_exchange_val_64_acq):
	Delete macro.
	(atomic_compare_and_exchange_val_acq,
	atomic_compare_and_exchange_val_rel,
	atomic_compare_and_exchange_bool_acq,
	catomic_compare_and_exchange_bool_acq,
	atomic_exchange_acq, atomic_exchange_rel,
	atomic_exchange_and_add_acq,
	atomic_exchange_and_add_rel,
	catomic_exchange_and_add, atomic_or_val,
	atomic_or, catomic_or, atomic_bit_test_set,
	atomic_and_val, atomic_and, catomic_and):
	Define macros with help of C11 atomic builtins.
2017-03-06 15:28:25 +01:00
Justus Winter 21d58b2a43 hurd: Provide truncate64 and ftruncate64.
* sysdeps/mach/hurd/ftruncate64.c: New file.
	* sysdeps/mach/hurd/truncate64.c: Likewise.
2017-03-04 14:25:49 +01:00
Florian Weimer 7eb5c06c35 tzset: Remove unused NOID macro 2017-03-03 11:25:44 +01:00
Florian Weimer b2f3c0c208 tzset: Remove __attribute_noinline__ from compute_offset
After commit 42261ad731,
compute_offset is only called once, so not inlining it
increases executable size.
2017-03-03 09:06:54 +01:00
Florian Weimer a10e9c4e53 Remove header file inclusion guard from elf/get-dynamic-info.h
This file is included multiple times, so the guard is harmful.
Fixes commit 9090848d06.
2017-03-02 17:28:41 +01:00
Florian Weimer 2d6ab5df3b Document and fix --enable-bind-now [BZ #21015] 2017-03-02 14:44:28 +01:00
Zack Weinberg 9090848d06 Narrowing the visibility of libc-internal.h even further.
posix/wordexp-test.c used libc-internal.h for PTR_ALIGN_DOWN; similar
to what was done with libc-diag.h, I have split the definitions of
cast_to_integer, ALIGN_UP, ALIGN_DOWN, PTR_ALIGN_UP, and PTR_ALIGN_DOWN
to a new header, libc-pointer-arith.h.

It then occurred to me that the remaining declarations in libc-internal.h
are mostly to do with early initialization, and probably most of the
files including it, even in the core code, don't need it anymore.  Indeed,
only 19 files actually need what remains of libc-internal.h.  23 others
need libc-diag.h instead, and 12 need libc-pointer-arith.h instead.
No file needs more than one of them, and 16 don't need any of them!

So, with this patch, libc-internal.h stops including libc-diag.h as
well as losing the pointer arithmetic macros, and all including files
are adjusted.

        * include/libc-pointer-arith.h: New file.  Define
	cast_to_integer, ALIGN_UP, ALIGN_DOWN, PTR_ALIGN_UP, and
        PTR_ALIGN_DOWN here.
        * include/libc-internal.h: Definitions of above macros
	moved from here.  Don't include libc-diag.h anymore either.
	* posix/wordexp-test.c: Include stdint.h and libc-pointer-arith.h.
        Don't include libc-internal.h.

	* debug/pcprofile.c, elf/dl-tunables.c, elf/soinit.c, io/openat.c
	* io/openat64.c, misc/ptrace.c, nptl/pthread_clock_gettime.c
	* nptl/pthread_clock_settime.c, nptl/pthread_cond_common.c
	* string/strcoll_l.c, sysdeps/nacl/brk.c
	* sysdeps/unix/clock_settime.c
	* sysdeps/unix/sysv/linux/i386/get_clockfreq.c
	* sysdeps/unix/sysv/linux/ia64/get_clockfreq.c
	* sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
	* sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c:
	Don't include libc-internal.h.

	* elf/get-dynamic-info.h, iconv/loop.c
	* iconvdata/iso-2022-cn-ext.c, locale/weight.h, locale/weightwc.h
	* misc/reboot.c, nis/nis_table.c, nptl_db/thread_dbP.h
	* nscd/connections.c, resolv/res_send.c, soft-fp/fmadf4.c
	* soft-fp/fmasf4.c, soft-fp/fmatf4.c, stdio-common/vfscanf.c
	* sysdeps/ieee754/dbl-64/e_lgamma_r.c
	* sysdeps/ieee754/dbl-64/k_rem_pio2.c
	* sysdeps/ieee754/flt-32/e_lgammaf_r.c
	* sysdeps/ieee754/flt-32/k_rem_pio2f.c
	* sysdeps/ieee754/ldbl-128/k_tanl.c
	* sysdeps/ieee754/ldbl-128ibm/k_tanl.c
	* sysdeps/ieee754/ldbl-96/e_lgammal_r.c
	* sysdeps/ieee754/ldbl-96/k_tanl.c, sysdeps/nptl/futex-internal.h:
	Include libc-diag.h instead of libc-internal.h.

        * elf/dl-load.c, elf/dl-reloc.c, locale/programs/locarchive.c
        * nptl/nptl-init.c, string/strcspn.c, string/strspn.c
	* malloc/malloc.c, sysdeps/i386/nptl/tls.h
	* sysdeps/nacl/dl-map-segments.h, sysdeps/x86_64/atomic-machine.h
	* sysdeps/unix/sysv/linux/spawni.c
        * sysdeps/x86_64/nptl/tls.h:
        Include libc-pointer-arith.h instead of libc-internal.h.

	* elf/get-dynamic-info.h, sysdeps/nacl/dl-map-segments.h
	* sysdeps/x86_64/atomic-machine.h:
        Add multiple include guard.
2017-03-01 20:33:46 -05:00
Zack Weinberg 5e4e10636c Miscellaneous low-risk changes preparing for _ISOMAC testsuite.
These are a grab bag of changes where the testsuite was using internal
symbols of some variety, but this was straightforward to fix, and the
fixed code should work with or without the change to compile the
testsuite under _ISOMAC.

Four of these are just more #include adjustments, but I want to highlight
sysdeps/powerpc/fpu/tst-setcontext-fpscr.c, which appears to have been
written before the advent of sys/auxv.h.  I think a big chunk of this file
could be replaced by a simple call to getauxval, but I'll let someone who
actually has a powerpc machine to test on do that.

dlfcn/tst-dladdr.c was including ldsodefs.h just so it could use
DL_LOOKUP_ADDRESS to print an additional diagnostic; as requested by Carlos,
I have removed this.

math/test-misc.c was using #ifndef NO_LONG_DOUBLE, which is an internal
configuration macro, to decide whether to do certain tests involving
'long double'.  I changed the test to #if LDBL_MANT_DIG > DBL_MANT_DIG
instead, which uses only public float.h macros and is equivalent on
all supported platforms.  (Note that NO_LONG_DOUBLE doesn't mean 'the
compiler doesn't support long double', it means 'long double is the
same as double'.)

tst-writev.c has a configuration macro 'ARTIFICIAL_LIMIT' that the
Makefiles are expected to define, and sysdeps/unix/sysv/linux/Makefile
was using the internal __getpagesize in the definition; changed to
sysconf(_SC_PAGESIZE) which is the POSIX equivalent.

ia64-linux doesn't supply 'clone', only '__clone2', which is not
defined in the public headers(!)  All the other clone tests have local
extern declarations of __clone2, but tst-clone.c doesn't; it was
getting away with this because include/sched.h does declare __clone2.

	* nss/tst-cancel-getpwuid_r.c: Include nss.h.
	* string/strcasestr.c: No need to include config.h.
	* sysdeps/powerpc/fpu/tst-setcontext-fpscr.c: Include
	sys/auxv.h. Don't include sysdep.h.
	* sysdeps/powerpc/tst-set_ppr.c: Don't include dl-procinfo.h.

	* dlfcn/tst-dladdr.c: Don't include ldsodefs.h.	 Don't use
	DL_LOOKUP_ADDRESS.
	* math/test-misc.c: Instead of testing NO_LONG_DOUBLE, test whether
	LDBL_MANT_DIG is greater than DBL_MANT_DIG.
	* sysdeps/unix/sysv/linux/Makefile (CFLAGS-tst-writev.c): Use
	sysconf (_SC_PAGESIZE) instead of __getpagesize in definition
	of ARTIFICIAL_LIMIT.
	* sysdeps/unix/sysv/linux/tst-clone.c [__ia64__]: Add extern
	declaration of __clone2.
2017-03-01 20:32:50 -05:00
Florian Weimer d2583c0b77 Add scripts/backport-support.sh
This script is intended for maintaining the stable branches and
distribution backports.
2017-02-28 16:36:26 +01:00
Florian Weimer cf0bd2f73b sunrpc: Improvements for UDP client timeout handling [BZ #20257]
This commit fixes various aspects in the UDP client timeout handling.
Timeouts are now applied in a more consistent fashion.  Discarded UDP
packets no longer prevent the timeout from happening at all.
2017-02-28 15:36:17 +01:00
Florian Weimer 37fb019cb0 sunrpc: Do not unregister services if not registered [BZ #5010]
The change in commit 718946816c
has no effect because of two bugs which cancel each other out:
The svc_is_mapped condition is inverted, and svc_is_mapped
always returns false because the check is performed after
the service has already been unregistered.  As a result,
pmap_unset is called unconditionally, as before.
2017-02-28 15:36:16 +01:00
Andreas Schwab b31737bdf9 Refer to <signal.h> instead of <pthread.h> in <bits/sigthread.h>
The <bits/sigthread.h> header is included by <signal.h>, not <pthread.h>.
2017-02-28 10:34:15 +01:00
Florian Weimer d42eed4a04 sunrpc: Avoid use-after-free read access in clntudp_call [BZ #21115]
After commit bc779a1a5b
(CVE-2016-4429: sunrpc: Do not use alloca in clntudp_call
[BZ #20112]), ancillary data is stored on the heap,
but it is accessed after it has been freed.

The test case must be run under a heap debugger such as valgrind
to observe the invalid access.  A malloc implementation which
immediately calls munmap on free would catch this bug as well.
2017-02-27 19:05:13 +01:00
Zack Weinberg 963394a22b Allow direct use of math_ldbl.h in testsuite.
A few 'long double'-related tests include math_private.h just for
their variety of math_ldbl.h, which contains macros for assembling and
disassembling the binary representation of 'long double'.  math_ldbl.h
insists on being included from math_private.h, but if we relax this
restriction (and fix some portability sloppiness) we can use it
directly and not have to expose all of math_private.h to the testsuite.

	* sysdeps/generic/math_private.h: Use __BIG_ENDIAN and
	__LITTLE_ENDIAN, not BIG_ENDIAN and LITTLE_ENDIAN.

	* sysdeps/generic/math_ldbl.h
	* sysdeps/ia64/fpu/math_ldbl.h
	* sysdeps/ieee754/ldbl-128/math_ldbl.h
	* sysdeps/ieee754/ldbl-128ibm/math_ldbl.h
	* sysdeps/ieee754/ldbl-96/math_ldbl.h
	* sysdeps/powerpc/fpu/math_ldbl.h
	* sysdeps/x86_64/fpu/math_ldbl.h:
	Allow direct inclusion.  Use uintNN_t instead of u_intNN_t.
	Use __BIG_ENDIAN and __LITTLE_ENDIAN, not BIG_ENDIAN and
	LITTLE_ENDIAN.  Include endian.h and/or stdint.h if necessary.
	Add copyright notices.

	* sysdeps/ieee754/ldbl-128ibm/math_ldbl.h (ldbl_canonicalize_int):
	Don't use EXTRACT_WORDS64.

	* sysdeps/ieee754/ldbl-96/test-canonical-ldbl-96.c
	* sysdeps/ieee754/ldbl-96/test-totalorderl-ldbl-96.c
	* sysdeps/ieee754/ldbl-128ibm/test-canonical-ldbl-128ibm.c
	* sysdeps/ieee754/ldbl-128ibm/test-totalorderl-ldbl-128ibm.c:
	Include math_ldbl.h, not math_private.h.
2017-02-25 10:40:48 -05:00
Zack Weinberg e15f7de60c Split DIAG_* macros to new header libc-diag.h.
Quite a few tests include libc-internal.h just for the DIAG_* macros.
Split those macros to their own file, which can be included safely in
_ISOMAC mode.  I also moved ignore_value, since it seems logically
related, even though I didn't notice any tests needing it.

Also add -Wnonnull suppressions to two tests that _should_ have them,
but the error is masked when compiling against internal headers.

	* include/libc-diag.h: New file.  Define ignore_value,
	DIAG_PUSH_NEEDS_COMMENT, DIAG_POP_NEEDS_COMMENT,
	DIAG_IGNORE_NEEDS_COMMENT, and DIAG_IGNORE_Os_NEEDS_COMMENT here.

	* include/libc-internal.h: Definitions of above macros moved from
	here.  Include libc-diag.h.  Add copyright notice.

	* malloc/tst-malloc.c, malloc/tst-memcheck.c, malloc/tst-realloc.c
	* misc/tst-error1.c, posix/tst-dir.c, stdio-common/bug21.c
	* stdio-common/scanf14.c, stdio-common/scanf4.c, stdio-common/scanf7.c
	* stdio-common/test-vfprintf.c, stdio-common/tst-printf.c
	* stdio-common/tst-printfsz.c, stdio-common/tst-sprintf.c
	* stdio-common/tst-unlockedio.c, stdio-common/tstdiomisc.c
	* stdlib/bug-getcontext.c, string/tester.c, string/tst-endian.c
	* time/tst-strptime2.c, wcsmbs/tst-wcstof.c:
	Include libc-diag.h instead of libc-internal.h.

	* stdlib/tst-environ.c: Include libc-diag.h.  Suppress -Wnonnull for
	call to unsetenv (NULL).
	* nptl/tst-mutex1.c: Include libc-diag.h.  Suppress -Wnonnull for
	call to pthread_mutexattr_destroy (NULL).
2017-02-25 09:59:46 -05:00
Zack Weinberg 7caa5054af Clean up conditionals for declaration of gets.
gets has the dubious honor of being the only C89 library feature that
has been completely removed from the current C and C++ standards.
glibc follows suit by not declaring it in _GNU_SOURCE mode either,
but it remains present in older compatibility modes.  Internally,
two test cases need to see stdio.h make the declaration, but all our
internal code is of course compiled under _GNU_SOURCE.  This is currently
kludged by duplicating the gets declaration, fortify wrapper and all,
in include/stdio.h.  Also, the conditional in the public headers for
deciding when to declare gets is complicated and repeated in two places.

This patch adds a new macro to features.h that encapsulates the
complicated rule for when to declare gets.  stdio.h and bits/stdio2.h
then simply test __GLIBC_USE (DEPRECATED_GETS), and instead of having
a duplicate gets declaration in include/stdio.h, debug/tst-chk1.c and
stdio-common/tst-gets.c can force gets to be declared.

        * include/features.h (__GLIBC_USE_DEPRECATED_GETS): New macro.
        * libio/stdio.h, libio/bits/stdio2.h: Condition gets on
        __GLIBC_USE (DEPRECATED_GETS).  Update comments to indicate
        gets was removed from C++ in C++14.
        * include/stdio.h: Remove redundant declaration of gets.
        * debug/tst-chk1.c, stdio-common/tst-gets.c: Force gets to
        be declared, since we are testing it.
        * stdio-common/Makefile (tst-gets.c): Compile with
        -Wno-deprecated-declarations.
	* debug/Makefile (tst-chk1.c, tst-chk2.c, tst-chk3.c, tst-chk4.cc)
	(tst-chk5.cc, tst-chk6.cc, tst-lfschk1.c, tst-lfschk2.c)
	(tst-lfschk3.c, tst-lfschk4.cc, tst-lfschk5.cc, tst-lfschk6.cc):
	Compile with -Wno-deprecated-declarations.
2017-02-25 09:47:51 -05:00
Tulio Magno Quites Machado Filho 4f5a9afffb Use independent type literals in libm-test-support.c
* math/libm-test-support.c (check_ulp): Use LIT() around literal
	numbers.
2017-02-24 21:14:09 -03:00
Stefan Liebler d4f94368a9 Get rid of duplicate const declaration specifier warning in tst-resolv-qtypes.c.
Compiling resolv/tst-resolv-qtypes.c with GCC 7 results in:
tst-resolv-qtypes.c:53:14: error: duplicate ‘const’ declaration specifier [-Werror=duplicate-decl-specifier]
 static const const char *domain = "www.example.com";

This patch removes the duplicate const and makes domain a const pointer
to const char literal.

ChangeLog:

	* resolv/tst-resolv-qtypes.c (domain):
	Change type to const pointer to const char.
2017-02-24 13:30:13 +01:00
Joseph Myers 92061bb033 Run libm tests separately for each function.
At present, libm tests for each function get built into a single
executable (for each floating point type, for each of normal / inline
/ finite-math-only functions, plus vector variants) and run together,
resulting in a single PASS or FAIL (for each of those nine variants
plus vector variants).  Building this executable involves reading
over 50 MB of libm-test-*.c sources.

This patch arranges for tests of each function to be run separately
from the makefiles instead.  There are 121 functions being tested for
each (type, variant pair) (actually 126, but run as 121 from the
Makefile because each of the pairs (exp10, pow10), (isfinite, finite),
(lgamma, gamma), (remainder, drem), (scalbn, ldexp), shares a table of
test results and so is run together), so 1089 separate tests run from
the Makefile, plus 48 vector tests on x86_64 (six functions for eight
vector variants).  Each test only involves a libm-test-<func>.c file
of no more than about 4 MB, rather than all such files taking about 50
MB.  With tests run separately, test summaries will indicate which
functions actually have problems (of course, those problems may just
be out-of-date libm-test-ulps files if the file hasn't been updated
for the architecture in question recently).

All the .c files for the 1089+48 tests are generated automatically
from the Makefiles.  Various checked-in boilerplate .c files are
removed as no longer needed.  CFLAGS definitions for the different
kinds of tests are generated using makefile iterators to apply
target-specific variable settings.  libm-have-vector-test.h is no
longer needed; the list of functions to test for each vector type is
now in the sysdeps Makefile.

This should reduce the amount of boilerplate needed for float128
testing support; test-float128.h will still be needed, but not various
.c files or Makefile CFLAGS definitions.  The logic for creating
dependencies on libm-test-support-*.o files should also render
<https://sourceware.org/ml/libc-alpha/2017-02/msg00279.html>
unnecessary.

Tested for x86_64 and x86.

	* math/Makefile (libm-tests-generated): Remove variable.
	(libm-tests-base-normal): New variable.
	(libm-tests-base-finite): Likewise.
	(libm-tests-base-inline): Likewise.
	(libm-tests-base): Likewise.
	(libm-tests-normal): Likewise.
	(libm-tests-finite): Likewise.
	(libm-tests-inline): Likewise.
	(libm-tests-vector): Likewise.
	(libm-tests): Define in terms of these new variables.
	(libm-tests-for-type): New variable.
	(libm-tests.o): Move definition.
	(tests): Move addition of $(libm-tests).
	(generated): Update for new and removed libm test files.
	($(objpfx)libm-test.c): Remove target.
	($(objpfx)libm-have-vector-test.h): Likewise.
	(CFLAGS-test-double-vlen2.c): Remove variable.
	(CFLAGS-test-double-vlen4.c): Likewise.
	(CFLAGS-test-double-vlen8.c): Likewise.
	(CFLAGS-test-float-vlen4.c): Likewise.
	(CFLAGS-test-float-vlen8.c): Likewise.
	(CFLAGS-test-float-vlen16.c): Likewise.
	(CFLAGS-test-float.c): Likewise.
	(CFLAGS-test-float-finite.c): Likewise.
	(CFLAGS-libm-test-support-float.c): Likewise.
	(CFLAGS-test-double.c): Likewise.
	(CFLAGS-test-double-finite.c): Likewise.
	(CFLAGS-libm-test-support-double.c): Likewise.
	(CFLAGS-test-ldouble.c): Likewise.
	(CFLAGS-test-ldouble-finite.c): Likewise.
	(CFLAGS-libm-test-support-ldouble.c): Likewise.
	(libm-test-inline-cflags): New variable.
	(CFLAGS-test-ifloat.c): Remove variable.
	(CFLAGS-test-idouble.c): Likewise.
	(CFLAGS-test-ildouble.c): Likewise.
	($(addprefix $(objpfx), $(libm-tests.o))): Move target and update
	dependencies.
	($(foreach t,$(libm-tests-normal),$(objpfx)$(t).c)): New rule.
	($(foreach t,$(libm-tests-finite),$(objpfx)$(t).c)): Likewise.
	($(foreach t,$(libm-tests-inline),$(objpfx)$(t).c)): Likewise.
	($(foreach t,$(libm-tests-vector),$(objpfx)$(t).c)): Likewise.
	($(foreach t,$(types),$(objpfx)libm-test-support-$(t).c)):
	Likewise.
	(dependencies on libm-test-support-*.o): Remove.
	($(foreach f,$(libm-test-funcs-all),$(objpfx)$(o)-$(f).o)): New
	rules using iterators.
	($(addprefix $(objpfx),$(call libm-tests-for-type,$(o)))):
	Likewise.
	($(objpfx)libm-test-support-$(o).o): Likewise.
	($(addprefix $(objpfx),$(filter-out $(tests-static)
	$(libm-vec-tests),$(tests)))): Filter out $(libm-tests-vector)
	instead.
	($(addprefix $(objpfx), $(libm-vec-tests))): Use iterator to
	define rule instead.
	* math/README.libm-test: Update.
	* math/libm-test-acos.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-acosh.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-asin.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-asinh.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-atan.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-atan2.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-atanh.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-cabs.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-cacos.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-cacosh.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-canonicalize.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-carg.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-casin.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-casinh.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-catan.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-catanh.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-cbrt.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-ccos.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-ccosh.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-ceil.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-cexp.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-cimag.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-clog.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-clog10.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-conj.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-copysign.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-cos.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-cosh.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-cpow.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-cproj.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-creal.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-csin.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-csinh.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-csqrt.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-ctan.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-ctanh.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-erf.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-erfc.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-exp.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-exp10.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-exp2.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-expm1.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-fabs.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-fdim.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-floor.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-fma.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-fmax.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-fmaxmag.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-fmin.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-fminmag.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-fmod.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-fpclassify.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-frexp.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-fromfp.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-fromfpx.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-getpayload.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-hypot.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-ilogb.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-iscanonical.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-iseqsig.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-isfinite.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-isgreater.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-isgreaterequal.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-isinf.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-isless.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-islessequal.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-islessgreater.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-isnan.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-isnormal.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-issignaling.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-issubnormal.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-isunordered.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-iszero.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-j0.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-j1.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-jn.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-lgamma.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-llogb.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-llrint.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-llround.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-log.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-log10.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-log1p.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-log2.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-logb.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-lrint.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-lround.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-modf.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-nearbyint.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-nextafter.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-nextdown.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-nexttoward.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-nextup.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-pow.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-remainder.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-remquo.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-rint.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-round.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-roundeven.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-scalb.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-scalbln.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-scalbn.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-setpayload.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-setpayloadsig.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-signbit.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-significand.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-sin.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-sincos.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-sinh.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-sqrt.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-tan.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-tanh.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-tgamma.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-totalorder.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-totalordermag.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-trunc.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-ufromfp.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-ufromfpx.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-y0.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-y1.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-yn.inc: Include libm-test-driver.c.
	(do_test): New function.
	* math/libm-test-driver.c: Do not include libm-have-vector-test.h.
	(HAVE_VECTOR): Remove macro.
	(START): Do not call HAVE_VECTOR.
	* math/test-double-vlen2.h (FUNC_TEST): Remove macro.
	* math/test-double-vlen4.h (FUNC_TEST): Remove macro.
	* math/test-double-vlen8.h (FUNC_TEST): Remove macro.
	* math/test-float-vlen16.h (FUNC_TEST): Remove macro.
	* math/test-float-vlen4.h (FUNC_TEST): Remove macro.
	* math/test-float-vlen8.h (FUNC_TEST): Remove macro.
	* math/test-math-vector.h (FUNC_TEST): New macro.
	(WRAPPER_DECL): Rename to WRAPPER_DECL_f.
	* sysdeps/x86_64/fpu/Makefile (double-vlen2-funcs): New variable.
	(double-vlen4-funcs): Likewise.
	(double-vlen4-avx2-funcs): Likewise.
	(double-vlen8-funcs): Likewise.
	(float-vlen4-funcs): Likewise.
	(float-vlen8-funcs): Likewise.
	(float-vlen8-avx2-funcs): Likewise.
	(float-vlen16-funcs): Likewise.
	(CFLAGS-test-double-vlen4-avx2.c): Remove variable.
	(CFLAGS-test-float-vlen8-avx2.c): Likewise.
	* sysdeps/x86_64/fpu/test-double-vlen4.h (TEST_VECTOR_cos): Remove
	macro.
	(TEST_VECTOR_sin): Likewise.
	(TEST_VECTOR_sincos): Likewise.
	(TEST_VECTOR_log): Likewise.
	(TEST_VECTOR_exp): Likewise.
	(TEST_VECTOR_pow): Likewise.
	* sysdeps/x86_64/fpu/test-double-vlen8.h (TEST_VECTOR_cos):
	Likewise.
	(TEST_VECTOR_sin): Likewise.
	(TEST_VECTOR_sincos): Likewise.
	(TEST_VECTOR_log): Likewise.
	(TEST_VECTOR_exp): Likewise.
	(TEST_VECTOR_pow): Likewise.
	* sysdeps/x86_64/fpu/test-float-vlen16.h (TEST_VECTOR_cosf):
	Likewise.
	(TEST_VECTOR_sinf): Likewise.
	(TEST_VECTOR_sincosf): Likewise.
	(TEST_VECTOR_logf): Likewise.
	(TEST_VECTOR_expf): Likewise.
	(TEST_VECTOR_powf): Likewise.
	* sysdeps/x86_64/fpu/test-float-vlen8.h (TEST_VECTOR_cosf):
	Likewise.
	(TEST_VECTOR_sinf): Likewise.
	(TEST_VECTOR_sincosf): Likewise.
	(TEST_VECTOR_logf): Likewise.
	(TEST_VECTOR_expf): Likewise.
	(TEST_VECTOR_powf): Likewise.
	* math/gen-libm-have-vector-test.sh: Remove file.
	* math/libm-test.inc: Likewise.
	* math/libm-test-support-double.c: Likewise.
	* math/libm-test-support-float.c: Likewise.
	* math/libm-test-support-ldouble.c: Likewise.
	* math/test-double-finite.c: Likewise.: Likewise.
	* math/test-double.c: Likewise.
	* math/test-float-finite.c: Likewise.
	* math/test-float.c: Likewise.
	* math/test-idouble.c: Likewise.
	* math/test-ifloat.c: Likewise.
	* math/test-ildouble.c: Likewise.
	* math/test-ldouble-finite.c: Likewise.
	* math/test-ldouble.c: Likewise.
	* sysdeps/x86_64/fpu/test-double-vlen2.c: Likewise.
	* sysdeps/x86_64/fpu/test-double-vlen2.h: Likewise.
	* sysdeps/x86_64/fpu/test-double-vlen4-avx2.c: Likewise.
	* sysdeps/x86_64/fpu/test-double-vlen4.c: Likewise.
	* sysdeps/x86_64/fpu/test-double-vlen8.c: Likewise.
	* sysdeps/x86_64/fpu/test-float-vlen16.c: Likewise.
	* sysdeps/x86_64/fpu/test-float-vlen4.c: Likewise.
	* sysdeps/x86_64/fpu/test-float-vlen4.h: Likewise.
	* sysdeps/x86_64/fpu/test-float-vlen8-avx2.c: Likewise.
	* sysdeps/x86_64/fpu/test-float-vlen8.c: Likewise.
2017-02-24 00:52:49 +00:00
Gabriel F. T. Gomes aec0821ce7 Add new templates for IEEE wrappers
Several wrappers for IEEE functions use _LIB_VERSION / matherr /
__kernel_standard functionality, which we want to obsolete.  New
wrappers, such as for float128, must not use this functionality.

This patch adds new wrappers that only __set_errno and can be used by
the new float128 wrappers.

Tested for powerpc64le.

	* math/Makefile: Add wrappers to gen-libm-calls.
	* math/w_acos_template.c: New file.
	* math/w_acosh_template.c: Likewise.
	* math/w_asin_template.c: Likewise.
	* math/w_atan2_template.c: Likewise.
	* math/w_atanh_template.c: Likewise.
	* math/w_cosh_template.c: Likewise.
	* math/w_exp10_template.c: Likewise.
	* math/w_exp2_template.c: Likewise.
	* math/w_exp_template.c: Likewise.
	* math/w_fmod_template.c: Likewise.
	* math/w_hypot_template.c: Likewise.
	* math/w_j0_template.c: Likewise.
	* math/w_j1_template.c: Likewise.
	* math/w_jn_template.c: Likewise.
	* math/w_lgamma_r_template.c: Likewise.
	* math/w_lgamma_template.c: Likewise.
	* math/w_log10_template.c: Likewise.
	* math/w_log2_template.c: Likewise.
	* math/w_log_template.c: Likewise.
	* math/w_pow_template.c: Likewise.
	* math/w_remainder_template.c: Likewise.
	* math/w_sinh_template.c: Likewise.
	* math/w_sqrt_template.c: Likewise.
	* math/w_tgamma_template.c: Likewise.: Likewise.
	* sysdeps/generic/math-type-macros-double.h
	(__USE_WRAPPER_TEMPLATE): New macro to control inclusion of
	the new wrappers.
	* sysdeps/generic/math-type-macros-float.h: Likewise.
	* sysdeps/generic/math-type-macros-ldouble.h: Likewise.
2017-02-23 11:28:50 -03:00
Joseph Myers 63e1c3768d Add TFD_TIMER_CANCEL_ON_SET to sys/timerfd.h.
In Linux 4.10, timerfd constants moved to a new uapi header, which
showed up that glibc's sys/timerfd.h is missing the old flag
TFD_TIMER_CANCEL_ON_SET.  This patch adds that flag to glibc's header.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/sys/timerfd.h (TFD_TIMER_CANCEL_ON_SET):
	New enum constant and macro.
2017-02-22 20:50:38 +00:00
Joseph Myers bf0b5360da Use Linux 4.10 in build-many-glibcs.py.
* scripts/build-many-glibcs.py (Context.checkout): Default Linux
	kernel version to 4.10.
2017-02-22 17:10:09 +00:00
Joseph Myers 72aaa20bbc Add IP_RECVFRAGSIZE from Linux 4.10.
Linux 4.10 adds a new IP_RECVFRAGSIZE macro to
include/uapi/linux/in.h.  This patch adds it to glibc's
sysdeps/unix/sysv/linux/bits/in.h.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/bits/in.h (IP_RECVFRAGSIZE): New macro.
2017-02-21 18:18:24 +00:00
Tulio Magno Quites Machado Filho 2f78098e39 powerpc: Update powerpc-fpu libm-test-ulps
* sysdeps/powerpc/fpu/libm-test-ulps: Update.
2017-02-21 14:00:01 -03:00
Wainer dos Santos Moschetta 6ec4140255 powerpc: Add tests for __ppc_set_ppr_* functions.
The sys/platform/ppc.h header defines a class of __ppc_set_ppr functions
used to set the Program Priority Register (PPR) in PowerPC.
This patch implements test cases for these functions.

Tested on ppc64le, ppc64, and ppc.

	* sysdeps/powerpc/tst-set_ppr.c: New file.
	Implement test cases for __ppc_set_ppr_* functions.
	* sysdeps/powerpc/Makefile ($(subdir),misc): Add tst-set_ppr
	in the list of tests.
2017-02-21 14:00:01 -03:00
Wainer dos Santos Moschetta ee6df1e6ab powerpc: Convert tests to the new support test-driver
Change the powerpc tests to use <support/test-driver.c>.
Also replace some of pthread calls to its xpthread equivalent.

Tested on ppc64le.

	* sysdeps/powerpc/test-get_hwcap.c: Use <support/test-driver.c>
	instead of test-skeleton.c.
	(do_test): Replaced pthread_create and pthread_join with
	xpthread_create and xpthread_join.  Use TEST_VERIFY_EXIT macro.
	Removed unneeded status variable.
	* sysdeps/powerpc/test-gettimebase.c: Use <support/test-driver.c>
	instead of test-skeleton.c.
	* sysdeps/powerpc/tst-tlsopt-powerpc.c: Likewise.
2017-02-21 14:00:00 -03:00
Mike FABIAN 0b38d66a4e Bug 20313: Update to Unicode 9.0.0
* Unicode 9.0.0 Support: Character encoding, character type info, and
  transliteration tables are all updated to Unicode 9.0.0, using
  generator scripts contributed by Mike FABIAN (Red Hat).
2017-02-21 06:30:38 -05:00
Joseph Myers 24b2a1b122 Remove some unused libm-test exception macros.
This patch removes some libm-test-support.h macros for exceptions that
are no longer used.  EXCEPTIONS_OK has been unused for some time.  The
macros for underflow exceptions with some types only were used when
the results for complex inverse trig and hyperbolic functions were
manually maintained, but are no longer needed now the auto-libm-test
machinery is used to determine the correct result and exceptions for
every floating-point format and rounding mode.

Tested for x86_64.

	* math/libm-test-support.h (EXCEPTIONS_OK): Remove macro.
	(UNDERFLOW_EXCEPTION_FLOAT): Likewise.
	(UNDERFLOW_EXCEPTION_OK_FLOAT): Likewise.
	(UNDERFLOW_EXCEPTION_DOUBLE): Likewise.
	(UNDERFLOW_EXCEPTION_OK_DOUBLE): Likewise.
	(UNDERFLOW_EXCEPTION_LDOUBLE_IBM): Likewise.
2017-02-20 17:53:51 +00:00
Zack Weinberg 71223d6880 One more obvious missing #include in the testsuite.
* rt/tst-mqueue4.c: Include stdint.h.
2017-02-19 10:29:34 -05:00
Joseph Myers 9174b4c3b6 Update arm, mips, powerpc-nofpu libm-test-ulps.
* sysdeps/arm/libm-test-ulps: Update.
	* sysdeps/mips/mips32/libm-test-ulps: Likewise.
	* sysdeps/mips/mips64/libm-test-ulps: Likewise.
	* sysdeps/powerpc/nofpu/libm-test-ulps: Likewise.
2017-02-17 23:10:01 +00:00
Adhemerval Zanella 3b33d6ed60 Rework -fno-omit-frame-pointer support on i386
Commit 6b1df8b27f fixed the -OS build issue on i386 (BZ#20729) by
expliciting disabling frame pointer (-fomit-frame-pointer) on the
faulty objects.  Although it does fix the issue, it is a subpar
workaround that adds complexity in build process (a rule for each
object to add the required compiler option and pontentially more
rules for objects that call {INLINE,INTERNAL}_SYSCALL) and does not
allow the implementations to get all the possible debug/calltrack
information possible (used mainly in debuggers and performance
measurement tools).

This patch fixes it by adding an explicit configure check to see
if -fno-omit-frame-pointer is set and to act accordingly (set or
not OPTIMIZE_FOR_GCC_5).  The make rules is simplified and only
one is required: to add libc-do-syscall on loader due mmap
(which will be empty anyway for default build with
-fomit-frame-pointer).

Checked on i386-linux-gnu with GCC 6.2.1 with CFLAGS sets as
'-Os', '-O2 -fno-omit-frame-pointer', and '-O2 -fomit-frame-pointer'.
For '-Os' the testsuite issues described by BZ#19463 and BZ#15105
still applied.

It fixes BZ #21029, although it is marked as duplicated of #20729
(I reopened to track this cleanup).

	[BZ #21029]
	* config.h.in [CAN_USE_REGISTER_ASM_EBP]: New define.
	* sysdeps/unix/sysv/linux/i386/Makefile
	[$(subdir) = elf] (sysdep-dl-routines): Add libc-do-syscall.
	(uses-6-syscall-arguments): Remove.
	[$(subdir) = misc] (CFLAGS-epoll_pwait.o): Likewise.
	[$(subdir) = misc] (CFLAGS-epoll_pwait.os): Likewise.
	[$(subdir) = misc] (CFLAGS-mmap.o): Likewise.
	[$(subdir) = misc] (CFLAGS-mmap.os): Likewise.
	[$(subdir) = misc] (CFLAGS-mmap64.o): Likewise.
	[$(subdir) = misc] (CFLAGS-mmap64.os): Likewise.
	[$(subdir) = misc] (CFLAGS-pselect.o): Likewise.
	[$(subdir) = misc] (cflags-pselect.o): Likewise.
	[$(subdir) = misc] (cflags-pselect.os): Likewise.
	[$(subdir) = misc] (cflags-rtld-mmap.os): Likewise.
	[$(subdir) = sysvipc] (cflags-semtimedop.o): Likewise.
	[$(subdir) = sysvipc] (cflags-semtimedop.os): Likewise.
	[$(subdir) = io] (CFLAGS-posix_fadvise64.o): Likewise.
	[$(subdir) = io] (CFLAGS-posix_fadvise64.os): Likewise.
	[$(subdir) = io] (CFLAGS-posix_fallocate.o): Likewise.
	[$(subdir) = io] (CFLAGS-posix_fallocate.os): Likewise.
	[$(subdir) = io] (CFLAGS-posix_fallocate64.o): Likewise.
	[$(subdir) = io] (CFLAGS-posix_fallocate64.os): Likewise.
	[$(subdir) = io] (CFLAGS-sync_file_range.o): Likewise.
	[$(subdir) = io] (CFLAGS-sync_file_range.os): Likewise.
	[$(subdir) = io] (CFLAGS-fallocate.o): Likewise.
	[$(subdir) = io] (CFLAGS-fallocate.os): Likewise.
	[$(subdir) = io] (CFLAGS-fallocate64.o): Likewise.
	[$(subdir) = io] (CFLAGS-fallocate64.os): Likewise.
	[$(subdir) = nptl] (CFLAGS-pthread_rwlock_timedrdlock.o):
	Likewise.
	[$(subdir) = nptl] (CFLAGS-pthread_rwlock_timedrdlock.os):
	Likewise.
	[$(subdir) = nptl] (CFLAGS-pthread_rwlock_timedrwlock.o):
	Likewise.
	[$(subdir) = nptl] (CFLAGS-pthread_rwlock_timedrwlock.os):
	Likewise.
	[$(subdir) = nptl] (CFLAGS-sem_wait.o): Likewise.
	[$(subdir) = nptl] (CFLAGS-sem_wait.os): Likewise.
	[$(subdir) = nptl] (CFLAGS-sem_timedwait.o): Likewise.
	[$(subdir) = nptl] (CFLAGS-sem_timedwait.os): Likewise.
	* sysdeps/unix/sysv/linux/i386/configure.ac: Add check if compiler allows
	ebp on inline assembly.
	* sysdeps/unix/sysv/linux/i386/configure: Regenerate.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (OPTIMIZE_FOR_GCC_5):
	Set if CAN_USE_REGISTER_ASM_EBP is set.
	(check_consistency): Likewise.
2017-02-17 18:06:29 -02:00
H.J. Lu 52ac22365a Use index_cpu_RTM and reg_RTM to clear the bit_cpu_RTM bit
* sysdeps/x86/cpu-features.c (init_cpu_features): Use
	index_cpu_RTM and reg_RTM to clear the bit_cpu_RTM bit.
2017-02-17 11:53:26 -08:00
Joseph Myers 2c51dfd05d Move tests of catan, catanh to auto-libm-test-*.
This patch moves tests of catan and catanh with finite inputs (other
than the divide-by-zero cases producing an exact infinity) to using
the auto-libm-test machinery.  Each of auto-libm-test-out-catan and
auto-libm-test-out-catanh takes about three seconds to generate on my
system (so in fact it wasn't necessary after all to defer the move to
auto-libm-test-* until the output files were split up by function).

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of catan and catanh.
	* math/auto-libm-test-out-catan: New generated file.
	* math/auto-libm-test-out-catanh: Likewise.
	* math/libm-test-catan.inc (catan_test_data): Use AUTO_TESTS_c_c.
	Move tests with finite inputs, except divide-by-zero cases, to
	auto-libm-test-in.
	* math/libm-test-catanh.inc (catanh_test_data): Likewise.
	* math/Makefile (libm-test-funcs-auto): Add catan and catanh.
	(libm-test-funcs-noauto): Remove catan and catanh.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2017-02-17 18:42:37 +00:00
Joseph Myers fa2a3dd7a3 Move tests of casin, casinh to auto-libm-test-*.
This patch moves tests of casin and casinh with finite inputs to using
the auto-libm-test machinery.  Each of auto-libm-test-out-casin and
auto-libm-test-out-casinh takes about 38 minutes to generate on my
system because of MPC slowness on special cases that appear in the
tests (with MPC 1.0.3; I don't know to what extent current MPC master
might speed it up).

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of casin and casinh.
	* math/auto-libm-test-out-casin: New generated file.
	* math/auto-libm-test-out-casinh: Likewise.
	* math/libm-test-casin.inc (casin_test_data): Use AUTO_TESTS_c_c.
	Move tests with finite inputs to auto-libm-test-in.
	* math/libm-test-casinh.inc (casinh_test_data): Likewise.
	* math/Makefile (libm-test-funcs-auto): Add casin and casinh.
	(libm-test-funcs-noauto): Remove casin and casinh.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2017-02-17 18:14:02 +00:00
Joseph Myers 6b8303a383 Move tests of cacos, cacosh to auto-libm-test-*.
This patch moves tests of cacos and cacosh with finite inputs to using
the auto-libm-test machinery.  Each of auto-libm-test-out-cacos and
auto-libm-test-out-cacosh takes about 80 minutes to generate on my
system because of MPC slowness on special cases that appear in the
tests (with MPC 1.0.3; I don't know to what extent current MPC master
might speed it up).

Tested for x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of cacos and cacosh.
	* math/auto-libm-test-out-cacos: New generated file.
	* math/auto-libm-test-out-cacosh: Likewise.
	* math/libm-test-cacos.inc (cacos_test_data): Use AUTO_TESTS_c_c.
	Move tests with finite inputs to auto-libm-test-in.
	* math/libm-test-cacosh.inc (cacosh_test_data): Likewise.
	* math/Makefile (libm-test-funcs-auto): Add cacos and cacosh.
	(libm-test-funcs-noauto): Remove cacos and cacosh.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/i386/i686/fpu/multiarch/libm-test-ulps: Likewise.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2017-02-17 17:44:23 +00:00
Joseph Myers f7a51347a4 Revert header inclusion changes that break math/ testing on x86_64.
Revert:
	2017-02-16  Zack Weinberg  <zackw@panix.com>

	* sysdeps/x86_64/fpu/math-tests-arch.h: Include cpu-features.h.
	Don't include init-arch.h.
	* sysdeps/x86_64/multiarch/test-multiarch.h: Include cpu-features.h.
	Don't include init-arch.h.
2017-02-17 17:08:17 +00:00
Tulio Magno Quites Machado Filho 51b34a9c47 Fix lgamma*, log10* and log2* results [BZ #21171]
lgamma(-x) should return +Inf and raise divide-by-zero.
log10(+-0) and log2(+-0) should return -Inf and raise divide-by-zero.

Tested on powerpc, powerpc64, powerpc64le and x86_64.

	[BZ #21171]
	* sysdeps/ieee754/dbl-64/e_lgamma_r.c (__ieee754_lgamma_r): Return
	+Inf and raise divide-by-zero when x is negative.
	* sysdeps/ieee754/flt-32/e_lgammaf_r.c (__ieee754_lgammaf_r): Likewise.
	* sysdeps/ieee754/ldbl-128/e_lgammal_r.c (__ieee754_lgammal_r): Likewise.

	* sysdeps/ieee754/dbl-64/e_log10.c (__ieee754_log10):  Return
	-Inf and raise divide-by-zero when x = +-0.
	* sysdeps/ieee754/dbl-64/e_log2.c (__ieee754_log2): Likewise.
	* sysdeps/ieee754/flt-32/e_log10f.c (__ieee754_log10f):	Likewise.
	* sysdeps/ieee754/flt-32/e_log2f.c (__ieee754_log2f): Likewise.
	* sysdeps/ieee754/ldbl-128/e_log10l.c (__ieee754_log10l): Likewise.
	* sysdeps/ieee754/ldbl-128/e_log2l.c (__ieee754_log2l): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_log10l.c (__ieee754_log10l): Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_log2l.c (__ieee754_log2l): Likewise.
2017-02-17 09:07:57 -02:00
Zack Weinberg f0166c1643 build-many-glibcs: don't crash if email is not configured
The 'bot-cycle' action for build-many-glibcs is a convenient way to
not have to remember all the steps in keeping a many-glibcs tree up
to date ... or it would be, if the script could send mail _optionally_.
Make it so by skipping the mail step if mail isn't configured.

	* scripts/build-many-glibcs.py (bot_build_mail):  If the
	bot_config does not contain all of the necessary email-
	related settings, just print a warning and continue.
2017-02-16 19:04:11 -05:00
Zack Weinberg ceaa98897c Add missing header files throughout the testsuite.
* crypt/md5.h: Test _LIBC with #if defined, not #if.
	* dirent/opendir-tst1.c: Include sys/stat.h.
	* dirent/tst-fdopendir.c: Include sys/stat.h.
	* dirent/tst-fdopendir2.c: Include stdlib.h.
	* dirent/tst-scandir.c: Include stdbool.h.
	* elf/tst-auditmod1.c: Include link.h and stddef.h.
	* elf/tst-tls15.c: Include stdlib.h.
	* elf/tst-tls16.c: Include stdlib.h.
	* elf/tst-tls17.c: Include stdlib.h.
	* elf/tst-tls18.c: Include stdlib.h.
	* iconv/tst-iconv6.c: Include endian.h.
	* iconvdata/bug-iconv11.c: Include limits.h.
	* io/test-utime.c: Include stdint.h.
	* io/tst-faccessat.c: Include sys/stat.h.
	* io/tst-fchmodat.c: Include sys/stat.h.
	* io/tst-fchownat.c: Include sys/stat.h.
	* io/tst-fstatat.c: Include sys/stat.h.
	* io/tst-futimesat.c: Include sys/stat.h.
	* io/tst-linkat.c: Include sys/stat.h.
	* io/tst-mkdirat.c: Include sys/stat.h and stdbool.h.
	* io/tst-mkfifoat.c: Include sys/stat.h and stdbool.h.
	* io/tst-mknodat.c: Include sys/stat.h and stdbool.h.
	* io/tst-openat.c: Include stdbool.h.
	* io/tst-readlinkat.c: Include sys/stat.h.
	* io/tst-renameat.c: Include sys/stat.h.
	* io/tst-symlinkat.c: Include sys/stat.h.
	* io/tst-unlinkat.c: Include stdbool.h.
	* libio/bug-memstream1.c: Include stdlib.h.
	* libio/bug-wmemstream1.c: Include stdlib.h.
	* libio/tst-fwrite-error.c: Include stdlib.h.
	* libio/tst-memstream1.c: Include stdlib.h.
	* libio/tst-memstream2.c: Include stdlib.h.
	* libio/tst-memstream3.c: Include stdlib.h.
	* malloc/tst-interpose-aux.c: Include stdint.h.
	* misc/tst-preadvwritev-common.c: Include sys/stat.h.
	* nptl/tst-basic7.c: Include limits.h.
	* nptl/tst-cancel25.c: Include pthread.h, not pthreadP.h.
	* nptl/tst-cancel4.c: Include stddef.h, limits.h, and sys/stat.h.
	* nptl/tst-cancel4_1.c: Include stddef.h.
	* nptl/tst-cancel4_2.c: Include stddef.h.
	* nptl/tst-cond16.c: Include limits.h.
	Use sysconf(_SC_PAGESIZE) instead of __getpagesize.
	* nptl/tst-cond18.c: Include limits.h.
	Use sysconf(_SC_PAGESIZE) instead of __getpagesize.
	* nptl/tst-cond4.c: Include stdint.h.
	* nptl/tst-cond6.c: Include stdint.h.
	* nptl/tst-stack2.c: Include limits.h.
	* nptl/tst-stackguard1.c: Include stddef.h.
	* nptl/tst-tls4.c: Include stdint.h. Don't include tls.h.
	* nptl/tst-tls4moda.c: Include stddef.h.
	Don't include stdio.h, unistd.h, or tls.h.
	* nptl/tst-tls4modb.c: Include stddef.h.
	Don't include stdio.h, unistd.h, or tls.h.
	* nptl/tst-tls5.h: Include stddef.h. Don't include stdlib.h or tls.h.
	* posix/tst-getaddrinfo2.c: Include stdio.h.
	* posix/tst-getaddrinfo5.c: Include stdio.h.
	* posix/tst-pathconf.c: Include sys/stat.h.
	* posix/tst-posix_fadvise-common.c: Include stdint.h.
	* posix/tst-preadwrite-common.c: Include sys/stat.h.
	* posix/tst-regex.c: Include stdint.h.
	Don't include spawn.h or spawn_int.h.
	* posix/tst-regexloc.c: Don't include spawn.h or spawn_int.h.
	* posix/tst-vfork3.c: Include sys/stat.h.
	* resolv/tst-bug18665-tcp.c: Include stdlib.h.
	* resolv/tst-res_hconf_reorder.c: Include stdlib.h.
	* resolv/tst-resolv-search.c: Include stdlib.h.
	* stdio-common/tst-fmemopen2.c: Include stdint.h.
	* stdio-common/tst-vfprintf-width-prec.c: Include stdlib.h.
	* stdlib/test-canon.c: Include sys/stat.h.
	* stdlib/tst-tls-atexit.c: Include stdbool.h.
	* string/test-memchr.c: Include stdint.h.
	* string/tst-cmp.c: Include stdint.h.
	* sysdeps/pthread/tst-timer.c: Include stdint.h.
	* sysdeps/unix/sysv/linux/tst-sync_file_range.c: Include stdint.h.
	* sysdeps/wordsize-64/tst-writev.c: Include limits.h and stdint.h.
	* sysdeps/x86_64/fpu/math-tests-arch.h: Include cpu-features.h.
	Don't include init-arch.h.
	* sysdeps/x86_64/multiarch/test-multiarch.h: Include cpu-features.h.
	Don't include init-arch.h.
	* sysdeps/x86_64/tst-auditmod10b.c: Include link.h and stddef.h.
	* sysdeps/x86_64/tst-auditmod3b.c: Include link.h and stddef.h.
	* sysdeps/x86_64/tst-auditmod4b.c: Include link.h and stddef.h.
	* sysdeps/x86_64/tst-auditmod5b.c: Include link.h and stddef.h.
	* sysdeps/x86_64/tst-auditmod6b.c: Include link.h and stddef.h.
	* sysdeps/x86_64/tst-auditmod6c.c: Include link.h and stddef.h.
	* sysdeps/x86_64/tst-auditmod7b.c: Include link.h and stddef.h.
	* time/clocktest.c: Include stdint.h.
	* time/tst-posixtz.c: Include stdint.h.
	* timezone/tst-timezone.c: Include stdint.h.
2017-02-16 17:33:18 -05:00
Zack Weinberg e546c3c99f ChangeLog entry for previous changeset 2017-02-16 17:05:51 -05:00
Zack Weinberg ab9536a75d Move bits/types.h into posix/bits.
bits/types.h has no sysdeps variants, so it should be in the
subdirectory that installs it (namely, posix).

	* bits/types.h: Move to posix/bits.
	* include/bits/types.h: New wrapper.
2017-02-16 09:43:50 -05:00
Wilco Dijkstra f7db120f67 Remove the str(n)cmp inlines from string/bits/string2.h. The strncmp
optimization seems unlikely to ever be useful, but if it occurs in
real code it should be added to GCC.  Expanding strcmp of small strings
does appear useful (benchmarking shows it is 2-3x faster), so this would
be useful to implement in GCC (PR 78809).

	* string/bits/string2.h (strcmp): Remove define.
	(__strcmp_cg): Likewise.
	(strncmp): Likewise.
2017-02-15 15:23:52 +00:00
Wilco Dijkstra 3172b27b2b The internal header include/string.h does not work in C++: it causes link errors
in several C++ debug tests when any of the functions it declares are called.
The best option would be to not use internal headers for tests (unless
explicitly needed).  Add guards so that it is safe to use include/string.h from
C++.

	* include/string.h: Add __cplusplus check.
2017-02-15 15:13:58 +00:00
Gabriel F. T. Gomes 4918e5f4cd Fix y0 and y1 exception handling for zero input [BZ #21134]
The Bessel functions of the second type (Yn) should raise the "divide
by zero" exception when input is zero (both positive and negative).
Current code gives the right output, but fails to set the exception.
This error is exposed for float, double, and long double when linking
with -lieee.  Without this flag, the error is not exposed, because the
wrappers for these functions, which use __kernel_standard
functionality, set the exception as expected.

Tested for powerpc64le.

	[BZ #21134]
	* sysdeps/ieee754/dbl-64/e_j0.c (__ieee754_y0): Raise the
	"divide by zero" exception when the input is zero.
	* sysdeps/ieee754/dbl-64/e_j1.c (__ieee754_y1): Likewise.
	* sysdeps/ieee754/flt-32/e_j0f.c (__ieee754_y0f): Likewise.
	* sysdeps/ieee754/flt-32/e_j1f.c (__ieee754_y1f): Likewise.
	* sysdeps/ieee754/ldbl-128/e_j0l.c (__ieee754_y0l): Likewise.
	* sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_y1l): Likewise.
2017-02-15 10:30:59 -02:00
Joseph Myers 10303eb74b Move most libmvec test contents from .c to .h files.
The libmvec tests put substantive, architecture-specific contents in
.c files such as test-double-vlen4.c, so making those files
architecture-specific and causing issues for generating such files
automatically when splitting up tests by function.

This patch moves all the substantive contents to .h files, so the .c
files only include the .h file and then libm-test.c.  This allows for
automatic generation of per-function .c files in future.  The .h files
in turn #include or #include_next the architecture-independent file
and add the architecture-specific definitions to that.  (Splitting by
function should in fact allow the TEST_VECTOR_* macros to be replaced
by sysdeps makefile information on which functions to test in each
case, removing the need for gen-libm-have-vector-test.sh as well as
removing the need for some of the architecture-specific headers.)

Tested for x86_64.

	* sysdeps/x86_64/fpu/test-double-vlen2.c: Move most contents to,
	and include ...
	* sysdeps/x86_64/fpu/test-double-vlen2.h: ... here.  New file.
	* sysdeps/x86_64/fpu/test-double-vlen4-avx2.c: Move most contents
	to, and include ...
	* sysdeps/x86_64/fpu/test-double-vlen4-avx2.h: ... here.  New
	file.
	* sysdeps/x86_64/fpu/test-double-vlen4.c: Move most contents to,
	and include ...
	* sysdeps/x86_64/fpu/test-double-vlen4.h: ... here.  New file.
	* sysdeps/x86_64/fpu/test-double-vlen8.c: Move most contents to,
	and include ...
	* sysdeps/x86_64/fpu/test-double-vlen8.h: ... here.  New file.
	* sysdeps/x86_64/fpu/test-float-vlen16.c: Move most contents to,
	and include ...
	* sysdeps/x86_64/fpu/test-float-vlen16.h: ... here.  New file.
	* sysdeps/x86_64/fpu/test-float-vlen4.c: Move most contents to,
	and include ...
	* sysdeps/x86_64/fpu/test-float-vlen4.h: ... here.  New file.
	* sysdeps/x86_64/fpu/test-float-vlen8-avx2.c: Move most contents
	to, and include ...
	* sysdeps/x86_64/fpu/test-float-vlen8-avx2.h: ... here.  New file.
	* sysdeps/x86_64/fpu/test-float-vlen8.c: Move most contents to,
	and include ...
	* sysdeps/x86_64/fpu/test-float-vlen8.h: ... here.  New file.
2017-02-15 01:13:15 +00:00
Joseph Myers b4e4172da6 Move INIT_ARCH_EXT call from libm-test-support to libm-test-driver.
libmvec tests involve calling INIT_ARCH_EXT during initialization then
CHECK_ARCH_EXT before testing each function to see if the processor
being used for testing supports the required instruction set
extensions.

After my refactoring of libm-test infrastructure, the INIT_ARCH_EXT
call is in libm-test-support.c, built only once per floating-point
type.  Now, in fact all definitions of this macro are empty, but given
that the definitions in sysdeps/x86_64/fpu/math-tests-arch.h are
conditional on REQUIRE_* macros defined in particular vector tests, it
seems more correct for the INIT_ARCH_EXT call to go instead in
libm-test-driver.c which gets built separately with those REQUIRE_*
macros properly defined.  This patch moves the call there.

Tested for x86_64 and x86.

	* math/libm-test-support.h: Do not include <math-tests-arch.h>
	here.
	* math/libm-test-support.c (libm_test_init): Do not call
	INIT_ARCH_EXT here.
	* math/libm-test-driver.c: Include <math-tests-arch.h>.
	(main): Call INIT_ARCH_EXT.
2017-02-14 00:15:48 +00:00
Gabriel F. T. Gomes b987917e6a ldbl-128: Fix y0 and y1 for -Inf input [BZ #21130]
The Bessel functions of the second type (Yn) are not defined for
negative input and should return NAN with the "invalid" exception
raised, in these cases.  However, current code checks for infinity and
return zero, regardless of the sign.  This error is exposed for long
double when linking with -lieee.  Without this flag, the error is not
exposed, because the wrappers for these functions, which use
__kernel_standard functionality, return the correct value.

Tested for powerpc64le.

	[BZ #21130]
	* sysdeps/ieee754/ldbl-128/e_j0l.c (__ieee754_y0l): Return NAN
	with the "invalid" exception raised when x is -Inf.
	* sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_y1l): Likewise.
2017-02-12 18:30:38 -02:00
Wilco Dijkstra 40b7fbf273 GLIBC uses strchr (s, '\0') as an idiom to find the end of a string.
This is transformed into rawmemchr by the bits/string2.h header.
However this is generally slower than strlen on most targets, even when
an optimized rawmemchr implementation exists.  Since GCC7 optimizes
strchr (s, '\0') to strlen (s) + s, the GLIBC headers should not
transform this to rawmemchr.  As GCC recognizes strchr as a builtin,
defining strchr as the builtin is not useful.

	* string/bits/string2.h (strchr): Remove define.
2017-02-10 17:28:11 +00:00
H.J. Lu 3403a17fea x86-64: Verify that _dl_runtime_resolve preserves vector registers
On x86-64, _dl_runtime_resolve must preserve the first 8 vector
registers.  Add 3 _dl_runtime_resolve tests to verify that SSE,
AVX and AVX512 registers are preserved.

	* sysdeps/x86_64/Makefile (tests): Add tst-sse, tst-avx and
	tst-avx512.
	(test-extras): Add tst-avx-aux and tst-avx512-aux.
	(extra-test-objs): Add tst-avx-aux.o and tst-avx512-aux.o.
	(modules-names): Add tst-ssemod, tst-avxmod and tst-avx512mod.
	($(objpfx)tst-sse): New rule.
	($(objpfx)tst-avx): Likewise.
	($(objpfx)tst-avx512): Likewise.
	(CFLAGS-tst-avx-aux.c): New.
	(CFLAGS-tst-avxmod.c): Likewise.
	(CFLAGS-tst-avx512-aux.c): Likewise.
	(CFLAGS-tst-avx512mod.c): Likewise.
	* sysdeps/x86_64/tst-avx-aux.c: New file.
	* sysdeps/x86_64/tst-avx.c: Likewise.
	* sysdeps/x86_64/tst-avx512-aux.c: Likewise.
	* sysdeps/x86_64/tst-avx512.c: Likewise.
	* sysdeps/x86_64/tst-avx512mod.c: Likewise.
	* sysdeps/x86_64/tst-avxmod.c: Likewise.
	* sysdeps/x86_64/tst-sse.c: Likewise.
	* sysdeps/x86_64/tst-ssemod.c: Likewise.
2017-02-09 12:19:58 -08:00
Joseph Myers 1266b9361a Move more csin, csinh tests to auto-libm-test-in.
When I moved tests of csin and csinh to auto-libm-test-in, I didn't
move a few tests for which gen-auto-libm-tests was very slow because
of MPC slowness on certain inputs.

Now that auto-libm-test-out has been split up, such slowness only
affects regenerating the test expectations for the individual
functions in question, rather than any addition of tests for any
function to auto-libm-test-in.  Thus, I no longer consider it a
problem to have these inputs in auto-libm-test-in, and this patch
moves them there.  This results in test generation for csin and csinh
taking 5m43s (for each of csin and csinh) on my system, while other
functions are unaffected.

I expect the test generation to be much faster in MPC 1.1 (the
relevant performance improvements went in MPC mainline in Dec 2013,
but there hasn't been a release from mainline since then).

Tested for x86_64 and x86.

	* math/auto-libm-test-in: Add more tests of csin and csinh.
	* math/auto-libm-test-out-csin: Regenerated.
	* math/auto-libm-test-out-csinh: Likewise.
	* math/libm-test-csin.inc (csin_test_data): Remove tests moved to
	auto-libm-test-in.
	* math/libm-test-csinh.inc (csinh_test_data): Likewise.
2017-02-09 18:30:41 +00:00
Gabriel F. T. Gomes 3789e2fd9d Merge libm-compat-calls-auto and libm-compat-calls
Both libm-compat-calls and libm-compat-calls-auto list the functions
that must be built for the types float, double, and long double, but
not for other floating-point types that get added to libm.  Besides
that, the use of libm-compat-calls-ldouble-yes to select if
w_lgamma_compatl and k_standardl should be built for long-double (in
libm-compat-calls) has the same effect of the use of type-foreach
(in libm-compat-calls-auto).

This patch merges the contents of libm-compat-calls into
libm-compat-calls-auto, then renames the latter to libm-compat-calls.

Tested for powerpc64le, s390, and x86_64.

	* math/Makefile (libm-compat-calls-ldouble-yes): Merge into
	libm-compat-calls-auto.
	(libm-compat-calls): Likewise.
	(libm-compat-calls-auto): Rename to libm-compat-calls and add
	w_lgamma_compatF and k_standardF (merged from the items above).
	(libm-routines): Use libm-compat-calls, instead of
	libm-compat-calls-auto, with type-foreach.
2017-02-09 15:58:41 -02:00
Joseph Myers 9b40563c8b Move -U__LIBC_INTERNAL_MATH_INLINES to test-math-inline.h.
The libm tests of inline functions undefine __NO_MATH_INLINES (from
math-CPPFLAGS) in test-math-inline.h, but __LIBC_INTERNAL_MATH_INLINES
via -U options in the makefile.

This is an odd inconsistency between the handling of the two macros.
It also depends on the ordering (in compilation commands) of the
various variables providing compiler options (which I think is why
it's using CPPFLAGS-*.c instead of CFLAGS-*.c).

This patch moves the undefine to test-math-inline.h, so improving
consistency and eliminating the dependency on the order in which
variables go in the compilation commands.  The CPPFLAGS-*.c variables
are renamed to CFLAGS-*.c, matching those for the non-inline libm
function tests.

By moving the -U option to the header file, this should ensure that
ordering issues don't arise with a subsequent move of the options to
these tests to target-specific CFLAGS += ... variable settings (for
when tests for each function are build separately and so compilation
options need setting for many more makefile targets, for which
target-specific variable settings seem to be the most convenient form
to generate with iterators).

Tested for x86_64.

	* math/test-math-inline.h (__LIBC_INTERNAL_MATH_INLINES): Undefine
	macro.
	* math/Makefile (CPPFLAGS-test-ifloat.c): Rename to ...
	(CFLAGS-test-ifloat.c): ... this.  Remove
	-U__LIBC_INTERNAL_MATH_INLINES.
	* math/Makefile (CPPFLAGS-test-idouble.c): Rename to ...
	(CFLAGS-test-idouble.c): ... this.  Remove
	-U__LIBC_INTERNAL_MATH_INLINES.
	* math/Makefile (CPPFLAGS-test-ildouble.c): Rename to ...
	(CFLAGS-test-ildouble.c): ... this.  Remove
	-U__LIBC_INTERNAL_MATH_INLINES.
2017-02-09 17:32:48 +00:00
Joseph Myers 3b2f60328e Build most libm-test support code once per type.
libm-test-driver.c contains various functions used in the course of
libm testing, which are built as part of each test using this
machinery.

Currently, these functions get built for three tests for each type
(e.g. test-float, test-ifloat, test-float-finite), plus the vector
function tests.  All these tests are huge and thus slow to build; the
output of gen-libm-test.pl totals around 40 MB across all functions.
To make the individual tests built from the Makefile smaller, it makes
sense to split these tests up so the tests for each function are built
separately (thus, three tests for each (function, type) pair, plus
vector tests built only for functions that actually have vector
versions).  This improves parallelism and means that if tests fail,
the summary of failed tests makes it more obvious where the problem
might be without needing to look in the .out files to see which
functions' tests failed (though architecture maintainers still need to
keep libm-test-ulps up to date to avoid spurious failures of little
interest).

Simply including libm-test-driver.c as-is in such individual-function
tests does not work because of unused static check_* functions (those
functions only being used for the types of the outputs of the function
under test).  It also means the common code gets built over 1000 times
instead of nine (plus vector tests).  To avoid that issue, this patch
splits out the bulk of the libm-test-driver.c code into a separate
file libm-test-support.c (with a few functions made non-static).  That
separate file is built only once for each floating-point type (so at
present three times, or twice on architectures with long double =
double).  Definitions needed in both libm-test-support.c and
libm-test-driver.c go in libm-test-support.h (it's possible some of
those are in fact only needed in one of the two files).
libm-test-driver.c keeps definitions of a limited number of variables
used to configure how libm-test-support.c behaves, various macros and
structures needed by individual-function tests, and the main function.

This move is also consistent in spirit with the move away from
test-skeleton.c having all the test support code, to a small
support/test-driver.c included in individual tests with most of the
code built separately.

Tested for x86_64 and x86.

	* math/libm-test-support.c: New file.  Content from
	math/libm-test-driver.c.
	* math/libm-test-support.h: Likewise.
	* math/libm-test-support-double.c: New file.
	* math/libm-test-support-float.c: Likewise.
	* math/libm-test-support-ldouble.c: Likewise.
	* math/libm-test-driver.c: Remove main comment and header
	includes.  Include libm-test-support.h.
	[!_GNU_SOURCE] (_GNU_SOURCE): Do not define.
	(flag_test_errno): Remove static.
	(flag_test_exceptions): Likewise.
	(flag_test_finite): Likewise.
	(flag_test_inline): Likewise.
	(flag_test_mathvec): Likewise.
	(test_msg): Likewise.
	(NO_EXCEPTION): Remove.
	(INVALID_EXCEPTION): Likewise.
	(DIVIDE_BY_ZERO_EXCEPTION): Likewise.
	(OVERFLOW_EXCEPTION): Likewise.
	(UNDERFLOW_EXCEPTION): Likewise.
	(INEXACT_EXCEPTION): Likewise.
	(INVALID_EXCEPTION_OK): Likewise.
	(DIVIDE_BY_ZERO_EXCEPTION_OK): Likewise.
	(OVERFLOW_EXCEPTION_OK): Likewise.
	(UNDERFLOW_EXCEPTION_OK): Likewise.
	(NO_INEXACT_EXCEPTION): Likewise.
	(EXCEPTIONS_OK): Likewise.
	(IGNORE_ZERO_INF_SIGN): Likewise.
	(TEST_NAN_SIGN): Likewise.
	(TEST_NAN_PAYLOAD): Likewise.
	(NO_TEST_INLINE): Likewise.
	(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.
	(__CONCATX): Likewise.
	(TYPE_MIN): Likewise.
	(TYPE_TRUE_MIN): Likewise.
	(TYPE_MAX): Likewise.
	(MIN_EXP): Likewise.
	(MAX_EXP): Likewise.
	(MANT_DIG): Likewise.
	(FSTR_MAX): Likewise.
	(ulp_idx): Likewise.
	(qtype_str): Remove static.
	(TEST_COND_binary32): Remove.
	(TEST_COND_binary64): Likewise.
	(TEST_COND_binary128): Likewise.
	(TEST_COND_ibm128): Likewise.
	(TEST_COND_intel96): Likewise.
	(TEST_COND_m68k96): Likewise.
	(TEST_COND_ibm128_libgcc): Likewise.
	(XFAIL_IBM128_LIBGCC): Likewise.
	(PAYLOAD_DIG): Likewise.
	(UNDERFLOW_EXCEPTION_FLOAT): Likewise.
	(UNDERFLOW_EXCEPTION_OK_FLOAT): Likewise.
	(UNDERFLOW_EXCEPTION_DOUBLE): Likewise.
	(UNDERFLOW_EXCEPTION_OK_DOUBLE): Likewise.
	(UNDERFLOW_EXCEPTION_LDOUBLE_IBM): Likewise.
	(UNDERFLOW_EXCEPTION_BEFORE_ROUNDING): Likewise.
	(TEST_COND_long32): Likewise.
	(TEST_COND_long64): Likewise.
	(TEST_COND_before_rounding): Likewise.
	(TEST_COND_after_rounding): Likewise.
	(ulps_file_name): Likewise.
	(ulps_file): Likewise.
	(output_ulps): Likewise.
	(output_dir): Likewise.
	(noErrors): Likewise.
	(noTests): Likewise.
	(noExcTests): Likewise.
	(noErrnoTests): Likewise.
	(verbose): Likewise.
	(output_max_error): Likewise.
	(output_points): Likewise.
	(ignore_max_ulp): Likewise.
	(max_error): Likewise.
	(real_max_error): Likewise.
	(imag_max_error): Likewise.
	(prev_max_error): Likewise.
	(prev_real_max_error): Likewise.
	(prev_imag_max_error): Likewise.
	(max_valid_error): Likewise.
	(TYPE_DECIMAL_DIG): Likewise.
	(TYPE_HEX_DIG): Likewise.
	(fmt_ftostr): Likewise.
	(compare_ulp_data): Likewise.
	(find_ulps): Likewise.
	(init_max_error): Likewise.
	(set_max_error): Likewise.
	(print_float): Likewise.
	(print_screen): Likewise.
	(print_screen_max_error): Likewise.
	(update_stats): Likewise.
	(print_function_ulps): Likewise.
	(print_complex_function_ulps): Likewise.
	(fpstack_test): Likewise.
	(print_max_error): Likewise.
	(print_complex_max_error): Likewise.
	(test_single_exception): Likewise.
	(test_exceptions): Likewise.
	(test_single_errno): Likewise.
	(test_errno): Likewise.
	(ULPDIFF): Likewise.
	(ulp): Likewise.
	(check_float_internal): Likewise.
	(check_float): Likewise.
	(check_complex): Likewise.
	(check_int): Likewise.
	(check_long): Likewise.
	(check_bool): Likewise.
	(check_longlong): Likewise.
	(check_intmax_t): Likewise.
	(check_uintmax_t): Likewise.
	(enable_test): Likewise.
	(matherr): Likewise.
	(initialize): Likewise.
	(options): Likewise.
	(doc): Remove static.
	(argp): Likewise.
	(parse_opt): Remove.
	(check_ulp): Likewise.
	(libm_test_init): Likewise.
	(libm_test_finish): Likewise.
	* math/Makefile (libm-test-support): New variable.
	(test-extras): Add libm-test-support files.
	(extra-test-objs): Likewise.
	(CFLAGS-libm-test-support-float.c): New variable.
	(CFLAGS-libm-test-support-double.c): Likewise.
	(CFLAGS-libm-test-support-ldouble.c): Likewise.
	($(addprefix $(objpfx),$(libm-tests)): Depend on appropriate
	libm-test-support objects.
2017-02-08 21:11:49 +00:00
Gabriel F. T. Gomes 5ab621c347 Move w_exp to libm-compat-call-auto
This patch adds the "_compat" suffix to the wrappers of the function
exp, which use _LIB_VERSION / matherr / __kernel_standard
functionality.

Tested for powerpc64le, s390, and x86_64.

	* math/Makefile (libm-calls): Move w_exp...
	(libm-compat-calls-auto): Here.

	* math/w_expl.c: Add suffix "_compat" to filename.
	* sysdeps/ia64/fpu/w_expl.c: Likewise.
	* sysdeps/ia64/fpu/w_expf.c: Likewise.
	* sysdeps/ia64/fpu/w_exp.c: Likewise.
	* sysdeps/ieee754/dbl-64/w_exp.c: Likewise.
	* sysdeps/ieee754/flt-32/w_expf.c: Likewise.
	* sysdeps/ieee754/ldbl-128/w_expl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/w_expl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/w_expl.c: Likewise.

	* math/w_expl_compat.c: New file, copied from above.
	* sysdeps/ia64/fpu/w_exp_compat.c: Likewise.
	* sysdeps/ia64/fpu/w_expf_compat.c: Likewise.
	* sysdeps/ia64/fpu/w_expl_compat.c: Likewise.
	* sysdeps/ieee754/dbl-64/w_exp_compat.c: Likewise.
	* sysdeps/ieee754/flt-32/w_expf_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-128/w_expl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/w_expl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-96/w_expl_compat.c: Likewise.

	* sysdeps/ieee754/ldbl-64-128/w_expl.c: Add suffix "_compat"
	to filename.
	* sysdeps/ieee754/ldbl-opt/w_exp.c: Likewise.

	* sysdeps/ieee754/ldbl-64-128/w_expl_compat.c: New file,
	copied from above and adjusted for the new filenames.
	* sysdeps/ieee754/ldbl-opt/w_exp_compat.c: Likewise.
2017-02-08 17:44:20 -02:00
Gabriel F. T. Gomes 163f65e28c Move w_lgamma to libm-compat-calls-auto
This patch adds the suffix "_compat2" to the wrappers for lgamma,
which use _LIB_VERSION / matherr / __kernel_standard functionality.
The suffix "_compat2" is used because the suffix "_compat" is already
used.

Tested for powerpc64le, s390, and x86_64.

	* math/Makefile (libm-calls): Move w_lgammaF...
	(libm-compat-calls-auto): Here.

	* math/w_lgamma.c: Add suffix "_compat2" to filename.
	* math/w_lgammaf.c: Likewise.
	* math/w_lgammal.c: Likewise.

	* math/w_lgamma_compat2.c: New file, copied from above.
	* math/w_lgammaf_compat2.c: Likewise.
	* math/w_lgammal_compat2.c: Likewise.
2017-02-08 17:40:11 -02:00
Gabriel F. T. Gomes ea814db27a Move w_lgamma_r to libm-compat-calls-auto
This patch adds the suffix "_compat" to lgamma_r wrappers and make
some adjustments to #includes and Makefiles.  This is a step towards
deprecation of wrappers that use _LIB_VERSION / matherr /
__kernel_standard functionality.

Tested for powerpc64le, s390, and x86_64.

	* math/Makefile (libm-calls): Move w_lgammaF_r...
	(libm-compat-calls-auto): Here.

	* math/w_lgamma_r.c: Add suffix "_compat" to filename.
	* math/w_lgammaf_r.c: Likewise.
	* math/w_lgammal_r.c: Likewise.
	* sysdeps/ia64/fpu/w_lgammal_r.c: Likewise.
	* sysdeps/ia64/fpu/w_lgammaf_r.c: Likewise.
	* sysdeps/ia64/fpu/w_lgamma_r.c: Likewise.

	* math/w_lgamma_r_compat.c: New file, copied from above.
	* math/w_lgammaf_r_compat.c: Likewise.
	* math/w_lgammal_r_compat.c: Likewise.
	* sysdeps/ia64/fpu/w_lgamma_r_compat.c: Likewise.
	* sysdeps/ia64/fpu/w_lgammaf_r_compat.c: Likewise.
	* sysdeps/ia64/fpu/w_lgammal_r_compat.c: Likewise.

	* sysdeps/ieee754/ldbl-opt/w_lgamma_r.c: Add suffix "_compat"
	to filename.
	* sysdeps/ieee754/ldbl-opt/w_lgammal_r.c: Likewise.

	* sysdeps/ieee754/ldbl-opt/w_lgamma_r_compat.c: New file
	copied from above and adjusted for the new filenames.
	* sysdeps/ieee754/ldbl-opt/w_lgammal_r_compat.c: Likewise.
2017-02-08 17:36:09 -02:00
Adhemerval Zanella 42de7e2029 aarch64: fix errno address calculation in SYSCALL_ERROR_HANDLER
This patch fixes the last regression in LTP lite scenario (mmap16) comparing
to lp64 in my source trees [1, 2]. The fix has been suggested back in 2015 [3]
but was never applied.

Checked on aarch64-linux-gnu.

	* sysdeps/unix/sysv/linux/aarch64/sysdep.h: use PTR_REG() for offset
	calculation in SYSCALL_ERROR_HANDLER().

[1] https://github.com/norov/glibc/tree/dev9
[2] https://github.com/norov/linux/tree/ilp32-20170203
[3] https://sourceware.org/ml/libc-alpha/2015-03/msg00587.html
2017-02-08 16:30:43 -02:00
Rical Jasan ef8659eab6 Fix a typo in the manual.
I only caught this because I saw a file in manual/ change.  Oh, the
irony...  and thank you!

	* manual/contrib.texi: Fix typo.
2017-02-08 01:34:12 -08:00
Siddhesh Poyarekar 8cbc826c37 Fix getting tunable values on big-endian (BZ #21109)
The code to set value passed a tunable_val_t, which when cast to
int32_t on big-endian gives the wrong value.  Instead, use
tunable_val_t.numval instead, which can then be safely cast into
int32_t.
2017-02-08 14:17:17 +05:30
Kir Kolyshkin 3f67d1a702 Add Linux PTRACE_EVENT_STOP
Add PTRACE_EVENT_STOP value to Linux's sys/ptrace.h, modify related
comments accordingly.

This constant initially appeared in Linux 3.1 (kernel commit 3544d72a,
"ptrace: implement PTRACE_SEIZE") but its value has changed later
in Linux 3.4 (kernel commit 5cdf389a, "ptrace: renumber
PTRACE_EVENT_STOP so that future new options and events can match").

The comment is also taken from the above commit.

This constant is used by e.g. strace, CRIU, Mozilla RR.

* sysdeps/unix/sysv/linux/aarch64/sys/ptrace.h (__ptrace_eventcodes):
Add PTRACE_EVENT_STOP.
* sysdeps/unix/sysv/linux/ia64/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/s390/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/sys/ptrace.h: Likewise.
* sysdeps/unix/sysv/linux/tile/sys/ptrace.h: Likewise.
2017-02-08 07:18:44 +00:00
Joseph Myers 12d6284c0e Clean up libm vector tests exception test disabling.
The libm vector tests disable tests of exception raising via defining
macros EXCEPTION_TESTS_float and EXCEPTION_TESTS_double to 0 in the
headers for individual vector lengths.

As EXCEPTION_TESTS is used in code in libm-test-driver.c that is
otherwise ready to be built only once per type, this is not a good
idea; it's better to define TEST_EXCEPTIONS appropriately so that
flag_test_exceptions then gets initialized appropriately.
Furthermore, it's better to do this just once, in test-math-vector.h,
since there is no actual dependence on the vector length or type.
This patch duly makes that change.

Tested for x86_64.

	* math/test-math-finite.h (TEST_EXCEPTIONS): New macro.
	* math/test-math-no-finite.h (TEST_EXCEPTIONS): Likewise.
	* math/test-math-vector.h (TEST_EXCEPTIONS): Likewise.
	* math/test-math-no-inline.h (TEST_EXCEPTIONS): Remove macro.
	* math/test-double-vlen2.h (EXCEPTION_TESTS_double): Likewise.
	* math/test-double-vlen4.h (EXCEPTION_TESTS_double): Likewise.
	* math/test-double-vlen8.h (EXCEPTION_TESTS_double): Likewise.
	* math/test-float-vlen4.h (EXCEPTION_TESTS_float): Likewise.
	* math/test-float-vlen8.h (EXCEPTION_TESTS_float): Likewise.
	* math/test-float-vlen16.h (EXCEPTION_TESTS_float): Likewise.
2017-02-07 23:06:19 +00:00
Joseph Myers edbbdb1855 Fix powf inaccuracy (bug 21112).
Bug 21112 reports a case where powf is substantially inaccurate.  This
results from a multiplication where cp_h*p_h is required to be exact,
and p_h is masked to have only 12 leading nonzero bits in its
mantissa, but the value of cp_h has the 13th bit nonzero, leading to
inexact multiplication results in some cases that can result in large
errors in the final result of powf.  This patch fixes this by using a
value of cp_h correctly rounded to nearest to 12 bits, with a
corresponding updated value of cp_l.

Tested for x86_64 and x86.

	[BZ #21112]
	* sysdeps/ieee754/flt-32/e_powf.c (cp_h): Use value with trailing
	12 bits zero.
	(cp_l): Update for new value of cp_h.
	* math/auto-libm-test-in: Add another test of pow.
	* math/auto-libm-test-out-pow: Regenerated.
2017-02-07 17:15:47 +00:00
Siddhesh Poyarekar 43ce02c6ec Fix typo in manual
Apparently, implementating is not a word; who would have thunk it...
2017-02-07 18:49:45 +05:30
Rajalakshmi Srinivasaraghavan c2ff5ec13f powerpc: Set minimum kernel version for powerpc64le
This patch sets the minimum kernel version required for ppc64le as 3.10.0.
2017-02-07 10:49:47 +05:30
Rajalakshmi Srinivasaraghavan e688cceee5 powerpc: Use latest optimizations for internal function calls
Some of the power8 strings optimizations are not updated to use the latest
version of other string optimizations
2017-02-07 10:42:06 +05:30
Rajalakshmi Srinivasaraghavan 04f0fd640d powerpc: Improve strcmp performance for shorter strings
For strings >16B and <32B existing algorithm takes more time than default
implementation when strings are placed closed to end of page. This is due
to byte by byte access for handling page cross. This is improved by
following >32B code path where the address is adjusted to aligned memory
before doing load doubleword operation instead of loading bytes.

Tested on powerpc64 and powerpc64le.
2017-02-07 10:40:26 +05:30
Joseph Myers dcd4cd5756 Refactor some code in libm-test-driver.c.
Splitting libm tests by function will mean about a thousand such tests
built separately instead of the present nine (plus vector variants).

When this is done, it's desirable to avoid needing to build all the
test infrastructure so many times.  Also, simply including
libm-test-driver.c as-is into per-function tests doesn't actually
work, because the various check_* functions are not used by all tests
and so generate errors for unused static functions.

Although some pieces of infrastructure depend on the type being tested
while others don't, building once per type seems the simplest
approach.  This patch makes changes to libm-test-driver.c in
preparation for that.  Various cases where functions directly use
macros such as TEST_ERRNO (that may vary depending on things other
than the type under test) are changed to use variables initialized
using those macros, while most of the code in main is moved out to
functions libm_test_init and libm_test_fini.

The idea is that all the functions in libm-test-driver.c will be moved
out in a subsequent patch to be built once per type (and be no longer
static when they are used from per-function tests), while
libm-test-driver.c remains containing definitions of various variables
(no longer static, of course, because they'll be used in the per-type
code) and the main function.  Declarations / macros relevant to both
the once-per-type code and the per-function tests will go in a shared
header.

Tested for x86_64.

	* math/libm-test-driver.c (flag_test_errno): New variable.
	(flag_test_exceptions): Likewise.
	(flag_test_finite): Likewise.
	(flag_test_inline): Likewise.
	(flag_test_mathvec): Likewise.
	(test_msg): Likewise.
	(ulp_idx): Likewise.
	(qtype_str): Likewise.
	(ULP_IDX): Remove macro.
	(QTYPE_STR): Likewise.
	(find_ulps): Use ulp_idx not ULP_IDX.
	(print_function_ulps): Use qtype_str, printed with %s, not
	QTYPE_STR, printed with concatentation to format string.
	(print_complex_function_ulps): Likewise.
	(test_exceptions): Use flag_test_exceptions not TEST_EXCEPTIONS.
	(test_errno): Use flag_test_errno not TEST_ERRNO.
	(enable_test): Use flag_test_inline, flag_test_finite and
	flag_test_mathvec instead of TEST_INLINE, TEST_FINITE and
	TEST_MATHVEC.
	(libm_test_init): New function.  Factored out of main.
	(libm_test_finish): Likewise.
	(main): Call libm_test_init and libm_test_finish and move most
	code to those functions.
2017-02-06 23:23:54 +00:00
Joseph Myers a622c2db55 Move libm-test TEST_MSG definitions to libm-test-driver.c.
Various files using the libm-test infrastructure define a TEST_MSG
macro with an informal description of the tests being run.

This patch moves this macro to libm-test-driver.c (the definition
depending on other macros already defined), so files specific to
(type, choice of whether to test inline functions or finite-math-only
functions, vector length) no longer need to define it.  This is in
preparation for replacing files such as test-float.c with per-function
test-float-<func>.c etc. automatically generated in the build
directory when tests are run.

Tested for x86_64.

	* math/libm-test-driver.c (STRX): New macro.
	(STR): Likewise.
	(STR_FLOAT): Likewise.
	(STR_VEC_LEN): Likewise.
	(TEST_MSG): Likewise.  Define here instead of expecting to be
	defined by including file.
	* math/test-double-finite.c (TEST_MSG): Remove macro.
	* math/test-double-vlen2.h (TEST_MSG): Likewise.
	* math/test-double-vlen4.h (TEST_MSG): Likewise.
	* math/test-double-vlen8.h (TEST_MSG): Likewise.
	* math/test-double.c (TEST_MSG): Likewise.
	* math/test-float-finite.c (TEST_MSG): Likewise.
	* math/test-float-vlen16.h (TEST_MSG): Likewise.
	* math/test-float-vlen4.h (TEST_MSG): Likewise.
	* math/test-float-vlen8.h (TEST_MSG): Likewise.
	* math/test-float.c (TEST_MSG): Likewise.
	* math/test-idouble.c (TEST_MSG): Likewise.
	* math/test-ifloat.c (TEST_MSG): Likewise.
	* math/test-ildouble.c (TEST_MSG): Likewise.
	* math/test-ldouble-finite.c (TEST_MSG): Likewise.
	* math/test-ldouble.c (TEST_MSG): Likewise.
2017-02-06 23:07:22 +00:00
Joseph Myers 5cbb58493d Split libm-test.inc by function.
Continuing the process of splitting up libm tests into more reasonably
sized units, this patch splits libm-test.inc into 121 separate
libm-test-<function>.inc files, one per array of test data.  (There
are 126 libm *_test functions, but five of those are for functions
that are aliases for test purposes and so share arrays of test data.)

In the present patch, the 121 files get processed separately by
gen-libm-test.pl, each using only the auto-libm-test-out-<function>
file that is relevant (/dev/null for functions not using
auto-libm-test-* at all).  This effectively eliminates the
serialization on running gen-libm-test.pl.  However, the resulting .c
files still all get #included together, so compiling the limited
number of libm tests using libm-test.inc may still act as a
serialization point (the compilations still all have 40 MB of code to
process).  libm-test.inc doesn't actually have anything in it any more
that needs gen-libm-test.pl processing, but is left as a .inc file
that gets processed to produce a .c file, rather than being renamed,
since the intent of this patch is as an intermediate step before
libm-test.inc gets removed and tests get compiled separately for each
function being tested.

Tested for x86_64.

	* math/libm-test.inc: Move all tests of individual functions to
	libm-test-*.inc and #include libm-test-*.c files.
	(acos_test_data): Remove.
	(acos_test): Likewise.
	(acosh_test_data): Likewise.
	(acosh_test): Likewise.
	(asin_test_data): Likewise.
	(asin_test): Likewise.
	(asinh_test_data): Likewise.
	(asinh_test): Likewise.
	(atan_test_data): Likewise.
	(atan_test): Likewise.
	(atanh_test_data): Likewise.
	(atanh_test): Likewise.
	(atan2_test_data): Likewise.
	(atan2_test): Likewise.
	(cabs_test_data): Likewise.
	(cabs_test): Likewise.
	(cacos_test_data): Likewise.
	(cacos_test): Likewise.
	(cacosh_test_data): Likewise.
	(cacosh_test): Likewise.
	(canonicalize_test_data): Likewise.
	(canonicalize_test): Likewise.
	(carg_test_data): Likewise.
	(carg_test): Likewise.
	(casin_test_data): Likewise.
	(casin_test): Likewise.
	(casinh_test_data): Likewise.
	(casinh_test): Likewise.
	(catan_test_data): Likewise.
	(catan_test): Likewise.
	(catanh_test_data): Likewise.
	(catanh_test): Likewise.
	(cbrt_test_data): Likewise.
	(cbrt_test): Likewise.
	(ccos_test_data): Likewise.
	(ccos_test): Likewise.
	(ccosh_test_data): Likewise.
	(ccosh_test): Likewise.
	(ceil_test_data): Likewise.
	(ceil_test): Likewise.
	(cexp_test_data): Likewise.
	(cexp_test): Likewise.
	(cimag_test_data): Likewise.
	(cimag_test): Likewise.
	(clog_test_data): Likewise.
	(clog_test): Likewise.
	(clog10_test_data): Likewise.
	(clog10_test): Likewise.
	(conj_test_data): Likewise.
	(conj_test): Likewise.
	(copysign_test_data): Likewise.
	(copysign_test): Likewise.
	(cos_test_data): Likewise.
	(cos_test): Likewise.
	(cosh_test_data): Likewise.
	(cosh_test): Likewise.
	(cpow_test_data): Likewise.
	(cpow_test): Likewise.
	(cproj_test_data): Likewise.
	(cproj_test): Likewise.
	(creal_test_data): Likewise.
	(creal_test): Likewise.
	(csin_test_data): Likewise.
	(csin_test): Likewise.
	(csinh_test_data): Likewise.
	(csinh_test): Likewise.
	(csqrt_test_data): Likewise.
	(csqrt_test): Likewise.
	(ctan_test_data): Likewise.
	(ctan_test): Likewise.
	(ctanh_test_data): Likewise.
	(ctanh_test): Likewise.
	(erf_test_data): Likewise.
	(erf_test): Likewise.
	(erfc_test_data): Likewise.
	(erfc_test): Likewise.
	(exp_test_data): Likewise.
	(exp_test): Likewise.
	(exp10_test_data): Likewise.
	(exp10_test): Likewise.
	(pow10_test): Likewise.
	(exp2_test_data): Likewise.
	(exp2_test): Likewise.
	(expm1_test_data): Likewise.
	(expm1_test): Likewise.
	(fabs_test_data): Likewise.
	(fabs_test): Likewise.
	(fdim_test_data): Likewise.
	(fdim_test): Likewise.
	(floor_test_data): Likewise.
	(floor_test): Likewise.
	(fma_test_data): Likewise.
	(fma_test): Likewise.
	(fmax_test_data): Likewise.
	(fmax_test): Likewise.
	(fmaxmag_test_data): Likewise.
	(fmaxmag_test): Likewise.
	(fmin_test_data): Likewise.
	(fmin_test): Likewise.
	(fminmag_test_data): Likewise.
	(fminmag_test): Likewise.
	(fmod_test_data): Likewise.
	(fmod_test): Likewise.
	(fpclassify_test_data): Likewise.
	(fpclassify_test): Likewise.
	(frexp_test_data): Likewise.
	(frexp_test): Likewise.
	(fromfp_test_data): Likewise.
	(fromfp_test): Likewise.
	(fromfpx_test_data): Likewise.
	(fromfpx_test): Likewise.
	(getpayload_test_data): Likewise.
	(getpayload_test): Likewise.
	(hypot_test_data): Likewise.
	(hypot_test): Likewise.
	(ilogb_test_data): Likewise.
	(ilogb_test): Likewise.
	(iscanonical_test_data): Likewise.
	(iscanonical_test): Likewise.
	(iseqsig_test_data): Likewise.
	(iseqsig_test): Likewise.
	(isfinite_test_data): Likewise.
	(isfinite_test): Likewise.
	(finite_test): Likewise.
	(isgreater_test_data): Likewise.
	(isgreater_test): Likewise.
	(isgreaterequal_test_data): Likewise.
	(isgreaterequal_test): Likewise.
	(isinf_test_data): Likewise.
	(isinf_test): Likewise.
	(isless_test_data): Likewise.
	(isless_test): Likewise.
	(islessequal_test_data): Likewise.
	(islessequal_test): Likewise.
	(islessgreater_test_data): Likewise.
	(islessgreater_test): Likewise.
	(isnan_test_data): Likewise.
	(isnan_test): Likewise.
	(isnormal_test_data): Likewise.
	(isnormal_test): Likewise.
	(issignaling_test_data): Likewise.
	(issignaling_test): Likewise.
	(issubnormal_test_data): Likewise.
	(issubnormal_test): Likewise.
	(isunordered_test_data): Likewise.
	(isunordered_test): Likewise.
	(iszero_test_data): Likewise.
	(iszero_test): Likewise.
	(j0_test_data): Likewise.
	(j0_test): Likewise.
	(j1_test_data): Likewise.
	(j1_test): Likewise.
	(jn_test_data): Likewise.
	(jn_test): Likewise.
	(lgamma_test_data): Likewise.
	(lgamma_test): Likewise.
	(gamma_test): Likewise.
	(llogb_test_data): Likewise.
	(llogb_test): Likewise.
	(lrint_test_data): Likewise.
	(lrint_test): Likewise.
	(llrint_test_data): Likewise.
	(llrint_test): Likewise.
	(log_test_data): Likewise.
	(log_test): Likewise.
	(log10_test_data): Likewise.
	(log10_test): Likewise.
	(log1p_test_data): Likewise.
	(log1p_test): Likewise.
	(log2_test_data): Likewise.
	(log2_test): Likewise.
	(logb_test_data): Likewise.
	(logb_test): Likewise.
	(lround_test_data): Likewise.
	(lround_test): Likewise.
	(llround_test_data): Likewise.
	(llround_test): Likewise.
	(modf_test_data): Likewise.
	(modf_test): Likewise.
	(nearbyint_test_data): Likewise.
	(nearbyint_test): Likewise.
	(nextafter_test_data): Likewise.
	(nextafter_test): Likewise.
	(nextup_test_data): Likewise.
	(nextup_test): Likewise.
	(nextdown_test_data): Likewise.
	(nextdown_test): Likewise.
	(nexttoward_test_data): Likewise.
	(nexttoward_test): Likewise.
	(pow_test_data): Likewise.
	(pow_test): Likewise.
	(remainder_test_data): Likewise.
	(remainder_test): Likewise.
	(drem_test): Likewise.
	(remquo_test_data): Likewise.
	(remquo_test): Likewise.
	(rint_test_data): Likewise.
	(rint_test): Likewise.
	(round_test_data): Likewise.
	(round_test): Likewise.
	(roundeven_test_data): Likewise.
	(roundeven_test): Likewise.
	(scalb_test_data): Likewise.
	(scalb_test): Likewise.
	(scalbn_test_data): Likewise.
	(scalbn_test): Likewise.
	(ldexp_test): Likewise.
	(scalbln_test_data): Likewise.
	(scalbln_test): Likewise.
	(setpayload_test_data): Likewise.
	(setpayload_test): Likewise.
	(setpayloadsig_test_data): Likewise.
	(setpayloadsig_test): Likewise.
	(signbit_test_data): Likewise.
	(signbit_test): Likewise.
	(sin_test_data): Likewise.
	(sin_test): Likewise.
	(sincos_test_data): Likewise.
	(sincos_test): Likewise.
	(sinh_test_data): Likewise.
	(sinh_test): Likewise.
	(sqrt_test_data): Likewise.
	(sqrt_test): Likewise.
	(tan_test_data): Likewise.
	(tan_test): Likewise.
	(tanh_test_data): Likewise.
	(tanh_test): Likewise.
	(tgamma_test_data): Likewise.
	(tgamma_test): Likewise.
	(totalorder_test_data): Likewise.
	(totalorder_test): Likewise.
	(totalordermag_test_data): Likewise.
	(totalordermag_test): Likewise.
	(trunc_test_data): Likewise.
	(trunc_test): Likewise.
	(ufromfp_test_data): Likewise.
	(ufromfp_test): Likewise.
	(ufromfpx_test_data): Likewise.
	(ufromfpx_test): Likewise.
	(y0_test_data): Likewise.
	(y0_test): Likewise.
	(y1_test_data): Likewise.
	(y1_test): Likewise.
	(yn_test_data): Likewise.
	(yn_test): Likewise.
	(significand_test_data): Likewise.
	(significand_test): Likewise.
	* math/Makefile (auto-libm-test-out-files): Remove variable.
	(libm-test-funcs-noauto): New variable.
	(libm-test-funcs-all): Likewise.
	(libm-test-c-auto): Likewise.
	(libm-test-c-noauto): Likewise.
	(libm-tests-generated): Add $(libm-test-c-auto) and
	$(libm-test-c-noauto).
	(generated): Do not add auto-libm-test-out.
	(libm-test-c-auto-obj): New variable.
	(libm-test-c-noauto-obj): Likewise.
	($(objpfx)libm-test.c): Do not generate or use auto-libm-test-out.
	($(libm-test-c-noauto-obj)): New static pattern rule.
	($(libm-test-c-auto-obj)): Likewise.
	(libm-test-incs): New variable.
	($(objpfx)libm-have-vector-test.h): Depend on $(libm-test-incs)
	and pass it to gen-libm-have-vector-test.sh.
	* math/gen-libm-have-vector-test.sh: Expect list of .inc files to
	be passed on command line.
	* math/libm-test-acos.inc: New file.  Content from
	math/libm-test.inc.
	* math/libm-test-acosh.inc: Likewise.
	* math/libm-test-asin.inc: Likewise.
	* math/libm-test-asinh.inc: Likewise.
	* math/libm-test-atan.inc: Likewise.
	* math/libm-test-atan2.inc: Likewise.
	* math/libm-test-atanh.inc: Likewise.
	* math/libm-test-cabs.inc: Likewise.
	* math/libm-test-cacos.inc: Likewise.
	* math/libm-test-cacosh.inc: Likewise.
	* math/libm-test-canonicalize.inc: Likewise.
	* math/libm-test-carg.inc: Likewise.
	* math/libm-test-casin.inc: Likewise.
	* math/libm-test-casinh.inc: Likewise.
	* math/libm-test-catan.inc: Likewise.
	* math/libm-test-catanh.inc: Likewise.
	* math/libm-test-cbrt.inc: Likewise.
	* math/libm-test-ccos.inc: Likewise.
	* math/libm-test-ccosh.inc: Likewise.
	* math/libm-test-ceil.inc: Likewise.
	* math/libm-test-cexp.inc: Likewise.
	* math/libm-test-cimag.inc: Likewise.
	* math/libm-test-clog.inc: Likewise.
	* math/libm-test-clog10.inc: Likewise.
	* math/libm-test-conj.inc: Likewise.
	* math/libm-test-copysign.inc: Likewise.
	* math/libm-test-cos.inc: Likewise.
	* math/libm-test-cosh.inc: Likewise.
	* math/libm-test-cpow.inc: Likewise.
	* math/libm-test-cproj.inc: Likewise.
	* math/libm-test-creal.inc: Likewise.
	* math/libm-test-csin.inc: Likewise.
	* math/libm-test-csinh.inc: Likewise.
	* math/libm-test-csqrt.inc: Likewise.
	* math/libm-test-ctan.inc: Likewise.
	* math/libm-test-ctanh.inc: Likewise.
	* math/libm-test-erf.inc: Likewise.
	* math/libm-test-erfc.inc: Likewise.
	* math/libm-test-exp.inc: Likewise.
	* math/libm-test-exp10.inc: Likewise.
	* math/libm-test-exp2.inc: Likewise.
	* math/libm-test-expm1.inc: Likewise.
	* math/libm-test-fabs.inc: Likewise.
	* math/libm-test-fdim.inc: Likewise.
	* math/libm-test-floor.inc: Likewise.
	* math/libm-test-fma.inc: Likewise.
	* math/libm-test-fmax.inc: Likewise.
	* math/libm-test-fmaxmag.inc: Likewise.
	* math/libm-test-fmin.inc: Likewise.
	* math/libm-test-fminmag.inc: Likewise.
	* math/libm-test-fmod.inc: Likewise.
	* math/libm-test-fpclassify.inc: Likewise.
	* math/libm-test-frexp.inc: Likewise.
	* math/libm-test-fromfp.inc: Likewise.
	* math/libm-test-fromfpx.inc: Likewise.
	* math/libm-test-getpayload.inc: Likewise.
	* math/libm-test-hypot.inc: Likewise.
	* math/libm-test-ilogb.inc: Likewise.
	* math/libm-test-iscanonical.inc: Likewise.
	* math/libm-test-iseqsig.inc: Likewise.
	* math/libm-test-isfinite.inc: Likewise.
	* math/libm-test-isgreater.inc: Likewise.
	* math/libm-test-isgreaterequal.inc: Likewise.
	* math/libm-test-isinf.inc: Likewise.
	* math/libm-test-isless.inc: Likewise.
	* math/libm-test-islessequal.inc: Likewise.
	* math/libm-test-islessgreater.inc: Likewise.
	* math/libm-test-isnan.inc: Likewise.
	* math/libm-test-isnormal.inc: Likewise.
	* math/libm-test-issignaling.inc: Likewise.
	* math/libm-test-issubnormal.inc: Likewise.
	* math/libm-test-isunordered.inc: Likewise.
	* math/libm-test-iszero.inc: Likewise.
	* math/libm-test-j0.inc: Likewise.
	* math/libm-test-j1.inc: Likewise.
	* math/libm-test-jn.inc: Likewise.
	* math/libm-test-lgamma.inc: Likewise.
	* math/libm-test-llogb.inc: Likewise.
	* math/libm-test-llrint.inc: Likewise.
	* math/libm-test-llround.inc: Likewise.
	* math/libm-test-log.inc: Likewise.
	* math/libm-test-log10.inc: Likewise.
	* math/libm-test-log1p.inc: Likewise.
	* math/libm-test-log2.inc: Likewise.
	* math/libm-test-logb.inc: Likewise.
	* math/libm-test-lrint.inc: Likewise.
	* math/libm-test-lround.inc: Likewise.
	* math/libm-test-modf.inc: Likewise.
	* math/libm-test-nearbyint.inc: Likewise.
	* math/libm-test-nextafter.inc: Likewise.
	* math/libm-test-nextdown.inc: Likewise.
	* math/libm-test-nexttoward.inc: Likewise.
	* math/libm-test-nextup.inc: Likewise.
	* math/libm-test-pow.inc: Likewise.
	* math/libm-test-remainder.inc: Likewise.
	* math/libm-test-remquo.inc: Likewise.
	* math/libm-test-rint.inc: Likewise.
	* math/libm-test-round.inc: Likewise.
	* math/libm-test-roundeven.inc: Likewise.
	* math/libm-test-scalb.inc: Likewise.
	* math/libm-test-scalbln.inc: Likewise.
	* math/libm-test-scalbn.inc: Likewise.
	* math/libm-test-setpayload.inc: Likewise.
	* math/libm-test-setpayloadsig.inc: Likewise.
	* math/libm-test-signbit.inc: Likewise.
	* math/libm-test-significand.inc: Likewise.
	* math/libm-test-sin.inc: Likewise.
	* math/libm-test-sincos.inc: Likewise.
	* math/libm-test-sinh.inc: Likewise.
	* math/libm-test-sqrt.inc: Likewise.
	* math/libm-test-tan.inc: Likewise.
	* math/libm-test-tanh.inc: Likewise.
	* math/libm-test-tgamma.inc: Likewise.
	* math/libm-test-totalorder.inc: Likewise.
	* math/libm-test-totalordermag.inc: Likewise.
	* math/libm-test-trunc.inc: Likewise.
	* math/libm-test-ufromfp.inc: Likewise.
	* math/libm-test-ufromfpx.inc: Likewise.
	* math/libm-test-y0.inc: Likewise.
	* math/libm-test-y1.inc: Likewise.
	* math/libm-test-yn.inc: Likewise.
	* math/README.libm-test: Update.
2017-02-06 18:57:25 +00:00
Joseph Myers 4f1bc131db Split auto-libm-test-out by function.
math/auto-libm-test-out is, at over 30 MB, by far the largest file in
the glibc source tree.  This patch splits it by function, so reducing
it to auto-libm-test-out-<func> files that are all under 5 MB in size.

This is preliminary to splitting up libm-test.inc as well so that each
function's tests can also be processed separately by
gen-libm-test.pl.  As a preliminary patch it doesn't actually
implement that step; rather, all the separate files get concatenated
by the Makefile to produce the monolithic auto-libm-test-out file
again as an input to gen-libm-test.pl.  (The concatentation is
identical to the file in the source tree before this patch.)

Even this preliminary step, however, is of use independent of
splitting up libm-test.inc: some tests for csin and csinh have not
been moved to auto-libm-test-in because they result in
auto-libm-test-out generation taking several minutes rather than a few
seconds (all released MPC versions are very slow for certain sin /
sinh inputs; there are some old improvements in MPC mainline which
should eventually become MPC 1.1, but the complex inverse trig and
hyperbolic functions are slow even in MPC mainline and have yet to be
moved to auto-libm-test-in at all), and it seems much more reasonable
to add such inputs to auto-libm-test-in when it will only slow down
regeneration for particular functions than when it will slow down
regeneration globally.

gen-auto-libm-tests still parses the whole input file, but only
generates output for the requested function.  This ensures bad syntax
in the file is always detected, and parsing the whole file is quick;
it's output generation that is comparatively slow for some functions.

Tested for x86_64.

	* math/gen-auto-libm-tests.c: Update comment about use of program.
	(generate_output): Add argument FUNCTION.
	(main): Require extra argument.  Pass function name to
	generate_output.
	* math/Makefile (generated): Add auto-libm-test-out.
	(libm-test-funcs-auto): New variable.
	(auto-libm-test-out-files): New variable.
	($(objpfx)libm-test.c): Depend on $(auto-libm-test-out-files).
	Concatenate those files to form $(objpfx)auto-libm-test-out and
	use it as input to gen-libm-test.pl.
	* math/README.libm-test: Update.
	* math/auto-libm-test-out: Remove.
	* math/auto-libm-test-out-acos: New generated file.
	* math/auto-libm-test-out-acosh: Likewise.
	* math/auto-libm-test-out-asin: Likewise.
	* math/auto-libm-test-out-asinh: Likewise.
	* math/auto-libm-test-out-atan: Likewise.
	* math/auto-libm-test-out-atan2: Likewise.
	* math/auto-libm-test-out-atanh: Likewise.
	* math/auto-libm-test-out-cabs: Likewise.
	* math/auto-libm-test-out-carg: Likewise.
	* math/auto-libm-test-out-cbrt: Likewise.
	* math/auto-libm-test-out-ccos: Likewise.
	* math/auto-libm-test-out-ccosh: Likewise.
	* math/auto-libm-test-out-cexp: Likewise.
	* math/auto-libm-test-out-clog: Likewise.
	* math/auto-libm-test-out-clog10: Likewise.
	* math/auto-libm-test-out-cos: Likewise.
	* math/auto-libm-test-out-cosh: Likewise.
	* math/auto-libm-test-out-cpow: Likewise.
	* math/auto-libm-test-out-csin: Likewise.
	* math/auto-libm-test-out-csinh: Likewise.
	* math/auto-libm-test-out-csqrt: Likewise.
	* math/auto-libm-test-out-ctan: Likewise.
	* math/auto-libm-test-out-ctanh: Likewise.
	* math/auto-libm-test-out-erf: Likewise.
	* math/auto-libm-test-out-erfc: Likewise.
	* math/auto-libm-test-out-exp: Likewise.
	* math/auto-libm-test-out-exp10: Likewise.
	* math/auto-libm-test-out-exp2: Likewise.
	* math/auto-libm-test-out-expm1: Likewise.
	* math/auto-libm-test-out-fma: Likewise.
	* math/auto-libm-test-out-hypot: Likewise.
	* math/auto-libm-test-out-j0: Likewise.
	* math/auto-libm-test-out-j1: Likewise.
	* math/auto-libm-test-out-jn: Likewise.
	* math/auto-libm-test-out-lgamma: Likewise.
	* math/auto-libm-test-out-log: Likewise.
	* math/auto-libm-test-out-log10: Likewise.
	* math/auto-libm-test-out-log1p: Likewise.
	* math/auto-libm-test-out-log2: Likewise.
	* math/auto-libm-test-out-pow: Likewise.
	* math/auto-libm-test-out-sin: Likewise.
	* math/auto-libm-test-out-sincos: Likewise.
	* math/auto-libm-test-out-sinh: Likewise.
	* math/auto-libm-test-out-sqrt: Likewise.
	* math/auto-libm-test-out-tan: Likewise.
	* math/auto-libm-test-out-tanh: Likewise.
	* math/auto-libm-test-out-tgamma: Likewise.
	* math/auto-libm-test-out-y0: Likewise.
	* math/auto-libm-test-out-y1: Likewise.
	* math/auto-libm-test-out-yn: Likewise.
2017-02-06 18:41:20 +00:00
Joseph Myers 5cd81881e2 Eliminate libm-test.stmp.
math/Makefile uses libm-test.stmp to handle dependencies involving
multiple generated files all generated by a single sequence of
commands in a single Makefile rule.

Having separated the libm-test-ulps.h and libm-test.c generation into
separate runs of gen-libm-test.pl, there is now no need for a single
rule to generate multiple target files; each of the three target files
involved can be generated by a separate Makefile rule, meaning normal
dependencies on the individual files can be used and so libm-test.stmp
is not needed at all.  This patch does just that, eliminating the
.stmp file, in further preparation for when there are many separate
libm-test-<func>.c files generated from libm-test-<func>.inc and the
dependencies are on just the relevant .c file in each case.

Tested for x86_64.

	* math/Makefile (generated): Do not include libm-test.stmp.
	($(addprefix $(objpfx), $(libm-tests-generated))): Do not depend
	on $(objpfx)libm-test.stmp.
	($(objpfx)libm-test.stmp): Remove rule.
	($(objpfx)libm-test-ulps.h): New rule.
	($(objpfx)libm-test.c): Likewise.
	($(objpfx)libm-have-vector-test.h): Likewise.
	($(addprefix $(objpfx), $(libm-tests.o)): Depend directly on
	individual generated files, not libm-test.stmp.
2017-02-06 18:28:33 +00:00
Joseph Myers 7e1e68b45c Rework gen-libm-test.pl input/output handling.
This patch reworks how input and output files are specified for
gen-libm-test.pl.

Previously, the script had names of various inputs and outputs
hardcoded, with a -o option to specify an output directory.  This
patch replaces this with all inputs and outputs being specified
explicitly as the arguments of options passed to the script.  Outputs
are only generated if the relevant option is passed, and only the
processing required for the indicated outputs is done.  The Makefile
is made to pass options for generating libm-test-ulps.h in a separate
invocation of gen-libm-test.pl from that generating libm-test.c.

This is all in preparation for splitting up libm-test.inc and
auto-libm-test-out and running tests separately for each function,
when gen-libm-test.pl will be run separately for each function to
generate the .c file but only once to generate libm-test-ulps.h (and
those runs will be able to be in parallel).

Tested for x86_64.  The generated libm-test.c and libm-test-ulps.h are
identical before and after the patch.  Also tested the "make
regen-ulps" case.

	* math/gen-libm-test.pl ($output_dir): Remove variable.
	($srcdir): Likewise.
	($opt_a): New variable.
	($opt_c): Likewise.
	($opt_C): Likewise.
	($opt_H): Likewise.
	(-n): Make option take argument and use it as NewUlps output.
	(-a): New option.  Use its argument for auto-libm-test-out input.
	(-c): New option.  Use its argument for libm-test.inc input.
	(-C): New option.  Use its argument for libm-test.c output.
	(-H): New option.  Use its argument for libm-test-ulps.h output.
	(top level): Only process inputs needed to generate outputs
	specified by command-line options.  Only generate outputs
	specified by command-line options.
	* math/README.libm-test: Update example gen-libm-test.pl command.
	* math/Makefile ($(objpfx)libm-test.stmp): Update gen-libm-test.pl
	commands.
	(regen-ulps): Likewise.
2017-02-06 18:21:06 +00:00
Wilco Dijkstra c7a37ad352 As a minor cleanup remove the (r)index defines from include/string.h as
they are only used internally in a few places.  Rename all uses that
occur in GLIBC.

	* hurd/path-lookup.c (file_name_path_scan): Rename index to strchr.
	* include/string.h (index): Remove define.
	(rindex): Likewise.
	* misc/getttyent.c (__getttyent): Rename index to strchr.
	* misc/ttyslot.c (ttyslot): Rename rindex to strrchr.
	* sunrpc/rpc_main.c (mkfile_output): Likewise.
2017-02-06 18:15:18 +00:00
Joseph Myers 5a68e857bf Move non-function-specific parts of libm-test.inc to separate file.
libm-test.inc contains both test infrastructure and tests of
individual functions.

This patch moves the infrastructure to a separate file
libm-test-driver.c.  This is in preparation for splitting the tests of
individual functions into separate source files, which will be
processed individually by gen-libm-test.pl (so e.g. libm-test-acos.inc
and auto-libm-test-out-acos will be processed by gen-libm-test.pl to
produce libm-test-acos.c, and files such as test-double-acos.c will be
generated by the Makefile to include appropriate headers,
libm-test-driver.c and libm-test-acos.c so tests of each function get
run separately).

It is no doubt possible to split things up further, so that functions
not depending on the type being tested only get compiled once and most
of those depending on the type being tested get compiled once per type
(rather than separately for variants such as inline / no-inline, and
separately for each function being tested after that split), but this
rearrangement as-is seems a useful incremental step towards splitting
these tests by function.

	* math/libm-test-driver.c: New file.  Based on math/libm-test.inc.
	* math/libm-test.inc: Move all contents, other than tests of
	individual functions, to libm-test-driver.c.
	[!FE_TONEAREST] (FE_TONEAREST): Move to libm-test-driver.c.
	[!FE_TOWARDZERO] (FE_TOWARDZERO): Likewise.
	[!FE_UPWARD] (FE_UPWARD): Likewise.
	[!FE_DOWNWARD] (FE_DOWNWARD): Likewise.
	(NO_EXCEPTION): Likewise.
	(INVALID_EXCEPTION): Likewise.
	(DIVIDE_BY_ZERO_EXCEPTION): Likewise.
	(OVERFLOW_EXCEPTION): Likewise.
	(UNDERFLOW_EXCEPTION): Likewise.
	(INEXACT_EXCEPTION): Likewise.
	(INVALID_EXCEPTION_OK): Likewise.
	(DIVIDE_BY_ZERO_EXCEPTION_OK): Likewise.
	(OVERFLOW_EXCEPTION_OK): Likewise.
	(UNDERFLOW_EXCEPTION_OK): Likewise.
	(NO_INEXACT_EXCEPTION): Likewise.
	(EXCEPTIONS_OK): Likewise.
	(IGNORE_ZERO_INF_SIGN): Likewise.
	(TEST_NAN_SIGN): Likewise.
	(TEST_NAN_PAYLOAD): Likewise.
	(NO_TEST_INLINE): Likewise.
	(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): Likewise.
	(__CONCATX): Likewise.
	(TYPE_MIN): Likewise.
	(TYPE_TRUE_MIN): Likewise.
	(TYPE_MAX): Likewise.
	(MIN_EXP): Likewise.
	(MAX_EXP): Likewise.
	(MANT_DIG): Likewise.
	(FSTR_MAX): Likewise.
	(ULP_IDX): Likewise.
	(QTYPE_STR): Likewise.
	(TEST_COND_binary32): Likewise.
	(TEST_COND_binary64): Likewise.
	(TEST_COND_binary128): Likewise.
	(TEST_COND_ibm128): Likewise.
	(TEST_COND_intel96): Likewise.
	(TEST_COND_m68k96): Likewise.
	(TEST_COND_ibm128_libgcc): Likewise.
	(XFAIL_IBM128_LIBGCC): Likewise.
	(PAYLOAD_DIG): Likewise.
	(UNDERFLOW_EXCEPTION_FLOAT): Likewise.
	(UNDERFLOW_EXCEPTION_OK_FLOAT): Likewise.
	(UNDERFLOW_EXCEPTION_DOUBLE): Likewise.
	(UNDERFLOW_EXCEPTION_OK_DOUBLE): Likewise.
	(UNDERFLOW_EXCEPTION_LDOUBLE_IBM): Likewise.
	(UNDERFLOW_EXCEPTION_BEFORE_ROUNDING): Likewise.
	(TEST_COND_long32): Likewise.
	(TEST_COND_long64): Likewise.
	(TEST_COND_before_rounding): Likewise.
	(TEST_COND_after_rounding): Likewise.
	(lit_pi_3_m_4_d): Likewise.
	(lit_pi_3_m_4_ln10_m_d): Likewise.
	(lit_pi_2_ln10_m_d): Likewise.
	(lit_pi_4_ln10_m_d): Likewise.
	(lit_pi_ln10_d): Likewise.
	(lit_pi_2_d): Likewise.
	(lit_pi_4_d): Likewise.
	(lit_pi): Likewise.
	(lit_e): Likewise.
	(ulps_file_name): Likewise.
	(ulps_file): Likewise.
	(output_ulps): Likewise.
	(output_dir): Likewise.
	(noErrors): Likewise.
	(noTests): Likewise.
	(noExcTests): Likewise.
	(noErrnoTests): Likewise.
	(verbose): Likewise.
	(output_max_error): Likewise.
	(output_points): Likewise.
	(ignore_max_ulp): Likewise.
	(plus_zero): Likewise.
	(minus_zero): Likewise.
	(plus_infty): Likewise.
	(minus_infty): Likewise.
	(qnan_value_pl): Likewise.
	(qnan_value): Likewise.
	(snan_value_pl): Likewise.
	(snan_value): Likewise.
	(max_value): Likewise.
	(min_value): Likewise.
	(min_subnorm_value): Likewise.
	(snan_value_ld): Likewise.
	(max_error): Likewise.
	(real_max_error): Likewise.
	(imag_max_error): Likewise.
	(prev_max_error): Likewise.
	(prev_real_max_error): Likewise.
	(prev_imag_max_error): Likewise.
	(max_valid_error): Likewise.
	(TYPE_DECIMAL_DIG): Likewise.
	(TYPE_HEX_DIG): Likewise.
	(fmt_ftostr): Likewise.
	(compare_ulp_data): Likewise.
	(find_ulps): Likewise.
	(init_max_error): Likewise.
	(set_max_error): Likewise.
	(print_float): Likewise.
	(print_screen): Likewise.
	(print_screen_max_error): Likewise.
	(update_stats): Likewise.
	(print_function_ulps): Likewise.
	(print_complex_function_ulps): Likewise.
	(fpstack_test): Likewise.
	(print_max_error): Likewise.
	(print_complex_max_error): Likewise.
	(test_single_exception): Likewise.
	(test_exceptions): Likewise.
	(test_single_errno): Likewise.
	(test_errno): Likewise.
	(ULPDIFF): Likewise.
	(ulp): Likewise.
	(check_float_internal): Likewise.
	(check_float): Likewise.
	(check_complex): Likewise.
	(check_int): Likewise.
	(check_long): Likewise.
	(check_bool): Likewise.
	(check_longlong): Likewise.
	(check_intmax_t): Likewise.
	(check_uintmax_t): Likewise.
	(enable_test): Likewise.
	(struct test_f_f_data): Likewise.
	(struct test_ff_f_data): Likewise.
	(struct test_fj_f_data): Likewise.
	(struct test_fi_f_data): Likewise.
	(struct test_fl_f_data): Likewise.
	(struct test_if_f_data): Likewise.
	(struct test_fff_f_data): Likewise.
	(struct test_fiu_M_data): Likewise.
	(struct test_fiu_U_data): Likewise.
	(struct test_c_f_data): Likewise.
	(struct test_f_f1_data): Likewise.
	(struct test_fF_f1_data): Likewise.
	(struct test_ffI_f1_data): Likewise.
	(struct test_c_c_data): Likewise.
	(struct test_cc_c_data): Likewise.
	(struct test_f_i_data): Likewise.
	(struct test_ff_i_data): Likewise.
	(struct test_f_l_data): Likewise.
	(struct test_f_L_data): Likewise.
	(struct test_fFF_11_data): Likewise.
	(struct test_Ff_b1_data): Likewise.
	(IF_ROUND_INIT_): Likewise.
	(IF_ROUND_INIT_FE_DOWNWARD): Likewise.
	(IF_ROUND_INIT_FE_TONEAREST): Likewise.
	(IF_ROUND_INIT_FE_TOWARDZERO): Likewise.
	(IF_ROUND_INIT_FE_UPWARD): Likewise.
	(ROUND_RESTORE_): Likewise.
	(ROUND_RESTORE_FE_DOWNWARD): Likewise.
	(ROUND_RESTORE_FE_TONEAREST): Likewise.
	(ROUND_RESTORE_FE_TOWARDZERO): Likewise.
	(ROUND_RESTORE_FE_UPWARD): Likewise.
	(RM_): Likewise.
	(RM_FE_DOWNWARD): Likewise.
	(RM_FE_TONEAREST): Likewise.
	(RM_FE_TOWARDZERO): Likewise.
	(RM_FE_UPWARD): Likewise.
	(COMMON_TEST_SETUP): Likewise.
	(EXTRA_OUTPUT_TEST_SETUP): Likewise.
	(COMMON_TEST_CLEANUP): Likewise.
	(EXTRA_OUTPUT_TEST_CLEANUP): Likewise.
	(RUN_TEST_f_f): Likewise.
	(RUN_TEST_LOOP_f_f): Likewise.
	(RUN_TEST_fp_f): Likewise.
	(RUN_TEST_LOOP_fp_f): Likewise.
	(RUN_TEST_2_f): Likewise.
	(RUN_TEST_LOOP_2_f): Likewise.
	(RUN_TEST_ff_f): Likewise.
	(RUN_TEST_LOOP_ff_f): Likewise.
	(RUN_TEST_LOOP_fj_f): Likewise.
	(RUN_TEST_fi_f): Likewise.
	(RUN_TEST_LOOP_fi_f): Likewise.
	(RUN_TEST_fl_f): Likewise.
	(RUN_TEST_LOOP_fl_f): Likewise.
	(RUN_TEST_if_f): Likewise.
	(RUN_TEST_LOOP_if_f): Likewise.
	(RUN_TEST_fff_f): Likewise.
	(RUN_TEST_LOOP_fff_f): Likewise.
	(RUN_TEST_fiu_M): Likewise.
	(RUN_TEST_LOOP_fiu_M): Likewise.
	(RUN_TEST_fiu_U): Likewise.
	(RUN_TEST_LOOP_fiu_U): Likewise.
	(RUN_TEST_c_f): Likewise.
	(RUN_TEST_LOOP_c_f): Likewise.
	(RUN_TEST_f_f1): Likewise.
	(RUN_TEST_LOOP_f_f1): Likewise.
	(RUN_TEST_fF_f1): Likewise.
	(RUN_TEST_LOOP_fF_f1): Likewise.
	(RUN_TEST_fI_f1): Likewise.
	(RUN_TEST_LOOP_fI_f1): Likewise.
	(RUN_TEST_ffI_f1_mod8): Likewise.
	(RUN_TEST_LOOP_ffI_f1_mod8): Likewise.
	(RUN_TEST_Ff_b1): Likewise.
	(RUN_TEST_LOOP_Ff_b1): Likewise.
	(RUN_TEST_Ffp_b1): Likewise.
	(RUN_TEST_LOOP_Ffp_b1): Likewise.
	(RUN_TEST_c_c): Likewise.
	(RUN_TEST_LOOP_c_c): Likewise.
	(RUN_TEST_cc_c): Likewise.
	(RUN_TEST_LOOP_cc_c): Likewise.
	(RUN_TEST_f_i): Likewise.
	(RUN_TEST_LOOP_f_i): Likewise.
	(RUN_TEST_f_i_tg): Likewise.
	(RUN_TEST_LOOP_f_i_tg): Likewise.
	(RUN_TEST_ff_b): Likewise.
	(RUN_TEST_LOOP_ff_b): Likewise.
	(RUN_TEST_ff_i_tg): Likewise.
	(RUN_TEST_LOOP_ff_i_tg): Likewise.
	(RUN_TEST_f_b): Likewise.
	(RUN_TEST_LOOP_f_b): Likewise.
	(RUN_TEST_f_b_tg): Likewise.
	(RUN_TEST_LOOP_f_b_tg): Likewise.
	(RUN_TEST_f_l): Likewise.
	(RUN_TEST_LOOP_f_l): Likewise.
	(RUN_TEST_f_L): Likewise.
	(RUN_TEST_LOOP_f_L): Likewise.
	(RUN_TEST_fFF_11): Likewise.
	(RUN_TEST_LOOP_fFF_11): Likewise.
	(VEC_SUFF): Likewise.
	(STR_CONCAT): Likewise.
	(STR_CON3): Likewise.
	(HAVE_VECTOR): Likewise.
	(START): Likewise.
	(END): Likewise.
	(END_COMPLEX): Likewise.
	(ALL_RM_TEST): Likewise.
	(matherr): Likewise.
	(initialize): Likewise.
	(options): Likewise.
	(doc): Likewise.
	(parse_opt): Likewise.
	(argp): Likewise.
	(check_ulp): Likewise.
	(main): Likewise.
	(do_test): New function.  Call tests of individual functions
	previously called from main.
2017-02-06 18:12:16 +00:00
Joseph Myers dd18757bd3 Remove libm-test.inc comment listing functions tested and not tested.
math/libm-test.inc has a comment listing the functions tested and not
tested.  The list of functions tested duplicates what is immediately
obvious from the rest of the file and adds another place to update
when adding a function.  I've put the information about functions not
tested on the wiki todo list; this patch removes that comment, in
preparation for splitting tests of each function into separate .inc
files with common code staying in a separate .c file.

Tested for x86_64.

	* math/libm-test.inc: Remove comment listing functions tested and
	not tested.
2017-02-06 18:04:10 +00:00
Adhemerval Zanella 37f8abad1c nptl: Remove COLORING_INCREMENT
This patch removes the COLORING_INCREMENT define and usage on allocatestack.c.
It has not been used since 564cd8b67e (glibc-2.3.3) by any architecture.
The idea is to simplify the code by removing obsolete code.

	* nptl/allocatestack.c [COLORING_INCREMENT] (nptl_ncreated): Remove.
	(allocate_stack): Remove COLORING_INCREMENT usage.
	* nptl/stack-aliasing.h (COLORING_INCREMENT). Likewise.
	* sysdeps/i386/i686/stack-aliasing.h (COLORING_INCREMENT): Likewise.
2017-02-06 15:58:32 -02:00
Joseph Myers 2b7dc4c868 Do not hardcode list of libm functions in libm-err-tab.pl.
manual/libm-err-tab.pl contains a hardcoded list of libm functions for
which ulps are listed in the manual, and another hardcoded list in a
comment of functions deliberately excluded because of an expected lack
of ulps (and the two together are not in fact an exhaustive list of
libm functions tested through the libm-test machinery).

This patch removes these hardcoded lists, so eliminating this from the
places needing updating when a new libm function is added.  Instead,
ulps are tabulated for functions for which they are seen in
libm-test-ulps files, in alphabetical order.  The pseudo-function
names such as *_downward and *_vlen* are excluded since they are
excluded from the existing lists, and the description in the manual is
updated to explain how those entries are excluded and if a function is
not listed at all it does not have known errors.

Tested for x86_64.

	* manual/libm-err-tab.pl (@all_functions): Change to
	%all_functions.  Initialize as empty.
	(parse_ulps): Add to %all_functions based on functions found in
	ulps files.  Ignore results for non-default rounding modes and
	vector functions.
	(print_platforms): Use %all_platforms.
	* manual/math.texi (Errors in Math Functions): Document omissions
	from the table.
2017-02-06 17:55:59 +00:00
Joseph Myers 95b2e07faf Remove before-compile setting in math/Makefile.
In <https://sourceware.org/ml/libc-alpha/2015-12/msg00543.html>,
Florian noted highly parallel builds being slowed down by
gen-libm-test.pl running during the build, when it should only run for
testing, not for building glibc itself.

This is a consequence of libm-test.c being listed in before-compile.
That listing in before-compile arose from the error reported in
<https://sourceware.org/ml/libc-hacker/1999-10/msg00054.html> when
building dependencies: at that time, dependencies were generated
separation from compilation, so if a source file included a generated
file it wasn't enough for the dependencies for the .o file to be
correct, the generated file needed to be listed in before-compile.

Since <https://sourceware.org/ml/libc-hacker/2003-05/msg00001.html>,
dependencies are generated as a side-effect of compilation.  This
means that having the right dependencies for the .o files for the
tests fully suffices to ensure that libm-test.c is generated by the
time it's needed; no entry in before-compile is needed.  And we indeed
have such a dependency for all the tests using libm-test.c:

$(addprefix $(objpfx), $(libm-tests.o)): $(objpfx)libm-test.stmp

Thus, the before-compile definition is unnecessary, and this patch
removes it.  (This may of course move serialization from the glibc
build to glibc testing, but I intend to split up libm-test.inc so that
tests for each (floating-point type, libm function) pair are built and
run separately, which should reduce that serialization.)

Tested for x86_64.

	* math/Makefile (before-compile): Remove.
2017-02-06 17:48:02 +00:00
Ivo Raisr 0b20e02c97 sparc: Remove unused assignment in __clone
It is no longer needed to preserve the flags parameter to `clone' since
the commit c579f48edb (Remove cached
PID/TID in clone).

Testing was performed successfully on sparcv9/Linux.

	[BZ #21075]
	* sysdeps/unix/sysv/linux/sparc/sparc64/clone.S (__clone): Remove
	unused assignment.
	* sysdeps/unix/sysv/linux/sparc/sparc32/clone.S (__clone): Likewise.
2017-02-06 11:30:41 -02:00
Stefan Liebler df3a4e104f Add __glibc_unlikely hint in lll_trylock, lll_cond_trylock.
The macros lll_trylock, lll_cond_trylock are extended by an __glibc_unlikely
hint.  Now the trylock macros are based on the same assumption about a
free/busy lock as lll_lock.
With the hint gcc emits code in e.g. pthread_mutex_trylock which does
not use jumps if the lock is free.  Without the hint it had to jump away
if the lock is free.

Tested on s390x, ppc.

ChangeLog:

	* sysdeps/nptl/lowlevellock.h (lll_trylock, lll_cond_trylock):
	Add __glibc_unlikely hint.
2017-02-06 13:46:01 +01:00
Adhemerval Zanella f2d7f23a30 Remove i686, x86_64, and powerpc strtok implementations
Based on comments on previous attempt to address BZ#16640 [1],
the idea is not support invalid use of strtok (the original
bug report proposal).  This leader to a new strtok optimized
strtok implementation [2].

The idea of this patch is to fix BZ#16640 to align all the
implementations to a same contract.  However, with newer strtok
code it is better to get remove the old assembly ones instead of
fix them.

For x86 is a gain in all cases since the new implementation can
potentially use sse2/sse42 implementation for strspn and strcspn.
This shows a better performance on both i686 and x86_64 using
the string benchtests.

On powerpc64 the gains are mixed, where only for larger inputs
or keys some gains are showns (based on benchtest it seems that
it shows some gains for keys larger than 10 and inputs larger
than 32).  I would prefer to remove the optimized implementation
based on first code simplicity and second because some more gain
could be optimized using a better optimized strcspn/strspn
code (as for x86).  However if powerpc arch maintainers prefer I
can send a v2 with the assembly code adjusted instead.

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

	[BZ #16640]
	* sysdeps/i386/i686/strtok.S: Remove file.
	* sysdeps/i386/i686/strtok_r.S: Likewise.
	* sysdeps/i386/strtok.S: Likewise.
	* sysdeps/i386/strtok_r.S: Likewise.
	* sysdeps/powerpc/powerpc64/strtok.S: Likewise.
	* sysdeps/powerpc/powerpc64/strtok_r.S: Likewise.
	* sysdeps/x86_64/strtok.S: Likewise.
	* sysdeps/x86_64/strtok_r.S: Likewise.

[1] https://sourceware.org/ml/libc-alpha/2016-10/msg00411.html
[2] https://sourceware.org/ml/libc-alpha/2016-12/msg00461.html
2017-02-06 10:24:17 -02:00
Adhemerval Zanella 841a67a0ad Consolidate arm and mips posix_fadvise implementations
As noted by c1f0601389, previous posix_fadvise consolidation
broke on mips o32.  As stated in commit message, MIPS o32 only defines
__NR_fadvise64 and it is behaves like __NR_fadvise64_64.

This patches consolidates both ARM and mips o32 version by fixing
the ARM used option (__NR_fadvise64_64 withouth the alignment required
by abi) and added another option, __ASSUME_FADVISE64_AS_64_64,
which is used on mips o32.

When this option is used, posix_fadvise will use __NR_fadvise64_64
behavior (by defining or not __ASSUME_FADVISE64_64_6ARG).  For
mips, if __NR_fadvise64_64 is not defined, __NR_fadvise will be used.

I also updated the posix_fadvise comments to explain better the
different kernel abi used in the supported architectures.

I checked with a mips o32 and verified that posix_fadvise.o is
indeed using 7 argument syscall with the expected argument position.
I also checked on i686-linux-gnu and arm-gnu-eabihf.

	* sysdeps/unix/sysv/linux/arm/posix_fadvise.c: Remove file.
	* sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	(__ASSUME_FADVISE64_AS_64_64): Define.
	* sysdeps/unix/sysv/linux/posix_fadvise.c [__NR_fadvise64]: Add
	!defined __ASSUME_FADVISE64_AS_64_64 to use syscall issue.
	[!__NR_fadvise64 && __ASSUME_FADVISE64_64_6ARG]: Remove
	__ALIGNMENT_ARG usage.
	[!__NR_fadvise64 && !__ASSUME_FADVISE64_64_6ARG]: Define
	__NR_fadvise64_64 if it is not defined.
2017-02-06 10:21:55 -02:00
Siddhesh Poyarekar 58557c2293 Open master for development 2017-02-05 21:27:52 +05:30
Siddhesh Poyarekar db0242e302 Update for 2.25 release 2017-02-05 20:58:43 +05:30
Siddhesh Poyarekar 1900fab98d Add more contributors to contrib.texi 2017-02-05 20:50:23 +05:30
Siddhesh Poyarekar 4e054e6b07 Add list of bugs fixed in 2.25 2017-02-05 20:50:23 +05:30
Siddhesh Poyarekar 0cea3587d3 Add missing NEWS items
Add NEWS items for the two new pthreads implementations, i.e. the
condition variables algorithms and the pthread_rwlock algorithms.
2017-02-05 20:50:22 +05:30
Siddhesh Poyarekar 53aa04a86c tunables: Fail tests correctly when setgid does not work
The child process of the tst-env-setuid process was failing correctly
with EXIT_UNSUPPORTED but the parent did not carry that status forward
and failed instead.  This patch fixes this so that tests on nosuid
/tmp fails gracefully with UNSUPPORTED.  Tested by making my tmpfs
nosuid.

	* elf/tst-env-setuid.c (do_execve): Return EXIT_UNSUPPORTED in
	parent if child exited in that manner.  Print WEXITSTATUS
	instead of the raw status.
	(do_test_prep): Rename to do_test.
	(do_test): Return the result of run_executable_sgid.
	(TEST_FUNCTION_ARGV): Adjust.
2017-02-04 12:02:37 +05:30
Alexandre Oliva d675eaf7d9 Bug 20915: Do not initialize DTV of other threads.
In _dl_nothread_init_static_tls() and init_one_static_tls() we must not
touch the DTV of other threads since we do not have ownership of them.
The DTV need not be initialized at this point anyway since only LD/GD
accesses will use them. If LD/GD accesses occur they will take care to
initialize their own thread's DTV.

Concurrency comments were removed from the patch since they need to be
reworked along with a full description of DTV ownership and when it is
or is not safe to modify these structures.

Alexandre Oliva's original patch and discussion:
https://sourceware.org/ml/libc-alpha/2016-09/msg00512.html
2017-02-03 21:34:14 -05:00
David S. Miller 33d7e138ca sparc: Remove optimized math routines which cause testsuite failures.
famx{,f}/fmin{,f} and 32-bit lrint cause math testsuite failures
either because they generate incorrect results or they fail to signal
the proper exceptions.

	* sysdeps/sparc/sparc64/fpu/multiarch/s_fmax-vis3.S: Remove file.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_fmax.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_fmaxf-vis3.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_fmaxf.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_fmin-vis3.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_fmin.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_fminf-vis3.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/multiarch/s_fminf.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/multiarch/Makefile
	(libm-sysdep_routines): Update.
	* sysdeps/sparc/sparc32/sparcv9/fpu/s_fmax.S: Remove file.
	* sysdeps/sparc/sparc32/sparcv9/fpu/s_fmaxf.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/s_fmin.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/s_fminf.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/s_lrint.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/s_fmax.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/s_fmaxf.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/s_fmin.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/s_fminf.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmax-vis3.S:
	Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmax.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmaxf-vis3.S:
	Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmaxf.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmin-vis3.S:
	Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fmin.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fminf-vis3.S:
	Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_fminf.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/Makefile
	(libm-sysdep_routines): Update.
2017-02-03 17:55:25 -08:00
H.J. Lu 6fab532b47 Allow IFUNC relocation against unrelocated shared library
IFUNC relocation against definition in unrelocated shared library
will lead to segfault when the IFUNC function is called.  This
patch allows such IFUNC relocations with a warning.  This isn't
a real fix for

https://sourceware.org/bugzilla/show_bug.cgi?id=21041

It simply allows the program to load.  The program will segfault
when longjmp is called.

	* sysdeps/i386/dl-machine.h (elf_machine_rel): Replace
	_dl_fatal_printf with _dl_error_printf for IFUNC relocation
	against unrelocated shared library.
	* sysdeps/x86_64/dl-machine.h (elf_machine_rela): Likewise.
2017-02-02 13:14:59 -08:00
Siddhesh Poyarekar ed8d5ffd0a Drop GLIBC_TUNABLES for setxid programs when tunables is disabled (bz #21073)
A setxid program that uses a glibc with tunables disabled may pass on
GLIBC_TUNABLES as is to its child processes.  If the child process
ends up using a different glibc that has tunables enabled, it will end
up getting access to unsafe tunables.  To fix this, remove
GLIBC_TUNABLES from the environment for setxid process.

	* sysdeps/generic/unsecvars.h: Add GLIBC_TUNABLES.
	* elf/tst-env-setuid-tunables.c
	(test_child_tunables)[!HAVE_TUNABLES]: Verify that
	GLIBC_TUNABLES is removed in a setgid process.
2017-02-02 15:50:24 +05:30
Siddhesh Poyarekar 8b9e9c3c0b tunables: Fix environment variable processing for setuid binaries (bz #21073)
Florian Weimer pointed out that we have three different kinds of
environment variables (and hence tunables):

1. Variables that are removed for setxid processes
2. Variables that are ignored in setxid processes but is passed on to
   child processes
3. Variables that are passed on to child processes all the time

Tunables currently only does (2) and (3) when it should be doing (1)
for MALLOC_CHECK_.  This patch enhances the is_secure flag in tunables
to an enum value that can specify which of the above three categories
the tunable (and its envvar alias) belongs to.

The default is for tunables to be in (1).  Hence, all of the malloc
tunables barring MALLOC_CHECK_ are explicitly specified to belong to
category (2).  There were discussions around abolishing category (2)
completely but we can do that as a separate exercise in 2.26.

Tested on x86_64 to verify that there are no regressions.

	[BZ #21073]
	* elf/dl-tunable-types.h (tunable_seclevel_t): New enum.
	* elf/dl-tunables.c (tunables_strdup): Remove.
	(get_next_env): Also return the previous envp.
	(parse_tunables): Erase tunables of category
	TUNABLES_SECLEVEL_SXID_ERASE.
	(maybe_enable_malloc_check): Make MALLOC_CHECK_
	TUNABLE_SECLEVEL_NONE if /etc/setuid-debug is accessible.
	(__tunables_init)[TUNABLES_FRONTEND ==
	TUNABLES_FRONTEND_valstring]: Update GLIBC_TUNABLES envvar
	after parsing.
	[TUNABLES_FRONTEND != TUNABLES_FRONTEND_valstring]: Erase
	tunable envvars of category TUNABLES_SECLEVEL_SXID_ERASE.
	* elf/dl-tunables.h (struct _tunable): Change member is_secure
	to security_level.
	* elf/dl-tunables.list: Add security_level annotations for all
	tunables.
	* scripts/gen-tunables.awk: Recognize and generate enum values
	for security_level.
	* elf/tst-env-setuid.c: New test case.
	* elf/tst-env-setuid-tunables: new test case.
	* elf/Makefile (tests-static): Add them.
2017-02-02 15:50:16 +05:30
Richard Henderson 9c8e644853 alpha: Use saturating arithmetic in memchr 2017-02-01 14:39:04 -08:00
Andreas Schwab 4283b38725 Fix missing test dependency 2017-02-01 17:40:56 +01:00
Andreas Schwab 64ae9fe456 m68k: fix 64bit atomic ops 2017-02-01 01:32:31 +01:00
Chung-Lin Tang efeca5dac6 Add ipc_priv.h header for Nios II to set __IPC_64 to zero. 2017-01-31 06:18:42 -08:00
H.J. Lu 02b78ff749 Add VZEROUPPER to memset-vec-unaligned-erms.S [BZ #21081]
Since memset-vec-unaligned-erms.S has VDUP_TO_VEC0_AND_SET_RETURN at
function entry, memset optimized for AVX2 and AVX512 will always use
ymm/zmm register. VZEROUPPER should be placed before ret in

L(stosb):
        movq    %rdx, %rcx
        movzbl  %sil, %eax
        movq    %rdi, %rdx
        rep stosb
        movq    %rdx, %rax
        ret

since it can be reached from

L(stosb_more_2x_vec):
        cmpq    $REP_STOSB_THRESHOLD, %rdx
        ja      L(stosb)

	[BZ #21081]
	* sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S
	(L(stosb)): Add VZEROUPPER before ret.
2017-01-30 10:59:31 -08:00
Carlos O'Donell f8bf15febc Bug 20116: Fix use after free in pthread_create()
The commit documents the ownership rules around 'struct pthread' and
when a thread can read or write to the descriptor. With those ownership
rules in place it becomes obvious that pd->stopped_start should not be
touched in several of the paths during thread startup, particularly so
for detached threads. In the case of detached threads, between the time
the thread is created by the OS kernel and the creating thread checks
pd->stopped_start, the detached thread might have already exited and the
memory for pd unmapped. As a regression test we add a simple test which
exercises this exact case by quickly creating detached threads with
large enough stacks to ensure the thread stack cache is bypassed and the
stacks are unmapped. Before the fix the testcase segfaults, after the
fix it works correctly and completes without issue.

For a detailed discussion see:
https://www.sourceware.org/ml/libc-alpha/2017-01/msg00505.html
2017-01-28 19:21:44 -05:00
Florian Weimer faf0e9c841 nptl: Add tst-robust-fork 2017-01-27 06:53:20 +01:00
Florian Weimer 5653ab12b4 string/tst-strcoll-overflow: Do not accept timeout as test result
The test completes within 300 seconds if enough memory is available.
2017-01-25 16:27:03 +01:00
Jakub Jelinek af1a265da0 * soft-fp/op-common.h (_FP_MUL, _FP_FMA, _FP_DIV): Add
/* FALLTHRU */ comments.
2017-01-24 23:27:36 +01:00
Adhemerval Zanella 5845ce01a7 Add missing bugzilla reference in previous ChangeLog entry 2017-01-24 10:01:39 -02:00
James Clarke 3e1b518550 Bug 21053: sh: Reduce namespace pollution from sys/ucontext.h
The problem is basically that sys/ucontext.h is defining R0..R15
which happens to conflict with some packages like Firefox when
trying to build on SH.

The very same problem existed on arm back then [1] and it was fixed by
renaming R0..R15 to REG_R0..REG_R15.  This patch imploy a similar
strategy for SH.

Checked on sh4-linux-gnu with run-built-tests=no and I also got reports
that it fixes Firefox build on Debian sh4.

	* sysdeps/unix/sysv/linux/sh/sh3/ucontext_i.sym: Use new REG_R*
	constants instead of the old R* ones.
	* sysdeps/unix/sysv/linux/sh/sh4/ucontext_i.sym: Likewise.
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h (NGPREG): Rename...
	(NGREG): ... to this, to fit in with other architectures.
	(gpregset_t): Use new NGREG macro.
	[__USE_GNU]: Remove condition; all architectures other than tile
	are unconditional.
	(R*): Rename to REG_R*.
2017-01-24 09:20:06 -02:00
DJ Delorie f3bef6a748 * elf/dl-tunables.c (tunable_set_val_if_valid_range): Split into ...
(tunable_set_val_if_valid_range_signed) ... this, and ...
(tunable_set_val_if_valid_range_unsigned) ... this.
(tunable_initialize): Call the correct one of the above based on type.
2017-01-20 19:55:53 -05:00
Joseph Myers aee47c934e Remove very old libm-test-ulps entries.
I noticed that some libm-test-ulps files still had long-obsolete
entries for *_tonearest functions, which will no longer be used since
functions with FE_TONEAREST explicitly set aren't tested separately
from those functions with it as the default rounding mode any more.

This patch removes those obsolete entries.  However, as they are a
sign of libm-test-ulps not having been regenerated from scratch for a
long time, I strongly advise people testing on those platforms to
remove / truncate the libm-test-ulps file, run "make regen-ulps" and
commit the regenerated-from-scratch file.  (Ideally any failures of
libm tests still present after regeneration would be investigated /
fixed - there are several open "math" bugs spread across these
platforms - but simply regenerating from scratch improves things.)

	* sysdeps/hppa/fpu/libm-test-ulps: Remove *_tonearest entries.
	* sysdeps/ia64/fpu/libm-test-ulps: Likewise.
	* sysdeps/m68k/m680x0/fpu/libm-test-ulps: Likewise.
	* sysdeps/microblaze/libm-test-ulps: Likewise.
	* sysdeps/sh/libm-test-ulps: Likewise.
2017-01-20 23:58:49 +00:00
Joseph Myers 76475eae8f Update README.libm-test.
This patch updates math/README.libm-test to have a more complete and
up-to-date list of the characters used in TEST_* macros to indicate
the types of function inputs and outputs.

	* math/README.libm-test: Update list of characters for input and
	output types.
2017-01-20 23:25:13 +00:00
Tulio Magno Quites Machado Filho eb1321f291 powerpc: Fix adapt_count update in __lll_unlock_elision
Commit e9a96ea1ac had an error that
prevents adapt_count from being updated in __lll_unlock_elision.
2017-01-20 16:40:30 -02:00
Torvald Riegel 6d523660e9 Fix mutex pretty printer test and pretty printer output.
This fixes the mutex pretty printer so that, if the owner ID isn't recorded
(such as in the current lock elision implementation), "Owner ID" will be shown
as "Unknown" instead of 0. It also changes the mutex printer output so that it
says "Acquired" instead of "Locked". The mutex tests are updated accordingly.

In addition, this adds a paragraph to the "Known issues" section of the
printers README explaining that the printer output isn't guaranteed to cover
every detail.

2017-01-14  Martin Galvan  <martingalvan@sourceware.org>

        * README.pretty-printers (Known issues): Warn about printers not
        always covering everything.
        * nptl/nptl-printers.py (MutexPrinter): Change output.
        * nptl/test-mutex-printers.py: Fix test and adapt to changed output.
2017-01-20 14:56:39 +01:00
Stefan Liebler 03b007771b S390: Adjust lock elision code after review.
This patch adjusts s390 specific lock elision code after review
of the following patches:
-S390: Use own tbegin macro instead of __builtin_tbegin.
(8bfc4a2ab4)
-S390: Use new __libc_tbegin_retry macro in elision-lock.c.
(53c5c3d5ac)
-S390: Optimize lock-elision by decrementing adapt_count at unlock.
(dd037fb3df)

The futex value is not tested before starting a transaction,
__glibc_likely is used instead of __builtin_expect and comments
are adjusted.

ChangeLog:

	* sysdeps/unix/sysv/linux/s390/htm.h: Adjust comments.
	* sysdeps/unix/sysv/linux/s390/elision-unlock.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/elision-lock.c: Adjust comments.
	(__lll_lock_elision): Do not test futex before starting a
	transaction.  Use __glibc_likely instead of __builtin_expect.
	* sysdeps/unix/sysv/linux/s390/elision-trylock.c: Adjust comments.
	(__lll_trylock_elision): Do not test futex before starting a
	transaction.  Use __glibc_likely instead of __builtin_expect.
2017-01-20 09:53:04 +01:00
Siddhesh Poyarekar 56009aa33c Add target to incorporate translations from translations.org
Add a convenience target for maintainers to download and incorporate
translation updates from translations.org.  Invoke as follows:

  make -r PARALLELMFLAGS="" -C ../po objdir=`pwd` update-translations

similar to generating libc.pot.

	* po/Makefile (update-translations): New target.
2017-01-20 12:32:46 +05:30
Joseph Myers fe3f0488da Restore clock_* librt exports for MicroBlaze (bug 21061).
MicroBlaze had clock_* functions exported from librt in glibc 2.18 and
2.19, as confirmed in
<https://sourceware.org/ml/libc-alpha/2017-01/msg00369.html>, and they
then disappeared in 2.20, presumably as a result of the fix
<https://sourceware.org/ml/libc-alpha/2014-02/msg00598.html> for a
Versions.def bug that had resulted in their unintended inclusion in
2.18 (followed by removal of the Versions.def mechanism that allowed
such bugs).

As they were released in that library, they should be considered part
of the GLIBC_2.18 ABI and so restored for the sake of any binaries
that expect them in that library.  This patch restores them by adding
a MicroBlaze version of clock-compat.c that overrides SHLIB_COMPAT.

Tested (compilation only) with build-many-glibcs.py (where this fixes
the librt ABI test failure; elf/check-execstack still fails and still
needs architecture maintainer attention to fix it or XFAIL it with an
appropriate explanatory comment).

	[BZ #21061]
	* sysdeps/unix/sysv/linux/microblaze/clock-compat.c: New file.
2017-01-19 20:57:16 +00:00
Siddhesh Poyarekar 41389c4049 Fix environment traversal when an envvar value is empty
The condition when the value of an envvar is empty (not just '\0'),
the loop in tunables_init gets stuck infinitely because envp is not
incremented.  Fix that by always incrementing envp in the loop.

Added test case (tst-empty-env.c) verifies the fix when the source is
configured with --enable-hardcoded-path-in-tests, thanks Josh Stone for
providing the test case.  Verified on x86_64.

	* elf/dl-tunables (get_next_env): Always advance envp.
	* stdlib/tst-empty-env.c: New test case.
	* stdlib/Makefile (tests): Use it.
2017-01-20 00:45:09 +05:30
Joseph Myers 3a66b2b063 Fix ARM fpu_control.h for assemblers requiring VFP insn names (bug 21047).
Bug 21047 reports that the clang assembler disallows the ARM
implementations of _FPU_GETCW and _FPU_SETCW.

These are deliberately written the way they are, using generic
coprocessor instructions (from the days when VFP was just one possible
coprocessor for ARM) that have the right encodings, to handle the case
of the instructions being used runtime-conditionally inside glibc,
where use of these macros is not meant to result in either the
assembler requiring VFP to be enabled at assembly time or in it
marking the object as using VFP.  However, more recent ARM ARM
versions have restricted the definitions of the coprocessor
instructions and reportedly the clang assembler follows that in
disallowing those names for VFP instructions.

In the non-__SOFTFP__ case - which in fact is the only case where
these macro definitions can be used outside the build of glibc itself
- using VFP instruction names is of course fine, since we know that
VFP is enabled for that compilation.  Thus, this patch uses the
current VFP names for these instructions in that case to improve
compatibility for this header file.

Tested for hard-float and soft-float builds of glibc, including that
installed stripped shared libraries are unchanged by the patch.

	[BZ #21047]
	* sysdeps/arm/fpu_control.h [!__SOFTFP__] (_FPU_GETCW): Use VFP
	name for instruction.
	[!__SOFTFP__] (_FPU_SETCW): Likewise.
2017-01-19 00:05:34 +00:00
Joseph Myers cd880aa2cc Avoid parallel GCC install in build-many-glibcs.py.
A recent build-many-glibcs.py build
<https://sourceware.org/ml/libc-testresults/2017-q1/msg00067.html> ran
into what proves to be an old known bug
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42980> with parallel
install of GCC (one which as discussed there might require automake
changes to fix).  This patch makes build-many-glibcs.py avoid such
intermittent failures from parallel install by using -j1 for GCC make
install (the code in question also applies to binutils make install,
but it doesn't seem worth trying to avoid -j1 there; the builds and
installs of different toolchains are still fully parallel with each
other, this is only about the case when there are few enough of those
that multiple jobs can get used within a single make install).

	* scripts/build-many-glibcs.py (Config.build_cross_tool): Use -j1
	for make install.
2017-01-18 23:13:09 +00:00
Siddhesh Poyarekar 0e8bac37d5 Merge translations from the Translation Project
* po/bg.po: Merge from Translation Project.
	* po/fr.po: Likewise.
	* po/ko.po: Likewise.
	* po/nl.po: Likewise.
	* po/sv.po: Likewise.
2017-01-19 00:21:00 +05:30
Joseph Myers ae7b8fbdda Update install.texi latest GCC version known to work.
* manual/install.texi (Tools for Compilation): Update GCC version
	known to work to build glibc.
	* INSTALL: Regenerated.
2017-01-18 17:27:47 +00:00
Stefan Liebler 570c443352 S390: Fix FAIL in test string/tst-xbzero-opt [BZ #21006]
On s390x this test failed with:
FAIL: explicit clear/test: expected 0 got 1

In setup_explicit_clear, the buffer is filled with the test_pattern.
On s390x the memcpy in prepare_test_buffer is done by loading
r4 / r5 with the test_pattern and using store multiple instruction
to store r4 / r5 to buf.
If explicit_bzero is resolved in setup_explicit_clear, r4 / r5 is
stored to stack by _dl_runtime_resolve and the call to memmem in
count_test_patterns finds a hit of the test_pattern on the stack.

This patch resolves all symbols at program startup by linking with
-z now.  This omits the call of _dl_runtime_resolve within
setup_explicit_clear and the test passes.

ChangeLog:

	[BZ #21006]
	* string/Makefile (LDFLAGS-tst-xbzero-opt): New variable.
2017-01-17 08:54:58 +01:00
Joseph Myers b040e1b084 Make soft-float powerpc swapcontext restore the signal mask (bug 21045).
The soft-float powerpc version of swapcontext does not restore the
signal mask, resulting in stdlib/tst-setcontext2 failing:

after getcontext
after setcontext
after swapcontext
FAIL: SIGUSR2 is blocked after swapcontext.

This patch fixes this by adjusting the arguments passed to
__sigprocmask so that it restores the saved signal mask as well as
saving the existing one.  (For hard-float, this code is only used for
a compat symbol, not for the current version of swapcontext.)

Tested for soft-float powerpc.

	[BZ #21045]
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S
	(__CONTEXT_FUNC_NAME): Pass address of signal mask to be restored
	to __sigprocmask.
2017-01-16 21:34:48 +00:00
Chris Metcalf 502697713f tile: Check for pointer add overflow in memchr
As was done in b224637928, check for large size causing an overflow
in the loop that walks over the array.

Branching out of line here is the fastest approach for handling this
problem, since tile can bundle the instructions to compute the branch
test in parallel with doing the required memchr loop setup computation.

Unfortunately, the existing saturated ops (e.g. tilegx addxsc) are
all signed saturing ops, so don't help with unsigned saturation.
2017-01-16 15:44:48 -05:00
Chris Metcalf 4cb89c1581 tile: pass __IPC_64 as zero for SysV IPC calls
In 1e5834c38a ("Refactor Linux ipc_priv header") a different
approach to passing __IPC_64 as zero was created.  The tile
architecture also needs to pass __IPC_64 as zero since it does
not set CONFIG_ARCH_WANT_IPC_PARSE_VERSION in the kernel.
So create a minimal ipc_priv.h that specifies __IPC_64 as zero.
2017-01-16 15:43:29 -05:00
Siddhesh Poyarekar 099191b1f5 Fix typo in NEWS
The ip6-bytestring resolver corresponds to the RES_USEBSTRING flag and
not RES_NOIP6DOTINT.  Thank you Michael Kerrisk for noticing and
pointing it out.
2017-01-14 16:37:41 +05:30
Torvald Riegel 8f9450a0b7 Add compiler barriers around modifications of the robust mutex list.
Any changes to the per-thread list of robust mutexes currently acquired as
well as the pending-operations entry are not simply sequential code but
basically concurrent with any actions taken by the kernel when it tries
to clean up after a crash.  This is not quite like multi-thread concurrency
but more like signal-handler concurrency.
This patch fixes latent bugs by adding compiler barriers where necessary so
that it is ensured that the kernel crash handling sees consistent data.

This is meant to be easy to backport, so we do not use C11-style signal
fences yet.

	* nptl/descr.h (ENQUEUE_MUTEX_BOTH, DEQUEUE_MUTEX): Add compiler
	barriers and comments.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Likewise.
	* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise.
2017-01-13 23:12:32 +01:00
Torvald Riegel 8e31cafb26 Clear list of acquired robust mutexes in the child process after forking.
Robust mutexes acquired at the time of a call to fork() do not remain
acquired by the forked child process.  We have to clear the list of
acquired robust mutexes before registering this list with the kernel;
otherwise, if some of the robust mutexes are process-shared, the parent
process can alter the child's robust mutex list, which can lead to
deadlocks or even modification of memory that may not be occupied by a
mutex anymore.

	[BZ #19402]
	* sysdeps/nptl/fork.c (__libc_fork): Clear list of acquired robust
	mutexes.
2017-01-13 17:17:38 +01:00
Torvald Riegel 65810f0ef0 robust mutexes: Fix broken x86 assembly by removing it
lll_robust_unlock on i386 and x86_64 first sets the futex word to
FUTEX_WAITERS|0 before calling __lll_unlock_wake, which will set the
futex word to 0.  If the thread is killed between these steps, then the
futex word will be FUTEX_WAITERS|0, and the kernel (at least current
upstream) will not set it to FUTEX_OWNER_DIED|FUTEX_WAITERS because 0 is
not equal to the TID of the crashed thread.

The lll_robust_lock assembly code on i386 and x86_64 is not prepared to
deal with this case because the fastpath tries to only CAS 0 to TID and
not FUTEX_WAITERS|0 to TID; the slowpath simply waits until it can CAS 0
to TID or the futex_word has the FUTEX_OWNER_DIED bit set.

This issue is fixed by removing the custom x86 assembly code and using
the generic C code instead.  However, instead of adding more duplicate
code to the custom x86 lowlevellock.h, the code of the lll_robust* functions
is inlined into the single call sites that exist for each of these functions
in the pthread_mutex_* functions.  The robust mutex paths in the latter
have been slightly reorganized to make them simpler.

This patch is meant to be easy to backport, so C11-style atomics are not
used.

	[BZ #20985]
	* nptl/Makefile: Adapt.
	* nptl/pthread_mutex_cond_lock.c (LLL_ROBUST_MUTEX_LOCK): Remove.
	(LLL_ROBUST_MUTEX_LOCK_MODIFIER): New.
	* nptl/pthread_mutex_lock.c (LLL_ROBUST_MUTEX_LOCK): Remove.
	(LLL_ROBUST_MUTEX_LOCK_MODIFIER): New.
	(__pthread_mutex_lock_full): Inline lll_robust* functions and adapt.
	* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Inline
	lll_robust* functions and adapt.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise.
	* sysdeps/nptl/lowlevellock.h (__lll_robust_lock_wait,
	__lll_robust_lock, lll_robust_cond_lock, __lll_robust_timedlock_wait,
	__lll_robust_timedlock, __lll_robust_unlock): Remove.
	* sysdeps/unix/sysv/linux/i386/lowlevellock.h (lll_robust_lock,
	lll_robust_cond_lock, lll_robust_timedlock, lll_robust_unlock): Remove.
	* sysdeps/unix/sysv/linux/x86_64/lowlevellock.h (lll_robust_lock,
	lll_robust_cond_lock, lll_robust_timedlock, lll_robust_unlock): Remove.
	* sysdeps/unix/sysv/linux/sparc/lowlevellock.h (__lll_robust_lock_wait,
	__lll_robust_lock, lll_robust_cond_lock, __lll_robust_timedlock_wait,
	__lll_robust_timedlock, __lll_robust_unlock): Remove.
	* nptl/lowlevelrobustlock.c: Remove file.
	* nptl/lowlevelrobustlock.sym: Likewise.
	* sysdeps/unix/sysv/linux/i386/lowlevelrobustlock.S: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S: Likewise.
2017-01-13 17:16:07 +01:00
Tulio Magno Quites Machado Filho f32941d80c powerpc: Regenerate ULPs
After this update, math/test-ildouble, math/test-ldouble and
math/test-ldouble-finite pass on hard float, POWER < 7 builds.

Tested on powerpc, powerpc64 and powerpc64le.
2017-01-13 09:36:46 -02:00
Siddhesh Poyarekar 468e525c81 Merge translations from the Translation Project
Update translations from the 2.25 candidate libc.pot.

	* po/cs.po: Merge translations from the Translation Project.
	* po/de.po: Likewise.
	* po/pl.po: Likewise.
	* po/ru.po: Likewise.
	* po/tr.po: Likewise.
	* po/uk.po: Likewise.
	* po/vi.po: Likewise.
	* po/zh_CN.po: Likewise.
2017-01-12 15:07:01 +05:30
Joseph Myers c1f0601389 Fix MIPS o32 posix_fadvise.
The posix_fadvise consolidation broke posix_fadvise for MIPS o32, so
resulting in posix/tst-posix_fadvise failing.

MIPS o32 (and the other ABIs) has only the posix_fadvise64 syscall,
which acts like posix_fadvise64_64 (in the o32 case, because of the
alignment argument it's actually a 7-argument syscall).  The generic
posix_fadvise implementation presumes that if __NR_fadvise64 is
defined, it's for the case where a single len argument is passed to
the syscall rather than two syscall arguments in the case of a 32-bit
system.

The generic posix_fadvise64 works fine for this case (defining
__NR_fadvise64_64 to __NR_fadvise64 as needed).  ARM has a
posix_fadvise.c that uses __posix_fadvise64_l64 in posix_fadvise, and
that approach also works for MIPS o32, so this patch makes MIPS o32
include the ARM file.

Tested for MIPS o32.

	* sysdeps/unix/sysv/linux/mips/mips32/posix_fadvise.c: New file.
2017-01-12 02:19:00 +00:00
Joseph Myers 4dfb9c9411 Make fallback fegetexceptflag work with generic fetestexceptflag.
The generic implementation of fetestexceptflag does:

int
fetestexceptflag (const fexcept_t *flagp, int excepts)
{
  /* Most versions of fegetexceptflag store exceptions in a form such
     that this works.  */
  return *flagp & excepts & FE_ALL_EXCEPT;
}

In the case where FE_ALL_EXCEPT is nonzero but exceptions may not be
supported at runtime, this only works if fegetexceptflag cleared all
the bits of FE_ALL_EXCEPT in *flagp; otherwise it accesses
uninitialized data.  This showed up as a failure of
math/test-fetestexceptflag for MIPS o32 soft-float.  This patch makes
the fallback fegetexceptflag store 0 (fexcept_t is an integer type
everywhere) so that this works.  (No bug report in Bugzilla because
this wasn't user-visible - at least, without using tools to detect
uninitialized memory use at runtime - without fetestexceptflag, which
is new in 2.25.)

Tested for MIPS o32 soft-float.

	* math/fgetexcptflg.c (__fegetexceptflag): Store 0 in fexcept_t
	object.
2017-01-12 01:52:37 +00:00
Joseph Myers 6a1cefac19 Make endian-conversion macros always return correct types (bug 16458).
Bug 16458 reports that the endian-conversion macros in <endian.h> and
<netinet/in.h>, in the case where no endian conversion is needed, just
return their arguments without converting to the expected return type,
so failing to act as expected for a macro version of a function.  (The
<netinet/in.h> macros, in particular, are described with prototypes in
POSIX so should act like correspondingly prototyped functions.)

Where previously this was a fairly obscure issue, it now results in
glibc build with GCC mainline breaking for big-endian systems:

nss_hesiod/hesiod-service.c: In function '_nss_hesiod_getservbyport_r':
nss_hesiod/hesiod-service.c:142:39: error: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size 6 [-Werror=format-truncation=]
   snprintf (portstr, sizeof portstr, "%d", ntohs (port));
                                       ^~
nss_hesiod/hesiod-service.c:142:38: note: using the range [1, -2147483648] for directive argument
   snprintf (portstr, sizeof portstr, "%d", ntohs (port));
                                      ^~~~
nss_hesiod/hesiod-service.c:142:3: note: format output between 2 and 12 bytes into a destination of size 6
   snprintf (portstr, sizeof portstr, "%d", ntohs (port));
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The port argument is passed as int to this function, so when ntohs
does not convert the compiler cannot tell that the result is within
the range of uint16_t.  (I don't know if in fact it's possible for
out-of-range values to reach this function and so get truncated as
strings without this patch or as integers with it.)

This patch arranges for these macros to use identity functions to
ensure appropriate conversions while having warnings for implicit
conversions of function arguments that might not occur with a cast.

Tested for x86_64 and x86; with build-many-glibcs.py with GCC 6; and
with build-many-glibcs.py with GCC mainline for powerpc to test the
build fix.

	[BZ #16458]
	* bits/uintn-identity.h: New file.
	* inet/netinet/in.h: Include <bits/uintn-identity.h>.
	[__BYTE_ORDER == __BIG_ENDIAN] (ntohl): Use __uint32_identity.
	[__BYTE_ORDER == __BIG_ENDIAN] (ntohs): Use __uint16_identity.
	[__BYTE_ORDER == __BIG_ENDIAN] (htonl): Use __uint32_identity.
	[__BYTE_ORDER == __BIG_ENDIAN] (htohs): Use __uint16_identity.
	* string/endian.h: Include <bits/uintn-identity.h>.
	[__BYTE_ORDER == __LITTLE_ENDIAN] (htole16): Use
	__uint16_identity.
	[__BYTE_ORDER == __LITTLE_ENDIAN] (le16toh): Likewise.
	[__BYTE_ORDER == __LITTLE_ENDIAN] (htole32): Use
	__uint32_identity.
	[__BYTE_ORDER == __LITTLE_ENDIAN] (le32toh): Likewise.
	[__BYTE_ORDER == __LITTLE_ENDIAN] (htole64): Use
	__uint64_identity.
	[__BYTE_ORDER == __LITTLE_ENDIAN] (le64toh): Likewise.
	[__BYTE_ORDER != __LITTLE_ENDIAN] (htobe16): Use
	__uint16_identity.
	[__BYTE_ORDER != __LITTLE_ENDIAN] (be16toh): Likewise.
	[__BYTE_ORDER != __LITTLE_ENDIAN] (htobe32): Use
	__uint32_identity.
	[__BYTE_ORDER != __LITTLE_ENDIAN] (be32toh): Likewise.
	[__BYTE_ORDER != __LITTLE_ENDIAN] (htobe64): Use
	__uint64_identity.
	[__BYTE_ORDER != __LITTLE_ENDIAN] (be64toh): Likewise.
	* string/Makefile (headers): Add bits/uintn-identity.h.
	(tests): Add test-endian-types.
	* string/test-endian-types.c: New file.
	* inet/Makefile (tests): Add test-hnto-types.
	* inet/test-hnto-types.c: New file.
2017-01-11 15:28:08 +00:00
Siddhesh Poyarekar bb44015143 Update translations from the Translation Project
Pulled from:

http://translationproject.org/latest/libc/
2017-01-11 19:35:35 +05:30
Joseph Myers 3c9378265a Fix testsuite build for GCC 7 -Wformat-truncation.
This patch fixes the glibc testsuite build for GCC 7
-Wformat-truncation, newly moved out of -Wformat-length and with some
further warnings that didn't previously appear.  Two tests that
previously disabled -Wformat-length are changed to disable
-Wformat-truncation instead; two others are made to disable that
option as well.

Tested (compilation only) with build-many-glibcs.py for aarch64 with
GCC mainline.

	* stdio-common/tst-printf.c [__GNUC_PREREQ (7, 0)]: Ignore
	-Wformat-truncation instead of -Wformat-length.
	* time/tst-strptime2.c (mkbuf) [__GNUC_PREREQ (7, 0)]: Likewise.
	* stdio-common/tstdiomisc.c (F): Ignore -Wformat-truncation for
	GCC 7.
	* wcsmbs/tst-wcstof.c: Include <libc-internal.h>.
	(do_test): Ignore -Wformat-truncation for GCC 7.
2017-01-11 14:02:23 +00:00
Joseph Myers 436cfba0ab Fix ld-address format-truncation error.
With the elf/sotruss-lib.c failure fixed, building 64-bit glibc with
GCC mainline fails with another format-truncation error in
locale/programs/ld-address.c, where 11 bytes are allocated for a
buffer to print a long int value.

This patch changes that code to allocate 21 bytes.  Treating this
value as signed is questionable and I don't think large values are
actually useful here, but I think those can be considered as instances
of bug 21036 which I've filed for overflow checks for numeric values
in localedef in general, and don't need to be addressed to fix the
build.

Tested with GCC mainline with compilation for aarch64 with
build-many-glibcs.py, and with glibc testsuite for x86_64 (built with
GCC 6).

(Note that while this fixes the build of 64-bit glibc with GCC
mainline, further fixes will be needed to get the testsuite building
with GCC mainline again.)

	* locale/programs/ld-address.c (INT_STR_ELEM): Increase size of
	buffer used to print long int value.
2017-01-11 13:59:01 +00:00
Joseph Myers 38d01bd6df Fix elf/sotruss-lib format-truncation error.
Building 64-bit glibc with GCC mainline fails with:

../elf/sotruss-lib.c: In function 'la_version':
../elf/sotruss-lib.c:91:28: error: '%lu' directive output may be truncated writing between 1 and 20 bytes into a region of size 11 [-Werror=format-truncation=]
      snprintf (endp, 12, ".%lu", (unsigned long int) pid);
                            ^~~
../elf/sotruss-lib.c:91:26: note: using the range [1, 18446744073709551615] for directive argument
      snprintf (endp, 12, ".%lu", (unsigned long int) pid);
                          ^~~~~~
../elf/sotruss-lib.c:91:6: note: format output between 3 and 22 bytes into a destination of size 12
      snprintf (endp, 12, ".%lu", (unsigned long int) pid);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Pids from getpid cannot actually be negative, but the compiler doesn't
know this.  Other places in this file use (signed) long int for
printing, so this patch makes this place do so as well.  Then it
increases the buffer size by one byte to allow for the minus sign that
can't actually occur.  It doesn't seem worth using diagnostic pragmas
to save one byte; other place in this file just use a cruder 3 *
sizeof (pid_t) calculation for number of digits.

Tested with GCC mainline with compilation for aarch64 with
build-many-glibcs.py, and with glibc testsuite for x86_64 (built with
GCC 6).

	* elf/sotruss-lib.c (init): Increase space allocated for pid by
	one byte.  Print it with %ld, cast to long int.
2017-01-11 13:57:59 +00:00
Szabolcs Nagy 64235ccc11 Make build-many-glibcs.py work on python3.2
I used this patch to run the new build script with python3.2, it may be worth
adding this hack if python3.5 is not widespread (might work with older python,
i haven't tested that).

This patch make build-many-glibcs.py work with python 3.2 by
adding fallback implementation to python 3.5 facilities if they
are not present.

Checked building a x86_64-linux-gnu toolchain with python 3.2.

2016-11-22  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* scripts/build-many-glibcs.py (os.cpu_count): Add compatibility definition.
	(re.fullmatch, subprocess.run): Likewise.
2017-01-11 10:30:40 -02:00