]> sourceware.org Git - glibc.git/log
glibc.git
7 years agoRefactor float_t, double_t information into bits/flt-eval-method.h.
Joseph Myers [Thu, 24 Nov 2016 18:44:50 +0000 (18:44 +0000)]
Refactor float_t, double_t information into bits/flt-eval-method.h.

At present, definitions of float_t and double_t are split among many
bits/mathdef.h headers.

For all but three architectures, these types are float and double.
Furthermore, if you assume __FLT_EVAL_METHOD__ to be defined, that
provides a more generic way of determining the correct values of these
typedefs.  Defining these typedefs more generally based on
__FLT_EVAL_METHOD__ was previously proposed by Paul Eggert in
<https://sourceware.org/ml/libc-alpha/2012-02/msg00002.html>.

This patch refactors things in the way I proposed in
<https://sourceware.org/ml/libc-alpha/2016-11/msg00745.html>.  A new
header bits/flt-eval-method.h defines a single macro,
__GLIBC_FLT_EVAL_METHOD, which is then used by math.h to define
float_t and double_t.  The default is based on __FLT_EVAL_METHOD__
(although actually a default to 0 would have the same effect for
current ports, because ports where values other than 0 or 16 are
possible all have their own headers).

To avoid changing the existing semantics in any case, including for
compilers not defining __FLT_EVAL_METHOD__, architecture-specific
files are then added for m68k, s390, x86 which replicate the existing
semantics.  At least with __FLT_EVAL_METHOD__ values possible with
GCC, there should be no change to the choices of float_t and double_t
for any supported configuration.

Architecture maintainer notes:

* m68k: sysdeps/m68k/m680x0/bits/flt-eval-method.h always defines
  __GLIBC_FLT_EVAL_METHOD to 2 to replicate the existing logic.  But
  actually GCC defines __FLT_EVAL_METHOD__ to 0 if TARGET_68040.  It
  might make sense to make the header prefer to base things on
  __FLT_EVAL_METHOD__ if defined, like the x86 version, and so make
  the choices of these types more accurate (with a NEWS entry as for
  the other changes to these types on particular architectures).

* s390: sysdeps/s390/bits/flt-eval-method.h always defines
  __GLIBC_FLT_EVAL_METHOD to 1 to replicate the existing logic.  As
  previously discussed, it might make sense in coordination with GCC
  to eliminate the historic mistake, avoid excess precision in the
  -fexcess-precision=standard case and make the typedefs match (with a
  NEWS entry, again).

Tested for x86-64 and x86.  Also did compilation-only testing with
build-many-glibcs.py.

* bits/flt-eval-method.h: New file.
* sysdeps/m68k/m680x0/bits/flt-eval-method.h: Likewise.
* sysdeps/s390/bits/flt-eval-method.h: Likewise.
* sysdeps/x86/bits/flt-eval-method.h: Likewise.
* math/Makefile (headers): Add bits/flt-eval-method.h.
* math/math.h: Include <bits/flt-eval-method.h>.
[__USE_ISOC99] (float_t): Define based on __GLIBC_FLT_EVAL_METHOD.
[__USE_ISOC99] (double_t): Likewise.
* bits/mathdef.h (float_t): Remove.
(double_t): Likewise.
* sysdeps/aarch64/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/alpha/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/arm/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/hppa/fpu/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/ia64/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/m68k/m680x0/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/mips/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/powerpc/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/s390/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/sh/sh4/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/sparc/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/tile/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.
* sysdeps/x86/bits/mathdef.h (float_t): Likewise.
(double_t): Likewise.

7 years agox86_64: fix static build of __memcpy_chk for compilers defaulting to PIC/PIE
Aurelien Jarno [Thu, 24 Nov 2016 11:10:13 +0000 (12:10 +0100)]
x86_64: fix static build of __memcpy_chk for compilers defaulting to PIC/PIE

When glibc is compiled with gcc 6.2 that has been configured with
to default to PIC/PIE, the static version of __memcpy_chk is not built,
as the test is done on PIC instead of SHARED. Fix the test to check for
SHARED, like it is done for similar functions like memmove_chk.

Changelog:
* sysdeps/x86_64/memcpy_chk.S (__memcpy_chk): Check for SHARED
instead of PIC.

7 years agoMore NEWS entries / fixes for float_t / double_t changes.
Joseph Myers [Wed, 23 Nov 2016 21:30:04 +0000 (21:30 +0000)]
More NEWS entries / fixes for float_t / double_t changes.

Document changes for x86_64 -mfpmath=sse and -mfpmath=sse+387.  Don't
put these NEWS entries in the middle of TS 18661-1 entries.

7 years agoFix SH4 FP_ILOGB0 (bug 20859).
Joseph Myers [Wed, 23 Nov 2016 21:23:12 +0000 (21:23 +0000)]
Fix SH4 FP_ILOGB0 (bug 20859).

ISO C requires that the value of FP_ILOGB0 must be INT_MIN or
-INT_MAX.  In sysdeps/sh/sh4/bits/mathdef.h, it's 0x80000001; that is,
a positive unsigned value that would be -INT_MAX if converted to int,
which is not valid (there's no actual constraint on the type, but
whatever the type the integer value must be one of the two permitted,
and types other than int don't really make sense).  This patch makes
the ABI-compatible change to (-0x7fffffff).

(The testcase handles positive and negative sign separately to avoid
any issues with implicit conversions that could result in e.g. INT_MIN
converted to uintmax_t wrongly passing.)

Tested (compilation only) with build-many-glibcs.py.

[BZ #20859]
* sysdeps/sh/sh4/bits/mathdef.h (FP_ILOGB0): Define to
(-0x7fffffff) instead of 0x80000001.
* math/test-fp-ilogb-constants.c: New file.
* math/Makefile (tests): Add test-fp-ilogb-constants.

7 years agoMIPS: Use R_MICROMIPS_JALR rather than R_MIPS_JALR in microMIPS code
Maciej W. Rozycki [Wed, 23 Nov 2016 12:39:39 +0000 (12:39 +0000)]
MIPS: Use R_MICROMIPS_JALR rather than R_MIPS_JALR in microMIPS code

In a microMIPS compilation of `.init' code use the R_MICROMIPS_JALR
relocation intended for PIC call relaxation in microMIPS code rather
than the corresponding R_MIPS_JALR relocation meant for regular MIPS
code only.

* sysdeps/mips/mips32/crti.S (JALR_RELOC): New macro.
(_init): Use it in place of hardcoded R_MIPS_JALR.
* sysdeps/mips/mips64/n32/crti.S (JALR_RELOC): New macro.
(_init): Use it in place of hardcoded R_MIPS_JALR.
* sysdeps/mips/mips64/n64/crti.S (JALR_RELOC): New macro.
(_init): Use it in place of hardcoded R_MIPS_JALR.

7 years agoFix x86_64 -mfpmath=387 float_t, double_t (bug 20787).
Joseph Myers [Wed, 23 Nov 2016 17:56:31 +0000 (17:56 +0000)]
Fix x86_64 -mfpmath=387 float_t, double_t (bug 20787).

Bug 20787 reports that, while float_t and double_t for 32-bit x86
properly respect -mfpmath=sse, for x86_64 they fail to reflect
-mfpmath=387, which is valid if unusual and results in FLT_EVAL_METHOD
being 2.  This patch fixes the definitions to respect
__FLT_EVAL_METHOD__ in that case, arranging for the test that the
types correspond with FLT_EVAL_METHOD to be run with both -mfpmath=387
and -mfpmath=sse.

Note: this patch will also have the effect of making float_t and
double_t be long double for x86_64 with -mfpmath=sse+387, when
FLT_EVAL_METHOD is -1.  It seems reasonable for x86_64 to be
consistent with 32-bit x86 in this case (and that definition is
conservatively safe, in that it makes the types correspond to the
widest evaluation format that might be used).

Tested for x86-64 and x86.

[BZ #20787]
* sysdeps/x86/bits/mathdef.h (float_t): Do not define to float if
[__x86_64__] when __FLT_EVAL_METHOD__ is nonzero.
(double_t): Do not define to double if [__x86_64__] when
__FLT_EVAL_METHOD__ is nonzero.
* sysdeps/x86/fpu/test-flt-eval-method-387.c: New file.
* sysdeps/x86/fpu/test-flt-eval-method-sse.c: Likewise.
* sysdeps/x86/fpu/Makefile [$(subdir) = math] (tests): Add
test-flt-eval-method-387 and test-flt-eval-method-sse.
[$(subdir) = math] (CFLAGS-test-flt-eval-method-387.c): New
variable.
[$(subdir) = math] (CFLAGS-test-flt-eval-method-sse.c): Likewise.

7 years agobuild-many-glibcs: Revert -fno-isolate-erroneous-paths options for tilepro
Chris Metcalf [Wed, 23 Nov 2016 17:25:23 +0000 (12:25 -0500)]
build-many-glibcs: Revert -fno-isolate-erroneous-paths options for tilepro

TILEPro now has a __builtin_trap instruction in gcc tip and gcc 6.

7 years agoelf: Assume TLS is initialized in _dl_map_object_from_fd
Florian Weimer [Wed, 23 Nov 2016 12:12:03 +0000 (13:12 +0100)]
elf: Assume TLS is initialized in _dl_map_object_from_fd

libc.so uses TLS data, so when dlopen is called later, the
TLS data structures have already been initialized.

7 years agoFix default float_t definition (bug 20855).
Joseph Myers [Wed, 23 Nov 2016 00:28:30 +0000 (00:28 +0000)]
Fix default float_t definition (bug 20855).

The default (top-level) version of bits/mathdef.h defines float_t to
double.  It is used on ColdFire, MicroBlaze, Nios II and SH3, all of
which define FLT_EVAL_METHOD to 0, so float_t should be float (and C11
requires a certain correspondence between these typedefs and
FLT_EVAL_METHOD values).

I proposed fixing this default in
<https://sourceware.org/ml/libc-alpha/2015-01/msg00499.html>, with no
objections from architecture maintainers, and this patch makes that
fix.  As noted in the NEWS entry added, this might affect the ABIs of
non-glibc libraries (ImageMagick has been mentioned in gcc-patches
discussion of the S/390 case - which is unaffected by this patch), but
as noted in my previous message, affected libraries would have
problems with -mfpmath=sse anyway on 32-bit x86.

A (compilation) testcase is added to verify the required
correspondence of typedefs to FLT_EVAL_METHOD values.  This test is
built with -fexcess-precision=standard to avoid any issues with GCC 7
on S/390 providing a more accurate FLT_EVAL_METHOD definition in the
default (no excess precision) mode.  (This will also be usable to test
a fix for the recently reported bug about these typedefs on x86_64
-mfpmath=387, as architecture-specific tests can be added that

It is entirely possible that the fixed default makes some
architecture-specific versions of bits/mathdef.h semantically
equivalent to the default version and so no longer required.  I don't
intend to investigate that separately from the refactoring I proposed
in <https://sourceware.org/ml/libc-alpha/2016-11/msg00745.html>, which
will create as few header variants as possible for each group of
definitions.

Tested (compilation only) with build-many-glibcs.py.

[BZ #20855]
* bits/mathdef.h (float_t): Define to float.
* math/test-flt-eval-method.c: New file.
* math/Makefile (tests): Add test-flt-eval-method.
(CFLAGS-test-flt-eval-method.c): New variable.

7 years agoAllow [f]statfs64 to alias [f]statfs
Steve Ellcey [Tue, 22 Nov 2016 17:59:12 +0000 (09:59 -0800)]
Allow [f]statfs64 to alias [f]statfs

* sysdeps/unix/sysv/linux/fstatfs64.c: Hide prototypes for fstatfs
and __fstatfs.  Make them aliases of __fstatfs64 if
STATFS_IS_STATFS64 is set to non-zero.
* sysdeps/unix/sysv/linux/statfs64.c: Ditto for __statfs, statfs,
and __statfs64.
* sysdeps/unix/sysv/linux/generic/wordsize-32/fstatfs.c: Do not
define __fstatfs and fstatfs if STATFS_IS_STATFS64 is non-zero.
* sysdeps/unix/sysv/linux/generic/wordsize-32/statfs.c: Ditto
for __statfs and statfs.
* sysdeps/unix/sysv/linux/alpha/kernel_stat.h: Set STATFS_IS_STATFS64
to 0.
* sysdeps/unix/sysv/linux/generic/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/hppa/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/ia64/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/microblaze/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/mips/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/s390/s390-64/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/sparc/sparc64/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/x86_64/kernel_stat.h: Ditto.

7 years agoFix multiple definitions of mk[o]stemp[s]64
Andreas Schwab [Tue, 22 Nov 2016 10:56:08 +0000 (11:56 +0100)]
Fix multiple definitions of mk[o]stemp[s]64

7 years agoFix writes past the allocated array bounds in execvpe (BZ#20847)
Adhemerval Zanella [Mon, 21 Nov 2016 13:06:15 +0000 (11:06 -0200)]
Fix writes past the allocated array bounds in execvpe (BZ#20847)

This patch fixes an invalid write out or stack allocated buffer in
2 places at execvpe implementation:

  1. On 'maybe_script_execute' function where it allocates the new
     argument list and it does not account that a minimum of argc
     plus 3 elements (default shell path, script name, arguments,
     and ending null pointer) should be considered.  The straightforward
     fix is just to take account of the correct list size on argument
     copy.

  2. On '__execvpe' where the executable file name lenght may not
     account for ending '\0' and thus subsequent path creation may
     write past array bounds because it requires to add the terminating
     null.  The fix is to change how to calculate the executable name
     size to add the final '\0' and adjust the rest of the code
     accordingly.

As described in GCC bug report 78433 [1], these issues were masked off by
GCC because it allocated several bytes more than necessary so that many
off-by-one bugs went unnoticed.

Checked on x86_64 with a latest GCC (7.0.0 20161121) with -O3 on CFLAGS.

[BZ #20847]
* posix/execvpe.c (maybe_script_execute): Remove write past allocated
array bounds.
(__execvpe): Likewise.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78433

7 years agoMake build-many-glibcs.py use -fno-isolate-erroneous-paths options for tilepro.
Joseph Myers [Tue, 22 Nov 2016 01:58:26 +0000 (01:58 +0000)]
Make build-many-glibcs.py use -fno-isolate-erroneous-paths options for tilepro.

My most recent build-many-glibcs.py build with GCC mainline showed
build failures for tilepro with the symptoms (multiple definitions of
symbols building ld.so, see the build log referenced in the GCC bug
referenced in the comment for an example) that correspond to the
isolate-erroneous-paths optimization not being suitable for building
glibc unless the GCC port provides a trap pattern (so __builtin_trap
expands to an inline instruction rather than a call to abort).  Since
tilepro indeed lacks such as pattern in GCC, this patch duly arranges
for this optimization to be disabled when building for tilepro, as it
is for sh.

Tested (compilation only) for tilepro.

* scripts/build-many-glibcs.py (Context.add_all_configs): Also use
-fno-isolate-erroneous-paths options for tilepro.

7 years agoAlways define XSTAT_IS_XSTAT64
Steve Ellcey [Mon, 21 Nov 2016 16:23:12 +0000 (08:23 -0800)]
Always define XSTAT_IS_XSTAT64

* sysdeps/unix/sysv/linux/generic/kernel_stat.h: Set XSTAT_IS_XSTAT64
to 0 when in 32 bit mode.
* sysdeps/unix/sysv/linux/hppa/kernel_stat.h: Set XSTAT_IS_XSTAT64 to 0.
* sysdeps/unix/sysv/linux/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/microblaze/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/mips/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/sparc/sparc32/kernel_stat.h: Ditto.
* sysdeps/unix/sysv/linux/fxstat.c: Replace #ifdef with #if on
XSTAT_IS_XSTAT64 test.
* sysdeps/unix/sysv/linux/fxstatat.c: Ditto.
* sysdeps/unix/sysv/linux/generic/lxstat.c: Ditto.
* sysdeps/unix/sysv/linux/generic/xstat.c: Ditto.
* sysdeps/unix/sysv/linux/i386/fxstat.c: Ditto.
* sysdeps/unix/sysv/linux/i386/fxstatat.c: Ditto.
* sysdeps/unix/sysv/linux/i386/lxstat.c: Ditto.
* sysdeps/unix/sysv/linux/i386/xstat.c: Ditto.
* sysdeps/unix/sysv/linux/lxstat.c: Ditto.
* sysdeps/unix/sysv/linux/mips/xstatconv.c: Ditto.
* sysdeps/unix/sysv/linux/xstat.c: Ditto.
* sysdeps/unix/sysv/linux/xstatconv.c: Ditto.

7 years agoAdd setpayload, setpayloadf, setpayloadl.
Joseph Myers [Sat, 19 Nov 2016 00:16:28 +0000 (00:16 +0000)]
Add setpayload, setpayloadf, setpayloadl.

TS 18661-1 defines functions for manipulating the payloads of NaNs.
This patch implements the setpayload functions for glibc; these set a
number (pointed to by a function argument) to a quiet NaN with the
given payload, or to +0 if the given payload is not valid.  The
implementations are structured to allow the substance of the
implementation to be shared with the setpayloadsig functions when
those are added.

The semantics in the TS are not entirely clear in the case where the
payload passed to the function is zero (see discussion on the WG14
reflector last month).  This patch implements what seems the most
sensible interpretation, that -0 is never valid to give as the
payload, but +0 is valid in the case where the kind of NaN being
generated has its high mantissa bit set so payload 0 is actually
possible in such a NaN.

Tested for x86_64, x86, mips64 and powerpc.

* math/bits/mathcalls.h [__GLIBC_USE (IEC_60559_BFP_EXT)]
(setpayload): New declaration.
* math/Versions (setpayload): New libm symbol at version
GLIBC_2.25.
(setpayloadf): Likewise.
(setpayloadl): Likewise.
* math/Makefile (libm-calls): Add s_setpayloadF.
* math/libm-test.inc (struct test_Ffp_b1_data): Rename to struct
test_Ff_b1_data.
(RUN_TEST_Ff_b1): New macro.
(RUN_TEST_LOOP_Ff_b1): Likewise.
(canonicalize_test_data): Update type.
(setpayload_test_data): New array.
(setpayload_test): New function.
(main): Call setpayload_test.
* manual/arith.texi (FP Bit Twiddling): Document setpayload,
setpayloadf and setpayloadl.
* manual/libm-err-tab.pl: Update comment on interfaces without
ulps tabulated.
* sysdeps/ieee754/dbl-64/s_setpayload.c: New file.
* sysdeps/ieee754/dbl-64/s_setpayload_main.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_setpayload_main.c:
Likewise.
* sysdeps/ieee754/flt-32/s_setpayloadf.c: Likewise.
* sysdeps/ieee754/flt-32/s_setpayloadf_main.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_setpayloadl.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_setpayloadl_main.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_setpayloadl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_setpayloadl_main.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_setpayloadl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_setpayloadl_main.c: Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-setpayload.c: Likewise.
* sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add
setpayload.
(CFLAGS-nldbl-setpayload.c): New variable.
* sysdeps/nacl/libm.abilist: Update.
* sysdeps/unix/sysv/linux/aarch64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/alpha/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/arm/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm-le.abilist:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libm.abilist:
Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libm.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist: Likewise.

7 years agoFix hurd __access_noerrno implementation.
Adhemerval Zanella [Fri, 18 Nov 2016 18:41:00 +0000 (16:41 -0200)]
Fix hurd __access_noerrno implementation.

This patch fixes some hurd bits from commit afcf3cd8eb that added the
__access_noerrno internal symbol.  It basically removes the nonrequired
__hurd_fail_noerrno (since the 'err' argument is ignored) and fixes
a typo for EACCES.

However, as stated on maillist [1] this __access_noerrno may still be
unsafe to run during initialization of tunables on the Hurd.  The
access_common calls __hurd_file_name_lookup, which calls
__hurd_file_name_lookup_retry, which can set errno.

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

7 years agotile: create new math-tests.h header
Chris Metcalf [Wed, 16 Nov 2016 15:09:50 +0000 (10:09 -0500)]
tile: create new math-tests.h header

The header makes tile use the new mechanisms for suppressing
exception and rounding support (the ROUNDING_TESTS_xxx() and
EXCEPTION_TESTS_xxx macros).

More importantly, it also now sets SNAN_TESTS_PRESERVE_PAYLOAD to 0,
since the tilegx fp hardware does not preserve NaN payloads.

7 years agoMake tile's set_dataplane API compatibility-only
Chris Metcalf [Mon, 14 Nov 2016 16:41:38 +0000 (11:41 -0500)]
Make tile's set_dataplane API compatibility-only

The set_dataplane() API in <sys/dataplane.h> originally supported the
Tilera version of Linux as shipped to our customers.  Once we started
upstreaming the dataplane support in the kernel, the API changed
to use fcntl() as part of the current task-isolation patch series.

It doesn't seem like continuing to support the old API is useful
for newly-compiled code, and even supporting the old glibc binary
API on an upstream kernel that supports the new task isolation mode
isn't straightforward, since the semantics have changed in ways that
make it hard to map the old semantics precisely to the new ones,
so just return ENOSYS.

7 years agoQuote shell commands in logs from build-many-glibcs.py.
Joseph Myers [Fri, 18 Nov 2016 18:22:09 +0000 (18:22 +0000)]
Quote shell commands in logs from build-many-glibcs.py.

As requested in
<https://sourceware.org/ml/libc-alpha/2016-11/msg00664.html>, this
patch makes the commands recorded in build-many-glibcs.py quote words
so they can be cut-and-pasted back into a shell.  (Note that these
logs are generated by the wrapper script generated to run commands
with logs, hence the needs for quoting logic to be implemented in that
shell script.)

* scripts/build-many-glibcs.py (Context.write_files): Make wrapper
script quote words in command output to log suitably for input to
the shell.

7 years agoMIPS: Add `.insn' to ensure a text label is defined as code not data
Maciej W. Rozycki [Thu, 17 Nov 2016 19:15:51 +0000 (19:15 +0000)]
MIPS: Add `.insn' to ensure a text label is defined as code not data

Avoid a build error with microMIPS compilation and recent versions of
GAS which complain if a branch targets a label which is marked as data
rather than microMIPS code:

../sysdeps/mips/mips32/crti.S: Assembler messages:
../sysdeps/mips/mips32/crti.S:72: Error: branch to a symbol in another ISA mode
make[2]: *** [.../csu/crti.o] Error 1

as commit 9d862524f6ae ("MIPS: Verify the ISA mode and alignment of
branch and jump targets") closed a hole in branch processing, making
relocation calculation respect the ISA mode of the symbol referred.
This allowed diagnosing the situation where an attempt is made to pass
control from code assembled for one ISA mode to code assembled for a
different ISA mode and either relaxing the branch to a cross-mode jump
or if that is not possible, then reporting this as an error rather than
letting such code build and then fail unpredictably at the run time.

This however requires the correct annotation of branch targets as code,
because the ISA mode is not relevant for data symbols and is therefore
not recorded for them.  The `.insn' pseudo-op is used for this purpose
and has been supported by GAS since:

Wed Feb 12 14:36:29 1997  Ian Lance Taylor  <ian@cygnus.com>

* config/tc-mips.c (mips_pseudo_table): Add "insn".
(s_insn): New static function.
* doc/c-mips.texi: Document .insn.

so there has been no reason to avoid it where required.  More recently
this pseudo-op has been documented, by the microMIPS architecture
specification[1][2], as required for the correct interpretation of any
code label which is not followed by an actual instruction in an assembly
source.

Use it in our crti.S files then, to mark that the trailing label there
with no instructions following is indeed not a code bug and the branch
is legitimate.

References:

[1] "MIPS Architecture for Programmers, Volume II-B: The microMIPS32
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00582,
    Revision 5.04, January 15, 2014, Section 7.1 "Assembly-Level
    Compatibility", p. 533

[2] "MIPS Architecture for Programmers, Volume II-B: The microMIPS64
    Instruction Set", MIPS Technologies, Inc., Document Number: MD00594,
    Revision 5.04, January 15, 2014, Section 8.1 "Assembly-Level
    Compatibility", p. 623

2016-11-18  Matthew Fortune  <Matthew.Fortune@imgtec.com>
            Maciej W. Rozycki  <macro@imgtec.com>

* sysdeps/mips/mips32/crti.S (_init): Add `.insn' pseudo-op at
`.Lno_weak_fn' label.
* sysdeps/mips/mips64/n32/crti.S (_init): Likewise.
* sysdeps/mips/mips64/n64/crti.S (_init): Likewise.

7 years agoConsolidate Linux setrlimit and getrlimit implementation
Adhemerval Zanella [Tue, 18 Oct 2016 11:41:56 +0000 (09:41 -0200)]
Consolidate Linux setrlimit and getrlimit implementation

This patch consolidates all Linux setrlimit and getrlimit on the default
sysdeps/unix/sysv/linux/{set,get}rlimit{64}.c.  It contains two exceptions:

  1. mips32 and mips64n32 which requires a versioned symbol for GLIBC 2.19
     and higher due a broken RLIM64_INFINITY constant.
  2. sparc32 does not define a compat symbol for getrlimit64 for old 2GB
     limit. I am not sure if it is required, but a RLIM_INFINITY fix [1]
     change its definition without adding a compat symbol.  This patch does
     not aim to address this possible issue, it follow current symbol
     export.

The default implementation uses prlimit64 for 64 bit rlim_t ({set,get}rlimit64)
and if it fails with ENOSYS it fall back to {get,set}rlimit syscall.  This
code path is only used on kernel older than 2.6.36 (basically now only x86)
and I avoid to user __ASSUME_PRLIMTI64 to simplify the implementation.  Once
x86 moves to be on par with other architectures regarding minimum kernel
supported we can get rid of using old syscalls and default path.

A new type size define is added, __RLIM_T_MATCHES_RLIM64_T, where is set as
default for 64 bits ports.  This allows the default implementation to avoid
{get,set}rlimit building and alias {get,set}rlimit64 to {get,set}rlimit.

Checked on x86_64, i386, armhf, aarch64, and powerpc64le.  I also did a
sanity build plus check-abi on all other supported architectures.

[1] Commit 9c96ff23858b0759e12ad69e3c4599931c90bee8

Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Yury Norov  <ynorov@caviumnetworks.com>

* bits/typesizes.h (__RLIM_T_MATCHES_RLIM64_T): define.
* sysdeps/unix/sysv/linux/alpha/bits/typesizes.h
(__RLIM_T_MATCHES_RLIM64_T): Likewise.
* sysdeps/unix/sysv/linux/generic/bits/typesizes.h
(__RLIM_T_MATCHES_RLIM64_T): Likewise.
* sysdeps/unix/sysv/linux/s390/bits/typesizes.h [__s390x__]
(__RLIM_T_MATCHES_RLIM64_T): Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/typesizes.h
[__arch64__ || __sparcv9] (__RLIM_T_MATCHES_RLIM64_T): Likewise.
* sysdeps/unix/sysv/linux/x86/bits/typesizes.h [__86_64__]
(__RLIM_T_MATCHES_RLIM64_T): Likewise.
* sysdeps/unix/sysv/linux/arm/Makefile [$(subdir) = resource]
(sysdep_routines): Remove oldgetrlimit64.
* sysdeps/unix/sysv/linux/i386/Makefile [$(subdir) = resource]
(sysdep_routines): Likewise.
* sysdeps/unix/sysv/linux/m68k/Makefile [$(subdir) = resource]
(sysdep_routines): Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/Makefile
[$(subdir) = resource] (sysdep_routines): Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/Makefile
[$(subdir) = resource] (sysdep_routines): Likewise.
* sysdeps/unix/sysv/linux/arm/getrlimit64.c: Remove file.
* sysdeps/unix/sysv/linux/arm/oldgetrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/hppa/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/i386/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/i386/oldgetrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/m68k/oldgetrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/oldgetrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/oldgetrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/sh/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/setrlimit64.c: Likewise.
* sysdeps/sysv/linux/generic/wordsize-32/syscalls.list: Remove
setrlimit and getrlimit.
* sysdeps/unix/sysv/linux/hppa/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/i386/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Likewise.
* sysdeps/unix/sysv/linux/getrlimit.c: New file.
* sysdeps/unix/sysv/linux/sparc/getrlimit64.c: Likewise.
* sysdeps/unix/sysv/linux/setrlimit.c: Likewise.
* sysdeps/unix/sysv/linux/getrlimit64.c (__getrlimit64): Handle
__RLIM_T_MATCHES_RLIM64_T and add alias if defined.
(__old_getrlimit64): Add compatibility symbol.
* sysdeps/unix/sysv/linux/setrlimit64.c (__setrlimit): Likewise.

7 years agoActually use newly built host libraries in build-many-glibcs.py.
Joseph Myers [Thu, 17 Nov 2016 17:45:41 +0000 (17:45 +0000)]
Actually use newly built host libraries in build-many-glibcs.py.

This patch adds the missing GCC configure options required to make use
of the newly built host libraries in build-many-glibcs.py.

* scripts/build-many-glibcs.py (Config.build_gcc): Configure with
newly built gmp, mpfr and mpc.

7 years agoMake Alpha <sys/user.h> self-contained.
Joseph Myers [Thu, 17 Nov 2016 14:15:03 +0000 (14:15 +0000)]
Make Alpha <sys/user.h> self-contained.

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

Tested for Alpha (compilation only).

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

7 years agoEnable linknamespace testing for libdl and libcrypt.
Joseph Myers [Wed, 16 Nov 2016 22:47:57 +0000 (22:47 +0000)]
Enable linknamespace testing for libdl and libcrypt.

When I set up linknamespace testing, the lists of libraries that might
contain functions from various standards were based on the -l options
POSIX says may be required to find certain functions with the c99
utility.

glibc has some POSIX functions in the libdl and libcrypt libraries,
not mentioned in the definition of the c99 utility (so an
implementation of that utility using glibc would need to use -ldl
-lcrypt automatically).  This patch adds those libraries to the ones
considered in linknamespace testing for relevant standards.  (The
crypt functions are XSI only, present in XPG3 and above; the libdl
ones were added in UNIX98, then moved from XSI to BASE in the 2008
edition of POSIX.)

* conform/Makefile (linknamespace-libs): Rename to
linknamespace-libs-thr.
(linknamespace-libs-posix): New variable.
(linknamespace-libs-xsi): Likewise.
(linknamespace-libs-XPG3): Include libcrypt.a.
(linknamespace-libs-XPG4): Use $(linknamespace-libs-XPG3).
(linknamespace-libs-POSIX): Use $(linknamespace-libs-thr).
(linknamespace-libs-UNIX98): Use $(linknamespace-libs-xsi).
(linknamespace-libs-XOPEN2K): Likewise.
(linknamespace-libs-XOPEN2K8): Likewise.
(linknamespace-libs-POSIX2008): Use $(linknamespace-libs-posix).

7 years agoFix crypt snprintf namespace (bug 20829).
Joseph Myers [Wed, 16 Nov 2016 22:46:48 +0000 (22:46 +0000)]
Fix crypt snprintf namespace (bug 20829).

Extending linknamespace tests to cover libcrypt showed that crypt
brings in references to snprintf, but is in XPG3 and XPG4 which don't
have snprintf.  This patch fixes it to use __snprintf instead,
exporting __snprintf from libc.so at version GLIBC_PRIVATE and adding
libc_hidden_proto / libc_hidden_def accordingly.

Tested for x86_64 and x86, in conjunction with the testsuite changes
to enable linknamespace testing for libdl and libcrypt.  Also tested
(compilation only) for powerpc to make sure there were no problem
interactions with the optional-long-double handling for snprintf.

[BZ #20829]
* stdio-common/Versions (__snprintf): Add to version
GLIBC_PRIVATE.
* include/stdio.h (__snprintf): Use libc_hidden_proto.
* stdio-common/snprintf.c (__snprintf): Use libc_hidden_def.
* crypt/sha256-crypt.c (__sha256_crypt_r): Use __snprintf instead
of snprintf.
* crypt/sha512-crypt.c (__sha512_crypt_r): Likewise.

7 years agoCorrect comments in string.h re strcoll_l, strxfrm_l.
Zack Weinberg [Wed, 16 Nov 2016 19:18:32 +0000 (14:18 -0500)]
Correct comments in string.h re strcoll_l, strxfrm_l.

* string/string.h: Remove obsolete comment stating that
strcoll_l and strxfrm_l have not yet been standardized.

7 years agoNew internal function __access_noerrno
Adhemerval Zanella [Thu, 10 Nov 2016 11:28:00 +0000 (09:28 -0200)]
New internal function __access_noerrno

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

Checked on x86_64.

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

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

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

Tested (compilation only) for SH4 soft-float.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

You call the script as

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Tested for SH3 and SH4 (compilation only).

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

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

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

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

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

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

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

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

Tested for x86_64, x86, mips64 and powerpc.

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

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

Since 327792c sh4 builds fails with:

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

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

Tested on a sh4-linux-gnu build.

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

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

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

Checked on x86_64.

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

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

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

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

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

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

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

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

Tested on x86_64, i386, aarch64, and armhf.

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

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

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

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

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

Tested on x86_64, i386, aarch64, and armhf.

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

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

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

Building with GCC 7 produces an error building rpcgen:

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

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

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

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

Tested for x86_64 and x86.

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

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

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

Tested for sh3 and sh4.

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

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

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

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

are no longer needed.

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

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

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

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

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

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

Tested for alpha.

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

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

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

Tested for nios2.

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

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

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

The general idea is:

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

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

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

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

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

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

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

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

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

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

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

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

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

Tested for powerpc64le.

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

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

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

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

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

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

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

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

* test-skeleton.c: Document do_test usage.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Tested for Alpha (compilation only).

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

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

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

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

Tested for x86_64.

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

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

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

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

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

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

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

Tested for MIPS (all 24 ABIs).

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

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

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

Tested for MIPS (all 24 ABIs).

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Tested for x86_64.

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

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

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

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

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

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

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

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

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

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

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

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

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

Tested for powerpc64le.

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

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

Tested for x86_64 and x86.

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

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

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

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

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

Tested on powerpc64.

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

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

These functions are externally visible with a static libcrypt
library.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Tested for x86_64, x86 and powerpc.

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

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

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

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