platform/upstream/glibc.git
5 years agohurd: Document dtable_cloexec size convention.
Samuel Thibault [Sun, 11 Nov 2018 17:55:24 +0000 (18:55 +0100)]
hurd: Document dtable_cloexec size convention.

* sysdeps/mach/hurd/spawni.c (__spawni): Use orig_dtablesize instead
of dtablesize for allocating dtable_cloexec.

5 years agoHurd: export _hurd_port_move
Samuel Thibault [Sat, 10 Nov 2018 11:33:12 +0000 (11:33 +0000)]
Hurd: export _hurd_port_move

* hurd/Versions (_hurd_port_move): Export function.
* sysdeps/mach/hurd/i386/libc.abilist (_hurd_port_move): Expect
symbol.

5 years agoHurd: Fix ulinks in fd table reallocation
Samuel Thibault [Sat, 10 Nov 2018 11:20:12 +0000 (11:20 +0000)]
Hurd: Fix ulinks in fd table reallocation

* hurd/hurd/userlink.h (_hurd_userlink_move): New function.
* hurd/hurd/port.h (_hurd_port_move): New function.
* sysdeps/mach/hurd/spawni.c (NEW_ULINK_TABLE): New macro.
(EXPAND_DTABLE): Use NEW_ULINK_TABLE macro for ulink_dtable.

5 years agoHurd: Implement chdir support in posix_spawn
Samuel Thibault [Wed, 7 Nov 2018 11:37:05 +0000 (12:37 +0100)]
Hurd: Implement chdir support in posix_spawn

This fixes build-many-glibcs.py on i686-gnu.

Thanks Florian Weimer for the initial version.

* sysdeps/mach/hurd/spawni.c (__spawni): Add ccwdir port. Test and use
it, free it if needed.
(reauthenticate): Test and use ccwdir.
(child_init_port): In non-resetids case, test and use ccwdir.
(child_chdir): New nested function to set ccwdir.

5 years agoAdd support for GCC 9 attribute copy.
Martin Sebor [Sat, 10 Nov 2018 00:24:12 +0000 (17:24 -0700)]
Add support for GCC 9 attribute copy.

GCC 9 has gained an enhancement to help detect attribute mismatches
between alias declarations and their targets.  It consists of a new
warning, -Wattribute-alias, an enhancement to an existing warning,
-Wmissing-attributes, and a new attribute called copy.

The purpose of the warnings is to help identify either possible bugs
(an alias declared with more restrictive attributes than its target
promises) or optimization or diagnostic opportunities (an alias target
missing some attributes that it could be declared with that might
benefit analysis and code generation).  The purpose of the new
attribute is to easily apply (almost) the same set of attributes
to one declaration as those already present on another.

As expected (and intended) the enhancement triggers warnings for
many alias declarations in Glibc code.  This change, tested on
x86_64-linux, avoids all instances of the new warnings by making
use of the attribute where appropriate.  To fully benefit from
the enhancement Glibc will need to be compiled with
 -Wattribute-alias=2 and remaining warnings reviewed and dealt with
(there are a couple of thousand but most should be straightforward
to deal with).

ChangeLog:

* include/libc-symbols.h (__attribute_copy__): Define macro unless
it's already defined.
(_strong_alias): Use __attribute_copy__.
(_weak_alias,  __hidden_ver1,  __hidden_nolink2): Same.
* misc/sys/cdefs.h (__attribute_copy__): New macro.
* sysdeps/x86_64/multiarch/memchr.c (memchr): Use __attribute_copy__.
* sysdeps/x86_64/multiarch/memcmp.c (memcmp): Same.
* sysdeps/x86_64/multiarch/mempcpy.c (mempcpy): Same.
* sysdeps/x86_64/multiarch/memset.c (memset): Same.
* sysdeps/x86_64/multiarch/stpcpy.c (stpcpy): Same.
* sysdeps/x86_64/multiarch/strcat.c (strcat): Same.
* sysdeps/x86_64/multiarch/strchr.c (strchr): Same.
* sysdeps/x86_64/multiarch/strcmp.c (strcmp): Same.
* sysdeps/x86_64/multiarch/strcpy.c (strcpy): Same.
* sysdeps/x86_64/multiarch/strcspn.c (strcspn): Same.
* sysdeps/x86_64/multiarch/strlen.c (strlen): Same.
* sysdeps/x86_64/multiarch/strncmp.c (strncmp): Same.
* sysdeps/x86_64/multiarch/strncpy.c (strncpy): Same.
* sysdeps/x86_64/multiarch/strnlen.c (strnlen): Same.
* sysdeps/x86_64/multiarch/strpbrk.c (strpbrk): Same.
* sysdeps/x86_64/multiarch/strrchr.c (strrchr): Same.
* sysdeps/x86_64/multiarch/strspn.c (strspn): Same.

5 years agoConvert tst-efgcvt to the new test framework
Gabriel F. T. Gomes [Thu, 1 Nov 2018 18:02:47 +0000 (15:02 -0300)]
Convert tst-efgcvt to the new test framework

The function do_test, in tst-efgcvt.c, increments an error counter for
each error that it finds, then returns it to the test framework.
However, the test framework does not expect an error count as return,
but zero for a passing test, one for a failing test, or 77 for an
unsupported test.  Alternatively, the framework provides the function
support_record_failure that records errors, which then allows the test
program to return zero unconditionally.

This patch removes the error counter, replaces each increment of the
counter with a call to support_record_failure, and makes do_test
unconditionally return zero.

Tested for powerpc64le (as-is and with a patched results table to check
that the error reporting actually works).

* misc/tst-efgcvt.c: Include support/check.h and
support/test-driver.c.  Do not include test-skeleton.c.
(error_count): Remove.
(output_error): Replace increments to error_count with calls to
support_record_failure.
(output_r_error): Likewise.
(special): Likewise.
(do_test): Unconditionally return zero.
(TEST_FUNCTION): Remove.

5 years agoUpdate conform/Makefile mkdir commands.
Joseph Myers [Fri, 9 Nov 2018 17:40:58 +0000 (17:40 +0000)]
Update conform/Makefile mkdir commands.

conform/Makefile creates $(@D)/scratch for the per-standard per-header
tests.  That directory was formerly used by the Perl scripts for
temporary files, but the Python implementations use
tempfile.TemporaryDirectory to get such files cleaned up
automatically.  This patch changes the Makefile to create only $(@D)
(required for the output redirection to work), not the scratch
subdirectory.

Tested for x86_64.

* conform/Makefile ($(conformtest-header-tests)): Create $(@D),
not $(@D)/scratch.
($(linknamespace-header-tests)): Likewise.

5 years agoReplace conformtest.pl with conformtest.py.
Joseph Myers [Fri, 9 Nov 2018 13:54:06 +0000 (13:54 +0000)]
Replace conformtest.pl with conformtest.py.

Continuing the consolidation on Python for various miscellaneous build
and test scripts, this patch moves conformtest from Perl to Python.

The substance of the tests run is intended to be the same as before,
except that the previous test for tags did not actually achieve the
intended purpose of verifying whether a tag was already declared, so
is changed to one that would actually fail for a tag that wasn't
declared, and a typo in the old test for variables being available
($xyzzy instead of xyzzy) would have made that test not use the
correct type (but it would have passed anyway with warnings).  No
attempt is made to keep the details of what the test output looks
like; instead, tests are given names which are made to follow PASS: /
FAIL: / XFAIL: / SKIP: / MISSING: as appropriate.

In the new version, there is more consistent parsing of test lines
(into a series of words, either surrounded by {} or separated by
spaces) that applies for all kinds of test lines, rather than the old
approach of different regular expressions for every kind of test.  A
few of the conform/data/ files are adjusted so their syntax works with
the new script (which now requires spaces in certain cases where the
old script tolerated them being missing, and does not allow stray
semicolons at the end of "function" lines).  Similarly, common logic
is used around what happens with a second subtest if a first one fails
(e.g., a test for a symbol's type if the test for availability fails),
rather than such logic being replicated separately for each kind of
test.  Common parsing also applies for test lines both when they are
lines for the header under test and when they are lines for another
header specified with allow-header, again unlike the old script.

Tested for x86_64, and with build-many-glibcs.py.

* conform/conformtest.py: New file.
* conform/conformtest.pl: Remove.
* conform/GlibcConform.pm: Likewise.
* conform/glibcconform.py (KEYWORDS_C90): New constant.
(KEYWORDS_C99): Likewise.
(KEYWORDS): Likewise.
* conform/Makefile ($(conformtest-header-tests)): Use
conformtest.py instead of conformtest.pl.  Do not pass --tmpdir
option.  Use --header instead of --headers.
* conform/data/arpa/inet.h-data: Remove trailing semicolons on
function entries.
* conform/data/spawn.h-data: Likewise.
* conform/data/fcntl.h-data (openat): Add space after function
name.
* conform/data/wchar.h-data (wcscasecmp): Likewise.
(wcscasecmp_l): Likewise.
* conform/data/termios.h-data (c_cc): Add space after element
name.

5 years agoUse TEST_COMPARE_STRING in recently added test
Gabriel F. T. Gomes [Tue, 6 Nov 2018 19:44:13 +0000 (17:44 -0200)]
Use TEST_COMPARE_STRING in recently added test

The commit

commit 1df872fd74f730bcae3df201a229195445d2e18a
Author: Florian Weimer <fweimer@redhat.com>
Date:   Wed Nov 7 12:42:44 2018 +0100

    support: Implement TEST_COMPARE_STRING

added the new macro TEST_COMPARE_STRING, which compares the output of
functions under test against expected strings, and, when there's a
mismatch, automatically reports an error and prints the differences.
This patch adapts recently added test cases to use this new macro.

Tested for powerpc64le (as is, and locally patched to intentionally fail
and produce error output).

* argp/tst-ldbl-argp.c (do_one_test): Use TEST_COMPARE_STRING,
instead of manually comparing and reporting mismatching strings.
* misc/tst-ldbl-error.c (do_one_test): Likewise.
* misc/tst-ldbl-warn.c (do_one_test): Likewise.

5 years agoRemove __ASSUME_SOCKETCALL.
Joseph Myers [Thu, 8 Nov 2018 20:28:07 +0000 (20:28 +0000)]
Remove __ASSUME_SOCKETCALL.

The __ASSUME_SOCKETCALL macro in kernel-features.h is no longer used
for anything.  (It used to be used in defining other macros related to
accept4 / recvmmsg / sendmmsg availability, but the code in that area
was simplified once we could assume a kernel with those features,
whether through a syscall or through socketcall, so allowing those
functions to be handled much like other socket operations, without
requring __ASSUME_SOCKETCALL.)  This patch removes that unused macro.

(Note: once we can assume a Linux 4.4 or later kernel, much of the
support for using socketcall at all can be removed from glibc,
although a few functions may need that support in glibc for longer.)

Tested with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/kernel-features.h: Remove comment about
__ASSUME_SOCKETCALL.
* sysdeps/unix/sysv/linux/i386/kernel-features.h
(__ASSUME_SOCKETCALL): Remove.
* sysdeps/unix/sysv/linux/m68k/kernel-features.h
(__ASSUME_SOCKETCALL): Likewise.
* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
(__ASSUME_SOCKETCALL): Likewise.
* sysdeps/unix/sysv/linux/powerpc/kernel-features.h
(__ASSUME_SOCKETCALL): Likewise.
* sysdeps/unix/sysv/linux/s390/kernel-features.h
(__ASSUME_SOCKETCALL): Likewise.
* sysdeps/unix/sysv/linux/sh/kernel-features.h
(__ASSUME_SOCKETCALL): Likewise.
* sysdeps/unix/sysv/linux/sparc/kernel-features.h
(__ASSUME_SOCKETCALL): Likewise.

5 years agoCheck multiple NT_GNU_PROPERTY_TYPE_0 notes [BZ #23509]
H.J. Lu [Thu, 8 Nov 2018 18:06:58 +0000 (10:06 -0800)]
Check multiple NT_GNU_PROPERTY_TYPE_0 notes [BZ #23509]

Linkers group input note sections with the same name into one output
note section with the same name.  One output note section is placed in
one PT_NOTE segment.  Since new linkers merge input .note.gnu.property
sections into one output .note.gnu.property section, there is only
one NT_GNU_PROPERTY_TYPE_0 note in one PT_NOTE segment with new linkers.
Since older linkers treat input .note.gnu.property section as a generic
note section and just concatenate all input .note.gnu.property sections
into one output .note.gnu.property section without merging them, we may
see multiple NT_GNU_PROPERTY_TYPE_0 notes in one PT_NOTE segment with
older linkers.

When an older linker is used to created the program on CET-enabled OS,
the linker output has a single .note.gnu.property section with multiple
NT_GNU_PROPERTY_TYPE_0 notes, some of which have IBT and SHSTK enable
bits set even if the program isn't CET enabled.  Such programs will
crash on CET-enabled machines.  This patch updates the note parser:

1. Skip note parsing if a NT_GNU_PROPERTY_TYPE_0 note has been processed.
2. Check multiple NT_GNU_PROPERTY_TYPE_0 notes.

[BZ #23509]
* sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Skip
note parsing if a NT_GNU_PROPERTY_TYPE_0 note has been processed.
Update the l_cet field when processing NT_GNU_PROPERTY_TYPE_0 note.
Check multiple NT_GNU_PROPERTY_TYPE_0 notes.
* sysdeps/x86/link_map.h (l_cet): Expand to 3 bits,  Add
lc_unknown.

5 years agoAdd an additional test to resolv/tst-resolv-network.c
Alexandra Hájková [Fri, 19 Oct 2018 11:30:44 +0000 (13:30 +0200)]
Add an additional test to resolv/tst-resolv-network.c

Test for the infinite loop in getnetbyname, bug #17630.

5 years agoFix __ASSUME_MLOCK2 for ARM, MicroBlaze (bug 23867).
Joseph Myers [Wed, 7 Nov 2018 16:27:35 +0000 (16:27 +0000)]
Fix __ASSUME_MLOCK2 for ARM, MicroBlaze (bug 23867).

The generic kernel-features.h defines __ASSUME_MLOCK2 for 4.4 and
later kernels.  However, for 32-bit ARM binaries running on 64-bit ARM
kernels, and for MicroBlaze, the syscall was only wired up in the 4.7
kernel.  (32-bit ARM kernels did have the syscall from 4.4 onwards.)
This patch duly arranges for the macro to be undefined for those
architectures for kernels before 4.7.

Tested with build-many-glibcs.py for its ARM and MicroBlaze
configurations.

[BZ #23867]
* sysdeps/unix/sysv/linux/arm/kernel-features.h
[__LINUX_KERNEL_VERSION < 0x040700] (__ASSUME_MLOCK2): Undefine.
* sysdeps/unix/sysv/linux/microblaze/kernel-features.h
[__LINUX_KERNEL_VERSION < 0x040700] (__ASSUME_MLOCK2): Undefine.

5 years agosupport: Fix printf format for TEST_COMPARE_STRING
Adhemerval Zanella [Wed, 7 Nov 2018 13:09:02 +0000 (11:09 -0200)]
support: Fix printf format for TEST_COMPARE_STRING

Fix the following on 32 bits targets:

support_test_compare_string.c: In function ‘support_test_compare_string’:
support_test_compare_string.c:80:37: error: format ‘%lu’ expects argument of
type ‘long unsigned int’, but argument 2 has type ‘size_t’ {aka ‘unsigned int’}
[-Werror=format=]
         printf ("  string length: %lu bytes\n", left_length);
                                   ~~^           ~~~~~~~~~~~
                                   %u
Checked on arm-linux-gnueabihf.

* support/support_test_compare_string.c
(support_test_compare_string): Fix printf format.

5 years agosupport: Implement TEST_COMPARE_STRING
Florian Weimer [Wed, 7 Nov 2018 11:42:44 +0000 (12:42 +0100)]
support: Implement TEST_COMPARE_STRING

5 years agoRISC-V: don't assume PI mutexes and robust futexes before 4.20 (bug 23864)
Andreas Schwab [Tue, 6 Nov 2018 08:23:02 +0000 (09:23 +0100)]
RISC-V: don't assume PI mutexes and robust futexes before 4.20 (bug 23864)

Support for futex_cmpxchg as only been added to 4.20-rc1.

5 years agoCorrect SH kernel-features.h undefines (bug 23862).
Joseph Myers [Tue, 6 Nov 2018 17:22:50 +0000 (17:22 +0000)]
Correct SH kernel-features.h undefines (bug 23862).

The SH kernel-features.h undefines __ASSUME_RENAMEAT2 for kernel
versions before 4.8, but fails to undefine __ASSUME_EXECVEAT,
__ASSUME_MLOCK2 and __ASSUME_COPY_FILE_RANGE, although all those
syscalls (and several others) were added for SH in the same Linux
kernel commit (first released in 4.8).  This patch adds the proper
undefines of those macros.

Tested with build-many-glibcs.py for its SH configurations.

[BZ #23862]
* sysdeps/unix/sysv/linux/sh/kernel-features.h
[__LINUX_KERNEL_VERSION < 0x040800] (__ASSUME_EXECVEAT): Undefine.
[__LINUX_KERNEL_VERSION < 0x040800] (__ASSUME_MLOCK2): Likewise.
[__LINUX_KERNEL_VERSION < 0x040800] (__ASSUME_COPY_FILE_RANGE):
Likewise.

5 years agoposix: New function posix_spawn_file_actions_addchdir_np [BZ #17405]
Florian Weimer [Tue, 6 Nov 2018 15:08:12 +0000 (16:08 +0100)]
posix: New function posix_spawn_file_actions_addchdir_np [BZ #17405]

5 years agoAdd tests with floating-point arguments for err* and verr* functions
Gabriel F. T. Gomes [Tue, 7 Aug 2018 13:39:47 +0000 (10:39 -0300)]
Add tests with floating-point arguments for err* and verr* functions

Similarly to what has been done for argp_error, and argp_failure, as
well as for warn, warnx, vwarn, and vwarnx, this patch adds new tests
for the following functions: err, errx, verr, verrx, error, and
error_at_line.  The new tests check that the conversion of long double
variables into string works correctly on the default format of the type.
Future patches will reuse these tests for other formats that long double
can take.

Tested for powerpc64le.

* misc/Makefile (tests): Add tst-ldbl-error.
* misc/tst-ldbl-error.c: New file.

5 years agoAdd test for warn, warnx, vwarn, and vwarnx with floating-point parameters
Gabriel F. T. Gomes [Mon, 6 Aug 2018 15:06:03 +0000 (12:06 -0300)]
Add test for warn, warnx, vwarn, and vwarnx with floating-point parameters

Similarly to what has been done for argp_error and argp_failure, this
patch patch adds new tests for the warn, warnx, vwarn, and vwarnx
functions.  The new tests use the format string to request the
conversion of long double parameters into string.  Currently, these
tests only check that the default format of the long double type works.
Future patches will extend the test for platforms that can have an
optional format for long double.

Tested for powerpc64le.

* misc/Makefile (tests): Add tst-ldbl-warn.
* misc/tst-ldbl-warn.c: New file.

5 years agoAdd tests for argp_error and argp_failure with floating-point parameters
Gabriel F. T. Gomes [Wed, 13 Jun 2018 01:27:21 +0000 (22:27 -0300)]
Add tests for argp_error and argp_failure with floating-point parameters

The functions argp_error and argp_failure, from argp.h, have a format
string as parameter, which can possibly request the printing of
floating-point values.  These values could be of long double type, which
can have different formats, depending on the architecture and on
compilation parameters (for instance, on powerpc, long double values can
have double format (-mlong-double-64) or IBM Extended Precision format
(-mlong-double-128)).

This patch adds tests for argp_error and argp_failure that contain a
format string with double and long double conversion specifiers ('%f'
and '%Lf').  These tests automatically check that the default format of
the long double type works.  A future patch will extend the test for
platforms that can have an optional format for long double.

Tested for powerpc64le.

* argp/Makefile (tests): Add tst-ldbl-argp.
* argp/tst-ldbl-argp.c: New file.

5 years agoUnconditionally call __gconv_get_path when reading iconv configuration
Arjun Shankar [Mon, 5 Nov 2018 14:45:07 +0000 (15:45 +0100)]
Unconditionally call __gconv_get_path when reading iconv configuration

__gconv_read_conf is only ever called once during the program's lifetime.
This means that __gconv_path_elem is always uninitialized when the function
begins executing.  __gconv_get_path has an assert to ensure that this
expected runtime behaviour is always exhibited.  Given this, checking for a
NULL value before calling __gconv_get_path is unnecessary.  This commit
drops the condition and calls __gconv_get_path unconditionally.

5 years agolibanl: properly cleanup if first helper thread creation failed (bug 22927)
Andreas Schwab [Mon, 5 Nov 2018 11:47:30 +0000 (12:47 +0100)]
libanl: properly cleanup if first helper thread creation failed (bug 22927)

5 years agohurd: Fix last-minute refactoring
Samuel Thibault [Sun, 4 Nov 2018 01:11:16 +0000 (02:11 +0100)]
hurd: Fix last-minute refactoring

* sysdeps/mach/hurd/msync.c (msync): Fix syntax.

5 years agohurd: Support msync
Samuel Thibault [Sat, 3 Nov 2018 21:47:57 +0000 (22:47 +0100)]
hurd: Support msync

* sysdeps/mach/hurd/msync.c: New file.

5 years agosupport/shell-container.c: Use support_copy_file_range
Florian Weimer [Fri, 2 Nov 2018 14:37:50 +0000 (15:37 +0100)]
support/shell-container.c: Use support_copy_file_range

Reviewed-by: DJ Delorie <dj@redhat.com>
5 years agosupport/test-container.c: Include <libc-pointer-arith.h>
Florian Weimer [Fri, 2 Nov 2018 14:36:09 +0000 (15:36 +0100)]
support/test-container.c: Include <libc-pointer-arith.h>

Reviewed-by: DJ Delorie <dj@redhat.com>
5 years agoFix typo in the documentation of gcvt
Gabriel F. T. Gomes [Mon, 29 Oct 2018 18:45:17 +0000 (15:45 -0300)]
Fix typo in the documentation of gcvt

In the description of gcvt, add missing closing parenthesis in the
comparison with sprintf.

* manual/arith.texi (gcvt): Add missing closing parenthesis.

5 years agosoft-fp: Add implementation for 128 bit self-contained
Zong Li [Thu, 1 Nov 2018 18:22:00 +0000 (18:22 +0000)]
soft-fp: Add implementation for 128 bit self-contained

Here only add the implementation when building the RV32 port.

These macros are used when the following situations occur at the same
time: soft-fp fma, ldbl-128 and 32-bit _FP_W_TYPE_SIZE. The RISC-V
32-bit port is the first port which use all three together.

This is the building flow about the situation:
When building soft-fp/s_fmal.c, there uses the FP_FMA_Q in __fmal.
The _FP_W_TYPE_SIZE is defined to 32-bit in sysdeps/riscv/sfp-machine.h,
so the FP_FMA_Q was defined to _FP_FMA (Q, 4, 8, R, X, Y, Z) in
soft-fp/quad.h.

Something in the soft-fp/quad.h:
 #if _FP_W_TYPE_SIZE < 64
    # define FP_FMA_Q(R, X, Y, Z)    _FP_FMA (Q, 4, 8, R, X, Y, Z)
 #else
    # define FP_FMA_Q(R, X, Y, Z)    _FP_FMA (Q, 2, 4, R, X, Y, Z)
 #endif

Finally, in _FP_FMA (fs, wc, dwc, R, X, Y, Z), it will use the
_FP_FRAC_HIGHBIT_DW_##dwc macro, and it will be expanded to
_FP_FRAC_HIGHBIT_DW_8, but the _FP_FRAC_HIGHBIT_DW_8 is not be
implemented in soft-fp/op-8.h. there is only _FP_FRAC_HIGHBIT_DW_1,
_FP_FRAC_HIGHBIT_DW_2 and _FP_FRAC_HIGHBIT_DW_4 in the
soft-fp/op-*.h.

After this modification, we can pass the soft floating testing of glibc
testsuites on RV32.

* soft-fp/op-8.h (_FP_FRAC_SET_8, _FP_FRAC_ADD_8, _FP_FRAC_SUB_8)
(_FP_FRAC_CLZ_8, _FP_MINFRAC_8, _FP_FRAC_NEGP_8, _FP_FRAC_ZEROP_8)
(_FP_FRAC_HIGHBIT_DW_8, _FP_FRAC_COPY_4_8, _FP_FRAC_COPY_8_4)
(__FP_FRAC_SET_8): Add implementation for RV32 use.

5 years agosoft-fp: Use temporary variable in FP_FRAC_SUB_3/FP_FRAC_SUB_4
Zong Li [Thu, 1 Nov 2018 17:34:39 +0000 (17:34 +0000)]
soft-fp: Use temporary variable in FP_FRAC_SUB_3/FP_FRAC_SUB_4

In FRAC_SUB_3(R, X, Y) and FRAC_SUB_4(R,, X, Y), it reference both
the X[N] and X[N] after R[N] have been set. If one of the X and Y is
the same address with R, the result of the calculation is wrong,
because the value of the original X and Y are overwritten.

In glibc, there are two places use FRAC_SUB and occurs the overlap.
The first is _FP_DIV_MEAT_N_loop in op-common.h, it uses the source
_FP_DIV_MEAT_N_loop_u as the destination. This macro only be used
when N is one(_FP_DIV_MEAT_1_loop) and then the _FP_FRAC_SUB_##wc
extend to _FP_FRAC_SUB_1 in this macro. so it also work because
_FP_FRAC_SUB_1 has no overlap problem in its implementation.
The second places is _FP_DIV_MEAT_4_udiv, the original value of X##_f[0]
is overwritten before the calculatation.

In FRAC_SUB_1 and FRAC_SUB_2, there don't refer the source after
destination have been set, so they have no problem.

After this modification, we can pass the soft floating testing of glibc
testsuites on RV32.

* soft-fp/op-4.h (_FP_FRAC_SUB_3, _FP_FRAC_SUB_4): Use temporary
variable to avoid overlap arguments.

5 years agoAvoid printf ("%s", NULL) in posix/bug-regex22.c.
Joseph Myers [Thu, 1 Nov 2018 17:20:27 +0000 (17:20 +0000)]
Avoid printf ("%s", NULL) in posix/bug-regex22.c.

Building posix/bug-regex22.c fails with GCC mainline because of
-Wformat-overflow= warnings for NULL arguments to %s formats.

This is *not* testing how glibc handles such format arguments; in the
context of the messages in question it makes no sense to pass NULL to
such a %s format (the code passes s, inside "if (s == NULL)").  So
this patch changes the code not to pass such a format argument at all
(which means the string passed is constant, so no need to use printf
at all - however, there are two separate tests here with different
length arguments passed to re_compile_pattern, so it *does* make sense
to make the strings used different so that in the event of failure
it's clear which one of the tests failed).

Tested with build-many-glibcs.py with GCC mainline for
aarch64-linux-gnu.

* posix/bug-regex22.c (main): Use puts with distinct error
messages for unexpected success of re_compile_pattern, not printf
with NULL argument to %s.

5 years agoDisable -Wformat-overflow= warnings for some printf tests.
Joseph Myers [Thu, 1 Nov 2018 17:13:55 +0000 (17:13 +0000)]
Disable -Wformat-overflow= warnings for some printf tests.

Recent GCC -Wformat-overflow= changes result in some printf tests
failing to build, because those tests are deliberately testing the
handling of formats writing more than INT_MAX characters and the
handling of NULL arguments to the %s format, which GCC now warns
about.  This patch duly disables -Wformat-overflow= for the relevant
calls to printf functions.

Tested with build-many-glibcs.py with GCC mainline for
aarch64-linux-gnu.

* stdio-common/bug22.c: Include <libc-diag.h>.
(do_test): Disable -Wformat-overflow= warnings around fprintf
calls outputting more than INT_MAX characters.
* stdio-common/tst-printf.c: Disable -Wformat-overflow= warnings
around printf call with NULL %s argument.

5 years agoUpdate and correct SPARC configuration for supported socket syscalls (bug 23848).
Joseph Myers [Thu, 1 Nov 2018 16:30:15 +0000 (16:30 +0000)]
Update and correct SPARC configuration for supported socket syscalls (bug 23848).

Looking at kernel-features.h files, I saw that SPARC was missing full
information on when it gained separate socket syscalls.

This patch adds such information to the SPARC kernel-features.h.  It
also corrects what appear to be bugs in the existing code (that would
cause syscalls to be assumed to be present when not actually present).
Various __ASSUME_* macros, defined by default, were not undefined for
32-bit despite those syscalls only being added for 32-bit in Linux
4.4.  Some syscalls were used in the SPARC64 syscalls.list but only
added in 4.4; this was harmless before the __NR_* macros were defined
at all, but once the macros were defined it means a build with
post-4.4 headers would assume the syscalls to be present regardless of
--enable-kernel version.  Then, various __ASSUME_* macros were
previously not defined in cases where they could be defined (this part
of the patch is just an optimization, not a bug fix).

Note the observation in a comment in the patch that even the latest
Linux kernel for SPARC does not have getpeername and getsockname
syscalls in the compat syscall table for 32-bit binaries on 64-bit
kernels (so glibc can't assume those syscalls to be present for 32-bit
at all, although the 32-bit syscall table gained them in 4.4).

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

[BZ #23848]
* sysdeps/unix/sysv/linux/sparc/kernel-features.h [!__arch64__ &&
__LINUX_KERNEL_VERSION < 0x040400] (__ASSUME_SENDMSG_SYSCALL):
Undefine.
[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
(__ASSUME_RECVMSG_SYSCALL): Likewise.
[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
(__ASSUME_SENDTO_SYSCALL): Likewise.
[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
(__ASSUME_ACCEPT_SYSCALL): Undefine under this condition, not just
[!__arch64__].
[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
(__ASSUME_CONNECT_SYSCALL): Likewise.
[!__arch64__ && __LINUX_KERNEL_VERSION < 0x040400]
(__ASSUME_RECVFROM_SYSCALL): Likewise.
[__LINUX_KERNEL_VERSION >= 0x040400] (__ASSUME_BIND_SYSCALL):
Define.
[__LINUX_KERNEL_VERSION >= 0x040400] (__ASSUME_LISTEN_SYSCALL):
Likewise.
[__LINUX_KERNEL_VERSION >= 0x040400]
(__ASSUME_SETSOCKOPT_SYSCALL): Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/syscalls.list (bind):
Remove.
(listen): Likewise.
(setsockopt): Likewise.

5 years agoMIPS: Use `.set mips2' to emulate LL/SC for the R5900 too
Fredrik Noring [Thu, 1 Nov 2018 14:36:48 +0000 (14:36 +0000)]
MIPS: Use `.set mips2' to emulate LL/SC for the R5900 too

GAS treats the R5900 as MIPS III, with some modifications.  The MIPS III
designation means that the GNU C Library will try to assemble the LL and
SC instructions, even though they are not implemented in the R5900.  GAS
will therefore produce the following errors:

Error: opcode not supported on this processor: r5900 (mips3) `ll $2,0($4)'
Error: opcode not supported on this processor: r5900 (mips3) `sc $6,0($4)'

The MIPS II ISA override as used here enables the kernel to trap and
emulate the LL and SC instructions, as required.

This change has been tested by compiling the GNU C Library 2.27 with a
GCC 8.2.0 cross-compiler for mipsr5900el-unknown-linux-gnu under Gentoo.

* sysdeps/mips/sys/tas.h (_test_and_set): Handle the R5900 CPU
with the ISA override.

5 years agohurd: Add pci RPC stubs
Samuel Thibault [Wed, 31 Oct 2018 21:43:44 +0000 (22:43 +0100)]
hurd: Add pci RPC stubs

* hurd/Makefile (user-interfaces): Add pci.

5 years agoSimplify an #if #else #endif
Rafael Avila de Espindola [Wed, 31 Oct 2018 17:31:06 +0000 (10:31 -0700)]
Simplify an #if #else #endif

The #else of two nested #if clauses were identical.

* sysdeps/unix/sysv/linux/sysdep-vdso.h: Simplify an #if #else
#endif.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
5 years agoMerge branch 'master' into errno
Samuel Thibault [Wed, 31 Oct 2018 09:33:45 +0000 (10:33 +0100)]
Merge branch 'master' into errno

5 years agohurd: Fix errno* generation
Samuel Thibault [Wed, 31 Oct 2018 09:02:06 +0000 (10:02 +0100)]
hurd: Fix errno* generation

* sysdeps/mach/hurd/errnos.awk: Avoid printing errnos.d.
* sysdeps/gnu/errlist.c (EIEIO): Move text to...
* manual/errno.texi (EIEIO): ... here.
* sysdeps/gnu/errlist.c (EIEIO): Regenerate.
* sysdeps/mach/hurd/bits/errno.h: Regenerate.

5 years agoMerge branch 'master' of git://sourceware.org/git/glibc
Samuel Thibault [Wed, 31 Oct 2018 08:19:28 +0000 (09:19 +0100)]
Merge branch 'master' of git://sourceware.org/git/glibc

5 years agohurd: Fix build
Samuel Thibault [Wed, 31 Oct 2018 08:17:05 +0000 (09:17 +0100)]
hurd: Fix build

* sysdeps/gnu/errlist.c (EIEIO): Fix comment marker.

5 years agohurd: Document how to translate EIEIO error message
Samuel Thibault [Wed, 31 Oct 2018 00:49:11 +0000 (01:49 +0100)]
hurd: Document how to translate EIEIO error message

* sysdeps/gnu/errlist.c (EIEIO): Document how translators should
translate the error message.

5 years agoConvert linknamespace tests from Perl to Python.
Joseph Myers [Tue, 30 Oct 2018 22:18:34 +0000 (22:18 +0000)]
Convert linknamespace tests from Perl to Python.

This patch replaces conform/linknamespace.pl with a new
conform/linknamespace.py, so continuing the consolidation on Python
instead of Perl for miscellaneous scripts used in building and testing
glibc.  The new script follows the same logic as the old one; as a
recently-added script, there were no major cleanups to be made in the
course of the language conversion.

Tested for x86_64, and with build-many-glibcs.py.  For x86_64 I also
tested that if the Perl and Python scripts were made to print all the
symbols in seen_where and the paths of symbol references by which
those symbols were linked in, even when those symbols were OK,
identical symbol lists appeared in the output with both versions of
the script (the differences in linknamespace.out files were only in
paths to temporary files in diagnostics for e.g. deprecated functions,
and error output for the expected compilation failures when testing
ndbm.h and varargs.h).

* conform/linknamespace.py: New file.
* conform/linknamespace.pl: Remove file.
* conform/Makefile ($(linknamespace-header-tests)): Use
linknamespace.py instead of linknamespace.pl.  Do not use --tmpdir
option.

5 years agostdlib/test-bz22786: Avoid memory leaks in the test itself
Florian Weimer [Tue, 30 Oct 2018 12:56:40 +0000 (13:56 +0100)]
stdlib/test-bz22786: Avoid memory leaks in the test itself

5 years agosupport_blob_repeat: Call mkstemp directory for the backing file
Florian Weimer [Tue, 30 Oct 2018 12:55:50 +0000 (13:55 +0100)]
support_blob_repeat: Call mkstemp directory for the backing file

This avoids a warning during post-test cleanup.

5 years agostdlib/tst-strtod-overflow: Switch to support_blob_repeat
Florian Weimer [Tue, 30 Oct 2018 12:55:01 +0000 (13:55 +0100)]
stdlib/tst-strtod-overflow: Switch to support_blob_repeat

This is another test with an avoidable large memory allocation.

5 years agostdlib/test-bz22786: Avoid spurious test failures using alias mappings
Florian Weimer [Tue, 30 Oct 2018 12:11:47 +0000 (13:11 +0100)]
stdlib/test-bz22786: Avoid spurious test failures using alias mappings

On systems without enough random-access memory, stdlib/test-bz22786
will go deeply into swap and time out, even with a substantial
TIMEOUTFACTOR.  This commit adds a facility to construct repeating
strings with alias mappings, so that the requirement for physical
memory, and uses it in stdlib/test-bz22786.

5 years agoRISC-V: properly terminate call chain (bug 23125)
Andreas Schwab [Tue, 25 Sep 2018 09:11:27 +0000 (11:11 +0200)]
RISC-V: properly terminate call chain (bug 23125)

Mark the ra register as undefined in _start, so that unwinding through
main works correctly.  Also, don't use a tail call so that ra points after
the call to __libc_start_main, not after the previous call.

5 years agoCurrency symbol should not preceed amount for [BZ #23791]
Sergi Almacellas Abellana [Mon, 29 Oct 2018 12:38:30 +0000 (13:38 +0100)]
Currency symbol should not preceed amount for [BZ #23791]

CLDR also has the currency symbol after the amount for Catalan.

Also set grouping in LC_NUMERIC to 3;3.

Reviewed-by: Mike FABIAN <mfabian@redhat.com>
5 years agohurd: return EIEIO instead of EIO
Samuel Thibault [Mon, 29 Oct 2018 17:57:13 +0000 (18:57 +0100)]
hurd: return EIEIO instead of EIO

EIO would be understood as hardware failure, while this is software
failure.

* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Return EIEIO instead of EIO

5 years agoUse tempfile.TemporaryDirectory in conform/glibcconform.py.
Joseph Myers [Mon, 29 Oct 2018 17:49:07 +0000 (17:49 +0000)]
Use tempfile.TemporaryDirectory in conform/glibcconform.py.

Now that we require Python 3.4 or later, Python code creating
temporary directories can use tempfile.TemporaryDirectory in "with" to
have the directory deleted automatically instead of needing to use
try/finally to handle removing a directory created with
tempfile.mkdtemp.  This patch does so in conform/glibcconform.py.

Tested for x86_64.

* conform/glibcconform.py: Do not import shutil.
(list_exported_functions): Use tempfile.TemporaryDirectory instead
of mkdtemp.

5 years agoPatch to require Python 3.4 or later to build glibc.
Joseph Myers [Mon, 29 Oct 2018 15:28:05 +0000 (15:28 +0000)]
Patch to require Python 3.4 or later to build glibc.

This patch makes Python 3.4 or later a required tool for building
glibc, so allowing changes of awk, perl etc. code used in the build
and test to Python code without any such changes needing makefile
conditionals or to handle older Python versions.

This patch makes the configure test for Python check the version and
give an error if Python is missing or too old, and removes makefile
conditionals that are no longer needed.  It does not itself convert
any code from another language to Python, and does not remove any
compatibility with older Python versions from existing scripts.

Tested for x86_64.

* configure.ac (PYTHON_PROG): Use AC_CHECK_PROG_VER.  Set
critic_missing for versions before 3.4.
* configure: Regenerated.
* manual/install.texi (Tools for Compilation): Document
requirement for Python to build glibc.
* INSTALL: Regenerated.
* Rules [PYTHON]: Make code unconditional.
* benchtests/Makefile [PYTHON]: Likewise.
* conform/Makefile [PYTHON]: Likewise.
* manual/Makefile [PYTHON]: Likewise.
* math/Makefile [PYTHON]: Likewise.

5 years agohurd: Fix race between calling RPC and handling a signal
Samuel Thibault [Tue, 9 Oct 2018 21:40:09 +0000 (23:40 +0200)]
hurd: Fix race between calling RPC and handling a signal

* sysdeps/mach/hurd/i386/intr-msg.h (INTR_MSG_TRAP): Make
_hurd_intr_rpc_msg_about_to global point to start of controlled
assembly snippet. Make it check canceled flag.
* hurd/hurdsig.c (_hurdsig_abort_rpcs): Only mutate thread if it passed
the _hurd_intr_rpc_msg_about_to point.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Remove comment on mutation
issue, remove cancel flag check.

5 years agohurd: Fix cancellation just before RPC call
Samuel Thibault [Sun, 28 Oct 2018 11:55:24 +0000 (12:55 +0100)]
hurd: Fix cancellation just before RPC call

* sysdeps/mach/hurd/i386/intr-msg.h (INTR_MSG_TRAP): Set
intr_port to 0 when canceled.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Pass intr_port
address.

5 years agohurd: Fix race between calling RPC and handling a signal
Samuel Thibault [Tue, 9 Oct 2018 21:40:09 +0000 (23:40 +0200)]
hurd: Fix race between calling RPC and handling a signal

* sysdeps/mach/hurd/i386/intr-msg.h (INTR_MSG_TRAP): Make
_hurd_intr_rpc_msg_about_to global point to start of controlled
assembly snippet. Make it check canceled flag again.
* hurd/hurdsig.c (_hurdsig_abort_rpcs): Only mutate thread if it passed the
_hurd_intr_rpc_msg_about_to point.
* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): Remove comment on mutation
issue.

5 years agohurd: Return EIO on non-responding interrupted servers
Samuel Thibault [Tue, 9 Oct 2018 20:25:19 +0000 (22:25 +0200)]
hurd: Return EIO on non-responding interrupted servers

since we do not actually know whether the RPC was completed or not,
which makes a huge difference for e.g. write(), so better really error
out than letting caller think that the RPC did not happen.

* hurd/intr-msg.c (_hurd_intr_rpc_mach_msg): When the server does not
answer to interrupt_operation, return EIO instead of EINTR.

5 years agohurd: set interrupt timeout to 1 minute
Samuel Thibault [Tue, 9 Oct 2018 20:27:59 +0000 (22:27 +0200)]
hurd: set interrupt timeout to 1 minute

Seeing a server not able to get interrupted for 3s is not so surprising when
e.g. a lot of writes are happening. 1 minute allows to actually notice the
issue and be able to debug it.

* hurd/hurdsig.c (_hurd_interrupted_rpc_timeout): Set to 60000.

5 years agoRemove pre-Python-3.4 compatibility from build-many-glibcs.py.
Joseph Myers [Fri, 26 Oct 2018 15:47:23 +0000 (15:47 +0000)]
Remove pre-Python-3.4 compatibility from build-many-glibcs.py.

Since we have consensus on requiring Python 3.4 or later to build
glibc, it follows that compatibility with older Python versions is
also no longer relevant to auxiliary Python scripts for use in glibc
development.  This patch removes such compatibility code from
build-many-glibcs.py (compatibility code needed for 3.4, which lacks
the newer subprocess interface, is kept).  Because
build-many-glibcs.py is not itself called from the glibc build system,
this patch is independent of the configure checks for having a
new-enough Python version, which are only relevant to uses of Python
from the main build and test process.

Tested with build-many-glibcs.py building glibc for aarch64-linux-gnu
(with Python 3.4 to make sure that still works).

* scripts/build-many-glibcs.py: Remove compatibility for missing
os.cpu_count and re.fullmatch.

5 years agoi64: fix missing exp2f, log2f and powf symbols in libm.a [BZ #23822]
Szabolcs Nagy [Fri, 26 Oct 2018 13:39:42 +0000 (14:39 +0100)]
i64: fix missing exp2f, log2f and powf symbols in libm.a [BZ #23822]

When new symbol versions were introduced without SVID compatible
error handling the exp2f, log2f and powf symbols were accidentally
removed from the ia64 lim.a.  The regression was introduced by
the commits

f5f0f5265162fe6f4f238abcd3086985f7c38d6d
New expf and exp2f version without SVID compat wrapper

72d3d281080be9f674982067d72874fd6cdb4b64
New symbol version for logf, log2f and powf without SVID compat

With WEAK_LIBM_ENTRY(foo), there is a hidden __foo and weak foo
symbol definition in both SHARED and !SHARED build.

[BZ #23822]
* sysdeps/ia64/fpu/e_exp2f.S (exp2f): Use WEAK_LIBM_ENTRY.
* sysdeps/ia64/fpu/e_log2f.S (log2f): Likewise.
* sysdeps/ia64/fpu/e_exp2f.S (powf): Likewise.

5 years agoAdd IN_MASK_CREATE from Linux 4.19 to sys/inotify.h.
Joseph Myers [Thu, 25 Oct 2018 15:57:23 +0000 (15:57 +0000)]
Add IN_MASK_CREATE from Linux 4.19 to sys/inotify.h.

This patch adds the IN_MASK_CREATE macro from Linux 4.19 to
sys/inotify.h.

Tested for x86_64.

* sysdeps/unix/sysv/linux/sys/inotify.h (IN_MASK_CREATE): New
macro.

5 years agoconform: XFAIL siginfo_t si_band test on sparc64
Florian Weimer [Thu, 25 Oct 2018 09:43:57 +0000 (11:43 +0200)]
conform: XFAIL siginfo_t si_band test on sparc64

We can use long int on sparcv9, but on sparc64, we must match the int
type used by the kernel (and not long int, as in POSIX).

5 years agoAdd new ELF note types from Linux 4.19 to elf.h.
Joseph Myers [Thu, 25 Oct 2018 11:55:23 +0000 (11:55 +0000)]
Add new ELF note types from Linux 4.19 to elf.h.

This patch adds NT_MIPS_DSP and NT_MIPS_FP_MODE from Linux 4.19 to
elf.h.

Tested for x86_64.

* elf/elf.h (NT_MIPS_DSP): New macro.
(NT_MIPS_FP_MODE): Likewise.

5 years agoelf: Fix the ld flags not be applied to tst-execstack-mod.so
Zong Li [Thu, 25 Oct 2018 11:08:24 +0000 (13:08 +0200)]
elf: Fix the ld flags not be applied to tst-execstack-mod.so

The Makefile variable name lacked the file extension (.so).  As a
result, tst-execstack-mod.so was not linked with the -z execstack
flag.

5 years agohurd: XFAIL absence of C11 threads implementation
Samuel Thibault [Wed, 24 Oct 2018 23:31:09 +0000 (01:31 +0200)]
hurd: XFAIL absence of C11 threads implementation

* sysdeps/mach/hurd/i386/Makefile [$(subdir) = conform]
(test-xfail-ISO11/threads.h/linknamespace,
test-xfail-ISO11/threads.h/conform): Add.

5 years agoUse gen-libm-test.py to generate ulps table for manual.
Joseph Myers [Wed, 24 Oct 2018 20:34:31 +0000 (20:34 +0000)]
Use gen-libm-test.py to generate ulps table for manual.

This patch extends gen-libm-test.py to generate the ulps table for the
manual, so meaning there is only a single ulps file parser needed and
another Perl script is eliminated.  As with the introduction of
gen-libm-test.py, this is designed to generate exactly the same
libm-err.texi as libm-err-tab.pl did.  (gen-libm-test.py is still
shorter in lines than the old gen-libm-test.pl even after this patch.)
Note that this introduces a Python dependency for building the manual,
which is thus noted in install.texi and NEWS.

Tested building html / info / pdf versions of the manual.

* math/gen-libm-test.py: Import os.
(ALL_FLOATS_MANUAL): New constant.
(ALL_FLOATS_SUFFIX): Likewise.
(Ulps.all_functions): New function.
(real_all_ulps): Likewise.
(generate_err_table_sub): Likewise.
(generate_err_table): Likewise.
(main): Handle -s and -m options.
* manual/libm-err-tab.pl: Remove.
* manual/Makefile ($(objpfx)stamp-libm-err): Use gen-libm-test.py
instead of libm-err-tab.pl.
[$(PERL) != no]: Change condition to [$(if $(PYTHON),$(PERL),no)
!= no].
* manual/install.texi (Tools for Compilation): Document
requirement for Python to build manual.
* INSTALL: Regenerated.

5 years agoY2038: Add 64-bit time for all architectures
Albert ARIBAUD (3ADEV) [Wed, 24 Oct 2018 20:09:34 +0000 (22:09 +0200)]
Y2038: Add 64-bit time for all architectures

glibc support for 64-bit time_t on 32-bit architectures
will involve:

- Using 64-bit times inside glibc, with conversions
  to and from 32-bit times taking place as necessary
  for interfaces using such times.

- Adding 64-bit-time support in the glibc public API.
  This support should be dynamic, i.e. glibc should
  provide both 32-bit and 64-bit implementations and
   let user code choose at compile time whether to use
   the 32-bit or 64-bit interfaces.

This requires a glibc-internal name for a type for times
that are always 64-bit.

Based on __TIMESIZE, a new macro is defined, __TIME64_T_TYPE,
 which is always the right __*_T_TYPE to hold a 64-bit-time.
__TIME64_T_TYPE equals __TIME_T_TYPE if __TIMESIZE equals 64
and equals __SQUAD_T_TYPE otherwise.

__time64_t can then replace uses of internal_time_t.

This patch was tested by running 'make check' on branch
master then applying this patch and its predecessor and
running 'make check' again, and checking that both 'make
check' yield identical results. This was done on
x86_64-linux-gnu and i686-linux-gnu.

* bits/time64.h: New file.
* include/time.h: Replace internal_time_t with __time64_t.
* posix/bits/types (__time64_t): Add.
* stdlib/Makefile: Add bits/time64.h to includes.
* time/tzfile.c: Replace internal_time_t with __time64_t.

5 years agoFix date typo in ChangeLog
Albert ARIBAUD (3ADEV) [Wed, 24 Oct 2018 19:48:54 +0000 (21:48 +0200)]
Fix date typo in ChangeLog

5 years agoposix: Add internal symbols for posix_spawn interface
Adhemerval Zanella [Wed, 12 Sep 2018 13:30:46 +0000 (10:30 -0300)]
posix: Add internal symbols for posix_spawn interface

This patch adds internal hidden definition for mostly of the posix_spawn
function so it can be used internally on both popen and system
implementations.

Checked on x86_64-linux-gnu.

* include/spawn.h (__posix_spawn, posix_spawn_file_actions_addclose,
__posix_spawn_file_actions_adddup2, __posix_spawn_file_actions_destroy,
__posix_spawn_file_actions_init, __posix_spawnattr_init,
__posix_spawnattr_destroy, __posix_spawnattr_setflags,
__posix_spawnattr_setsigdefault, __posix_spawnattr_setsigmask): New
prototype.
* posix/spawn.c (__posix_spawn): Add libc_hidden_def.
* posix/spawn_faction_addclose.c
(__posix_spawn_file_actions_addclose): Add hidden definition.
* posix/spawn_faction_adddup2.c
(__posix_spawn_file_actions_adddup2): Likewise.
* posix/spawn_faction_destroy.c
(__posix_spawn_file_actions_destroy): Likewise.
* posix/spawn_faction_init.c (__posix_spawn_file_actions_init):
Likewise.
* posix/spawnattr_destroy.c (__posix_spawnattr_destroy): Likewise.
* posix/spawnattr_init.c (__posix_spawnattr_init): Likewise.
* posix/spawnattr_setdefault.c (__posix_spawnattr_setsigdefault):
Likewise.
* posix/spawnattr_setflags.c (__posix_spawnattr_setflags): Likewise.
* posix/spawnattr_setsigmask.c (__posix_spawnattr_setsigmask):
Likewise.

5 years agoAdd more checks for valid ld.so.cache file (bug 18093)
Andreas Schwab [Tue, 23 Oct 2018 07:40:14 +0000 (09:40 +0200)]
Add more checks for valid ld.so.cache file (bug 18093)

5 years ago Y2038: provide size of default time_t for target architecture
Albert ARIBAUD (3ADEV) [Wed, 24 Oct 2018 09:34:26 +0000 (11:34 +0200)]
Y2038: provide size of default time_t for target architecture

    To determine whether the default time_t interfaces are 32-bit
    and so need conversions, or are 64-bit and so are compatible
    with the internal 64-bit type without conversions, a macro
    giving the size of the  default time_t is also required.
    This macro is called __TIMESIZE.

    This macro can then be used instead of __WORDSIZE in msq-pad.h
    and shm-pad.h files, which in turn allows removing their x86
    variants, and in sem-pad.h files but keeping the x86 variant.

    This patch was tested by running 'make check' on branch master
    then applying this patch and running 'make check' again, and
    checking that both 'make check' yield identical results.
    This was done on x86_64-linux-gnu and i686-linux-gnu.

* bits/timesize.h: New file.
* stdlib/Makefile (headers): Add bits/timesize.h.
* sysdeps/unix/sysv/linux/bits/msq-pad.h
(__MSQ_PAD_AFTER_TIME): Use __TIMESIZE instead of __WORDSIZE.
* sysdeps/unix/sysv/linux/bits/sem-pad.h
(__SEM_PAD_AFTER_TIME): Likewise.
* sysdeps/unix/sysv/linux/bits/shm-pad.h
(__SHM_PAD_AFTER_TIME): Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/msq-pad.h
(__MSQ_PAD_BEFORE_TIME): Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/sem-pad.h
(__SEM_PAD_BEFORE_TIME): Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/shm-pad.h
(__SHM_PAD_BEFORE_TIME, __SHM_PAD_BETWEEN_TIME_AND_SEGSZ): Likewise.
* sysdeps/unix/sysv/linux/mips/bits/msq-pad.h
        (__MSQ_PAD_AFTER_TIME, __MSQ_PAD_BEFORE_TIME): Likewise.
        * sysdeps/unix/sysv/linux/powerpc/bits/msq-pad.h
        (__MSQ_PAD_BEFORE_TIME): Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/sem-pad.h
(__SEM_PAD_BEFORE_TIME): Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/shm-pad.h
(__SHM_PAD_BEFORE_TIME, __SHM_PAD_BETWEEN_TIME_AND_SEGSZ): Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/msq-pad.h
(__MSQ_PAD_BEFORE_TIME): Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/sem-pad.h
(__SEM_PAD_BEFORE_TIME): Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/shm-pad.h
(__SHM_PAD_BEFORE_TIME): Likewise.
* sysdeps/unix/sysv/linux/x86/bits/msq-pad.h: Delete file.
* sysdeps/unix/sysv/linux/x86/bits/shm-pad.h: Likewise.
* sysdeps/unix/sysv/linux/x86/bits/timesize.h: New file.

5 years agox86: Support RDTSCP for benchtests
H.J. Lu [Wed, 24 Oct 2018 09:19:15 +0000 (02:19 -0700)]
x86: Support RDTSCP for benchtests

RDTSCP waits until all previous instructions have executed and all
previous loads are globally visible before reading the counter.  RDTSC
doesn't wait until all previous instructions have been executed before
reading the counter.  All x86 processors since 2010 support RDTSCP
instruction.  This patch adds RDTSCP support to benchtests.

* benchtests/Makefile (CPPFLAGS-nonlib): Add -DUSE_RDTSCP if
USE_RDTSCP is defined.
* sysdeps/x86/hp-timing.h (HP_TIMING_NOW): Use RDTSCP if
USE_RDTSCP is defined.

5 years agoFix tst-preadvwritev2 build failure on HURD
Adhemerval Zanella [Tue, 23 Oct 2018 17:53:12 +0000 (14:53 -0300)]
Fix tst-preadvwritev2 build failure on HURD

Commit 7a16bdbb9ff41 uses IOV_MAX, which is not defined on hurd.

Checked on a build for i686-gnu.

* misc/tst-preadvwritev2-common.c (IOV_MAX): Define if not
defined.

5 years agox86: Fix Haswell strong flags (BZ#23709)
Adhemerval Zanella [Thu, 11 Oct 2018 18:18:40 +0000 (15:18 -0300)]
x86: Fix Haswell strong flags (BZ#23709)

Th commit 'Disable TSX on some Haswell processors.' (2702856bf4) changed the
default flags for Haswell models.  Previously, new models were handled by the
default switch path, which assumed a Core i3/i5/i7 if AVX is available. After
the patch, Haswell models (0x3f, 0x3c, 0x45, 0x46) do not set the flags
Fast_Rep_String, Fast_Unaligned_Load, Fast_Unaligned_Copy, and
Prefer_PMINUB_for_stringop (only the TSX one).

This patch fixes it by disentangle the TSX flag handling from the memory
optimization ones.  The strstr case cited on patch now selects the
__strstr_sse2_unaligned as expected for the Haswell cpu.

Checked on x86_64-linux-gnu.

[BZ #23709]
* sysdeps/x86/cpu-features.c (init_cpu_features): Set TSX bits
independently of other flags.

5 years agotime/tst-mktime2: Improve test error reporting
Florian Weimer [Tue, 23 Oct 2018 09:25:05 +0000 (11:25 +0200)]
time/tst-mktime2: Improve test error reporting

5 years agoDon't use PSEUDO_END for non-PSEUDO function
Andreas Schwab [Thu, 4 Oct 2018 13:46:00 +0000 (15:46 +0200)]
Don't use PSEUDO_END for non-PSEUDO function

5 years agoUpdate kernel version in syscall-names.list to 4.19.
Joseph Myers [Mon, 22 Oct 2018 23:26:37 +0000 (23:26 +0000)]
Update kernel version in syscall-names.list to 4.19.

Linux 4.19 does not add any new syscalls (some existing ones are added
to more architectures); this patch updates the version number in
syscall-names.list to reflect that it's still current for 4.19.

Tested with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
version to 4.19.

5 years agoUse Linux 4.19 in build-many-glibcs.py.
Joseph Myers [Mon, 22 Oct 2018 16:49:37 +0000 (16:49 +0000)]
Use Linux 4.19 in build-many-glibcs.py.

* scripts/build-many-glibcs.py (Context.checkout): Default Linux
version to 4.19.

5 years agoStop c32rtomb and mbrtoc32 aliasing wcrtomb and mbrtowc (bug 23793).
Joseph Myers [Mon, 22 Oct 2018 14:52:14 +0000 (14:52 +0000)]
Stop c32rtomb and mbrtoc32 aliasing wcrtomb and mbrtowc (bug 23793).

glibc does:

/* There should be no difference between the UTF-32 handling required
   by c32rtomb and the wchar_t handling which has long since been
   implemented in wcrtomb.  */
weak_alias (__wcrtomb, c32rtomb)

/* There should be no difference between the UTF-32 handling required
   by mbrtoc32 and the wchar_t handling which has long since been
   implemented in mbrtowc.  */
weak_alias (__mbrtowc, mbrtoc32)

The reasoning in those comments to justify those aliases is incorrect:
ISO C requires that, for the case of a NULL mbstate_t* being passed,
each function has its *own* internal static mbstate_t.  Thus a program
must be able to use both wcrtomb and c32rtomb at the same time with
each keeping its own separate state, and likewise for mbrtowc and
mbrtoc32.

This patch duly sets up separarate char32_t function that wrap the
wchar_t ones.  Note that the included test only covers the mbrtoc32 /
mbrtowc pair.  While I think the change made is logically correct for
c32rtomb / wcrtomb as well, I'm not sure we have a locale with a
suitable state-dependent multibyte encoding for testing that part of
the change.

Tested for x86_64.

[BZ #23793]
* wcsmbs/c32rtomb.c: New file.
* wcsmbs/mbrtoc32.c: Likewise.
* wcsmbs/tst-c32-state.c: Likewise.
* wcsmbs/mbrtowc.c (mbrtoc32): Do not define as alias.
* wcsmbs/wcrtomb.c (c32rtomb): Likewise.
* wcsmbs/Makefile (routines): Add mbrtoc32 and c32rtomb.
(tests): Add tst-c32-state.
[$(run-built-tests) = yes] ($(objpfx)tst-c32-state.out): Depend on
$(gen-locales).

5 years agox86: Don't include <x86intrin.h>
H.J. Lu [Sun, 21 Oct 2018 07:37:11 +0000 (00:37 -0700)]
x86: Don't include <x86intrin.h>

Use __builtin_ia32_rdtsc directly since including <x86intrin.h> makes
building glibc very slow.  On Intel Core i5-6260U, this patch reduces
x86-64 build time from 8 minutes 33 seconds to 3 minutes 48 seconds
with "make -j4" and GCC 8.2.1.

* sysdeps/x86/hp-timing.h: Don't include <x86intrin.h>.
(HP_TIMING_NOW): Replace _rdtsc with __builtin_ia32_rdtsc.

5 years agoHandle surrogate pairs in c16rtomb (bug 23794, DR#488, C2X).
Joseph Myers [Fri, 19 Oct 2018 16:31:29 +0000 (16:31 +0000)]
Handle surrogate pairs in c16rtomb (bug 23794, DR#488, C2X).

The c16rtomb implementation has:

  // XXX The ISO C 11 spec I have does not say anything about handling
  // XXX surrogates in this interface.

The DR#488 resolution, as applied to C2X, requires surrogate pairs to
be handled here (so the first call returns 0 and stores the high
surrogate in the mbstate_t, while the second call combines the
surrogates, produces a multibyte character and returns the number of
bytes written).  This patch implements that.  (mbrtoc16 already
handled producing surrogates as output.)

Tested for x86_64.

[BZ #23794]
* wcsmbs/c16rtomb.c (c16rtomb): Save first character of surrogate
pair and return 0 in that case, and use saved character to
interpret following character.
* wcsmbs/tst-c16-surrogate.c: New file.
* wcsmbs/Makefile (tests): Add tst-c16-surrogate.c.
[$(run-built-tests) = yes] ($(objpfx)tst-c16-surrogate.out):
Depend on $(gen-locales)

5 years agosignal: Use correct type for si_band in siginfo_t [BZ #23562]
Ilya Yu. Malakhov [Fri, 19 Oct 2018 16:06:32 +0000 (18:06 +0200)]
signal: Use correct type for si_band in siginfo_t [BZ #23562]

5 years agoresource: Update struct rusage comments [BZ #23689]
Florian Weimer [Fri, 19 Oct 2018 16:03:21 +0000 (18:03 +0200)]
resource: Update struct rusage comments [BZ #23689]

5 years agoAdd VDSO support to sparc.
David S. Miller [Thu, 18 Oct 2018 18:42:19 +0000 (11:42 -0700)]
Add VDSO support to sparc.

* sysdeps/unix/sysv/linux/sparc/init-first.c: New file.
* sysdeps/unix/sysv/linux/sparc/libc-vdso.h: New file.
* sysdeps/unix/sysv/linux/sparc/Makefile: Add dl-vdso to
sysdep_routines in subdir elf.
* sysdeps/unix/sysv/linux/sparc/Versions: Add GLIBC_PRIVATE
version for __vdso_clock_gettime.
* sysdeps/unix/sysv/linux/sparc/sysdep.h (INTERNAL_VSYSCALL_CALL):
Define.
(HAVE_CLOCK_GETTIME_VSYSCALL): Define.
(HAVE_GETTIMEOFDAY_VSYSCALL): Define.

5 years agoRegenerate sparc ulps.
David S. Miller [Thu, 18 Oct 2018 18:39:51 +0000 (11:39 -0700)]
Regenerate sparc ulps.

* sysdeps/sparc/fpu/libm-test-ulps: Regenerated.

5 years agox86: Use _rdtsc intrinsic for HP_TIMING_NOW
H.J. Lu [Wed, 17 Oct 2018 22:16:38 +0000 (15:16 -0700)]
x86: Use _rdtsc intrinsic for HP_TIMING_NOW

Since _rdtsc intrinsic is supported in GCC 4.9, we can use it for
HP_TIMING_NOW.  This patch

1. Create x86 hp-timing.h to replace i686 and x86_64 hp-timing.h.
2. Move MINIMUM_ISA from init-arch.h to isa.h so that x86 hp-timing.h
can check minimum x86 ISA to decide if _rdtsc can be used.

NB: Checking if __i686__ isn't sufficient since __i686__ may not be
defined when building for i686 class processors.

* sysdeps/i386/init-arch.h: Removed.
* sysdeps/i386/i586/init-arch.h: Likewise.
* sysdeps/i386/i686/init-arch.h: Likewise.
* sysdeps/i386/i686/hp-timing.h: Likewise.
* sysdeps/x86_64/hp-timing.h: Likewise.
* sysdeps/i386/isa.h: New file.
* sysdeps/i386/i586/isa.h: Likewise.
* sysdeps/i386/i686/isa.h: Likewise.
* sysdeps/x86_64/isa.h: Likewise.
* sysdeps/x86/hp-timing.h: New file.
* sysdeps/x86/init-arch.h: Include <isa.h>.

5 years agoDo not allow divide-by-zero exception for pow(+/- 0, -Inf).
Joseph Myers [Wed, 17 Oct 2018 21:23:40 +0000 (21:23 +0000)]
Do not allow divide-by-zero exception for pow(+/- 0, -Inf).

C99 wrongly specified a divide-by-zero exception for pow(+/- 0, -Inf);
C11 made it optional after this was pointed out, and the permission
for this exception has been removed in the current C2x draft.  This
patch makes the glibc pow tests reflect the stricter requirement
(which follows the normal IEEE rules that a divide-by-zero exception
is for the case of exact infinite results from *finite* operands, not
for such results when any operand is infinite).

Tested for x86_64 and x86.  (If any other pow implementation in glibc,
not exercised on those architectures, turns out to fail the stricter
test, it should be fixed to avoid the exception in this case.)

* math/libm-test-pow.inc (pow_test_data): Do not allow
divide-by-zero exception for pow(+/- 0, -Inf).

5 years ago[manual] Job control is no longer optional.
Zack Weinberg [Wed, 17 Oct 2018 18:10:51 +0000 (14:10 -0400)]
[manual] Job control is no longer optional.

Job control was made mandatory in POSIX.1-2001: compare
<http://pubs.opengroup.org/onlinepubs/7990989775/xsh/unistd.h.html> with
<http://pubs.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html>.
Seventeen years later, we need not devote an entire manual @node to
warning people that this was once an optional POSIX feature.

* manual/job.texi (Job Control is Optional): Remove node, as
job control has not been optional in quite some time.
(Job Control): Mention briefly that systems older than
POSIX.1-2001 might not support job control.
* manual/conf.texi (_POSIX_JOB_CONTROL): Will always be
defined on systems conforming to POSIX.1-2001.

5 years agoRemove unnecessary locking when reading iconv configuration [BZ #22062]
Arjun Shankar [Wed, 17 Oct 2018 15:47:29 +0000 (17:47 +0200)]
Remove unnecessary locking when reading iconv configuration [BZ #22062]

In iconv/gconv_conf.c, __gconv_get_path unnecessarily obtains a lock when
populating the array pointed to by __gconv_path_elem. The locking is not
necessary because all calls to __gconv_read_conf (which in turn calls
__gconv_get_path) are serialized using __libc_once.

This patch:
- removes all locking in __gconv_get_path;
- replaces all explicitly serialized __gconv_read_conf calls with calls to
  __gconv_load_conf, a new wrapper that is serialized internally;
- adds a new test, iconv/tst-iconv_mt.c, to exercise iconv initialization,
  usage, and cleanup in a multi-threaded program;
- indents __gconv_get_path correctly, removing tab characters (which makes
  the patch look a little bigger than it really is).

After removing the unnecessary locking, it was confirmed that the test case
fails if the relevant __libc_once is removed. Additionally, four localedata
and iconvdata tests also fail. This gives confidence that the testsuite
sufficiently guards against some regressions relating to multi-threading
with iconv.

Tested on x86_64 and i686.

5 years agoUse single bits/shm.h for all architectures.
Joseph Myers [Wed, 17 Oct 2018 11:56:28 +0000 (11:56 +0000)]
Use single bits/shm.h for all architectures.

After my patch to move SHMLBA to its own header, the bits/shm.h
headers for architectures using the Linux kernel still vary in a few
ways: the use of __syscall_ulong_t; whether padding for 32-bit systems
is present before or after time fields, or missing altogether (mips,
x32); whether shm_segsz is before or after the time fields; whether,
if after time fields, there is extra padding before shm_segsz.

This patch arranges for a single header to be used.  __syscall_ulong_t
is safe to use everywhere, while bits/shm-pad.h is added with new
macros __SHM_PAD_AFTER_TIME, __SHM_PAD_BEFORE_TIME,
__SHM_SEGSZ_AFTER_TIME and __SHM_PAD_BETWEEN_TIME_AND_SEGSZ to
describe the differences.

Tested for x86_64 and x86, and with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
bits/shm-pad.h.
* sysdeps/unix/sysv/linux/bits/shm.h: Include <bits/shm-pad.h>.
(shmatt_t): Define as __syscall_ulong_t.
(__SHM_PAD_TIME): New macro, depending on [__SHM_PAD_BEFORE_TIME]
and [__SHM_PAD_AFTER_TIME].
(struct shmid_ds): Define time fields using __SHM_PAD_TIME.
Define shm_segsz and associated padding based on
[__SHM_SEGSZ_AFTER_TIME] and [__SHM_PAD_BETWEEN_TIME_AND_SEGSZ].
Use __syscall_ulong_t instead of unsigned long int.
[__USE_MISC] (struct shminfo): Use __syscall_ulong_t instead of
unsigned long int.
[__USE_MISC] (struct shm_info): Likewise.
* sysdeps/unix/sysv/linux/bits/shm-pad.h: New file.
* sysdeps/unix/sysv/linux/hppa/bits/shm-pad.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/shm-pad.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/shm-pad.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/shm-pad.h: Likewise.
* sysdeps/unix/sysv/linux/x86/bits/shm-pad.h: Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/shm.h: Remove.
* sysdeps/unix/sysv/linux/mips/bits/shm.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/shm.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/shm.h: Likewise.
* sysdeps/unix/sysv/linux/x86/bits/shm.h: Likewise.

5 years agoMove SHMLBA to its own header.
Joseph Myers [Wed, 17 Oct 2018 11:55:10 +0000 (11:55 +0000)]
Move SHMLBA to its own header.

One difference between bits/shm.h headers for architectures using the
Linux kernel is the definition of SHMLBA.  This was noted in
<https://sourceware.org/ml/libc-alpha/2018-09/msg00175.html> as a
reason why even a new architecture (C-SKY) might need its own
bits/shm.h; thus, splitting it out of bits/shm.h can allow less
duplication of headers for new architectures.

This patch moves that definition to its own header, bits/shmlba.h, to
allow more sharing of headers between architectures.  That move allows
the arm, ia64 and sh variants of bits/shm.h to be removed, as they had
no other significant differences from the generic bits/shm.h; powerpc
and x86 have their own bits/shm.h but do not need to get their own
bits/shmlba.h because they use the same SHMLBA as the generic header.
Other architectures with their own bits/shm.h get their own
bits/shmlba.h without being able to remove their own bits/shm.h until
the generic one has been adapted to be able to handle more
architectures (where, in addition to the differences seen for
bits/msq.h and bits/sem.h, the position of shm_segsz in struct
shmid_ds also depends on the architecture).

Tested for x86_64 and x86, and with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
bits/shmlba.h.
* sysdeps/unix/sysv/linux/bits/shm.h: Include <bits/shmlba.h>.
(SHMLBA): Remove macro.
(__getpagesize): Remove function declaration.
* sysdeps/unix/sysv/linux/hppa/bits/shm.h: Include
<bits/shmlba.h>.
(SHMLBA): Remove macro.
* sysdeps/unix/sysv/linux/mips/bits/shm.h: Include
<bits/shmlba.h>.
(SHMLBA): Remove macro.
* sysdeps/unix/sysv/linux/powerpc/bits/shm.h: Include
<bits/shmlba.h>.
(SHMLBA): Remove macro.
(__getpagesize): Remove function declaration.
* sysdeps/unix/sysv/linux/sparc/bits/shm.h: Include
<bits/shmlba.h>.
(SHMLBA): Remove macro.
(__getshmlba): Remove function declaration.
* sysdeps/unix/sysv/linux/x86/bits/shm.h: Include <bits/shmlba.h>.
(SHMLBA): Remove macro.
(__getpagesize): Remove function declaration.
* sysdeps/unix/sysv/linux/arm/bits/shm.h: Remove file.
* sysdeps/unix/sysv/linux/ia64/bits/shm.h: Likewise.
* sysdeps/unix/sysv/linux/sh/bits/shm.h: Likewise.
* sysdeps/unix/sysv/linux/bits/shmlba.h: New file.
* sysdeps/unix/sysv/linux/arm/bits/shmlba.h: Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/shmlba.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/bits/shmlba.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/shmlba.h: Likewise.
* sysdeps/unix/sysv/linux/sh/bits/shmlba.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/shmlba.h: Likewise.

5 years agoFix race in pthread_mutex_lock while promoting to PTHREAD_MUTEX_ELISION_NP [BZ #23275]
Stefan Liebler [Wed, 17 Oct 2018 10:23:04 +0000 (12:23 +0200)]
Fix race in pthread_mutex_lock while promoting to PTHREAD_MUTEX_ELISION_NP [BZ #23275]

The race leads either to pthread_mutex_destroy returning EBUSY
or triggering an assertion (See description in bugzilla).

This patch is fixing the race by ensuring that the elision path is
used in all cases if elision is enabled by the GLIBC_TUNABLES framework.

The __kind variable in struct __pthread_mutex_s is accessed concurrently.
Therefore we are now using the atomic macros.

The new testcase tst-mutex10 is triggering the race on s390x and intel.
Presumably also on power, but I don't have access to a power machine
with lock-elision. At least the code for power is the same as on the other
two architectures.

ChangeLog:

[BZ #23275]
* nptl/tst-mutex10.c: New File.
* nptl/Makefile (tests): Add tst-mutex10.
(tst-mutex10-ENV): New variable.
* sysdeps/unix/sysv/linux/s390/force-elision.h: (FORCE_ELISION):
Ensure that elision path is used if elision is available.
* sysdeps/unix/sysv/linux/powerpc/force-elision.h (FORCE_ELISION):
Likewise.
* sysdeps/unix/sysv/linux/x86/force-elision.h: (FORCE_ELISION):
Likewise.
* nptl/pthreadP.h (PTHREAD_MUTEX_TYPE, PTHREAD_MUTEX_TYPE_ELISION)
(PTHREAD_MUTEX_PSHARED): Use atomic_load_relaxed.
* nptl/pthread_mutex_consistent.c (pthread_mutex_consistent): Likewise.
* nptl/pthread_mutex_getprioceiling.c (pthread_mutex_getprioceiling):
Likewise.
* nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full)
(__pthread_mutex_cond_lock_adjust): Likewise.
* nptl/pthread_mutex_setprioceiling.c (pthread_mutex_setprioceiling):
Likewise.
* nptl/pthread_mutex_timedlock.c (__pthread_mutex_timedlock): Likewise.
* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise.
* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock_full): Likewise.
* sysdeps/nptl/bits/thread-shared-types.h (struct __pthread_mutex_s):
Add comments.
* nptl/pthread_mutex_destroy.c (__pthread_mutex_destroy):
Use atomic_load_relaxed and atomic_store_relaxed.
* nptl/pthread_mutex_init.c (__pthread_mutex_init):
Use atomic_store_relaxed.

5 years agoDon't reduce test timeout to less than default
Andreas Schwab [Tue, 16 Oct 2018 15:45:02 +0000 (17:45 +0200)]
Don't reduce test timeout to less than default

This removes all overrides of TIMEOUT that are less than or equal to the
default timeout.

5 years agoRemove extra space at end of line.
Steve Ellcey [Tue, 16 Oct 2018 18:02:03 +0000 (11:02 -0700)]
Remove extra space at end of line.

5 years agoaarch64: optimized memcpy implementation for thunderx2
Anton Youdkevitch [Tue, 16 Oct 2018 18:00:27 +0000 (11:00 -0700)]
aarch64: optimized memcpy implementation for thunderx2

Since aligned loads and stores are huge performance
advantage the implementation always tries to do aligned
access. Among the cases when src and dst addresses are
aligned or unaligned evenly there are cases of not evenly
unaligned src and dst. For such cases (if the length is
big enough) ext instruction is used to merge-and-shift
two memory chunks loaded from two adjacent aligned
locations and then the adjusted chunk gets stored to
aligned address.

Performance gain against the current T2 implementation:
     memcpy-large: 65K-32M: +40% - +10%
     memcpy-walk:  128-32M: +20% - +2%

5 years agoUse single bits/sem.h for all architectures.
Joseph Myers [Mon, 15 Oct 2018 19:28:04 +0000 (19:28 +0000)]
Use single bits/sem.h for all architectures.

The bits/sem.h headers for architectures using the Linux kernel vary
in a few ways:

* x32 uses __syscall_ulong_t instead of unsigned long int.

* The x86 header uses padding after time fields unconditionally
  (including for both x86_64 ABIs), not just for 32-bit time (unlike
  in msqid_ds where there is only padding for 32-bit time).  Because
  this padding is present for x32, and is __syscall_ulong_t there, it
  does have to be __syscall_ulong_t, not unsigned long int.

* The MIPS header never uses padding around time fields, even when
  32-bit (unlike in msqid_ds where it has endian-dependent padding for
  32-bit time).

* Some older 32-bit big-endian architectures have padding before
  rather than after time fields, although the preferred generic
  approach is padding after the time fields independent of endianness.

(There are also insubstantial differences such as use of unsigned int
for padding instead of unsigned long int, which makes no difference to
layout since the padding fields using unsigned int are only present on
32-bit architectures.)

For the first, __syscall_ulong_t can be used in the generic version as
it's the same as unsigned long int everywhere except x32.  For the
other differences, this patch adds macros __SEM_PAD_BEFORE_TIME and
__SEM_PAD_AFTER_TIME in a new bits/sem-pad.h header, so that header is
the only one needing to be provided on architectures with differences
in this area, and everything else can go in a single common bits/sem.h
header.

Tested for x86_64 and x86, and with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
bits/sem-pad.h.
* sysdeps/unix/sysv/linux/bits/sem.h: Include <bits/sem-pad.h>
instead of <bits/wordsize.h>.
(__SEM_PAD_TIME): New macro, depending on [__SEM_PAD_BEFORE_TIME]
and [__SEM_PAD_AFTER_TIME].
(struct semid_ds): Define time fields using __SEM_PAD_TIME.  Use
__syscall_ulong_t instead of unsigned long int.
* sysdeps/unix/sysv/linux/bits/sem-pad.h: New file.
* sysdeps/unix/sysv/linux/hppa/bits/sem-pad.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/sem-pad.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/sem-pad.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/sem-pad.h: Likewise.
* sysdeps/unix/sysv/linux/x86/bits/sem-pad.h: Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/sem.h: Remove.
* sysdeps/unix/sysv/linux/mips/bits/sem.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/sem.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/sem.h: Likewise.
* sysdeps/unix/sysv/linux/x86/bits/sem.h: Likewise.

5 years agoregex: simplify by using intprops.h
Paul Eggert [Mon, 15 Oct 2018 03:20:08 +0000 (22:20 -0500)]
regex: simplify by using intprops.h

[BZ#23744]
* posix/regex_internal.h [_LIBC]: Include intprops.h.
(TYPE_SIGNED, INT_ADD_WRAPV) [_LIBC]: Remove.
intprops.h defines them.

5 years agoregex: __builtin_expect → __glibc_unlikely
Paul Eggert [Mon, 15 Oct 2018 03:20:08 +0000 (22:20 -0500)]
regex: __builtin_expect → __glibc_unlikely

[BZ#23744]
This refactoring was prompted by a problem when the regex code is
used as part of Gnulib and when the builder’s compiler does not grok
__builtin_expect.  Problem reported for Gawk by Nelson H.F. Beebe in:
https://lists.gnu.org/r/bug-gnulib/2018-09/msg00137.html
Although this refactoring does not fix the problem directly,
we might as well have Gawk use the now-preferred glibc style for when
__builtin_expect is unavailable.
* posix/regex_internal.h (BE): Remove.
All uses replaced by __glibc_unlikely or __glibc_likely.

5 years agoUse single bits/msq.h for all architectures.
Joseph Myers [Thu, 11 Oct 2018 12:07:27 +0000 (12:07 +0000)]
Use single bits/msq.h for all architectures.

The bits/msq.h headers for architectures using the Linux kernel vary
in a few ways:

* x32 uses __syscall_ulong_t instead of unsigned long int.

* x32 has 64-bit time_t, so no padding around time fields despite
  __WORDSIZE == 32.

* Some older 32-bit big-endian architectures have padding before
  rather than after time fields, although the preferred generic
  approach is padding after the time fields independent of endianness.

(There are also insubstantial differences such as use of unsigned int
for padding instead of unsigned long int, which makes no difference to
layout since the padding fields using unsigned int are only present on
32-bit architectures.)

For the first, __syscall_ulong_t can be used in the generic version as
it's the same as unsigned long int everywhere except x32.  For the
other two differences, this patch adds macros __MSQ_PAD_BEFORE_TIME
and __MSQ_PAD_AFTER_TIME in a new bits/msq-pad.h header, so that
header is the only one needing to be provided on architectures with
differences in this area, and everything else can go in a single
common bits/msq.h header.  Once we have __TIMESIZE, the generic
bits/msq-pad.h can change to use that instead of __WORDSIZE, at which
point the x86 version of bits/msq-pad.h won't be needed either.

Tested for x86_64 and x86, and with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/Makefile (sysdep_headers): Add
bits/msq-pad.h.
* sysdeps/unix/sysv/linux/bits/msq.h: Include <bits/msq-pad.h>
instead of <bits/wordsize.h>.
(msgqnum_t): Define as __syscall_ulong_t.
(msglen_t): Likewise.
(__MSQ_PAD_TIME): New macro, depending on [__MSQ_PAD_BEFORE_TIME]
and [__MSQ_PAD_AFTER_TIME].
(struct msqid_ds): Define time fields using __MSQ_PAD_TIME.  Use
__syscall_ulong_t instead of unsigned long int.
* sysdeps/unix/sysv/linux/bits/msq-pad.h: New file.
* sysdeps/unix/sysv/linux/hppa/bits/msq-pad.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/msq-pad.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/msq-pad.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/msq-pad.h: Likewise.
* sysdeps/unix/sysv/linux/x86/bits/msq-pad.h: Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/msq.h: Remove.
* sysdeps/unix/sysv/linux/mips/bits/msq.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/msq.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/msq.h: Likewise.
* sysdeps/unix/sysv/linux/x86/bits/msq.h: Likewise.

5 years agoUse common bits/shm.h for more architectures.
Joseph Myers [Wed, 10 Oct 2018 00:56:17 +0000 (00:56 +0000)]
Use common bits/shm.h for more architectures.

sysdeps/unix/sysv/linux/bits/shm.h has padding after time fields in
struct shmid_ds unconditionally, and thus is only suitable for 32-bit
architectures (no 64-bit configurations use this file);
sysdeps/unix/sysv/linux/generic/bits/shm.h is substantively the same,
except that the padding is conditioned on __WORDSIZE == 32, and so it
can be used for 64-bit architectures as well.

This patch adds the conditionals to
sysdeps/unix/sysv/linux/bits/shm.h.  The linux/generic/ version is
then no longer needed and so is removed, as are the alpha and s390
versions which are also no longer needed.  The other
architecture-specific versions have different padding, layout, types
or SHMLBA definitions and so are still needed after this change.

This is essentially the same change for bits/shm.h as the bits/msq.h
patch and the bits/sem.h patch.  However, the details of the padding
variations for the architectures that aren't changed are not all the
same between msqid_ds, shmid_ds and semid_ds.

Tested with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/bits/shm.h: Include <bits/wordsize.h>.
(struct shmid_ds): Condition padding after time fields on
[__WORDSIZE == 32].
* sysdeps/unix/sysv/linux/alpha/bits/shm.h: Remove file.
* sysdeps/unix/sysv/linux/generic/bits/shm.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/shm.h: Likewise.

5 years agoUse common bits/sem.h for more architectures.
Joseph Myers [Wed, 10 Oct 2018 00:54:27 +0000 (00:54 +0000)]
Use common bits/sem.h for more architectures.

sysdeps/unix/sysv/linux/bits/sem.h has padding after time fields in
struct semid_ds unconditionally, and thus is only suitable for 32-bit
architectures (no 64-bit configurations use this file);
sysdeps/unix/sysv/linux/generic/bits/sem.h is substantively the same,
except that the padding is conditioned on __WORDSIZE == 32, and so it
can be used for 64-bit architectures as well.

This patch adds the conditionals to
sysdeps/unix/sysv/linux/bits/sem.h.  The linux/generic/ version is
then no longer needed and so is removed, as are the alpha, ia64 and
s390 versions which are also no longer needed.  The other
architecture-specific versions have different padding or types and so
are still needed after this change.

This is essentially the same change for bits/sem.h as the bits/msq.h
patch.  However, the details of the padding variations for the
architectures that aren't changed are not all the same between
msqid_ds and semid_ds.

Tested with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/bits/sem.h: Include <bits/wordsize.h>.
(struct semid_ds): Condition padding after time fields on
[__WORDSIZE == 32].
* sysdeps/unix/sysv/linux/alpha/bits/sem.h: Remove file.
* sysdeps/unix/sysv/linux/generic/bits/sem.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/bits/sem.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/sem.h: Likewise.

5 years agoUse common bits/msq.h for more architectures.
Joseph Myers [Wed, 10 Oct 2018 00:52:47 +0000 (00:52 +0000)]
Use common bits/msq.h for more architectures.

sysdeps/unix/sysv/linux/bits/msq.h has padding after time fields in
struct msqid_ds unconditionally, and thus is only suitable for 32-bit
architectures (no 64-bit configurations use this file);
sysdeps/unix/sysv/linux/generic/bits/msq.h is substantively the same,
except that the padding is conditioned on __WORDSIZE == 32, and so it
can be used for 64-bit architectures as well.

This patch adds the conditionals to
sysdeps/unix/sysv/linux/bits/msq.h.  The linux/generic/ version is
then no longer needed and so is removed, as are the alpha, ia64 and
s390 versions which are also no longer needed.  The other
architecture-specific versions have different padding or types and so
are still needed after this change.

Tested with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/bits/msq.h: Include <bits/wordsize.h>.
(struct msqid_ds): Condition padding after time fields on
[__WORDSIZE == 32].
* sysdeps/unix/sysv/linux/alpha/bits/msq.h: Remove file.
* sysdeps/unix/sysv/linux/generic/bits/msq.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/bits/msq.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/msq.h: Likewise.