Commit Graph

1241 Commits

Author SHA1 Message Date
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