Commit Graph

1422 Commits

Author SHA1 Message Date
Joseph Myers edea402804 Fix ldbl-128 powl sign of result in overflow / underflow cases (bug 17097).
This patch fixes bug 17097, ldbl-128 powl producing overflowing /
underflowing results with positive sign when the result should have
been negative.  This was shown up by the tests in non-default rounding
modes added by my patch for bug 16315, but isn't actually limited to
non-default rounding modes: rather, when rounding to nearest the
wrappers produced a result with the correct sign and so always hid the
bug unless -lieee was used to disable the wrappers.  The problem is
that in the cases where Y is large enough that the result overflows or
underflows for X not very close to 1, but not large enough to overflow
or underflow for all X != +/- 1 (in the latter case Y is always an
even integer), a positive overflowing / underflowing result is always
returned, rather than one with the correct sign.  This patch moves the
relevant part of computation of the sign earlier and returns a result
of the correct sign.

Tested for mips64.

	[BZ #17097]
	* sysdeps/ieee754/ldbl-128/e_powl.c (__ieee754_powl): Return
	result with correct sign in case of exponents that produce
	overflow except for X very close to 1.
2014-06-29 11:49:08 +00:00
Arjun Shankar 6f12d0629f Correctly report nscd child process status (BZ #17092)
The nscd parent process returns the result of a `wait' call rather
than the exit status of the child it waits for. These two aren't
exactly the same. In my case (and probably on most machines), the exit
status is in the 2nd LSB of the result of `wait', and so:

e.g. if the nscd child process returns 1, the parent returns 1 << 8,
which Bash happily reports as 0.
2014-06-27 23:31:47 +05:30
Joseph Myers be25493251 Fix yn overflow handling in non-default rounding modes (bug 16561, bug 16562).
This patch fixes bugs 16561 and 16562, bad results of yn in overflow
cases in non-default rounding modes, both because an intermediate
overflow in the recurrence does not get detected if the result is not
an infinity and because an overflowing result may occur in the wrong
sign.  The fix is to set FE_TONEAREST mode internally for the parts of
the function where such overflows can occur (which includes the call
to y1 - where yn is used to compute a Bessel function of order -1,
negating the result of y1 isn't correct for overflowing results in
directed rounding modes) and then compute an overflowing value in the
original rounding mode if the to-nearest result was an infinity.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 and powerpc32 to test the ldbl-128 and ldbl-128ibm changes.

(The tests for these bugs were added in my previous y1 patch, so the
only thing this patch has to do with the testsuite is enable yn
testing in all rounding modes.)

	[BZ #16561]
	[BZ #16562]
	* sysdeps/ieee754/dbl-64/e_jn.c: Include <float.h>.
	(__ieee754_yn): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/ieee754/flt-32/e_jnf.c: Include <float.h>.
	(__ieee754_ynf): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/ieee754/ldbl-128/e_jnl.c: Include <float.h>.
	(__ieee754_ynl): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Include <float.h>.
	(__ieee754_ynl): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/ieee754/ldbl-96/e_jnl.c: Include <float.h>.
	(__ieee754_ynl): Set FE_TONEAREST mode internally and then
	recompute overflowing results in original rounding mode.
	* sysdeps/i386/fpu/fenv_private.h [!__SSE2_MATH__]
	(libc_feholdsetround_ctx): New macro.
	* math/libm-test.inc (yn_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps : Likewise.
2014-06-27 14:52:13 +00:00
Joseph Myers cfd2ea5047 Update README and NEWS for ports directory removal.
This patch updates README to remove a mention of the ports directory.
It also adds a NEWS item for the merge of ports into the main sysdeps
tree (I think it's NEWS-worthy, although not strictly a user-visible
feature).

Other remaining ports references to resolve: a comment in
manual/signal.texi (not giving a literal path, but maybe should change
anyway); a comment in config.h.in (path should be updated);
scripts/list-sources.sh (appears to date back to ports being a
separate repository).

	* README: Do not mention ports directory.
2014-06-25 12:55:21 +00:00
Siddhesh Poyarekar 911422da02 Add compat symbols for scalb* in i386
Bring back symbols into libc.so for scalb* functions.  They are no
longer used but unfortunately they're now part of the ABI.
2014-06-25 08:47:13 +05:30
Joseph Myers 4060283dec Fix x86/x86_64 expm1l spurious underflow exceptions (bug 16539).
This patch fixes bug 16539, spurious underflow exceptions from x86 /
x86-64 expm1l.  The problem is that the computation of a base-2
exponent with extra precision involves spurious underflows for
arguments that are small but not subnormal, so a check is added to
just return the argument in those cases.  (If the argument *is*
subnormal, underflowing is correct and the existing code will always
underflow, so it suffices to keep using the existing code in that
case; some expm1 implementations have a bug (bug 16353) with missing
underflow exceptions, but I don't think there's such a bug in this
particular version.)

Tested x86_64 and x86; no ulps updates needed.

(auto-libm-test-out diffs omitted below.)

	[BZ #16539]
	* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]: Just
	return the argument for normal arguments with exponent below -64.
	* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL) [USE_AS_EXPM1L]:
	Likewise.
	* math/auto-libm-test-in: Add another test of expm1.
	* math/auto-libm-test-out: Regenerated.
2014-06-24 21:00:08 +00:00
Joseph Myers e7dd3c8c1d Fix ldbl-128 erfl spurious underflows (bug 16287).
This patch fixes bug 16287, spurious underflows from ldbl-128 erfl
arising from it calling erfcl for arguments with absolute value at
least 1.0, although for large positive arguments erfcl correctly
underflows but erfl shouldn't.  The fix is simply to avoid calling
erfcl, and just return 1, for arguments above a cut-off large enough
that erfl correctly rounds to-nearest as 1 but not so large that erfcl
underflows.

Tested mips64.  Also tested x86_64 and x86 to confirm the new tests
(taken from the tests of erfc) don't cause any problems there; no ulps
updates needed.

	[BZ #16287]
	* sysdeps/ieee754/ldbl-128/s_erfl.c (__erfl): Return 1 without
	calling __erfcl for arguments at least 16.
	* math/auto-libm-test-in: Add more tests of erf.
	* math/auto-libm-test-out: Regenerated.
2014-06-24 20:56:56 +00:00
Siddhesh Poyarekar 2307e1261e Fix namespace violation in pthreadtypes.h (BZ #17084)
This was causing conformtest failures on i386.
2014-06-24 22:43:34 +05:30
Wilco c0a4ed7799 Add bug 16918 to NEWS. 2014-06-24 15:40:29 +00:00
Marcus Shawcroft 56046ce637 Revert "Add bug 16918 to NEWS."
This reverts commit 222b787a6f.
2014-06-24 16:28:06 +01:00
Wilco 222b787a6f Add bug 16918 to NEWS. 2014-06-24 14:48:05 +00:00
Joseph Myers 4648909d56 Fix cosh spurious underflows from expm1 (bug 16354), inaccurate results near 0 (bug 17061).
This patch fixes bug 16354, spurious underflows from cosh when a tiny
argument is passed to expm1 and expm1 correctly underflows although
the final result of cosh should be 1.  As noted in that bug, some
cases are latent because of expm1 implementations not raising
underflow (bug 16353), but all the implementations are fixed
similarly.  They already contained checks for tiny arguments, but the
checks were too late to avoid underflow from expm1 (although they
would avoid underflow from subsequent squaring of the result of
expm1); they are moved before the expm1 calls.

The thresholds used for considering arguments tiny are not
particularly consistent in how they relate to the precision of the
floating-point format in question.  They are, however, all sufficient
to ensure that the round-to-nearest result of cosh is indeed 1 below
the threshold (although sometimes they are smaller than necessary).
But the previous logic did not return 1, but the previously computed 1
+ expm1(abs(x)) value.  And the thresholds in the ldbl-128 and
ldbl-128ibm code (0x1p-71L - I suspect 0x3f8b was intended in the code
instead of 0x3fb8 - and (roughly) 0x1p-55L) are not sufficient for
that value to be 1.  So by moving the test for tiny arguments, and
consequently returning 1 directly now the expm1 value hasn't been
computed by that point, this patch also fixes bug 17061, the (large
number of ulps) inaccuracy for small arguments in those
implementations.  Tests for that bug are duly added.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 and powerpc32 to validate the ldbl-128 and ldbl-128ibm changes.

	[BZ #16354]
	[BZ #17061]
	* sysdeps/ieee754/dbl-64/e_cosh.c (__ieee754_cosh): Check for
	small arguments before calling __expm1.
	* sysdeps/ieee754/flt-32/e_coshf.c (__ieee754_coshf): Check for
	small arguments before calling __expm1f.
	* sysdeps/ieee754/ldbl-128/e_coshl.c (__ieee754_coshl): Check for
	small arguments before calling __expm1l.
	* sysdeps/ieee754/ldbl-128ibm/e_coshl.c (__ieee754_coshl):
	Likewise.
	* sysdeps/ieee754/ldbl-96/e_coshl.c (__ieee754_coshl): Likewise.
	* math/auto-libm-test-in: Add more cosh tests.  Do not allow
	spurious underflow for some cosh tests.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
2014-06-23 20:20:10 +00:00
Joseph Myers 46a3d3c7d6 Set errno for y1 overflow (bug 17050).
This patch fixes bug 17050, missing errno setting for y1 overflow (for
small positive arguments).  An appropriate check is added for overflow
directly in the __ieee754_y1 implementation, similar to the check
present for yn (doing it there rather than in the wrapper also avoids
yn needing to repeat the check when called for order 1 or -1 and it
uses __ieee754_y1).

Tested x86_64 and x86; no ulps update needed.  Also tested for mips64
to verify the ldbl-128 fix (the ldbl-128ibm code just #includes the
ldbl-128 file).

	[BZ #17050]
	* sysdeps/ieee754/dbl-64/e_j1.c: Include <errno.h>.
	(__ieee754_y1): Set errno if return value overflows.
	* sysdeps/ieee754/flt-32/e_j1f.c: Include <errno.h>.
	(__ieee754_y1f): Set errno if return value overflows.
	* sysdeps/ieee754/ldbl-128/e_j1l.c: Include <errno.h>.
	(__ieee754_y1l): Set errno if return value overflows.
	* sysdeps/ieee754/ldbl-96/e_j1l.c: Include <errno.h>.
	(__ieee754_y1l): Set errno if return value overflows.
	* math/auto-libm-test-in: Add more tests of y0, y1 and yn.
	* math/auto-libm-test-out: Regenerated.
2014-06-23 20:17:13 +00:00
Joseph Myers 4da6db5188 Fix pow overflow in non-default rounding modes (bug 16315).
This patch fixes bug 16315, bad pow handling of overflow/underflow in
non-default rounding modes.  Tests of pow are duly converted to
ALL_RM_TEST to run all tests in all rounding modes.

There are two main issues here.  First, various implementations
compute a negative result by negating a positive result, but this
yields inappropriate overflow / underflow values for directed
rounding, so either overflow / underflow results need recomputing in
the correct sign, or the relevant overflowing / underflowing operation
needs to be made to have a result of the correct sign.  Second, the
dbl-64 implementation sets FE_TONEAREST internally; in the overflow /
underflow case, the result needs recomputing in the original rounding
mode.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16315]
	* sysdeps/i386/fpu/e_pow.S (__ieee754_pow): Ensure possibly
	overflowing or underflowing operations take place with sign of
	result.
	* sysdeps/i386/fpu/e_powf.S (__ieee754_powf): Likewise.
	* sysdeps/i386/fpu/e_powl.S (__ieee754_powl): Likewise.
	* sysdeps/ieee754/dbl-64/e_pow.c: Include <math.h>.
	(__ieee754_pow): Recompute overflowing and underflowing results in
	original rounding mode.
	* sysdeps/x86/fpu/powl_helper.c: Include <stdbool.h>.
	(__powl_helper): Allow negative argument X and scale negated value
	as needed.  Avoid passing value outside [-1, 1] to f2xm1.
	* sysdeps/x86_64/fpu/e_powl.S (__ieee754_powl): Ensure possibly
	overflowing or underflowing operations take place with sign of
	result.
	* sysdeps/x86_64/fpu/multiarch/e_pow.c [HAVE_FMA4_SUPPORT]:
	Include <math.h>.
	* math/auto-libm-test-in: Add more tests of pow.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (pow_test): Use ALL_RM_TEST.
	(pow_tonearest_test_data): Remove.
	(pow_test_tonearest): Likewise.
	(pow_towardzero_test_data): Likewise.
	(pow_test_towardzero): Likewise.
	(pow_downward_test_data): Likewise.
	(pow_test_downward): Likewise.
	(pow_upward_test_data): Likewise.
	(pow_test_upward): Likewise.
	(main): Don't call removed functions.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-06-23 20:12:33 +00:00
Andreas Schwab ac60763eac Don't ignore too long lines in nss_files (BZ #17079) 2014-06-23 12:29:51 +02:00
Allan McRae d03efb2f97 Mention CVE-2014-4043 in NEWS 2014-06-21 17:23:55 +10:00
Maciej W. Rozycki 90e5dd482f [BZ #17075] ARM: Fix immediate calculation of R_ARM_TLS_DESC
This fixes the calculation of R_ARM_TLS_DESC relocations for lazy global
symbol references, i.e. created with `-z lazy' in effect with the static
linker, where immediate resolution is requested with LD_BIND_NOW.
2014-06-20 20:22:42 +01:00
Andreas Schwab aa6ec754f3 Fix another memory leak in regexp compiler (BZ #17069) 2014-06-20 14:03:40 +02:00
Siddhesh Poyarekar 7892406e35 Fix ChangeLog and NEWS goof-up
The ChangeLog belonged to localedata and the bug is not completely
fixed, so it didn't deserve to enter the NEWS yet.
2014-06-20 17:12:10 +05:30
Stefan Liebler 3ef6b85059 [BZ #6803] Set errno for scalbln, scalbn
Errno is not set and the testcases will fail.

Now the scalbln-aliases are removed in i386/m68
and the wrappers are used when calling the scalbln-functions.

On ia64 only scalblnf has its own implementation.
For scalbln and scalblnl the ieee754/dbl-64 and ieee754/ldbl-96 are used, thus
the wrappers are needed, too.
2014-06-20 07:48:20 +05:30
Richard Earnshaw f940b96522 [AArch64] Add optimized strchr.
Implementation of strchr for AArch64.  Speedups taken from micro-bench
show the improvements relative to the standard C code.

The use of LD1 means we have identical code for both big- and
little-endian systems.
2014-06-19 11:03:59 +01:00
Joseph Myers 4ba7a00fe3 Fix __ieee754_logl (-LDBL_MAX) in FE_DOWNWARD mode (bug 17022).
This patch fixes __ieee754_logl (-LDBL_MAX) on x86_64 and x86 not to
subtract 1 from its argument and so cause spurious overflow in
FE_DOWNWARD mode.  (For any argument strictly less than -1, it doesn't
matter whether or not 1 is subtracted before computing log1p, as long
as the result doesn't overflow to -Inf.)

Tested x86_64 and x86.  (This particular case lacks test coverage,
since the testsuite doesn't cover -lieee, but it will be covered by
tests after the following patch to test pow in all rounding modes,
which was the context in which this bug was found.)

	[BZ #17022]
	* sysdeps/i386/fpu/e_logl.S (__ieee754_logl): Do not subtract 1
	from arguments -2 or below.
	* sysdeps/i386/i686/fpu/e_logl.S (__ieee754_logl): Likewise.
	* sysdeps/x86_64/fpu/e_logl.S (__ieee754_logl): Likewise.
2014-06-18 12:32:01 +00:00
Andreas Schwab b3a9f56ba5 Don't read past end of pattern in fnmatch (BZ #17062) 2014-06-18 14:20:02 +02:00
Rajalakshmi Srinivasaraghavan 754c5a08aa PowerPC: Fix nearbyintl failure for few inputs
This patch fixes few failures in nearbyintl() where the fraction part is
close to 0.5.i  The new tests added report few extra failures in
nearbyint_downward and nearbyint_towardzero which is a known issue.

Fixes #17031.
2014-06-17 08:46:25 -05:00
Joseph Myers 91c03c5389 Add CFI to x86 ceil / floor / trunc (bug 16681).
This patch adds CFI to the sysdeps/i386/fpu/ implementations of ceil,
floor and trunc functions, for consistency with other x86 .S files in
glibc which have CFI for stack adjustments.

Tested x86.

	[BZ #16681]
	* sysdeps/i386/fpu/s_ceil.S (__ceil): Add CFI.
	* sysdeps/i386/fpu/s_ceilf.S (__ceilf): Likewise.
	* sysdeps/i386/fpu/s_ceill.S (__ceill): Likewise.
	* sysdeps/i386/fpu/s_floor.S (__floor): Likewise.
	* sysdeps/i386/fpu/s_floorf.S (__floorf): Likewise.
	* sysdeps/i386/fpu/s_floorl.S (__floorl): Likewise.
	* sysdeps/i386/fpu/s_trunc.S (__trunc): Likewise.
	* sysdeps/i386/fpu/s_truncf.S (__truncf): Likewise.
	* sysdeps/i386/fpu/s_truncl.S (__truncl): Likewise.
2014-06-16 22:54:46 +00:00
Florian Weimer a729111732 Fix tautological comparison in non-executed part of tst-setuid2 (BZ #17058)
This part never runs with the current implementation
because the setresuid call currently aborts (as intended).
2014-06-16 18:00:09 +02:00
Meador Inge 995a46bbfb get_nprocs: Only return explictly set cache values (BZ #16996)
The implementation of __get_nprocs uses a stactic variable to cache
the value of the current number of processors.  The caching breaks when
'time (NULL) == 0':

  $ cat nproc.c
  #include <stdio.h>
  #include <time.h>
  #include <sys/time.h>

  int main(int argc, char *argv[])
  {
    time_t t;
    struct timeval tv = {0, 0};
    printf("settimeofday({0, 0}, NULL) = %d\n", settimeofday(&tv, NULL));
    t = time(NULL);
    printf("Time: %d, CPUs: %d\n", (unsigned int)t, get_nprocs());
    return 0;
  }
  $ gcc -O3 nproc.c
  $ ./a.out
  settimeofday({0, 0}, NULL) = -1
  Time: 1401311578, CPUs: 4
  $ sudo ./a.out
  settimeofday({0, 0}, NULL) = 0
  Time: 0, CPUs: 0

The problem is with the condition used to check whether a cached
value should be returned or not:

  static int cached_result;
  static time_t timestamp;

  time_t now = time (NULL);
  time_t prev = timestamp;
  atomic_read_barrier ();
  if (now == prev)
    return cached_result;

This patch fixes the problem by ensuring that 'cached_result' has
been set at least once before returning it.
2014-06-13 14:02:04 +05:30
Florian Weimer 89e435f355 posix_spawn_file_actions_addopen needs to copy the path argument (BZ 17048)
POSIX requires that we make a copy, so we allocate a new string
and free it in posix_spawn_file_actions_destroy.

Reported by David Reid, Alex Gaynor, and Glyph Lefkowitz.  This bug
may have security implications.
2014-06-11 23:13:42 +02:00
Joseph Myers f8ba1b5654 Fix log2 (1) in round-downward mode (bug 17042).
As with other issues of this kind, bug 17042 is log2 (1) wrongly
returning -0 instead of +0 in round-downward mode because of
implementations effectively in terms of log1p (x - 1).  This patch
fixes the issue in the same way used for log and log10.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 to confirm a fix was needed for ldbl-128 and to validate that
fix (also applied to ldbl-128ibm since that version of log2l is
essentially the same as the ldbl-128 one).

	[BZ #17042]
	* sysdeps/i386/fpu/e_log2.S (__ieee754_log2): Take absolete value
	when x - 1 is zero.
	* sysdeps/i386/fpu/e_log2f.S (__ieee754_log2f): Likewise.
	* sysdeps/i386/fpu/e_log2l.S (__ieee754_log2l): Likewise.
	* sysdeps/ieee754/ldbl-128/e_log2l.c (__ieee754_log2l): Return
	0.0L for an argument of 1.0L.
	* sysdeps/ieee754/ldbl-128ibm/e_log2l.c (__ieee754_log2l):
	Likewise.
	* sysdeps/x86_64/fpu/e_log2l.S (__ieee754_log2l): Take absolute
	value when x - 1 is zero.
	* math/libm-test.inc (log2_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-06-10 12:07:15 +00:00
Ondřej Bílka d89b3d80f9 Fix memory overrun in getifaddrs_internal. Fixes bug 15698. 2014-06-05 19:25:23 +02:00
Andreas Schwab bd1b9d956b Install uz_UZ.UTF-8 locale (BZ #16095) 2014-06-05 15:12:16 +02:00
David S. Miller 902b71f9af Fixup ChangeLog and add missing NEWS entry for previous commits. 2014-06-03 16:14:06 -07:00
Andreas Schwab f9d2d03254 Fix invalid file descriptor reuse while sending DNS query (BZ #15946) 2014-06-03 18:03:39 +02:00
Wilco c95b301101 [AArch64] Rewrite feupdateenv (BZ 17009). 2014-06-02 12:36:34 +01:00
Eric Wong 26b0d2e1a1 Avoid stat/fstat in statvfs/fstatvfs (BZ #15132)
Delay the use of stat/fstat until stat data is required.  When the
kernel returns ST_VALID, stat data is not used by __internal_statvfs.
2014-05-29 09:41:29 +05:30
Will Newton 36ffe7398a ARM: Fix handling of concurrent TLS descriptor resolution
The current code for handling concurrent resolution says that the
ABI for _dl_tlsdesc_resolve_hold is the same as that of
_dl_tlsdesc_lazy_resolver. However _dl_tlsdesc_resolve_hold is
called from the trampoline directly rather than the lazy resolver
stub so, for example, r2 has not been pushed so does not needed
to be restored.

This fixes an intermittent failure in nptl/tst-tls3 when building
glibc for arm-linux-gnueabihf with -mtls-dialect=gnu2.

ChangeLog:

2014-05-27  Will Newton  <will.newton@linaro.org>

	[BZ #16990]
	* sysdeps/arm/dl-tlsdesc.S (_dl_tlsdesc_resolve_hold): Save
	and restore r2 rather than just restoring.
2014-05-27 10:39:18 +01:00
Siddhesh Poyarekar 2482ae433a Fix offset computation for append+ mode on switching from read (BZ #16724)
The offset computation in write mode uses the fact that _IO_read_end
is kept in sync with the external file offset.  This however is not
true when O_APPEND is in effect since switching to write mode ought to
send the external file offset to the end of file without making the
necessary adjustment to _IO_read_end.

Hence in append mode, offset computation when writing should only
consider the effect of unflushed writes, i.e. from _IO_write_base to
_IO_write_ptr.

The wiki has a detailed document that describes the rationale for
offsets returned by ftell in various conditions:

https://sourceware.org/glibc/wiki/File%20offsets%20in%20a%20stdio%20stream%20and%20ftell
2014-05-27 13:54:19 +05:30
Andreas Schwab b60ea6fff5 Fix searching localedef input on I18NPATH (BZ #16984) 2014-05-26 12:32:57 +02:00
Kyle McMartin 75f11331f9 [AARCH64] correct alignment of TLS_TCB_ALIGN (BZ #16796)
This fixes a variety of testsuite failures for me:
tststatic.out Error 1
tststatic2.out Error 1
tst-tls9-static.out Error 1
tst-audit8.out Error 127
tst-audit9.out Error 127
tst-audit1.out Error 127
and also has the added benefit of making LD_AUDIT/sotruss work on
AArch64.

Otherwise, we bail out early in _dl_try_allocate_static_tls as the
alignment requirement of the PT_TLS section in libc is 16.
2014-05-26 12:37:19 +05:30
Siddhesh Poyarekar c3ec475c5d Use NSS_STATUS_TRYAGAIN to indicate insufficient buffer (BZ #16878)
The netgroups nss modules in the glibc tree use NSS_STATUS_UNAVAIL
(with errno as ERANGE) when the supplied buffer does not have
sufficient space for the result.  This is wrong, because the canonical
way to indicate insufficient buffer is to set the errno to ERANGE and
the status to NSS_STATUS_TRYAGAIN, as is used by all other modules.

This fixes nscd behaviour when the nss_ldap module returns
NSS_STATUS_TRYAGAIN to indicate that a netgroup entry is too long to
fit into the supplied buffer.
2014-05-26 11:40:08 +05:30
Joseph Myers e59252a58e Define TSVTX in tar.h for older POSIX (bug 16978).
As noted in bug 16978, older POSIX versions include

in the specified contents of <tar.h>, with only the 2001 edition
introducing the notion of XSI-conditional definitions and conditioning
that definition.  Thus, this macro should be defined for
!__USE_XOPEN2K as well as for __USE_XOPEN, and this patch duly defines
it in that case.  Tested x86_64.

	[BZ #16978]
	* posix/tar.h [!__USE_XOPEN2K] (TSVTX): Define macro.
	* conform/Makefile (test-xfail-POSIX/tar.h/conform): Remove
	variable.
2014-05-23 20:37:40 +00:00
Joseph Myers b72592e75f Fix log10 (1) in round-downward mode (bug 16977).
As with various other issues of this kind, bug 16977 is log10 (1)
wrongly returning -0 rather than +0 in round-downward mode because of
an implementation effectively in terms of log1p (x - 1).  This patch
fixes the issue in the same way used for log.

Tested x86_64 and x86 and ulps updated accordingly.  Also tested for
mips64 to confirm a fix was needed for ldbl-128 and to validate that
fix (also applied to ldbl-128ibm since that version of logl is
essentially the same as the ldbl-128 one).

	[BZ #16977]
	* sysdeps/i386/fpu/e_log10.S (__ieee754_log10): Take absolute
	value when x - 1 is zero.
	* sysdeps/i386/fpu/e_log10f.S (__ieee754_log10f): Likewise.
	* sysdeps/i386/fpu/e_log10l.S (__ieee754_log10l): Likewise.
	* sysdeps/ieee754/ldbl-128/e_log10l.c (__ieee754_log10l): Return
	0.0L for an argument of 1.0L.
	* sysdeps/ieee754/ldbl-128ibm/e_log10l.c (__ieee754_log10l):
	Likewise.
	* sysdeps/x86_64/fpu/e_log10l.S (__ieee754_log10l): Take absolute
	value when x - 1 is zero.
	* math/libm-test.inc (log10_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-05-23 12:07:50 +00:00
Aurelien Jarno 4406c41c1d Fix strtold on 32-bit sparc (and probably others) (BZ #16965)
This patch fixes an issue observed running the tst-strtod-round test on
32 bit sparc. In some conditions, strtold calls round_and_return, which in
turn calls __mpn_rshift with cnt = 0, while stdlib/rshift.c explicitly says
that cnts should satisfy 0 < CNT < BITS_PER_MP_LIMB. In this case, the code
end up doing a logical shift right of the same amount than the register,
which is undefined in the C standard.

Due to this bug, 32-bit sparc does not correctly convert the value
"0x1p-16446", but it is likely that other architectures are also
affected for other input values.
2014-05-20 18:44:28 +02:00
Aurelien Jarno ae75a883f2 fix nl_langinfo with static linking (BZ #16915)
For static linking the locale code avoids linking code and data for
unused categories. However for nl_langinfo we know only at runtime which
categories are used, so direct reference to every nl_current_CATEGORY
symbol should be done.

This was broken by commit bc3e1c1273 where
nl_langinfo_l and nl_langinfo have been merged and some code has been
lost in the process.

In order to detect locales issues with static linking, compile a version
of tst-langinfo with static linking.

Note: this is Debian bug#747103 reported by Raphael <raphael.astier@eliot-sa.com>
2014-05-20 18:43:14 +02:00
Richard Henderson de9d8f2098 alpha: fix sa_flags type (BZ 16967) 2014-05-20 07:17:27 -07:00
Richard Henderson 4c0a1e6392 alpha: Remove bits/siginfo.h (BZ 16966)
Using the default header instead.  This matches the kernel, which also
uses the generic header.  Fixes the sys/wait.h conform issue, where
si_band had the wrong type.
2014-05-20 07:17:24 -07:00
Jose E. Marchesi 834caf06f3 Fix sparc memcpy data corruption when using niagara2 optimized routines.
* sysdeps/sparc/sparc64/multiarch/memcpy-niagara2.S: Add missing
	membar to avoid block loads/stores to overlap previous stores.
2014-05-17 14:09:55 -07:00
Aurelien Jarno d16e6ec7ca SPARC: add prlimit and prlimit64 in <bits/resource.h> (BZ #16943)
prlimit and prlimit64 have been added in the main <bits/resource.h>, but
not in the SPARC specific version. Fix that.

Note: this is Debian bug#703559, reported by Emilio Pozuelo Monfort
<pochu@debian.org>
2014-05-16 00:07:32 +02:00
Aurelien Jarno d0583c4039 ptsname_r: don't leak uninitialized memory (BZ #16917)
If the fd refers to a terminal device, but not a pty master, the
TIOCGPTN ioctl returns with ENOTTY. This error is not caught, and the
possibly undefined buffer passed to ptsname_r is sent directly to the
stat64 syscall.

Fix this by using a fallback to the old method only if the TIOCGPTN
ioctl fails with EINVAL. This also fix the return value in that specific
case (it return ENOENT without this patch).

Also add tests to the ptsname_r function (and ptsname at the same time).

Note: this is Debian bug#741482, reported by Jakub Wilk <jwilk@debian.org>
2014-05-16 00:07:29 +02:00
Siddhesh Poyarekar cf26a0cb6a Return EAI_AGAIN for AF_UNSPEC when herrno is TRY_AGAIN (BZ #16849)
getaddrinfo correctly returns EAI_AGAIN for AF_INET and AF_INET6
queries.  For AF_UNSPEC however, an older change
(a682a1bf55) broke the check and due to
that the returned error was EAI_NONAME.

This patch fixes the check so that a non-authoritative not-found is
returned as EAI_AGAIN to the user instead of EAI_NONAME.
2014-05-15 12:33:11 +05:30
Joseph Myers 1a84c3d6d4 Fix log1pl (LDBL_MAX) in FE_UPWARD mode (bug 16564).
Bug 16564 is spurious overflow of log1pl (LDBL_MAX) in FE_UPWARD mode,
resulting from log1pl adding 1 to its argument (for arguments not
close to 0), which overflows in that mode.  This patch fixes this by
avoiding adding 1 to large arguments (precisely what counts as large
depends on the floating-point format).

Tested x86_64 and x86, and spot-checked log1pl tests on mips64 and
powerpc64.

	[BZ #16564]
	* sysdeps/i386/fpu/s_log1pl.S (__log1pl): Do not add 1 to positive
	arguments with exponent 65 or above.
	* sysdeps/ieee754/ldbl-128/s_log1pl.c (__log1pl): Do not add 1 to
	arguments 0x1p113L or above.
	* sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Do not add 1
	to arguments 0x1p107L or above.
	* sysdeps/x86_64/fpu/s_log1pl.S (__log1pl): Do not add 1 to
	positive arguments with exponent 65 or above.
	* math/auto-libm-test-in: Add more tests of log1p.
	* math/auto-libm-test-out: Regenerated.
2014-05-14 12:38:56 +00:00
Joseph Myers 01dbacd22a Fix cacos (+Inf + finite*i) in round-downward mode (bug 16928).
According to C99/C11 Annex G, cacos applied to a value with real part
+Inf and finite imaginary part should produce a result with real part
+0.  glibc wrongly produces a result with real part -0 in FE_DOWNWARD
mode.  This patch fixes this by checking for zero results in the
relevant case of non-finite arguments (where there should never be a
result with -0 real part), and converts the tests of cacos to
ALL_RM_TEST.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16928]
	* math/s_cacos.c (__cacos): Ensure zero real part of result from
	non-finite arguments is +0.
	* math/s_cacosf.c (__cacosf): Likewise.
	* math/s_cacosl.c (__cacosl): Likewise.
	* math/libm-test.inc (cacos_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-05-14 12:37:24 +00:00
Joseph Myers 913d03c864 Fix acosh (1) in round-downward mode (bug 16927).
According to C99 and C11 Annex F, acosh (1) should be +0 in all
rounding modes.  However, some implementations in glibc wrongly return
-0 in round-downward mode (which is what you get if you end up
computing log1p (-0), via 1 - 1 being -0 in round-downward mode).
This patch fixes the problem implementations, by correcting the test
for an exact 1 value in the ldbl-96 implementation to allow for the
explicit high bit of the mantissa, and by inserting fabs instructions
in the i386 implementations; tests of acosh are duly converted to
ALL_RM_TEST.  I believe all the other sysdeps/ieee754 implementations
are already OK (I haven't checked the ia64 versions, but if buggy then
that will be obvious from the results of test runs after this patch is
in).

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16927]
	* sysdeps/i386/fpu/e_acosh.S (__ieee754_acosh): Use fabs on x-1
	value.
	* sysdeps/i386/fpu/e_acoshf.S (__ieee754_acoshf): Likewise.
	* sysdeps/i386/fpu/e_acoshl.S (__ieee754_acoshl): Likewise.
	* sysdeps/ieee754/ldbl-96/e_acoshl.c (__ieee754_acoshl): Correct
	for explicit high bit of mantissa when testing for argument equal
	to 1.
	* math/libm-test.inc (acosh_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-05-14 12:35:40 +00:00
Joseph Myers 0bf061d3e3 Fix erf underflow handling near 0 (bug 16516).
Bug 16516 reports spurious underflows from erf (for all floating-point
types), when the result is close to underflowing but does not actually
underflow.

erf (x) is about (2/sqrt(pi))*x for x close to 0, so there are
subnormal arguments for which it does not underflow.  The various
implementations do (x + efx*x) (for efx = 2/sqrt(pi) - 1), for greater
accuracy than if just using a single multiplication by an
approximation to 2/sqrt(pi) (effectively, this way there are a few
more bits in the approximation to 2/sqrt(pi)).  This can introduce
underflows when efx*x underflows even though the final result does
not, so a scaled calculation with 8*efx is done in these cases - but 8
is not a big enough scale factor to avoid all such underflows.  16 is
(any underflows with a scale factor of 16 would only occur when the
final result underflows), so this patch changes the code to use that
factor.  Rather than recomputing all the values of the efx8 variable,
it is removed, leaving it to the compiler's constant folding to
compute 16*efx.  As such scaling can also lose underflows when the
final scaling down happens to be exact, appropriate checks are added
to ensure underflow exceptions occur when required in such cases.

Tested x86_64 and x86; no ulps updates needed.  Also spot-checked for
powerpc32 and mips64 to verify the changes to the ldbl-128ibm and
ldbl-128 implementations.

	[BZ #16516]
	* sysdeps/ieee754/dbl-64/s_erf.c (efx8): Remove variable.
	(__erf): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/flt-32/s_erff.c (efx8): Remove variable.
	(__erff): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/ldbl-128/s_erfl.c: Include <float.h>.
	(efx8): Remove variable.
	(__erfl): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/ldbl-128ibm/s_erfl.c: Include <float.h>.
	(efx8): Remove variable.
	(__erfl): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* sysdeps/ieee754/ldbl-96/s_erfl.c: Include <float.h>.
	(efx8): Remove variable.
	(__erfl): Scale by 16 instead of 8 in potentially underflowing
	case.  Ensure exception if result actually underflows.
	* math/auto-libm-test-in: Add more tests of erf.
	* math/auto-libm-test-out: Regenerated.
2014-05-14 12:34:03 +00:00
Andreas Schwab 315eb1d86a Fix unbound stack use in NIS NSS module 2014-05-12 15:17:51 +02:00
Joseph Myers 77d08acaad Include SSE state in i386 fenv_t (bug 16064).
This patch fixes bug 16064, i386 fenv_t not including SSE state, using
the technique suggested there of storing the state in the existing
__eip field of fenv_t to avoid needing to increase the size of fenv_t
and add new symbol versions.  The included testcase, which previously
failed for i386 (but passed for x86_64), illustrates how the previous
state was buggy.

This patch causes the SSE state to be included *to the extent it is on
x86_64*.  Where some state should logically be included but isn't for
x86_64 (see bug 16068), this patch does not cause it to be included
for i386 either.  The idea is that any patch fixing that bug should
fix it for both x86_64 and i386 at once.

Tested i386 and x86_64.  (I haven't tested the case of a CPU without
SSE2 disabling the test.)

	[BZ #16064]
	* sysdeps/i386/fpu/fegetenv.c: Include <unistd.h>, <ldsodefs.h>
	and <dl-procinfo.h>.
	(__fegetenv): Save SSE state in envp->__eip if supported.
	* sysdeps/i386/fpu/feholdexcpt.c (feholdexcept): Save SSE state in
	envp->__eip if supported.
	* sysdeps/i386/fpu/fesetenv.c: Include <unistd.h>, <ldsodefs.h>
	and <dl-procinfo.h>.
	(__fesetenv): Always set __eip, __cs_selector, __opcode,
	__data_offset and __data_selector in environment to 0.  Set SSE
	state if supported.
	* sysdeps/x86/fpu/Makefile [$(subdir) = math] (tests): Add
	test-fenv-sse.
	[$(subdir) = math] (CFLAGS-test-fenv-sse.c): Add -msse2
	-mfpmath=sse.
	* sysdeps/x86/fpu/test-fenv-sse.c: New file.
2014-05-09 16:59:56 +00:00
Dominik Vogt 5a414ff70c S/390: Port of lock elision to System/z
Added support for TX lock elision of pthread mutexes on s390 and
s390x.  This may improve lock scaling of existing programs on TX
capable systems.  The lock elision code is only built with
--enable-lock-elision=yes and then requires a GCC version supporting
the TX builtins.  With lock elision default mutexes are elided via
__builtin_tbegin, if the cpu supports transactions. By default lock
elision is not enabled and the elision code is not built.
2014-05-09 16:58:46 +02:00
Will Newton f63c86fed0 ARM: Add optimized ARMv7 strcmp implementation
Add an optimized implementation of strcmp for ARMv7-A cores. This
implementation is significantly faster than the current generic C
implementation, particularly for strings of 16 bytes and longer.

Tested with the glibc string tests for arm-linux-gnueabihf and
armeb-linux-gnueabihf.

The code was written by ARM, who have agreed to assign the copyright
to the FSF for integration into glibc.

ChangeLog:

2014-05-09  Will Newton  <will.newton@linaro.org>

	* sysdeps/arm/armv7/strcmp.S: New file.
	* NEWS: Mention addition of ARMv7 optimized strcmp.
2014-05-09 10:01:28 +01:00
Steve Ellcey e393b1d7ed Add 16922 to list of bugs fixed. 2014-05-07 13:15:52 -07:00
Ondřej Bílka a11892631d Fix typo in nscd/selinux.c 2014-05-07 14:09:24 +02:00
Ondřej Bílka ce0c5b8f36 Fix typo in nptl/sockperf.c 2014-05-07 14:00:01 +02:00
Aurelien Jarno 83df9ad0cc SPARC: add EFD_SEMAPHORE in <bits/eventfd.h> (BZ #16916)
EFD_SEMAPHORE has been added in the main <bits/eventfd.h>, but not in
the SPARC specific version. Fix that.
2014-05-07 00:00:56 +02:00
Andreas Schwab 978a41c357 Don't use catomic functions in mcount (BZ #16912)
mcount cannot use catomic functions since it is called by
__libc_start_main before TLS is set up.  This reverts the change made by
commit 8099361.
2014-05-06 16:30:48 +02:00
David S. Miller bf895cb9c3 NEWS: Add 16885 to fixed bug list. 2014-05-01 16:36:33 -04:00
Andreas Schwab 4fdfe821e2 Correctly handle %p in wprintf (BZ #16890) 2014-05-01 20:42:08 +02:00
Will Newton 7470db0c8e NEWS: Add 15119 to fixed bug list 2014-05-01 16:26:35 +01:00
Julian Brown 60c8f1f60b ARM: Fix R_ARM_IRELATIVE RELA relocations.
This patch fixes what I believe to be a bug in the handling of
R_ARM_IRELATIVE RELA relocations. At present, these are handled the
same as REL relocations: i.e. the addend is loaded from the relocation
address. Most of the time this isn't a problem because RELA relocations
aren't used on ARM (GNU/Linux at least) anyway, but it causes problems
with prelink, which uses RELA on all targets for its conflict table.
(Support for ifunc prelinking requires a prelink patch, not yet posted.)

Anyway, this patch works, though I'm not 100% sure if it is correct: I
notice that this code path received attention last year:

https://sourceware.org/ml/libc-ports/2013-07/msg00000.html

I'm not sure under what circumstances that patch would have had an
effect, nor if my patch conflicts with that case.

No regressions using Mentor's usual glibc cross-testing infrastructure.

	[BZ #16888]
	* sysdeps/arm/dl-machine.h (elf_machine_rela): Fix R_ARM_IRELATIVE
	handling.
2014-04-30 16:17:59 +00:00
Joseph Myers d0f5b3f851 Increase minimum Linux kernel version to 2.6.32.
This patch increases the minimum Linux kernel version for glibc to
2.6.32, as discussed in the thread starting at
<https://sourceware.org/ml/libc-alpha/2014-01/msg00511.html>.

This patch just does the minimal change to arch_minimum_kernel
settings (and LIBC_LINUX_VERSION, which determines the minimum kernel
headers version, as it doesn't make sense for that to be older than
the minimum kernel that can be used at runtime).  Followups would be
expected to do, roughly and not necessarily precisely in this order:

* Remove __LINUX_KERNEL_VERSION checks in kernel-features.h files
  where those checks are always true / always false for kernels 2.6.32
  and above.

* Otherwise simplify/improve conditionals in those files (for example,
  where defining once in the main file then undefining in
  architecture-specific files makes things clearer than having lots of
  separate definitions of the same macro), possibly fixing in the
  process cases where a macro should optimally have been defined for a
  given architecture but wasn't.  (In the review in preparation for
  this version increase I checked what the right conditions should be
  for all macros in the main kernel-features.h whose definitions there
  would have been affected by the increase - but I only fixed that
  subset of the issues found where --enable-kernel=2.6.32 would have
  caused a kernel feature to be wrongly assumed to be present, not any
  cases where a feature is not assumed but could be assumed.)

* Remove conditionals on __ASSUME_* where they can now be taken to be
  always-true, and the definitions when the macros are only used in
  Linux-specific files.

* Split more architectures out of the main kernel-features.h (like
  ex-ports architectures), once various of the architecture
  conditionals there have been eliminated so the new
  architecture-specific files are no larger than actually necessary.

Tested x86_64.

2014-03-27  Joseph Myers  <joseph@codesourcery.com>

	[BZ #9894]
	* sysdeps/unix/sysv/linux/configure.ac (LIBC_LINUX_VERSION):
	Change to 2.6.32.
	(arch_minimum_kernel): Change all 2.6.16 settings to 2.6.32.
	* sysdeps/unix/sysv/linux/configure: Regenerated.
	* sysdeps/unix/sysv/linux/microblaze/configure.ac: Remove file.
	* sysdeps/unix/sysv/linux/microblaze/configure: Likewise.
	* sysdeps/unix/sysv/linux/tile/configure.ac: Likewise.
	* sysdeps/unix/sysv/linux/tile/configure: Likewise.
	* README: Update reference to required Linux kernel version.
	* manual/install.texi (Linux): Update reference to required Linux
	kernel headers version.
	* INSTALL: Regenerated.
2014-04-30 15:41:03 +00:00
Siddhesh Poyarekar bc8f194c8c Initialize all of datahead structure in nscd (BZ #16791)
The datahead structure has an unused padding field that remains
uninitialized.  Valgrind prints out a warning for it on querying a
netgroups entry.  This is harmless, but is a potential data leak since
it would result in writing out an uninitialized byte to the cache
file.  Besides, this happens only when there is a cache miss, so we're
not adding computation to any fast path.
2014-04-30 12:00:39 +05:30
Siddhesh Poyarekar 16b293a7a6 Do not fail if one of the two responses to AF_UNSPEC fails (BZ #14308)
[Fixes BZ #14308, #12994, #13651]

AF_UNSPEC results in sending two queries in parallel, one for the A
record and the other for the AAAA record.  If one of these is a
referral, then the query fails, which is wrong.  It should return at
least the one successful response.

The fix has two parts.  The first part makes the referral fall back to
the SERVFAIL path, which results in using the successful response.
There is a bug in that path however, due to which the second part is
necessary.  The bug here is that if the first response is a failure
and the second succeeds, __libc_res_nsearch does not detect that and
assumes a failure.  The case where the first response is a success and
the second fails, works correctly.

This condition is produced by buggy routers, so here's a crude
interposable library that can simulate such a condition.  The library
overrides the recvfrom syscall and modifies the header of the packet
received to reproduce this scenario.  It has two key variables:
mod_packet and first_error.

The mod_packet variable when set to 0, results in odd packets being
modified to be a referral.  When set to 1, even packets are modified
to be a referral.

The first_error causes the first response to be a failure so that a
domain-appended search is performed to test the second part of the
__libc_nsearch fix.

The driver for this fix is a simple getaddrinfo program that does an
AF_UNSPEC query.  I have omitted this since it should be easy to
implement.

I have tested this on x86_64.

The interceptor library source:

/* Override recvfrom and modify the header of the first DNS response to make it
   a referral and reproduce bz #845218.  We have to resort to this ugly hack
   because we cannot make bind return the buggy response of a referral for the
   AAAA record and an authoritative response for the A record.  */
 #define _GNU_SOURCE
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <stdio.h>
 #include <stdbool.h>
 #include <endian.h>
 #include <dlfcn.h>
 #include <stdlib.h>

/* Lifted from resolv/arpa/nameser_compat.h.  */
typedef struct {
    unsigned        id :16;         /*%< query identification number */
 #if BYTE_ORDER == BIG_ENDIAN
    /* fields in third byte */
    unsigned        qr: 1;          /*%< response flag */
    unsigned        opcode: 4;      /*%< purpose of message */
    unsigned        aa: 1;          /*%< authoritive answer */
    unsigned        tc: 1;          /*%< truncated message */
    unsigned        rd: 1;          /*%< recursion desired */
    /* fields
     * in
     * fourth
     * byte
     * */
    unsigned        ra: 1;          /*%< recursion available */
    unsigned        unused :1;      /*%< unused bits (MBZ as of 4.9.3a3) */
    unsigned        ad: 1;          /*%< authentic data from named */
    unsigned        cd: 1;          /*%< checking disabled by resolver */
    unsigned        rcode :4;       /*%< response code */
 #endif
 #if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
    /* fields
     * in
     * third
     * byte
     * */
    unsigned        rd :1;          /*%< recursion desired */
    unsigned        tc :1;          /*%< truncated message */
    unsigned        aa :1;          /*%< authoritive answer */
    unsigned        opcode :4;      /*%< purpose of message */
    unsigned        qr :1;          /*%< response flag */
    /* fields
     * in
     * fourth
     * byte
     * */
    unsigned        rcode :4;       /*%< response code */
    unsigned        cd: 1;          /*%< checking disabled by resolver */
    unsigned        ad: 1;          /*%< authentic data from named */
    unsigned        unused :1;      /*%< unused bits (MBZ as of 4.9.3a3) */
    unsigned        ra :1;          /*%< recursion available */
 #endif
    /* remaining
     * bytes
     * */
    unsigned        qdcount :16;    /*%< number of question entries */
    unsigned        ancount :16;    /*%< number of answer entries */
    unsigned        nscount :16;    /*%< number of authority entries */
    unsigned        arcount :16;    /*%< number of resource entries */
} HEADER;

static int done = 0;

/* Packets to modify.  0 for the odd packets and 1 for even packets.  */
static const int mod_packet = 0;

/* Set to true if the first request should result in an error, resulting in a
   search query.  */
static bool first_error = true;

static ssize_t (*real_recvfrom) (int sockfd, void *buf, size_t len, int flags,
			  struct sockaddr *src_addr, socklen_t *addrlen);

void
__attribute__ ((constructor))
init (void)
{
  real_recvfrom = dlsym (RTLD_NEXT, "recvfrom");

  if (real_recvfrom == NULL)
    {
      printf ("Failed to get reference to recvfrom: %s\n", dlerror ());
      printf ("Cannot simulate test\n");
      abort ();
    }
}

/* Modify the second packet that we receive to set the header in a manner as to
   reproduce BZ #845218.  */
static void
mod_buf (HEADER *h, int port)
{
  if (done % 2 == mod_packet || (first_error && done == 1))
    {
      printf ("(Modifying header)");

      if (first_error && done == 1)
	h->rcode = 3;
      else
	h->rcode = 0;	/* NOERROR == 0.  */
      h->ancount = 0;
      h->aa = 0;
      h->ra = 0;
      h->arcount = 0;
    }
  done++;
}

ssize_t
recvfrom (int sockfd, void *buf, size_t len, int flags,
	  struct sockaddr *src_addr, socklen_t *addrlen)
{
  ssize_t ret = real_recvfrom (sockfd, buf, len, flags, src_addr, addrlen);
  int port = htons (((struct sockaddr_in *) src_addr)->sin_port);
  struct in_addr addr = ((struct sockaddr_in *) src_addr)->sin_addr;
  const char *host = inet_ntoa (addr);
  printf ("\n*** From %s:%d: ", host, port);

  mod_buf (buf, port);

  printf ("returned %zd\n", ret);
  return ret;
}
2014-04-30 11:48:43 +05:30
Stefan Liebler b6bfc58131 Mention BZ16823 in NEWS 2014-04-29 15:45:11 +02:00
Ondřej Bílka fff763a512 Fix types of stream hook functions in manual. 2014-04-28 18:54:24 +02:00
Ondřej Bílka f7ed60c252 Fix recvmmsg comment. 2014-04-28 18:16:07 +02:00
Will Newton 37d3500738 aarch64: Re-implement setcontext without rt_sigreturn syscall
The current implementation of setcontext uses rt_sigreturn to restore
the contents of registers. This contrasts with the way most other
architectures implement setcontext:

  powerpc64, mips, tile:

  Call rt_sigreturn if context was created by a call to a signal handler,
  otherwise restore in user code.

  powerpc32:

  Call swapcontext system call and don't call sigreturn or rt_sigreturn.

  x86_64, sparc, hppa, sh, ia64, m68k, s390, arm:

  Only support restoring "synchronous" contexts, that is contexts
  created by getcontext, and restoring in user code and don't call
  sigreturn or rt_sigreturn.

  alpha:

  Call sigreturn (but not rt_sigreturn) in all cases to do the restore.

The text of the setcontext manpage suggests that the requirement to be
able to restore a signal handler created context has been dropped from
SUSv2:

  If  the context was obtained by a call to a signal handler, then old
  standard text says that "program execution continues with the program
  instruction following the instruction interrupted by the signal".
  However, this sentence was removed in SUSv2, and the present verdict
  is "the result is unspecified".

Implementing setcontext by calling rt_sigreturn unconditionally causes
problems when used with sigaltstack as in BZ #16629. On this basis it
seems that aarch64 is broken and that new ports should only support
restoring contexts created with getcontext and do not need to call
rt_sigreturn at all.

This patch re-implements the aarch64 setcontext function to restore
the context in user code in a similar manner to x86_64 and other ports.

ChangeLog:

2014-04-17  Will Newton  <will.newton@linaro.org>

	[BZ #16629]
	* sysdeps/unix/sysv/linux/aarch64/setcontext.S (__setcontext):
	Re-implement to restore registers in user code and avoid
	rt_sigreturn system call.
2014-04-17 11:38:50 +01:00
Stefan Liebler 4fa8bc3b35 [BZ #14770] S/390: Require Binutils >= 2.24 for target S/390. 2014-04-16 13:04:33 +02:00
Stefan Liebler 8ea587db2b [BZ #16824] Fix failing y1 due to too large ulps in downward/upward rounding mode. 2014-04-16 13:03:46 +02:00
Alan Modra 9860b04502 Update fixed bug list 2014-04-16 19:47:02 +09:30
Carlos O'Donell f737dfd071 Support _r_debug for static binaries.
We initialize _r_debug for static binaries to allows debug
agents to treat static binaries a little more like dyanmic
ones. This simplifies the work a debug agent has to do to
access TLS in a static binary via libthread_db.

Tested on x86_64.

See:
https://sourceware.org/ml/libc-alpha/2014-04/msg00183.html

	[BZ #16831]
	* csu/libc-start.c (LIBC_START_MAIN) [!SHARED]: Call
	_dl_debug_initialize.
2014-04-14 15:45:40 -04:00
Allan McRae 89e691f2ae Fix qsort argument order in collation example 2014-04-12 14:26:29 +10:00
Andreas Krebbel ee4ec1d7f9 NEWS: Add comment about changed ABI on s390 and s390x. 2014-04-11 13:08:10 +02:00
Peter TB Brett a88ddc902b Use statvfs64() for pathconf(_PC_NAME_MAX).
pathconf(_PC_NAME_MAX) was implemented on top of statfs().  The 32bit
version therefore fails EOVERFLOW if the filesystem blockcount is
sufficiently large.

Most pathconf() queries use statvfs64(), which avoids this issue.  This
patch modifies pathconf(_PC_NAME_MAX) to do likewise.
2014-04-09 20:09:56 +02:00
Adhemerval Zanella 8bd70862e1 PowerPC: Fix nearbyint/nearbyintf result for FE_DOWNWARD
This patch fixes the powerpc32 optimized nearbyint/nearbyintf bogus
results for FE_DOWNWARD rounding mode.  This is due wrong instructions
sequence used in the rounding calculation (two subtractions instead of
adition and a subtraction).

Fixes BZ#16815.
2014-04-06 14:58:05 -05:00
Joseph Myers a84e78c8b3 Fix catan, catanh, __ieee754_logf in round-downward mode (bug 16799, bug 16800).
This patch fixes incorrect results from catan and catanh of certain
special inputs in round-downward mode (bug 16799), and incorrect
results of __ieee754_logf (+/-0) in round-downward mode (bug 16800)
that show up through catan/catanh when tested in all rounding modes,
but not directly in the testing for logf because the bug gets hidden
by the wrappers.

Both bugs involve a zero that should be +0 being -0 instead: one
computed as (1-x)*(1+x) in the catan/catanh case, and one as (x-x) in
the logf case.  The fixes ensure positive zero is used.  Testing of
catan and catanh in all rounding modes is duly enabled.

I expect there are various other bugs in special cases in __ieee754_*
functions that are normally hidden by the wrappers but would show up
for testing with -lieee (or in future with -fno-math-errno if we
replace -lieee and _LIB_VERSION with compile-time redirection to new
*_noerrno symbol names).

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16799]
	[BZ #16800]
	* math/s_catan.c (__catan): Avoid passing -0 denominator to atan2
	with 0 numerator.
	* math/s_catanf.c (__catanf): Likewise.
	* math/s_catanh.c (__catanh): Likewise.
	* math/s_catanhf.c (__catanhf): Likewise.
	* math/s_catanhl.c (__catanhl): Likewise.
	* math/s_catanl.c (__catanl): Likewise.
	* sysdeps/ieee754/flt-32/e_logf.c (__ieee754_logf): Always divide
	by positive zero when computing -Inf result.
	* math/libm-test.inc (catan_test): Use ALL_RM_TEST.
	(catanh_test): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-04-02 17:41:02 +00:00
Joseph Myers 6f05bafeba Fix clog / clog10 sign of zero result in round-downward mode (bug 16789).
This patch fixes bug 16789, incorrect sign of (real part) zero result
from clog and clog10 in round-downward mode, arising from that real
part being computed as 0 - 0.  To ensure that an underflow exception
occurred, the code used an underflowing value (the next term in the
series for log1p) in arithmetic computing the real part of the result,
yielding the problematic 0 - 0 computation in some cases even when the
mathematical result would be small but positive.  The patch changes
this code to use the math_force_eval approach to ensuring that an
underflowing computation actually occurs.  Tests of clog and clog10
are enabled in all rounding modes.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16789]
	* math/s_clog.c (__clog): Use math_force_eval to ensure underflow
	instead of using underflowing value in computing result.
	* math/s_clog10.c (__clog10): Likewise.
	* math/s_clog10f.c (__clog10f): Likewise.
	* math/s_clog10l.c (__clog10l): Likewise.
	* math/s_clogf.c (__clogf): Likewise.
	* math/s_clogl.c (__clogl): Likewise.
	* math/libm-test.inc (clog_test): Use ALL_RM_TEST.
	(clog10_test): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-04-02 13:10:19 +00:00
Alan Modra b0abbc2103 Correct IBM long double nextafterl.
Fix for values near a power of two, and some tidies.

	[BZ #16739]
	* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl): Correct
	output when value is near a power of two.  Use int64_t for lx and
	remove casts.  Use decimal rather than hex exponent constants.
	Don't use long double multiplication when double will suffice.
	* math/libm-test.inc (nextafter_test_data): Add tests.
	* NEWS: Add 16739 and 16786 to bug list.
2014-04-02 13:46:19 +10:30
Florian Weimer 606d8377ae Update NEWS for fixed bug 13347 2014-04-01 14:20:01 +02:00
Joseph Myers 8795b4a443 Set errno for scalb errors (bug 6803, bug 6804).
This patch fixes the default mode of scalb to set errno (bugs 6803 and
6804).

Previously, the _LIB_VERSION == _SVID_ mode would set errno but only
in some relevant cases, and with various peculiarities (such as errno
setting when an exact infinity or zero result arises with an argument
to scalb being an infinity).  This patch leaves this mode
bug-compatible, while making the default mode set errno in accordance
with normal practice (so an exact infinity from an infinite argument
is not an error, and nor is an exact zero result).  gen-libm-test.pl
is taught new notation such as ERRNO_PLUS_OFLOW to facilitate writing
the tests of errno setting for underflow / overflow in libm-test.inc.

Note that bug 6803 also covers scalbn and scalbln, but this patch only
addresses the scalb parts of that bug (along with the whole of bug
6804).

Tested x86_64 and x86.

	[BZ #6803]
	[BZ #6804]
	* math/w_scalb.c (__scalb): For non-SVID mode, check result and
	set errno as appropriate.
	* math/w_scalbf.c (__scalbf): Likewise.
	* math/w_scalbl.c (__scalbl): Likewise.
	* math/gen-libm-test.pl (parse_args): Handle ERRNO_PLUS_OFLOW,
	ERRNO_MINUS_OFLOW, ERRNO_PLUS_UFLOW and ERRNO_MINUS_UFLOW.
	* math/libm-test.inc (scalb_test_data): Add errno expectations.
	Add more NaN tests.
2014-03-31 14:57:53 +00:00
Joseph Myers 54fa2475d3 Set errno for atan2 underflow (bug 16349).
This patch fixes bug 16349, missing errno setting for atan2 underflow,
by adding appropriate checks to the existing wrappers.  (As in other
cases, the __kernel_standard support for calling matherr is considered
to be for existing code expecting existing rules for what's considered
an error, even if those don't correspond to a general logical scheme
for what counts as what kind of error, so __set_errno calls are added
directly without any changes to __kernel_standard.)

Tested x86_64 and x86.

	[BZ #16349]
	* math/w_atan2.c: Include <errno.h>.
	(__atan2): Set errno for result underflowing to zero.
	* math/w_atan2f.c: Include <errno.h>.
	(__atan2f): Set errno for result underflowing to zero.
	* math/w_atan2l.c: Include <errno.h>.
	(__atan2l): Set errno for result underflowing to zero.
	* math/auto-libm-test-in: Don't allow missing errno for some atan2
	tests.
	* math/auto-libm-test-out: Regenerated.
2014-03-31 14:56:37 +00:00
Joseph Myers d7a68734f7 Fix futimesat for older MicroBlaze kernels (bug 16648).
Continuing the fixes for __ASSUME_* issues in preparation for moving
to a 2.6.32 minimum kernel version, this *untested* patch fixes bug
16648, the definition of __ASSUME_ATFCTS meaning that the futimesat
syscall is assumed for all MicroBlaze kernels despite not being
present until 2.6.33.

__ASSUME_ATFCTS controls conditionals relating to a lot of different
syscalls in Linux-specific code (fstatat64 faccessat fchmodat fchownat
futimesat newfstatat linkat mkdirat openat readlinkat renameat
symlinkat unlinkat mknodat), where whether newfstatat fstatat64
futimesat are used depends on the architecture, as well as controlling
whether openat64_not_cancel_3 is expected to work in
sysdeps/posix/getcwd.c.  The assumptions are all OK as of 2.6.32
except for this MicroBlaze case, and it's generally desirable to get
rid of as many of the __ASSUME_ATFCTS conditionals as possible, to
simplify the code (the fallbacks include potential unbounded dynamic
stack allocations).  Thus, rather than the simplest approach of
undefining __ASSUME_ATFCTS for older kernels on MicroBlaze, this patch
takes the approach of using the linux-generic implementation of
futimesat for MicroBlaze kernels before 2.6.33 (all such kernels have
the utimensat syscall).

	[BZ #16648]
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_FUTIMESAT): Define.
	* sysdeps/unix/sysv/linux/microblaze/futimesat.c: New file.
2014-03-31 12:51:45 +00:00
Joseph Myers ea6029b19c Fix scalb spurious "invalid" exceptions (bug 16770).
This patch fixes bug 16770, spurious "invalid" exceptions from scalb
when testing whether the second argument is an integer, by inserting
appropriate range checks to determine whether a cast to int is safe.
(Note that invalid_fn is a function that handles both nonintegers and
large integers, distinguishing them reliably using functions such as
__rint; note also that there are no issues with scalb needing to avoid
spurious "inexact" exceptions - it's an old-POSIX XSI function, not a
standard C function bound to an IEEE 754 operation - although the
return value is still fully determined.)

Tested x86_64 and x86.

	[BZ #16770]
	* math/e_scalb.c (__ieee754_scalb): Check second argument is not
	too large before casting to int.
	* math/e_scalbf.c (__ieee754_scalbf): Likewise.
	* math/e_scalbl.c (__ieee754_scalbl): Likewise.
	* math/libm-test.inc (scalb_test_data): Add more tests.
2014-03-29 17:22:14 +00:00
Joseph Myers 289e077957 Fix clog10 (-0 +/- 0i) (bug 16362).
This patch fixes the imaginary part of clog10 (-0 +/- 0i), which
should be +/-pi / log(10) by analogy with clog (the functions were
wrongly returning a result with imaginary part +/-pi, same as for
clog, and the tests matched the incorrect result, though both
functions and tests were correct for the similar case of clog10 (-inf
+/- 0i)).  Tested x86_64 and x86.

	[BZ #16362]
	* math/s_clog10.c (M_PI_LOG10E): New macro.
	(__clog10): Use M_PI_LOG10E instead of M_PI when real and
	imaginary parts are 0.
	* math/s_clog10f.c (M_PI_LOG10Ef): New macro.
	(__clog10f): Use M_PI_LOG10Ef instead of M_PI when real and
	imaginary parts are 0.
	* math/s_clog10l.c (M_PI_LOG10El): New macro.
	(__clog10l): Use M_PI_LOG10El instead of M_PIl when real and
	imaginary parts are 0.
	* math/libm-test.inc (clog10_test_data): Update expected results
	for when real and imaginary parts are 0.
2014-03-28 20:53:32 +00:00
Joseph Myers 03a7091fa2 Fix x86/x86_64 expl/exp10l spurious underflows (bug 16348).
This patch fixes bug 16348, spurious underflows from x86/x86_64 expl
on arguments close to 0.  These implementations effectively use expm1
(on the fractional part of the argument) internally, so resulting in
spurious underflows when the result is very close to 1.  For arguments
small enough that the round-to-nearest correct result is 1, this patch
uses 1+x instead.

These implementations are also used for exp10l and so the patch fixes
similar issues there (the 0x1p-67 threshold being small enough to be
correct for exp10l as well as expl).  But because of spurious
underflows in other exp10 implementations (bug 16560), the tests
aren't added for exp10 at this point - they can be added when the
other exp10 parts of that bug are fixed.

Tested x86_64 and x86; no ulps updates needed.

	[BZ #16348]
	* sysdeps/i386/fpu/e_expl.S (IEEE754_EXPL) [!USE_AS_EXPM1L]: Use
	1+x for argument with exponent below -67.
	* sysdeps/x86_64/fpu/e_expl.S (IEEE754_EXPL) [!USE_AS_EXPM1L]:
	Likewise.
	* math/auto-libm-test-in: Add more tests of exp.
	* math/auto-libm-test-out: Regenerated.
2014-03-27 18:41:14 +00:00
Siddhesh Poyarekar dd3022d75e Return NULL for wildcard values in getnetgrent from nscd (BZ #16759)
getnetgrent is supposed to return NULL for values that are wildcards
in the (host, user, domain) triplet.  This works correctly with nscd
disabled, but with it enabled, it returns a blank ("") instead of a
NULL.  This is easily seen with the output of `getent netgroup foonet`
for a netgroup foonet defined as follows in /etc/netgroup:

    foonet (,foo,)

The output with nscd disabled is:

    foonet ( ,foo,)

while with nscd enabled, it is:

    foonet (,foo,)

The extra space with nscd disabled is due to the fact that `getent
netgroup` adds it if the return value from getnetgrent is NULL for
either host or user.
2014-03-27 19:49:51 +05:30
Siddhesh Poyarekar ea7d8b95e2 Avoid overlapping addresses to stpcpy calls in nscd (BZ #16760)
Calls to stpcpy from nscd netgroups code will have overlapping source
and destination when all three values in the returned triplet are
non-NULL and in the expected (host,user,domain) order.  This is seen
in valgrind as:

==3181== Source and destination overlap in stpcpy(0x19973b48, 0x19973b48)
==3181==    at 0x4C2F30A: stpcpy (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==3181==    by 0x12567A: addgetnetgrentX (string3.h:111)
==3181==    by 0x12722D: addgetnetgrent (netgroupcache.c:665)
==3181==    by 0x11114C: nscd_run_worker (connections.c:1338)
==3181==    by 0x4E3C102: start_thread (pthread_create.c:309)
==3181==    by 0x59B81AC: clone (clone.S:111)
==3181==

Fix this by using memmove instead of stpcpy.
2014-03-27 19:48:15 +05:30
Siddhesh Poyarekar fbd6b5a405 Fix nscd lookup for innetgr when netgroup has wildcards (BZ #16758)
nscd works correctly when the request in innetgr is a wildcard,
i.e. when one or more of host, user or domain parameters is NULL.
However, it does not work when the the triplet in the netgroup
definition has a wildcard.  This is easy to reproduce for a triplet
defined as follows:

    foonet (,foo,)

Here, an innetgr call that looks like this:

    innetgr ("foonet", "foohost", "foo", NULL);

should succeed and so should:

    innetgr ("foonet", NULL, "foo", "foodomain");

It does succeed with nscd disabled, but not with nscd enabled.  This
fix adds this additional check for all three parts of the triplet so
that it gives the correct result.

	[BZ #16758]
	* nscd/netgroupcache.c (addinnetgrX): Succeed if triplet has
	blank values.
2014-03-27 07:15:22 +05:30
Joseph Myers 9be36fb8cb Make x86_64 fegetenv preserve exception mask (bug 16198).
Bug 16198 is x86_64 fegetenv wrongly masking exceptions for which
traps are enabled, because that's a side-effect of the fnstenv
instruction.  This patch fixes it to use fldenv immediately after
fnstenv, like the i386 version.  Tested x86_64 and x86.

	[BZ #16198]
	* sysdeps/x86_64/fpu/fegetenv.c (fegetenv): Use fldenv after
	fnstenv.
	* math/test-fenv-preserve.c: New file.
	* math/Makefile (tests): Add test-fenv-preserve.
2014-03-26 18:59:08 +00:00
Joseph Myers 046651c168 Relax gen-auto-libm-tests may-underflow rules, test log1p in all rounding modes.
gen-auto-libm-tests presently allows but does not require underflow
exceptions for results with magnitude in the range (greatest
subnormal, least normal].

In some cases, the magnitude of the exact result is very slightly
above the least normal, but rounding in the implementation results in
it effectively computing an infinite-precision result that is slightly
below the least normal, so raising an underflow exception.  This is in
accordance with the documented accuracy goals, but results in
testsuite failures.

This patch changes the logic to allow underflows when the mathematical
result is up to 0.5ulp above the least normal (so in any case where
the round-to-nearest result is the least normal).  Ideally underflows
in all these cases would be accepted only when an underflow with the
actual result is consistent with the rounding mode (in FE_TOWARDZERO
mode, a return value of the least normal implies that the
infinite-precision result did not underflow so there should be no
underflow exception, for example), so as to match the documented goals
more precisely - whereas at present the tests for exceptions are
completely independent of the tests of the returned values.  (The same
applies to overflow exceptions as well - they too should be checked
for consistency with the result, as in FE_TOWARDZERO mode a result
1ulp below the largest finite value should be inconsistent with an
overflow exception and cause a failure with overflow rather than
simply being considered a 1ulp error when overflow is expected.)  But
the present patch at least deals with the cases causing spurious
failures so that (a) certain existing tests no longer need to be
marked as having spurious exceptions (such markings in
auto-libm-test-in end up applying to more cases than just those they
are needed for) and (b) log1p can be tested in all rounding modes
without introducing more such failures.  This patch duly moves tests
of log1p to ALL_RM_TEST.

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16357]
	[BZ #16599]
	* math/gen-auto-libm-tests.c (fp_format_desc): Add field
	min_plus_half.
	(fp_formats): Update initializers.
	(init_fp_formats): Initialize new field.
	(output_for_one_input_case): Allow underflow for results up to
	min_plus_half.
	* math/libm-test.inc (log1p_test): Use ALL_RM_TEST.
	* math/auto-libm-test-in: Don't mark some underflows from asin and
	atanh as spurious.
	* math/auto-libm-test-out: Regenerated.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-25 12:26:06 +00:00
Stefan Liebler de0318743a NEWS: Add 16712, 16713, 16714 to fixed bug list. 2014-03-25 10:16:08 +01:00
Paul Pluzhnikov a42faf59d6 Fix BZ #16634.
An application that erroneously tries to repeatedly dlopen("a.out", ...)
may hit assertion failure:

  Inconsistency detected by ld.so: dl-tls.c: 474: _dl_allocate_tls_init:
  Assertion `listp != ((void *)0)' failed!

dlopen() actually fails with  "./a.out: cannot dynamically load executable",
but it does so after incrementing dl_tls_max_dtv_idx.

Once we run out of TLS_SLOTINFO_SURPLUS (62), we exit with above assertion
failure.

2014-03-24  Paul Pluzhnikov  <ppluzhnikov@google.com>

	[BZ #16634]

	* elf/dl-load.c (open_verify): Add mode parameter.
        Error early when ET_EXEC and mode does not have __RTLD_OPENEXEC.
        (open_path): Change from boolean 'secure' to complete flag 'mode'
        (_dl_map_object): Adjust.
	* elf/Makefile (tests): Add tst-dlopen-aout.
	* elf/tst-dlopen-aout.c: New test.
2014-03-24 10:58:26 -07:00
Andreas Schwab a071766ebf Fix use of half-initialized result in getaddrinfo when using nscd (bug 16743)
This fixes a bug in the way the results from __nscd_getai are collected:
for every returned result a new entry is first added to the
gaih_addrtuple list, but if that result doesn't match the request this
entry remains uninitialized.  So for this non-matching result an extra
result with uninitialized content is returned.

To reproduce (with nscd running):

	$ getent ahostsv4 localhost
	127.0.0.1       STREAM localhost
	127.0.0.1       DGRAM
	127.0.0.1       RAW
	(null)          STREAM
	(null)          DGRAM
	(null)          RAW
2014-03-24 16:51:53 +01:00
Andreas Schwab 44152e4b05 Account for alloca use when collecting interface addresses (bug 16002)
To reproduce:

	# ip li add name dummy0 type dummy
	# site_id=$(head -c6 /dev/urandom | od -tx2 -An | tr ' ' ':')
	# for ((i = 0; i < 65536; i++)) do
	> ip ad ad $(printf fd80$site_id::%04x $i)/128 dev dummy0
	> done
	# (ulimit -s 900; getent ahosts localhost)
	# ip li de dummy0
2014-03-24 16:05:13 +01:00
Joseph Myers b376a11a19 Fix dbl-64 exp overflow/underflow in non-default rounding modes (bug 16284).
The dbl-64 version of exp needs round-to-nearest mode for its internal
computations, but that has the consequence of inappropriate
overflowing and underflowing results in other rounding modes.  This
patch fixes this by recomputing the relevant results in cases where
the round-to-nearest result overflows to infinity or underflows to
zero (most of the diffs are actually just consequent reindentation).
Tests are enabled in all rounding modes for complex functions using
exp - but not for cexp because it turns out there are bugs causing
spurious underflows for cexp for some tests, which will need to be
fixed separately (I suspect ccos ccosh csin csinh ctan ctanh have
similar bugs, just not shown by the present set of test inputs).

Tested x86_64 and x86 and ulps updated accordingly.

	[BZ #16284]
	* sysdeps/ieee754/dbl-64/e_exp.c (__ieee754_exp): Use original
	rounding mode to recompute results that overflow to infinity or
	underflow to zero.
	* math/auto-libm-test-in: Don't mark tests as expected to fail for
	bug 16284.
	* math/auto-libm-test-out: Regenerated.
	* math/libm-test.inc (ccos_test): Use ALL_RM_TEST.
	(ccosh_test): Likewise.
	(csin_test_data): Use plus_oflow.
	(csin_test): Use ALL_RM_TEST.
	(csinh_test_data): Use plus_oflow.
	(csinh_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-24 12:18:45 +00:00
Joseph Myers f7be737659 Fix log (1) in round-downward mode (bug 16731).
According to ISO C Annex F, log (1) should be +0 in all rounding
modes, but some implementations in glibc wrongly return -0 in
round-downward mode (mapping to log1p (x - 1) is problematic because 1
- 1 is -0 in round-downward mode, and log1p (-0) is -0).  This patch
fixes this.  (It helps with some implementations of other functions
such as acosh, log2 and log10 that call out to log, but not enough to
enable all-rounding-modes testing for those functions without further
fixes to other implementations of them.)

Tested x86_64 and x86 and ulps updated accordingly, and did spot tests
for mips64 for the ldbl-128 fix, and i586 for the sysdeps/i386/fpu
implementations shadowed by those in sysdeps/i386/i686/fpu.

	[BZ #16731]
	* sysdeps/i386/fpu/e_log.S (__ieee754_log): Take absolute value
	when x - 1 is zero.
	* sysdeps/i386/fpu/e_logf.S (__ieee754_logf): Likewise.
	* sysdeps/i386/fpu/e_logl.S (__ieee754_logl): Likewise.
	* sysdeps/i386/i686/fpu/e_logl.S (__ieee754_logl): Likewise.
	* sysdeps/ieee754/dbl-64/e_log.c (__ieee754_log): Return +0 when
	argument is 1.
	* sysdeps/ieee754/ldbl-128/e_logl.c (__ieee754_logl): Likewise.
	* sysdeps/x86_64/fpu/e_logl.S: Take absolute value when x - 1 is
	zero.
	* math/libm-test.inc (log_test): Use ALL_RM_TEST.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
2014-03-21 18:13:58 +00:00
Joseph Myers b1115e916a Fix __ASSUME_PREADV and __ASSUME_PWRITEV for Alpha and MicroBlaze (bug 16649).
Reviewing (for all architectures, with a baseline kernel version of
2.6.32) the kernel support for features for which __ASSUME_* macros
would be affected by a move to 2.6.32 as minimum kernel version showed
up that __ASSUME_PREADV and __ASSUME_PWRITEV were wrongly defined for
MicroBlaze (despite the corresponding syscall table entries not being
wired up in the kernel) and Alpha for 2.6.30 and above (although the
support on Alpha was added in 2.6.33).  This patch makes the
kernel-features.h files undefine those macros for appropriate
versions.

	[BZ #16649]
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h
	[__LINUX_KERNEL_VERSION < 0x020621] (__ASSUME_PREADV): Undefine.
	[__LINUX_KERNEL_VERSION < 0x020621] (__ASSUME_PWRITEV): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_PREADV): Undefine.
	(__ASSUME_PWRITEV): Likewise.
2014-03-19 13:10:52 +00:00
Siddhesh Poyarekar ea33158c96 Fix offset caching for streams and use it for ftell (BZ #16680)
The ftell implementation was made conservative to ensure that
incorrectly cached offsets never affect it.  However, this causes
problems for append mode when a file stream is rewound.  Additionally,
the 'clever' trick of using stat to get position for append mode files
caused more problems than it solved and broke old behavior.  I have
described the various problems that it caused and then finally the
solution.

For a and a+ mode files, rewinding the stream should result in ftell
returning 0 as the offset, but the stat() trick caused it to
(incorrectly) always return the end of file.  Now I couldn't find
anything in POSIX that specifies the stream position after rewind()
for a file opened in 'a' mode, but for 'a+' mode it should be set to
0.  For 'a' mode too, it probably makes sense to keep it set to 0 in
the interest of retaining old behavior.

The initial file position for append mode files is implementation
defined, so the implementation could either retain the current file
position or move the position to the end of file.  The earlier ftell
implementation would move the offset to end of file for append-only
mode, but retain the old offset for a+ mode.  It would also cache the
offset (this detail is important).  My patch broke this and would set
the initial position to end of file for both append modes, thus
breaking old behavior.  I was ignorant enough to write an incorrect
test case for it too.

The Change:

I have now brought back the behavior of seeking to end of file for
append-only streams, but with a slight difference.  I don't cache the
offset though, since we would want ftell to query the current file
position through lseek while the stream is not active.  Since the
offset is moved to the end of file, we can rely on the file position
reported by lseek and we don't need to resort to the stat() nonsense.

Finally, the cache is always reliable, except when there are unflished
writes in an append mode stream (i.e. both a and a+).  In the latter
case, it is safe to just do an lseek to SEEK_END.  The value can be
safely cached too, since the file handle is already active at this
point.  Incidentally, this is the only state change we affect in the
file handle (apart from taking locks of course).

I have also updated the test case to correct my impression of the
initial file position for a+ streams to the initial behavior.  I have
verified that this does not break any existing tests in the testsuite
and also passes with the new tests.
2014-03-17 21:23:56 +05:30
Joseph Myers d6fe5e582d Do not terminate default test runs on test failure.
This patch is an updated version of
<https://sourceware.org/ml/libc-alpha/2014-01/msg00198.html> and
<https://sourceware.org/ml/libc-alpha/2014-03/msg00180.html>.

Normal practice for software testsuites is that rather than
terminating immediately when a test fails, they continue running and
report at the end on how many tests passed or failed.

The principle behind the glibc testsuite stopping on failure was
probably that the expected state is no failures and so any failure
indicates a problem such as miscompilation.  In practice, while this
is fairly close to true for native testing on x86_64 and x86 (kernel
bugs and race conditions can still cause intermittent failures), it's
less likely to be the case on other platforms, and so people testing
glibc run the testsuite with "make -k" and then examine the logs to
determine whether the failures are what they expect to fail on that
platform, possibly with some automation for the comparison.

This patch switches the glibc testsuite to the normal convention of
not stopping on failure - unless you use stop-on-test-failure=y, in
which case it behaves essentially as it did before (and does not
generate overall test summaries on failure).  Instead, the summary
tests.sum may contain tests that FAILed.  At the end of the test run,
any FAIL or ERROR lines from tests.sum are printed, and then it exits
with error status if there were any such lines.  In addition, build
failures will also cause the test run to stop - this has the
justification that those *do* indicate serious problems that should be
promptly fixed and aren't generally hard to fix (but apart from that,
avoiding the build stopping on those failures seems harder).

Note that unlike the previous patches in this series, this *does*
require people with automation around testing glibc to change their
processes - either to start using tests.sum / xtests.sum to track
failures and compare them with expectations (with or without also
using "make -k" and examining "make" logs to identify build failures),
or else to use stop-on-test-failure=y and ignore the new tests.sum /
xtests.sum mechanism.  (If all you check is the exit status from "make
check", no changes are needed unless you want to avoid test runs
continuing after the first failure.)

Tested x86_64.

	* scripts/evaluate-test.sh: Handle fourth argument to determine
	whether test run should stop on failure.
	* Makeconfig (stop-on-test-failure): New variable.
	(evaluate-test): Pass fourth argument to evaluate-test.sh based on
	$(stop-on-test-failure).
	* Makefile (tests): Give a summary of results from testing and
	exit with failure status if they include an ERROR or FAIL.
	(xtests): Likewise.
	* manual/install.texi (Configuring and compiling): Mention
	stop-on-test-failure=y.
	* INSTALL: Regenerated.
2014-03-14 21:02:40 +00:00
Adhemerval Zanella c7de502503 PowerPC: remove wrong roundl implementation for PowerPC64
The roundl assembly implementation
(sysdeps/powerpc/powerpc64/fpu/s_roundl.S)
returns wrong results for some inputs where first double is a exact
integer and the precision is determined by second long double.

Checking on implementation comments and history, I am very confident the
assembly implementation was based on a version before commit
5c68d40169 that fixes BZ#2423 (Errors in
long double (ldbl-128ibm) rounding functions in glibc-2.4).

By just removing the implementation and make the build select
sysdeps/ieee754/ldbl-128ibm/s_roundl.c instead fixes the failing math.

This fixes 16707.
2014-03-14 12:54:47 -05:00
Adhemerval Zanella 98fb27a373 PowerPC: remove wrong nearbyintl implementation for PPC64
The nearbyintl assembly implementation
(sysdeps/powerpc/powerpc64/fpu/s_nearbyintl.S)
returns wrong results for some inputs where first double is a exact
integer and the precision is determined by second long double.

Checking on implementation comments and history, I am very confident the
assembly implementation was based on a version before commit
5c68d40169 that fixes BZ#2423 (Errors in
long double (ldbl-128ibm) rounding functions in glibc-2.4).

By just removing the implementation and make the build select
sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c instead fixes the failing
math.

Fixes BZ#16706.
2014-03-14 12:54:47 -05:00
Adhemerval Zanella 374f7f6121 PowerPC: remove wrong ceill implementation for PowerPC64
The ceill assembly implementation (sysdeps/powerpc/powerpc64/fpu/s_ceill.S)
returns wrong results for some inputs where first double is a exact
integer and the precision is determined by second long double.

Checking on implementation comments and history, I am very confident the
assembly implementation was based on a version before commit
5c68d40169 that fixes BZ#2423 (Errors in
long double (ldbl-128ibm) rounding functions in glibc-2.4).

By just removing the implementation and make the build select
sysdeps/ieee754/ldbl-128ibm/s_ceill.c instead fixes the failing math.

Fixes BZ#16701.
2014-03-14 12:54:47 -05:00
Paul Pluzhnikov 798212a013 2014-03-12 Paul Pluzhnikov <ppluzhnikov@google.com>
[BZ #16381]

	* elf/Makefile (tests): Add tst-pie2.
        (tests-pie): Add tst-pie2.
	* elf/tst-pie2.c: New file.
	* elf/dl-load.c (_dl_map_object_from_fd): Assert correct l_type
	for ET_EXEC.
	* elf/rtld.c (map_doit): Load executable as lt_executable.
	(dl_main): Likewise.
2014-03-12 15:58:39 -07:00
Joseph Myers abe6d90cc8 Fix __ASSUME_PSELECT for MicroBlaze (bug 16642).
Reviewing (for all architectures, with a baseline kernel version of
2.6.32) the kernel support for features for which __ASSUME_* macros
would be affected by a move to 2.6.32 as minimum kernel version showed
up that __ASSUME_PSELECT was wrongly defined for MicroBlaze, despite
the corresponding syscall table entry not being wired up in the
MicroBlaze kernel.

This patch makes the MicroBlaze kernel-features.h undefine
__ASSUME_PSELECT.  I'd also encourage wiring it up in the kernel (so
you can then make this #undef conditional, and eventually obsolete
once a recent-enough kernel is required).  I suspect it wasn't wired
up because of the mistaken comment in asm/unistd.h "obsolete ->
sys_pselect7" (there is no such syscall as pselect7).

	[BZ #16642]
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_PSELECT): Undefine.
2014-03-12 17:29:24 +00:00
Adhemerval Zanella dd3946c615 PowerPC: Fix bzero definition for static libc for PPC32
This patch fixes an issue for powerpc32-fpu static build which fails
with an 'bzero' undefined reference. This patch adds bzero ifunc selector
for static builds and fixes the '__bzero_ppc' reference to default
memset symbol (since static memset build does not provide ifunc
selector).

Fixes BZ#16689.
2014-03-12 09:03:22 -05:00
Siddhesh Poyarekar c44496df2f Provide correct buffer length to netgroup queries in nscd (BZ #16695)
The buffer to query netgroup entries is allocated sufficient space for
the netgroup entries and the key to be appended at the end, but it
sends in an incorrect available length to the NSS netgroup query
functions, resulting in overflow of the buffer in some special cases.
The fix here is to factor in the key length when sending the available
buffer and buffer length to the query functions.
2014-03-12 17:28:13 +05:30
Joseph Myers 600fa36158 Fix nextafter overflow in non-default rounding modes (bug 16677).
ISO C requires the result of nextafter to be independent of the
rounding mode, even when underflow or overflow occurs.  This patch
fixes the bug in various nextafter implementations that, having done
an overflowing computation to force an overflow exception (correct),
they then return the result of that computation rather than an
infinity computed some other way (incorrect, when the overflowing
result of arithmetic with that sign and rounding mode is finite but
the correct result is infinite) - generally by falling through to
existing code to return a value that in fact is correct for this case
(but was computed by an integer increment and so without generating
the exceptions required).  Having fixed the bug, the previously
deferred conversion of nextafter testing in libm-test.inc to
ALL_RM_TEST is also included.

Tested x86_64 and x86; also spot-checked results of nextafter tests
for powerpc32 and mips64 to test the ldbl-128ibm and ldbl-128
changes.  (The m68k change is untested.)

	[BZ #16677]
	* math/s_nextafter.c (__nextafter): Do not return value from
	overflowing computation.
	* sysdeps/i386/fpu/s_nextafterl.c (__nextafterl): Likewise.
	* sysdeps/ieee754/flt-32/s_nextafterf.c (__nextafterf): Likewise.
	* sysdeps/ieee754/ldbl-128/s_nextafterl.c (__nextafterl):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_nextafterl.c (__nextafterl):
	Likewise.
	* sysdeps/m68k/m680x0/fpu/s_nextafterl.c (__nextafterl): Likewise.
	* math/libm-test.inc (nextafter_test): Use ALL_RM_TEST.
2014-03-11 22:24:00 +00:00
Adhemerval Zanella 4facea4730 PowerPC: Fix bzero definition for static libc for PPC64
This patch fixes an issue for powerpc64[le] static build where __bzero
is definied in multiple places (memset-ppc64.o and bzero.o). It is now
defined only in bzero.o and memset-ppc64.o only defined __bzero_ppc for
both dynamic and static library.

Fixes BZ#16683.
2014-03-11 09:31:59 -05:00
Siddhesh Poyarekar 8b4ff97413 Mark nscd service as forking in systemd service file (BZ #16639)
Currently the nscd service is installed in systemd as a simple
service, which means that it is able to handle its own errors and does
not quit.  Since nscd does not fit that description, i.e. it can exit
on errors like, say, failing to parse nscd.conf, it should be declared
as forking instead.
2014-03-10 13:17:54 +05:30
Joseph Myers 5c7808498e Fix POSIX namespace for <bits/siginfo.h> (bug 16674).
<bits/siginfo.h> causes symbols ILL_*, FPE_*, SEGV_* BUS_*, CLD_*,
POLL_* and TRAP_* to be exposed in <signal.h> (and <sys/wait.h>), even
though those symbols are not in non-XSI POSIX before POSIX.1-2008 and
even in POSIX.1-2008 the TRAP_* symbols are XSI-only.  This patch
conditions the symbols appropriately in the various <bits/siginfo.h>
implementations (various <signal.h> and <sys/wait.h> conformtest
issues remain for standards other than POSIX (1995/6)).  Tested
x86_64.

	[BZ #16674]
	* bits/siginfo.h (ILL_ILLOPC): Condition on [__USE_XOPEN_EXTENDED
	|| __USE_XOPEN2K8].
	(ILL_ILLOPN): Likewise.
	(ILL_ILLADR): Likewise.
	(ILL_ILLTRP): Likewise.
	(ILL_PRVOPC): Likewise.
	(ILL_PRVREG): Likewise.
	(ILL_COPROC): Likewise.
	(ILL_BADSTK): Likewise.
	(FPE_INTDIV): Likewise.
	(FPE_INTOVF): Likewise.
	(FPE_FLTDIV): Likewise.
	(FPE_FLTOVF): Likewise.
	(FPE_FLTUND): Likewise.
	(FPE_FLTRES): Likewise.
	(FPE_FLTINV): Likewise.
	(FPE_FLTSUB): Likewise.
	(SEGV_MAPERR): Likewise.
	(SEGV_ACCERR): Likewise.
	(BUS_ADRALN): Likewise.
	(BUS_ADRERR): Likewise.
	(BUS_OBJERR): Likewise.
	(TRAP_BRKPT): Condition on [__USE_XOPEN_EXTENDED].
	(TRAP_TRACE): Likewise.
	(CLD_EXITED): Condition on [__USE_XOPEN_EXTENDED ||
	__USE_XOPEN2K8].
	(CLD_KILLED): Likewise.
	(CLD_DUMPED): Likewise.
	(CLD_TRAPPED): Likewise.
	(CLD_STOPPED): Likewise.
	(CLD_CONTINUED): Likewise.
	(POLL_IN): Likewise.
	(POLL_OUT): Likewise.
	(POLL_MSG): Likewise.
	(POLL_ERR): Likewise.
	(POLL_PRI): Likewise.
	(POLL_HUP): Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/siginfo.h (ILL_ILLOPC):
	Likewise.
	(ILL_ILLOPN): Likewise.
	(ILL_ILLADR): Likewise.
	(ILL_ILLTRP): Likewise.
	(ILL_PRVOPC): Likewise.
	(ILL_PRVREG): Likewise.
	(ILL_COPROC): Likewise.
	(ILL_BADSTK): Likewise.
	(FPE_INTDIV): Likewise.
	(FPE_INTOVF): Likewise.
	(FPE_FLTDIV): Likewise.
	(FPE_FLTOVF): Likewise.
	(FPE_FLTUND): Likewise.
	(FPE_FLTRES): Likewise.
	(FPE_FLTINV): Likewise.
	(FPE_FLTSUB): Likewise.
	(SEGV_MAPERR): Likewise.
	(SEGV_ACCERR): Likewise.
	(BUS_ADRALN): Likewise.
	(BUS_ADRERR): Likewise.
	(BUS_OBJERR): Likewise.
	(BUS_MCEERR_AR): Likewise.
	(BUS_MCEERR_AO): Likewise.
	(TRAP_BRKPT): Condition on [__USE_XOPEN_EXTENDED].
	(TRAP_TRACE): Likewise.
	(CLD_EXITED): Condition on [__USE_XOPEN_EXTENDED ||
	__USE_XOPEN2K8].
	(CLD_KILLED): Likewise.
	(CLD_DUMPED): Likewise.
	(CLD_TRAPPED): Likewise.
	(CLD_STOPPED): Likewise.
	(CLD_CONTINUED): Likewise.
	(POLL_IN): Likewise.
	(POLL_OUT): Likewise.
	(POLL_MSG): Likewise.
	(POLL_ERR): Likewise.
	(POLL_PRI): Likewise.
	(POLL_HUP): Likewise.
	* sysdeps/unix/sysv/linux/bits/siginfo.h (ILL_ILLOPC): Likewise.
	(ILL_ILLOPN): Likewise.
	(ILL_ILLADR): Likewise.
	(ILL_ILLTRP): Likewise.
	(ILL_PRVOPC): Likewise.
	(ILL_PRVREG): Likewise.
	(ILL_COPROC): Likewise.
	(ILL_BADSTK): Likewise.
	(FPE_INTDIV): Likewise.
	(FPE_INTOVF): Likewise.
	(FPE_FLTDIV): Likewise.
	(FPE_FLTOVF): Likewise.
	(FPE_FLTUND): Likewise.
	(FPE_FLTRES): Likewise.
	(FPE_FLTINV): Likewise.
	(FPE_FLTSUB): Likewise.
	(SEGV_MAPERR): Likewise.
	(SEGV_ACCERR): Likewise.
	(BUS_ADRALN): Likewise.
	(BUS_ADRERR): Likewise.
	(BUS_OBJERR): Likewise.
	(BUS_MCEERR_AR): Likewise.
	(BUS_MCEERR_AO): Likewise.
	(TRAP_BRKPT): Condition on [__USE_XOPEN_EXTENDED].
	(TRAP_TRACE): Likewise.
	(CLD_EXITED): Condition on [__USE_XOPEN_EXTENDED ||
	__USE_XOPEN2K8].
	(CLD_KILLED): Likewise.
	(CLD_DUMPED): Likewise.
	(CLD_TRAPPED): Likewise.
	(CLD_STOPPED): Likewise.
	(CLD_CONTINUED): Likewise.
	(POLL_IN): Likewise.
	(POLL_OUT): Likewise.
	(POLL_MSG): Likewise.
	(POLL_ERR): Likewise.
	(POLL_PRI): Likewise.
	(POLL_HUP): Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/siginfo.h (ILL_ILLOPC):
	Likewise.
	(ILL_ILLOPN): Likewise.
	(ILL_ILLADR): Likewise.
	(ILL_ILLTRP): Likewise.
	(ILL_PRVOPC): Likewise.
	(ILL_PRVREG): Likewise.
	(ILL_COPROC): Likewise.
	(ILL_BADSTK): Likewise.
	(ILL_BADIADDR): Likewise.
	(ILL_BREAK): Likewise.
	(FPE_INTDIV): Likewise.
	(FPE_INTOVF): Likewise.
	(FPE_FLTDIV): Likewise.
	(FPE_FLTOVF): Likewise.
	(FPE_FLTUND): Likewise.
	(FPE_FLTRES): Likewise.
	(FPE_FLTINV): Likewise.
	(FPE_FLTSUB): Likewise.
	(FPE_DECOVF): Likewise.
	(FPE_DECDIV): Likewise.
	(FPE_DECERR): Likewise.
	(FPE_INVASC): Likewise.
	(FPE_INVDEC): Likewise.
	(SEGV_MAPERR): Likewise.
	(SEGV_ACCERR): Likewise.
	(SEGV_PSTKOVF): Likewise.
	(BUS_ADRALN): Likewise.
	(BUS_ADRERR): Likewise.
	(BUS_OBJERR): Likewise.
	(BUS_MCEERR_AR): Likewise.
	(BUS_MCEERR_AO): Likewise.
	(TRAP_BRKPT): Condition on [__USE_XOPEN_EXTENDED].
	(TRAP_TRACE): Likewise.
	(TRAP_BRANCH): Likewise.
	(TRAP_HWBKPT): Likewise.
	(CLD_EXITED): Condition on [__USE_XOPEN_EXTENDED ||
	__USE_XOPEN2K8].
	(CLD_KILLED): Likewise.
	(CLD_DUMPED): Likewise.
	(CLD_TRAPPED): Likewise.
	(CLD_STOPPED): Likewise.
	(CLD_CONTINUED): Likewise.
	(POLL_IN): Likewise.
	(POLL_OUT): Likewise.
	(POLL_MSG): Likewise.
	(POLL_ERR): Likewise.
	(POLL_PRI): Likewise.
	(POLL_HUP): Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/siginfo.h (ILL_ILLOPC): Likewise.
	(ILL_ILLOPN): Likewise.
	(ILL_ILLADR): Likewise.
	(ILL_ILLTRP): Likewise.
	(ILL_PRVOPC): Likewise.
	(ILL_PRVREG): Likewise.
	(ILL_COPROC): Likewise.
	(ILL_BADSTK): Likewise.
	(FPE_INTDIV): Likewise.
	(FPE_INTOVF): Likewise.
	(FPE_FLTDIV): Likewise.
	(FPE_FLTOVF): Likewise.
	(FPE_FLTUND): Likewise.
	(FPE_FLTRES): Likewise.
	(FPE_FLTINV): Likewise.
	(FPE_FLTSUB): Likewise.
	(SEGV_MAPERR): Likewise.
	(SEGV_ACCERR): Likewise.
	(BUS_ADRALN): Likewise.
	(BUS_ADRERR): Likewise.
	(BUS_OBJERR): Likewise.
	(BUS_MCEERR_AR): Likewise.
	(BUS_MCEERR_AO): Likewise.
	(TRAP_BRKPT): Condition on [__USE_XOPEN_EXTENDED].
	(TRAP_TRACE): Likewise.
	(CLD_EXITED): Condition on [__USE_XOPEN_EXTENDED ||
	__USE_XOPEN2K8].
	(CLD_KILLED): Likewise.
	(CLD_DUMPED): Likewise.
	(CLD_TRAPPED): Likewise.
	(CLD_STOPPED): Likewise.
	(CLD_CONTINUED): Likewise.
	(POLL_IN): Likewise.
	(POLL_OUT): Likewise.
	(POLL_MSG): Likewise.
	(POLL_ERR): Likewise.
	(POLL_PRI): Likewise.
	(POLL_HUP): Likewise.
	* sysdeps/unix/sysv/linux/s390/bits/siginfo.h (ILL_ILLOPC): Likewise.
	(ILL_ILLOPN): Likewise.
	(ILL_ILLADR): Likewise.
	(ILL_ILLTRP): Likewise.
	(ILL_PRVOPC): Likewise.
	(ILL_PRVREG): Likewise.
	(ILL_COPROC): Likewise.
	(ILL_BADSTK): Likewise.
	(FPE_INTDIV): Likewise.
	(FPE_INTOVF): Likewise.
	(FPE_FLTDIV): Likewise.
	(FPE_FLTOVF): Likewise.
	(FPE_FLTUND): Likewise.
	(FPE_FLTRES): Likewise.
	(FPE_FLTINV): Likewise.
	(FPE_FLTSUB): Likewise.
	(SEGV_MAPERR): Likewise.
	(SEGV_ACCERR): Likewise.
	(BUS_ADRALN): Likewise.
	(BUS_ADRERR): Likewise.
	(BUS_OBJERR): Likewise.
	(BUS_MCEERR_AR): Likewise.
	(BUS_MCEERR_AO): Likewise.
	(TRAP_BRKPT): Condition on [__USE_XOPEN_EXTENDED].
	(TRAP_TRACE): Likewise.
	(CLD_EXITED): Condition on [__USE_XOPEN_EXTENDED ||
	__USE_XOPEN2K8].
	(CLD_KILLED): Likewise.
	(CLD_DUMPED): Likewise.
	(CLD_TRAPPED): Likewise.
	(CLD_STOPPED): Likewise.
	(CLD_CONTINUED): Likewise.
	(POLL_IN): Likewise.
	(POLL_OUT): Likewise.
	(POLL_MSG): Likewise.
	(POLL_ERR): Likewise.
	(POLL_PRI): Likewise.
	(POLL_HUP): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/siginfo.h (ILL_ILLOPC): Likewise.
	(ILL_ILLOPN): Likewise.
	(ILL_ILLADR): Likewise.
	(ILL_ILLTRP): Likewise.
	(ILL_PRVOPC): Likewise.
	(ILL_PRVREG): Likewise.
	(ILL_COPROC): Likewise.
	(ILL_BADSTK): Likewise.
	(FPE_INTDIV): Likewise.
	(FPE_INTOVF): Likewise.
	(FPE_FLTDIV): Likewise.
	(FPE_FLTOVF): Likewise.
	(FPE_FLTUND): Likewise.
	(FPE_FLTRES): Likewise.
	(FPE_FLTINV): Likewise.
	(FPE_FLTSUB): Likewise.
	(SEGV_MAPERR): Likewise.
	(SEGV_ACCERR): Likewise.
	(BUS_ADRALN): Likewise.
	(BUS_ADRERR): Likewise.
	(BUS_OBJERR): Likewise.
	(BUS_MCEERR_AR): Likewise.
	(BUS_MCEERR_AO): Likewise.
	(TRAP_BRKPT): Condition on [__USE_XOPEN_EXTENDED].
	(TRAP_TRACE): Likewise.
	(CLD_EXITED): Condition on [__USE_XOPEN_EXTENDED ||
	__USE_XOPEN2K8].
	(CLD_KILLED): Likewise.
	(CLD_DUMPED): Likewise.
	(CLD_TRAPPED): Likewise.
	(CLD_STOPPED): Likewise.
	(CLD_CONTINUED): Likewise.
	(POLL_IN): Likewise.
	(POLL_OUT): Likewise.
	(POLL_MSG): Likewise.
	(POLL_ERR): Likewise.
	(POLL_PRI): Likewise.
	(POLL_HUP): Likewise.
	* sysdeps/unix/sysv/linux/tile/bits/siginfo.h (ILL_ILLOPC): Likewise.
	(ILL_ILLOPN): Likewise.
	(ILL_ILLADR): Likewise.
	(ILL_ILLTRP): Likewise.
	(ILL_PRVOPC): Likewise.
	(ILL_PRVREG): Likewise.
	(ILL_COPROC): Likewise.
	(ILL_BADSTK): Likewise.
	(ILL_DBLFLT): Likewise.
	(ILL_HARDWALL): Likewise.
	(FPE_INTDIV): Likewise.
	(FPE_INTOVF): Likewise.
	(FPE_FLTDIV): Likewise.
	(FPE_FLTOVF): Likewise.
	(FPE_FLTUND): Likewise.
	(FPE_FLTRES): Likewise.
	(FPE_FLTINV): Likewise.
	(FPE_FLTSUB): Likewise.
	(SEGV_MAPERR): Likewise.
	(SEGV_ACCERR): Likewise.
	(BUS_ADRALN): Likewise.
	(BUS_ADRERR): Likewise.
	(BUS_OBJERR): Likewise.
	(BUS_MCEERR_AR): Likewise.
	(BUS_MCEERR_AO): Likewise.
	(TRAP_BRKPT): Condition on [__USE_XOPEN_EXTENDED].
	(TRAP_TRACE): Likewise.
	(CLD_EXITED): Condition on [__USE_XOPEN_EXTENDED ||
	__USE_XOPEN2K8].
	(CLD_KILLED): Likewise.
	(CLD_DUMPED): Likewise.
	(CLD_TRAPPED): Likewise.
	(CLD_STOPPED): Likewise.
	(CLD_CONTINUED): Likewise.
	(POLL_IN): Likewise.
	(POLL_OUT): Likewise.
	(POLL_MSG): Likewise.
	(POLL_ERR): Likewise.
	(POLL_PRI): Likewise.
	(POLL_HUP): Likewise.
	* sysdeps/unix/sysv/linux/x86/bits/siginfo.h (ILL_ILLOPC): Likewise.
	(ILL_ILLOPN): Likewise.
	(ILL_ILLADR): Likewise.
	(ILL_ILLTRP): Likewise.
	(ILL_PRVOPC): Likewise.
	(ILL_PRVREG): Likewise.
	(ILL_COPROC): Likewise.
	(ILL_BADSTK): Likewise.
	(FPE_INTDIV): Likewise.
	(FPE_INTOVF): Likewise.
	(FPE_FLTDIV): Likewise.
	(FPE_FLTOVF): Likewise.
	(FPE_FLTUND): Likewise.
	(FPE_FLTRES): Likewise.
	(FPE_FLTINV): Likewise.
	(FPE_FLTSUB): Likewise.
	(SEGV_MAPERR): Likewise.
	(SEGV_ACCERR): Likewise.
	(BUS_ADRALN): Likewise.
	(BUS_ADRERR): Likewise.
	(BUS_OBJERR): Likewise.
	(BUS_MCEERR_AR): Likewise.
	(BUS_MCEERR_AO): Likewise.
	(TRAP_BRKPT): Condition on [__USE_XOPEN_EXTENDED].
	(TRAP_TRACE): Likewise.
	(CLD_EXITED): Condition on [__USE_XOPEN_EXTENDED ||
	__USE_XOPEN2K8].
	(CLD_KILLED): Likewise.
	(CLD_DUMPED): Likewise.
	(CLD_TRAPPED): Likewise.
	(CLD_STOPPED): Likewise.
	(CLD_CONTINUED): Likewise.
	(POLL_IN): Likewise.
	(POLL_OUT): Likewise.
	(POLL_MSG): Likewise.
	(POLL_ERR): Likewise.
	(POLL_PRI): Likewise.
	(POLL_HUP): Likewise.
	* conform/Makefile (test-xfail-POSIX/signal.h/conform): Remove.
	(test-xfail-POSIX/sys/wait.h/conform): Likewise.
2014-03-07 23:57:56 +00:00
Joseph Myers bc61d27c61 Include all of <time.h> from <sched.h> for older standards (bug 16670).
This patch fixes one of the header namespace issues shown up by
conformtest, <sched.h> failing to expose all symbols from <time.h> as
required by older standards.  The patch keeps the existing behavior if
__USE_XOPEN2K is defined (the default; POSIX.1-2001 was the version
that made it optional to expose these symbols), but ensures that all
the symbols from <time.h> are exposed if an older standard is
selected.  Tested x86_64.

	[BZ #16670]
	* posix/sched.h [!__USE_XOPEN2K] (__need_time_t): Don't define
	before #include of <time.h>.
	[!__USE_XOPEN2K] (__need_timespec): Likewise.
	* conform/Makefile (test-xfail-POSIX/sched.h/conform): Remove.
	(test-xfail-UNIX98/sched.h/conform): Likewise.
2014-03-07 20:54:03 +00:00
Siddhesh Poyarekar 000232b9bc Separate ftell from fseek logic and avoid modifying FILE data (#16532)
ftell semantics are distinct from fseek(SEEK_CUR) especially when it
is called on a file handler that is not yet active.  Due to this
caveat, much care needs to be taken while modifying the handler data
and hence, this first iteration on separating out ftell focusses on
maintaining handler data integrity at all times while it figures out
the current stream offset.  The result is that it makes a syscall for
every offset request.

There is scope for optimizing this by caching offsets when we know
that the handler is active.  A simple way to find out is when the
buffers have data.  It is not so simple to find this out when the
buffer is empty without adding some kind of flag.
2014-03-04 07:45:58 +05:30
Siddhesh Poyarekar 1cadc85813 Fix sign of input to bsloww1 (BZ #16623)
In 84ba214c, I removed some redundant sign computations and in the
process, I incorrectly got rid of a temporary variable, thus passing
the absolute value of the input to bsloww1.  This caused #16623.

This fix undoes the incorrect change.
2014-02-27 21:12:09 +05:30
Carlos O'Donell ade40b10ff BZ #16632: Change [_BSD/_SVID]_SOURCE warning.
Source packages that need to support both 2.19 and
2.20 will need to decide to use _BSD_SOURCE and
_SVID_SOURCE vs. _DEFAULT_SOURCE.

The difficulty in making that decision is that
__GLIBC_MINOR__ is itself defined in features.h,
but you want to set the feature test macros before
including features.h.

Therefore to ease the transition we should disable
the warning if _DEFAULT_SOURCE is also defined.

https://sourceware.org/ml/libc-alpha/2014-02/msg00666.html

https://sourceware.org/glibc/wiki/Release/2.20#Packaging_Changes
2014-02-25 13:23:25 -05:00
Carlos O'Donell d050367659 BZ #16613: Support TLS in audit libraries.
This commit fixes a bug where the dynamic loader would crash
when loading audit libraries, via LD_AUDIT, where those libraries
used TLS. The dynamic loader was not considering that the audit
libraries would use TLS and failed to bump the TLS generation
counter leaving TLS usage inconsistent after loading the audit
libraries.

https://sourceware.org/ml/libc-alpha/2014-02/msg00569.html
2014-02-25 13:18:15 -05:00
Florian Weimer 4cbf380ce9 misc/sys/select.h (__FD_MASK): Avoid signed integer overflow.
Shifting into the sign position is currently supported as a GCC
extension, but explicitly subjected to future changes.  Computation
in the unsigned type followed by a cast to the signed type is a GCC
extension that will be available forever.
2014-02-25 14:56:10 +01:00
Andreas Schwab b04acb2651 Fix race conditions in pldd that may leave the process stopped after detaching
Fixes bug 15804
2014-02-25 09:29:34 +01:00
Yury Gribov a5d82e4e34 Update ARM ulps for VFPv4 (bug 16600).
[BZ #16600]
	* sysdeps/arm/libm-test-ulps: Update for VFPv4.
2014-02-21 17:21:13 +00:00
Joseph Myers bc688c1029 Fix __ASSUME_SENDMMSG issues (bug 16611).
Similar to the issues for accept4 and recvmmsg, __ASSUME_SENDMMSG is
also confused about whether it relates to function availability or
socketcall operation availability, and the conditions for the
definition are always wrong (sendmmsg appeared in Linux kernel 3.0,
not 2.6.39); this is now bug 16611.

This patch splits the macro into separate macros like those for
accept4 and recvmmsg, defining them for appropriate kernel versions.

Tested x86_64, including that disassembly of the installed shared
libraries is unchanged by this patch.

	[BZ #16611]
	* sysdeps/unix/sysv/linux/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x030000 && __ASSUME_SOCKETCALL]
	(__ASSUME_SENDMMSG_SOCKETCALL): Define.
	[__LINUX_KERNEL_VERSION >= 0x030000 && (__i386__ || __x86_64__ ||
	__powerpc__ || __sh__ || __sparc__)] (__ASSUME_SENDMMSG_SYSCALL):
	Likewise.
	[__i386__ || __powerpc__ || __sh__ || __sparc__]
	(__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
	[__ASSUME_SENDMMSG_SOCKETCALL || __ASSUME_SENDMMSG_SYSCALL]
	(__ASSUME_SENDMMSG): Define instead of using previous
	[__LINUX_KERNEL_VERSION >= 0x020627] condition.
	* sysdeps/unix/sysv/linux/aarch64/kernel-features.h
	(__ASSUME_SENDMMSG_SYSCALL): Define.
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x030200] (__ASSUME_SENDMMSG_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x030000] (__ASSUME_SENDMMSG_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x030000] (__ASSUME_SENDMMSG_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/internal_sendmmsg.S [__ASSUME_SOCKETCALL
	&& !__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL &&
	!__ASSUME_SENDMMSG_SYSCALL] (__NR_sendmmsg): Undefine.
	[__ASSUME_SENDMMSG]: Change conditionals to
	[__ASSUME_SENDMMSG_SOCKETCALL].
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x030300] (__ASSUME_SENDMMSG_SYSCALL):
	Define.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x030100] (__ASSUME_SENDMMSG_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/sendmmsg.c [__ASSUME_SOCKETCALL &&
	!__ASSUME_SENDMMSG_SYSCALL_WITH_SOCKETCALL &&
	!__ASSUME_SENDMMSG_SYSCALL] (__NR_sendmmsg): Undefine.
	[!__ASSUME_SENDMMSG]: Change conditional to
	[!__ASSUME_SENDMMSG_SOCKETCALL].
	* sysdeps/unix/sysv/linux/tile/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x030000] (__ASSUME_SENDMMSG_SYSCALL):
	Define.

	* sysdeps/unix/sysv/linux/hppa/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x030100] (__ASSUME_SENDMMSG_SYSCALL):
	Define.
2014-02-20 17:55:35 +00:00
Joseph Myers 0e31b18ca2 Fix __ASSUME_RECVMMSG issues (bug 16610).
Similar to the issues for accept4, __ASSUME_RECVMMSG is also confused
about whether it relates to function availability or socketcall
operation availability; this is now bug 16610.

Nothing actually tests __ASSUME_RECVMMSG for function availability,
but implicit in the definition in kernel-features.h is the idea that
it makes sense when the syscall is available and socketcall is not
being used.  As with accept4, there are architectures where the
syscall was added later than the socketcall operation, meaning that
assuming glibc is built with recent enough kernel headers, it does not
attempt to use socketcall for these operations and __ASSUME_RECVMMSG
gets defined for kernels >= 2.6.33 even when the syscall was only
added later.

This patch splits the macro into separate macros like those used for
accept4; having similar macro structure in both cases (and for
sendmmsg once I've dealt with that) seems likely to be less confusing
than having a different structure on the basis of nothing actually
needing to assume the recvmmsg function works.  Appropriate
definitions are added for all architectures.

Architecture-specific note: Tile's kernel-features.h says "TILE glibc
support starts with 2.6.36", which is accurate in that 2.6.36 was the
first kernel version with Tile support, and on that basis I've made
that header define __ASSUME_RECVMMSG_SYSCALL unconditionally.
However, Tile's configure.ac has arch_minimum_kernel=2.6.32.  Since
arch_minimum_kernel is meant to reflect only kernel.org kernel
versions, I think that should change to 2.6.36.  (If using glibc with
kernel versions from before a port went in kernel.org, it's your
responsibility to change arch_minimum_kernel in a local patch, and at
the same time to adjust any __ASSUME_* definitions that may not be
correct for your older kernel; for developing the official glibc it
should only ever be necessary to consider what official kernel.org
releases support.)

Tested x86_64, including that disassembly of the installed shared
libraries is unchanged by this patch.

	[BZ #16610]
	* sysdeps/unix/sysv/linux/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621 && __ASSUME_SOCKETCALL]
	(__ASSUME_RECVMMSG_SOCKETCALL): Define.
	[(__LINUX_KERNEL_VERSION >= 0x020621 && (__i386__ || __x86_64__ ||
	__sparc__)) || (__LINUX_KERNEL_VERSION >= 0x020625 && (__powerpc__
	|| __sh__))] (__ASSUME_RECVMMSG_SYSCALL): Likewise.
	[__i386__ || __sparc__]
	(__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
	[__ASSUME_RECVMMSG_SOCKETCALL || __ASSUME_RECVMMSG_SYSCALL]
	(__ASSUME_RECVMMSG): Define instead of using previous
	[__LINUX_KERNEL_VERSION >= 0x020621] condition.
	* sysdeps/unix/sysv/linux/aarch64/kernel-features.h
	(__ASSUME_RECVMMSG_SYSCALL): Define.
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/internal_recvmmsg.S [__ASSUME_SOCKETCALL
	&& !__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL &&
	!__ASSUME_RECVMMSG_SYSCALL] (__NR_recvmmsg): Undefine.
	[__ASSUME_RECVMMSG]: Change condition to
	[__ASSUME_RECVMMSG_SOCKETCALL].
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG_SYSCALL):
	Define.
	(__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_RECVMMSG_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/recvmmsg.c [__ASSUME_SOCKETCALL &&
	!__ASSUME_RECVMMSG_SYSCALL_WITH_SOCKETCALL &&
	!__ASSUME_RECVMMSG_SYSCALL] (__NR_recvmmsg): Undefine.
	[!__ASSUME_RECVMMSG]: Change condition to
	[!__ASSUME_RECVMMSG_SOCKETCALL].
	* sysdeps/unix/sysv/linux/tile/kernel-features.h
	(__ASSUME_RECVMMSG_SYSCALL): Define.

	* sysdeps/unix/sysv/linux/hppa/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020622] (__ASSUME_RECVMMSG_SYSCALL):
	Define.
2014-02-20 17:53:08 +00:00
Joseph Myers dd481ccffd Fix __ASSUME_ACCEPT4 issues (bug 16609).
In <https://sourceware.org/ml/libc-alpha/2013-12/msg00008.html>,
Aurelien noted issues with the definition of __ASSUME_ACCEPT4, which I
discussed in more detail in
<https://sourceware.org/ml/libc-alpha/2013-12/msg00014.html>; these
are now bug 16609.

As previously noted, __ASSUME_ACCEPT4 is used in two ways:

* In OS-independent code, to mean "accept4 can be assumed to work
  rather than fail with ENOSYS".  It doesn't matter whether it's
  implemented with socketcall or a separate syscall.

* In Linux-specific code, to mean "the socketcall multiplex syscall
  can be assumed to handle the accept4 operation.  When used in
  Linux-specific code, it *never* refers to anything relating to the
  accept4 syscall, only to the socketcall multiplexer.

This patch splits the macro into separate __ASSUME_ACCEPT4_SOCKETCALL,
__ASSUME_ACCEPT4_SYSCALL and __ASSUME_ACCEPT4 to clarify the different
cases involved.  A macro __ASSUME_SOCKETCALL is added for convenience
in writing logic relating to all socketcall architectures.  In
addition, to address the issue of architectures where socketcall
support for accept4 was added before a separate syscall was added (and
so the separate syscall should not be used unless known to be present
or fallback to socketcall is available), a fourth macro
__ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL is added to indicate that the
syscall became available at the same time as socketcall support.  This
is then used in the relevant places in a conditional determining
whether to undefine __NR_accept4 (the simple approach to avoiding the
syscall's presence causing problems; I didn't try to implement runtime
fallback from the syscall to socketcall).

Architecture-specific note: alpha defined __ASSUME_ACCEPT4 for 2.6.33
and later, but actually the syscall was added for alpha in 3.2, so
this patch uses the correct condition for __ASSUME_ACCEPT4_SYSCALL
there.

Tested x86_64, including that disassembly of the installed shared
libraries is unchanged by this patch.

	[BZ #16609]
	* sysdeps/unix/sysv/linux/kernel-features.h [__i386__ ||
	__powerpc__ || __s390__ || __sh__ || __sparc__]
	(__ASSUME_SOCKETCALL): Define.
	[__LINUX_KERNEL_VERSION && __ASSUME_SOCKETCALL]
	(__ASSUME_ACCEPT4_SOCKETCALL): Likewise.
	[(__LINUX_KERNEL_VERSION >= 0x02061c && (__x86_64__ || __sparc__))
	|| (__LINUX_KERNEL_VERSION >= 0x020625 && (__powerpc__ ||
	__sh__))] (__ASSUME_ACCEPT4_SYSCALL): Likewise.
	[__sparc__] (__ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL): Likewise.
	[__ASSUME_ACCEPT4_SOCKETCALL || __ASSUME_ACCEPT4_SYSCALL]
	(__ASSUME_ACCEPT4): Define instead of using previous
	[__LINUX_KERNEL_VERSION >= 0x02061c && (__i386__ || __x86_64__ ||
	__powerpc__ || __sparc__ || __s390__)] condition.
	* sysdeps/unix/sysv/linux/aarch64/kernel-features.h
	(__ASSUME_ACCEPT4): Change to __ASSUME_ACCEPT4_SYSCALL.
	* sysdeps/unix/sysv/linux/accept4.c [__ASSUME_SOCKETCALL &&
	!__ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL &&
	!__ASSUME_ACCEPT4_SYSCALL] (__NR_accept4): Undefine.
	[!__ASSUME_ACCEPT4]: Change condition to
	[!__ASSUME_ACCEPT4_SOCKETCALL].
	* sysdeps/unix/sysv/linux/alpha/kernel-features.h
	(__ASSUME_ACCEPT4): Change to __ASSUME_ACCEPT4_SYSCALL.  Correct
	condition to [__LINUX_KERNEL_VERSION >= 0x030200].
	* sysdeps/unix/sysv/linux/arm/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020624] (__ASSUME_ACCEPT4): Change to
	__ASSUME_ACCEPT4_SYSCALL.
	* sysdeps/unix/sysv/linux/i386/accept4.S [__ASSUME_ACCEPT4]:
	Change conditions to [__ASSUME_ACCEPT4_SOCKETCALL].
	* sysdeps/unix/sysv/linux/ia64/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x030300] (__ASSUME_ACCEPT4): Change to
	__ASSUME_ACCEPT4_SYSCALL.
	* sysdeps/unix/sysv/linux/internal_accept4.S [__ASSUME_SOCKETCALL
	&& !__ASSUME_ACCEPT4_SYSCALL_WITH_SOCKETCALL &&
	!__ASSUME_ACCEPT4_SYSCALL] (__NR_accept4): Undefine.
	[__ASSUME_ACCEPT4]: Change condition to
	[__ASSUME_ACCEPT4_SOCKETCALL].
	* sysdeps/unix/sysv/linux/m68k/kernel-features.h
	(__ASSUME_SOCKETCALL): Define.
	[__LINUX_KERNEL_VERSION >= 0x02061c] (__ASSUME_ACCEPT4): Remove.
	* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
	(__ASSUME_SOCKETCALL): Define.
	(__ASSUME_ACCEPT4): Remove.
	[__LINUX_KERNEL_VERSION >= 0x020621] (__ASSUME_ACCEPT4_SYSCALL):
	Define.
	* sysdeps/unix/sysv/linux/mips/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x02061f] (__ASSUME_ACCEPT4_SYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/tile/kernel-features.h
	(__ASSUME_ACCEPT4): Change to __ASSUME_ACCEPT4_SYSCALL.

	* sysdeps/unix/sysv/linux/hppa/kernel-features.h
	[__LINUX_KERNEL_VERSION >= 0x020622] (__ASSUME_ACCEPT4_SYSCALL):
	Define.
2014-02-20 17:50:31 +00:00
Andreas Schwab d668061994 Fix memory leak in _nss_dns_gethostbyname4_r with big DNS answer 2014-02-13 12:54:34 +01:00
Dylan Alex Simon fbfdf9cb03 Update x86_64 libm-test-ulps on AMD family 21h model 1 (bug 16545). 2014-02-12 15:55:10 +00:00
Andreas Krebbel 8fd7b0d559 NEWS: Add 16447 to fixed bugs list. 2014-02-12 09:33:43 +01:00
Joseph Myers c941736c92 Remove _BSD_SOURCE and _SVID_SOURCE.
This is a minimal patch to remove _BSD_SOURCE and _SVID_SOURCE from
the documented user API, making them into aliases for _DEFAULT_SOURCE
with a #warning given, but keeping most of the features.h logic using
those macros and all the exising __USE_* conditionals, on the basis
that all the consequent cleanups will go in followup patches.

Tested x86_64.

	* include/features.h: Update comment documenting feature test
	macros.
	[_BSD_SOURCE || _SVID_SOURCE]: Give #warning.  Define
	_DEFAULT_SOURCE.
	* manual/creature.texi (_BSD_SOURCE): Remove documentation.
	(_SVID_SOURCE): Likewise.
	(_DEFAULT_SOURCE): Update description of default features.
	(Feature Test Macros): Don't mention _SVID_SOURCE in conjunction
	with _GNU_SOURCE.
	* manual/filesys.texi (__ftw_func_t): Do not refer to _BSD_SOURCE.
	(S_ISVTX): Likewise.
	* manual/math.texi (Mathematical Constants): Likewise.
	* manual/signal.texi (Interrupted Primitives): Likewise.
	* manual/startup.texi (putenv): Do not refer to _SVID_SOURCE.
	* math/test-matherr.c (_SVID_SOURCE): Do not define.
	* sysvipc/sys/ipc.h [__USE_SVID && !__USE_XOPEN && __GNUC__ >= 2]:
	Don't refer to _SVID_SOURCE in warning text.
2014-02-11 23:40:07 +00:00
Ondřej Bílka f3d338c9f3 Deduplicate setenv.
Setenv contained a code path that was redundant as it could be handled
in general case.
2014-02-10 12:54:10 +01:00
Joseph Myers 464263cc00 Remove am33 port.
This patch removes the am33 port (no other port #includes any files
from it), as previously discussed (see
<https://sourceware.org/ml/libc-ports/2014-01/msg00046.html>).
2014-02-08 00:16:57 +00:00
Allan McRae d5b396c1c8 Open development for 2.20 2014-02-08 08:10:29 +10:00
Joseph Myers ed27ed836d Bug 15968 was fixed by commit 0748546f66. 2014-02-07 02:47:37 +00:00
Joseph Myers fd2f9486a1 Bug 6981 was fixed by commit 1484e65736. 2014-02-07 02:36:28 +00:00
Carlos O'Donell 3bfff2edbe BZ #16529: Fix pedantic warning with netinet/in.h.
When compiling with pedantic the following warning is seen:

gcc -Wall -pedantic -O0 -o test test.c
In file included from test.c:3:0:
/path/inet/netinet/in.h:111:21: warning: comma at end of \
enumerator list [-Wpedantic]
     IPPROTO_MH = 135,      /* IPv6 mobility header.  */
                     ^

It is valid C99 to have a trailing comma after the last item in
an enumeration. However it is not valid C90. If possible glibc
attempts to keep all headers C90 + long long without requiring
C99 features. In this case it's easy to fix the headers and it
removes the warning seem with -pedantic.
2014-02-06 11:18:51 -05:00
David Holsgrove dbe7af29a5 Revert "microblaze BZ #15705: Define MMAP2_PAGE_SHIFT"
This reverts commit 79b846ecc0.

Conflicts:

	NEWS
	ports/ChangeLog.microblaze

Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
2014-02-06 09:57:56 +10:00
Allan McRae f482dbbec7 Revert "BZ 16133 has been fixed (async signal safe TLS)."
This reverts commit a494421f52.

Conflicts:
	NEWS
2014-02-06 08:46:20 +10:00
David Holsgrove 79b846ecc0 microblaze BZ #15705: Define MMAP2_PAGE_SHIFT
Define MMAP2_PAGE_SHIFT to -1 for microblaze so the correct shift
for the syscall is determined dynamically using getpagesize

ports/ChangeLog.microblaze

 2014-02-04  David Holsgrove <david.holsgrove@xilinx.com>

   * sysdeps/unix/sysv/linux/microblaze/mmap64.c: New file.

Signed-off-by: David Holsgrove <david.holsgrove@xilinx.com>
2014-02-05 17:25:43 +10:00
Siddhesh Poyarekar 58c744fc40 Update NEWS for #16398 2014-02-05 12:50:22 +05:30
Alexandre Oliva 9f529d7cfa [BZ #12751]
* manual/memory.texi: Document MTASC-safety properties.
2014-01-31 23:28:38 -02:00
Maciej W. Rozycki 0d23a5c1b1 [BZ #16046] Static dlopen correction fallout fixes.
Fixes to address issues from BZ #15022 resolution, as follows:

* TLS updates to csu/libc-tls.c -- we now have a proper main map, so
  there's no longer a need to create a separate fake one to keep TLS
  structures,

* random updates to elf/dl-close.c -- LM_ID_BASE is now a valid name
  space ID for static executables as well, so assert that we don't
  unload the main map.  Similarly dl_nns isn't supposed to be 0 for
  static executables anymore,

* actual BZ #16046 fix to elf/dl-iteratephdr.c -- the dl_iterate_phdr
  special function for static executables isn't needed anymore, provided
  that l_phdr and l_phnum members of the main map have been properly
  initialized (done in _dl_non_dynamic_init in elf/dl-support.c now),

* ld.so.cache loader update to elf/dl-load.c --
  GL(dl_ns)[LM_ID_BASE]._ns_loaded is now always initialized in static
  executables so can become the fallback loader map to check for
  DF_1_NODEFLIB, provided that the l_flags_1 member of the main map has
  been properly initialized (done in elf/dl-support.c now); this also
  ensures previous semantics elsewhere in elf/dl-load.c,

* matching updates to elf/dl-support.c -- to complement the two fixes
  above.
2014-01-31 17:51:31 +00:00
H.J. Lu 409e00bd69 Disable x87 inline functions for SSE2 math
When i386 and x86-64 mathinline.h was merged into a single mathinline.h,
"gcc -m32" enables x87 inline functions on x86-64 even when -mfpmath=sse
and SSE2 is enabled.  It is a regression on x86-64.  We should check
__SSE2_MATH__ instead of __x86_64__ when disabling x87 inline functions.
2014-01-29 11:19:05 -08:00
Alexandre Oliva 0a57b83e4a * manual/macros.texi: Introduce macros to document multi
thread, asynchronous signal and asynchronous cancellation
safety properties.
* manual/intro.texi: Introduce the properties themselves.
2014-01-29 05:20:37 -02:00
Siddhesh Poyarekar 7329c17bcb Add bug entry for previous commit in NEWS 2014-01-27 17:08:54 +05:30
Siddhesh Poyarekar 5d41dadf31 Adjust pointers to triplets in netgroup query data (BZ #16474)
The _nss_*_getnetgrent_r query populates the netgroup results in the
allocated buffer and then sets the result triplet to point to strings
in the buffer.  This is a problem when the buffer is reallocated since
the pointers to the triplet strings are no longer valid.  The pointers
need to be adjusted so that they now point to strings in the
reallocated buffer.
2014-01-24 13:51:15 +05:30
Adhemerval Zanella d98720e07f PowerPC: Fix gettimeofday ifunc selection
The IFUNC selector for gettimeofday runs before _libc_vdso_platform_setup where
__vdso_gettimeofday is set. The selector then sets __gettimeofday (the internal
version used within GLIBC) to use the system call version instead of the vDSO one.
This patch changes the check if vDSO is available to get its value directly
instead of rely on __vdso_gettimeofday.

This patch changes it by getting the vDSO value directly.

It fixes BZ#16431.
2014-01-20 12:29:51 -06:00
Tom Tromey 3a3acb6afc [AArch64] BZ #16169 Add CFI directives to clone.S
[BZ #16169] Add CFI directives to the AArch64 clone.S implementation
and ensure that the FP in the child is zero'd in order to comply with
AAPCS.
2014-01-20 15:44:05 +00:00