Consolidate code to compute sin and cos from lookup tables

This patch consolidates the multiple copies of code that looks up sin
and cos of a number from the lookup table and computes the final
value, into static functions.  This does not have a noticeable
performance impact since the functions are inlined by gcc.

There is further scope for consolidation in the functions but they
cause a more noticable impact on performance (>5%) due to which I have
held back on them.
Move various TEST_c_c tests from libm-test.inc to auto-libm-test-inc.

This patch moves tests of ccos, ccosh, cexp, clog, csqrt, ctan and
ctanh to auto-libm-test-in, adding the required support to
gen-auto-libm-tests.  Other TEST_c_c functions aren't moved for now
(although the relevant table entries are put in gen-auto-libm-tests
for it to know how to handle them): clog10 because of a known MPC bug
causing it to hang for at least some pure imaginary inputs (fixed in
SVN, but I'd rather not rely on unreleased versions of MPFR or MPC
even if relying on very recent releases); the inverse trig and
hyperbolic functions because of known slowness in special cases; and
csin / csinh because of observed slowness that I need to investigate
and report to the MPC maintainers.  Slowness can be bypassed by moving
to incremental generation (only for new / changed tests) rather than
regenerating the whole of auto-libm-test-out every time, but that
needs implementing.  (This patch takes the time for running
gen-auto-libm-tests from about one second to seven, on my system,
which I think is reasonable.  The slow functions would make it take
several minutes at least, which seems unreasonable.)

Tested x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of ccos, ccosh, cexp, clog,
	csqrt, ctan and ctanh.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (TEST_COND_x86_64): New macro.
	(TEST_COND_x86): Likewise.
	(ccos_test_data): Use AUTO_TESTS_c_c.
	(ccosh_test_data): Likewise.
	(cexp_test_data): Likewise.
	(clog_test_data): Likewise.
	(csqrt_test_data): Likewise.
	(ctan_test_data): Likewise.
	(ctan_tonearest_test_data): Likewise.
	(ctan_towardzero_test_data): Likewise.
	(ctan_downward_test_data): Likewise.
	(ctan_upward_test_data): Likewise.
	(ctanh_test_data): Likewise.
	(ctanh_tonearest_test_data): Likewise.
	(ctanh_towardzero_test_data): Likewise.
	(ctanh_downward_test_data): Likewise.
	(ctanh_upward_test_data): Likewise.
	* math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpc_c_c.
	(func_calc_desc): Add mpc_c_c union field.
	(FUNC_mpc_c_c): New macro.
	(test_functions): Add cacos, cacosh, casin, casinh, catan, catanh,
	ccos, ccosh, cexp, clog, clog10, csin, csinh, csqrt, ctan and
	ctanh.
	(special_fill_min_subnorm_p120): New function.
	(special_real_inputs): Add min_subnorm_p120.
	(calc_generic_results): Handle mpc_c_c.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
Move tests of cpow from libm-test.inc to auto-libm-test-in.

This patch moves tests of cpow to auto-libm-test-in, adding the
required support to gen-auto-libm-tests.

Tested x86_64 and x86 and ulps updated accordingly.

	* math/auto-libm-test-in: Add tests of cpow.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (cpow_test_data): Use AUTO_TESTS_cc_c.
	* * math/gen-auto-libm-tests.c (func_calc_method): Add value
	mpc_cc_c.
	(func_calc_desc): Add mpc_cc_c union field.
	(test_functions): Add cpow.
	(special_fill_2pi): New function.
	(special_real_inputs): Add 2pi.
	(calc_generic_results): Handle mpc_cc_c.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
Update timezone code from tzcode 2013i.

Now we have Paul's support for version-3 tz files checked in, this
patch updates all the code we take (unmodified) from tzcode to version
2013i (which includes the support for generating version-3 tz files
where necessary).

Tested x86_64.

	* timezone/checktab.awk: Update from tzcode 2013i.
	* timezone/private.h: Likewise.
	* timezone/scheck.c: Likewise.
	* timezone/tzfile.h: Likewise.
	* timezone/tzselect.ksh: Likewise.
	* timezone/zdump.c: Likewise.
	* timezone/zic.c: Likewise.
Add lang_name to various locales.
Revert spurious copying of ChangeLog to localedata/ChangeLog.
fix localedata/ChangeLog
Add more libm-test coverage of [a-c]* real functions.

Various libm functions have inadequate test coverage in libm-test.inc
/ auto-libm-test-in - failing to cover all the usual special cases
(infinities, NaNs, zero, large and small finite values, subnormals) as
well as a reasonable range of ordinary inputs and, where appropriate,
inputs close to the thresholds for underflow and overflow.

This patch improves test coverage for real functions [a-c]* (with the
expectation of adding more coverage for other functions later).

Tested x86_64 and x86 and ulps updated accordingly (and eight glibc
bugs and one C11 DR filed for issues found in the process).

	* math/auto-libm-test-in: Add more tests of acos, acosh, asin,
	asinh, atan, atan2, atanh, cbrt, cos and cosh.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (acosh_test_data): Add more tests.
	(atanh_test_data): Likewise.
	(ceil_test_data): Likewise.
	(copysign_test_data): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
Fix x86 / x86_64 expl / expl10l wild results in directed rounding modes (bug 16356).

This patch fixes bug 16356, bad results from x86 / x86_64 expl /
exp10l in directed rounding modes, the most serious of the bugs shown
up by my patch expanding libm test coverage.  When I fixed bug 16293,
I thought it was only necessary to set round-to-nearest when using
frndint in expm1 functions, because in other cases the cancellation
error from having the resulting fractional part close to 1 or -1 would
not be significant.  However, in expl and exp10l, the way the final
fractional part gets computed (something more complicated than a
simple subtraction, because more precision is needed than you'd get
that way) can result in a value outside the range [-1, 1] when the
argument to frndint was very close to an integer and was rounded the
"wrong" way because of the rounding mode - and the f2xm1 instruction
has undefined results if its argument is outside [-1, 1], so resulting
in the large errors seen.  So this patch removes the USE_AS_EXPM1L
conditionals on the round-to-nearest settings, so all of expl, expm1l
and exp10l now get round-to-nearest used for frndint (meaning the
final fractional part can at most be slightly above 0.5 in
magnitude).  Associated tests of exp and exp10 are added and testing
of exp10 in directed rounding modes enabled.

Tested x86_64 and x86 and ulps updated accordingly.

	* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL): Also set
	round-to-nearest for [!USE_AS_EXPM1L].
	* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL): Likewise.
	* math/auto-libm-test-in: Do not expect cosh tests to fail.  Add
	more tests of exp and exp10.  Expect some exp10 tests to miss
	exceptions or fail in directed rounding modes.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (exp10_tonearest_test_data): New array.
	(exp10_test_tonearest): New function.
	(exp10_towardzero_test_data): New array.
	(exp10_test_towardzero): New function.
	(exp10_downward_test_data): New array.
	(exp10_test_downward): New function.
	(exp10_upward_test_data): New array.
	(exp10_test_upward): New function.
	(main): Call the new functions.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
Flatten sysdeps/unix/bsd/bsd4.4 into sysdeps/unix/bsd.

As discussed in
<https://sourceware.org/ml/libc-alpha/2012-04/msg00840.html> and
<https://sourceware.org/ml/libc-alpha/2012-04/msg00989.html>, it seems
appropriate to flatten sysdeps/unix/bsd/bsd4.4 into sysdeps/unix/bsd.

The bulk of the patch is just moving files.  The only other changes
are: update paths in sysdeps/mach/hurd/Implies and
sysdeps/unix/sysv/linux/wait3.c; merge the two syscalls.list files,
with the removal of syscalls that were in
sysdeps/unix/bsd/syscalls.list but overridden in the bsd4.4 directory
by .c files there.

Tested x86_64.  The installed shared libraries are identical before
and after the patch except for libc.so where the move of wait3.c
(included by sysdeps/unix/sysv/linux/wait3.c) affects debug info, but
the disassembly is unchanged.

	* sysdeps/mach/hurd/Implies: Change unix/bsd/bsd4.4 to unix/bsd.
	* sysdeps/unix/bsd/syscalls.list (chflags): Add entry from
	sysdeps/unix/bsd/bsd4.4/syscalls.list.
	(fchflags): Likewise.
	(revoke): Likewise.
	(setlogin): Likewise.
	(sigaltstack): Likewise.
	(wait4): Likewise.
	(sigblock): Remove.
	(sigsetmask): Likewise.
	(wait3): Likewise.
	(waitpid): Likewise.
	* sysdeps/unix/bsd/bsd4.4/syscalls.list: Remove file.
	* sysdeps/unix/sysv/linux/wait3.c: Update directory of included
	file.
	* sysdeps/unix/bsd/bsd4.4/Makefile: Move to ...
	* sysdeps/unix/bsd/Makefile: ... here.
	* sysdeps/unix/bsd/bsd4.4/Versions: Move to ...
	* sysdeps/unix/bsd/Versions: ... here.
	* sysdeps/unix/bsd/bsd4.4/bits/sockaddr.h: Move to ...
	* sysdeps/unix/bsd/bits/sockaddr.h: ... here.
	* sysdeps/unix/bsd/bsd4.4/cmsg_nxthdr.c: Move to ...
	* sysdeps/unix/bsd/cmsg_nxthdr.c: ... here.
	* sysdeps/unix/bsd/bsd4.4/sigblock.c: Move to ...
	* sysdeps/unix/bsd/sigblock.c: ... here.
	* sysdeps/unix/bsd/bsd4.4/sigsetmask.c: Move to ...
	* sysdeps/unix/bsd/sigsetmask.c: ... here.
	* sysdeps/unix/bsd/bsd4.4/sigvec.c: Move to ...
	* sysdeps/unix/bsd/sigvec.c: ... here.
	* sysdeps/unix/bsd/bsd4.4/tcdrain.c: Move to ...
	* sysdeps/unix/bsd/tcdrain.c: ... here.
	* sysdeps/unix/bsd/bsd4.4/tcgetattr.c: Move to ...
	* sysdeps/unix/bsd/tcgetattr.c: ... here.
	* sysdeps/unix/bsd/bsd4.4/tcsetattr.c: Move to ...
	* sysdeps/unix/bsd/tcsetattr.c: ... here.
	* sysdeps/unix/bsd/bsd4.4/wait.c: Move to ...
	* sysdeps/unix/bsd/wait.c: ... here.
	* sysdeps/unix/bsd/bsd4.4/wait3.c: Move to ...
	* sysdeps/unix/bsd/wait3.c: ... here.
	* sysdeps/unix/bsd/bsd4.4/waitpid.c: Move to ...
	* sysdeps/unix/bsd/waitpid.c: ... here.
Fix ldbl-128 lgammal for small negative arguments (bug 16337).

This patch fixes bug 16337, ldbl-128 lgammal spurious overflows for
small negative arguments (the arguments in question are already in the
testsuite).  The implementation uses the reflection formula to compute
lgamma of negative x from lgamma of -x, effectively resulting in a
calculation -log(x^2) + log(-x); cancellation isn't problematic in
this case (bugs for problematic cancellation in lgamma are 2542, 2543,
2558), but the x^2 calculation can underflow (in which case there is
spurious logic to return an overflowing value - lgamma can only ever
correctly overflow for large positive arguments, though tgamma can
overflow for small arguments of either sign as well as large positive
arguments).  The fix is simply to calculate the result directly with
logl when the argument is a small enough negative number.

Tested mips64.

	* sysdeps/ieee754/ldbl-128/e_lgammal_r.c (__ieee754_lgammal_r):
	Calculate results for small negative arguments directly rather
	than using reflection formula with special underflow handling.
Update powerpc-fpu ULPs.
Clarify that scanf does not use character classes.  Fixes bug 12986

Update documentation to say that scanf ("%[[:alpha:]]", c) does not read
alphabetic characters but is parsed literarily.
Add Changelog and news entry.
Fix race in free() of fastbin chunk: BZ #15073

Perform sanity check only if we have_lock.  Due to lockless nature of fastbins
we need to be careful derefencing pointers to fastbin entries (chunksize(old)
in this case) in multithreaded environments.

The fix is to add have_lock to the if-condition checks.  The rest of the patch
only makes code more readable.

	* malloc/malloc.c (_int_free): Perform sanity check only if we
	have_lock.
Restore accidentally deleted bug-fix entries in NEWS.

	* NEWS: Restore accidentally deleted bug-fix entries.
Define __CORRECT_ISO_CPP_STRING_H_PROTO correctly for Clang.

In the string/string.h and string/strings.h headers, we have a couple
of macros that "tell the caller that we provide correct C++
prototypes" according to the comment; they are used to determine
whether to wrap some prototypes in "extern "C++"" (and provide
multiple overloads of them, and some other magic) when __cplusplus is
defined.

The macros are set to check for sufficiently-recent GCC versions (4.4
and later), but this is not the right check for non-GCC compilers.  In
particular, these macros should also be set when using Clang -- if
they are not set, then Clang will be unable to correctly diagnose a
number of subtle bugs that will be errors in GCC compilations.

As per discussion on earlier versions of this patch, rather than
restrict the fix to Clang per se, we assume that all C++ compilers that
claim to fully support C++98 are using a standard-conforming C++
standard library, which seems pretty reasonable.  Clang has been
providing an appropriate value of __cplusplus since May 2012.
ia64: link.h: adjust whitespace

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
ia64: implement sotruss support

Tested with:
	$ cat test.c
	main(){close(0x1024, 2, 3);}
	$ gcc test.c
	$ sotruss -e ./a.out
		a.out -> libc.so.6.1    : __libc_start_main(0x4000000000000950, 0x1, 0x60000fffffb56bc8)
		a.out -> libc.so.6.1    : close(0x1024, 0x2, 0x3)
		a.out -> libc.so.6.1    : close - 0xffffffffffffffff

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
ia64: ioperm: clean up long dead code

This file has a few #if 0 code paths which cause a build time warning:
ports/sysdeps/unix/sysv/linux/ia64/ioperm.c:66:7: warning:
	variable 'prot' set but not used [-Wunused-but-set-variable]

Rather than add more #if 0 around that variable, just delete the code
altogether.  Not like it's going to ever be implemented.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>