platform/upstream/glibc.git
6 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.

6 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>
6 years agoMerge branch 'master' into errno
Samuel Thibault [Wed, 31 Oct 2018 09:33:45 +0000 (10:33 +0100)]
Merge branch 'master' into errno

6 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.

6 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

6 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.

6 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.

6 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.

6 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

6 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.

6 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.

6 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.

6 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.

6 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>
6 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

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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).

6 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.

6 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.

6 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.

6 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.

6 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.

6 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

6 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.

6 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)

6 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.

6 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.

6 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.

6 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.

6 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

6 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

6 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.

6 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.

6 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).

6 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.

6 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)

6 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]

6 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]

6 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.

6 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.

6 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>.

6 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).

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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%

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 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.

6 years agoIncrease timeout of nss/tst-nss-files-hosts-multi
Szabolcs Nagy [Tue, 9 Oct 2018 14:00:39 +0000 (15:00 +0100)]
Increase timeout of nss/tst-nss-files-hosts-multi

Increase timeout from the default 20s to 40s. This test makes close to
2 million syscalls with distribution:

1180249 connect
 297952 getsockname
 144040 lseek
 143734 read
  14466 close
...

connect can be slow, so the default timeout was not enough on slow
systems.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* nss/tst-nss-files-hosts-multi.c (TIMEOUT): Define.

6 years agoIncrease timeout of libio/tst-readline
Szabolcs Nagy [Tue, 9 Oct 2018 13:31:28 +0000 (14:31 +0100)]
Increase timeout of libio/tst-readline

Increase timeout from the default 20s to 100s. This test makes close to
20 million syscalls with distribution:

12327675 read
 4143204 lseek
  929475 close
  929471 openat
   92817 fstat
    1431 write
...

The default timeout assumes each can finish in 1us on average which
is not true on slow machines.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* libio/tst-readline.c (TIMEOUT): Define.

6 years agomktime fix for Gnulib + coreutils
Paul Eggert [Mon, 8 Oct 2018 05:30:13 +0000 (22:30 -0700)]
mktime fix for Gnulib + coreutils

[BZ#23745]
This fix affects only Gnulib.  Problem discovered when
mktime.c was used as part of Gnulib in bleeding-edge Coreutils.
* time/mktime.c:
(my_tzset) [!_LIBC && !NEED_MKTIME_WORKING && !NEED_MKTIME_WINDOWS]:
Do not define since it is not used.  Defining an unused static
function prompts a warning from GCC when Coreutils is configured
with --enable-gcc-warnings.

6 years agobenchtests: Set float type on --threshold argument
Leonardo Sandoval [Thu, 4 Oct 2018 21:40:36 +0000 (16:40 -0500)]
benchtests: Set float type on --threshold argument

Otherwise, we see the following runtime error when using the parameter:

  File "./glibc/benchtests/scripts/compare_bench.py", line 46, in do_compare
    if d > threshold:
TypeError: '>' not supported between instances of 'float' and 'str'

* benchtests/scripts/compare_bench.py (main): set float type on
threshold argument.

6 years agokl_GL: Update the month names and date formats (bug 23740).
Rafal Luzynski [Fri, 5 Oct 2018 20:52:51 +0000 (22:52 +0200)]
kl_GL: Update the month names and date formats (bug 23740).

Month names as provided by Oqaasileriffik, the official Greenlandic
language regulator.  They have recently reached the consensus regarding
the orthography of the month names.

Date formats updated to match the correct Greenlandic order which is MDY.

[BZ #23740]
* localedata/locales/kl_GL (mon): Update, the relative case.
(alt_mon): Add, fill with month names in the nominative case.
(d_t_fmt): Set to "%a %b %d %Y %T %Z".
(d_fmt): Set to "%b %d %Y".

6 years agoUse bits/mman-linux.h for hppa.
Joseph Myers [Thu, 4 Oct 2018 19:47:23 +0000 (19:47 +0000)]
Use bits/mman-linux.h for hppa.

hppa currently has a bits/mman.h that does not include
bits/mman-linux.h, unlike all other architectures using the Linux
kernel.  This sort of variation between architectures is generally
unhelpful when making global changes for new constants added to new
Linux kernel releases.

This patch changes hppa to use bits/mman-linux.h, overriding constants
with different values as necessary (including with #undef after
bits/mman.h inclusion when needed, as already done for alpha).  While
there could possibly be further improvements through e.g. splitting
more sets of definitions into separate bits/ headers, I think this is
still an improvement on the current state.  diffstat shows 27 lines
added, 51 deleted (and some of that is actually existing lines moving
to a different place in the file).

Tested with build-many-glibcs.py for hppa-linux-gnu.

* sysdeps/unix/sysv/linux/hppa/bits/mman.h: Include
<bits/mman-linux.h>.
(PROT_READ): Don't define here.
(PROT_WRITE): Likewise.
(PROT_EXEC): Likewise.
(PROT_NONE): Likewise.
(PROT_GROWSDOWN): Likewise.
(PROT_GROWSUP): Likewise.
(MAP_SHARED): Likewise.
(MAP_PRIVATE): Likewise.
[__USE_MISC] (MAP_SHARED_VALIDATE): Likewise.
[__USE_MISC] (MAP_FILE): Likewise.
[__USE_MISC] (MAP_ANONYMOUS): Likewise.
[__USE_MISC] (MAP_ANON): Likewise.
[__USE_MISC] (MAP_HUGE_SHIFT): Likewise.
[__USE_MISC] (MAP_HUGE_MASK): Likewise.
(MCL_CURRENT): Likewise.
(MCL_FUTURE): Likewise.
(MCL_ONFAULT): Likewise.
[__USE_MISC] (MADV_NORMAL): Likewise.
[__USE_MISC] (MADV_RANDOM): Likewise.
[__USE_MISC] (MADV_SEQUENTIAL): Likewise.
[__USE_MISC] (MADV_WILLNEED): Likewise.
[__USE_MISC] (MADV_DONTNEED): Likewise.
[__USE_MISC] (MADV_FREE): Likewise.
[__USE_MISC] (MADV_REMOVE): Likewise.
[__USE_MISC] (MADV_DONTFORK): Likewise.
[__USE_MISC] (MADV_DOFORK): Likewise.
[__USE_MISC] (MADV_HWPOISON): Likewise.
[__USE_XOPEN2K] (POSIX_MADV_NORMAL): Likewise.
[__USE_XOPEN2K] (POSIX_MADV_RANDOM): Likewise.
[__USE_XOPEN2K] (POSIX_MADV_SEQUENTIAL): Likewise.
[__USE_XOPEN2K] (POSIX_MADV_WILLNEED): Likewise.
[__USE_XOPEN2K] (POSIX_MADV_DONTNEED): Likewise.
(__MAP_ANONYMOUS): New macro.
[__USE_MISC] (MAP_TYPE): Undefine and redefine after
<bits/mman-linux.h> inclusion.
(MAP_FIXED): Likewise.
(MS_SYNC): Likewise.
(MS_ASYNC): Likewise.
(MS_INVALIDATE): Likewise.
[__USE_MISC] (MADV_MERGEABLE): Likewise.
[__USE_MISC] (MADV_UNMERGEABLE): Likewise.
[__USE_MISC] (MADV_HUGEPAGE): Likewise.
[__USE_MISC] (MADV_NOHUGEPAGE): Likewise.
[__USE_MISC] (MADV_DONTDUMP): Likewise.
[__USE_MISC] (MADV_DODUMP): Likewise.
[__USE_MISC] (MADV_WIPEONFORK): Likewise.
[__USE_MISC] (MADV_KEEPONFORK): Likewise.

6 years agoFix libnldbl_nonshared.a references to internal libm symbols (bug 23735).
Joseph Myers [Thu, 4 Oct 2018 12:16:05 +0000 (12:16 +0000)]
Fix libnldbl_nonshared.a references to internal libm symbols (bug 23735).

The redirection of built-in functions such as sqrt in include/math.h
applies when the wrappers for those functions in libnldbl_nonshared.a
are built, resulting in references to internal names such as
__ieee754_sqrt that aren't actually exported from the shared libm.
(This applies for sqrt in 2.28, also for the round-to-integer
functions in current master because of my changes there.)  This patch
arranges for NO_MATH_REDIRECT to be used for all the affected
functions, and adds a test for those functions in
libnldbl_nonshared.a.

(We could of course choose to obsolete libnldbl_nonshared.a and
require that people building with -mlong-double-64 either include the
relevant headers and have a compiler supporting asm redirection, or
have some other means of achieving that redirection at compile time if
not including those headers.  But while we have libnldbl_nonshared.a,
it seems appropriate to fix such bugs in it.)

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

[BZ #23735]
* sysdeps/ieee754/ldbl-opt/nldbl-compat.h (NO_MATH_REDIRECT):
Define.
* sysdeps/ieee754/ldbl-opt/test-nldbl-redirect.c: New file.
* sysdeps/ieee754/ldbl-opt/Makefile [$(subdir) = math] (tests):
Add test-nldbl-redirect.
[$(subdir) = math] (CFLAGS-test-nldbl-redirect.c): New variable.
[$(subdir) = math] ($(objpfx)test-nldbl-redirect): Depend on
$(objpfx)libnldbl_nonshared.a.

6 years agoAdjust name of ld.so in test-container.c.
Stefan Liebler [Thu, 4 Oct 2018 11:07:29 +0000 (13:07 +0200)]
Adjust name of ld.so in test-container.c.

The test-container.c file assumes that ld.so is always named
something like /elf/ld-linux-*.
But e.g. on s390x it is named ld64.so.1 or ld.so.1 on s390.
There are other architectures like power or mips with similar names.

This patch introduces the new global variable support_objdir_elf_ldso
which contains the absolute path to the runtime linker used by the
testsuite, e.g. OBJDIR_PATH/elf/ld-linux-x86-64.so.2.
The check in test-container.c is now comparing against this path.
Without this patch, test-container.c is searching invalid files / directories
and fails to find glibc/nss/tst-nss-test3.root/tst-nss-test3.script.
Then the test tst-nss-test3 fails!

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
ChangeLog:

* support/support.h (support_objdir_elf_ldso): New variable.
* support/support_paths.c (support_objdir_elf_ldso): Likewise.
* support/Makefile (CFLAGS-support_paths.c): Add definition
for OBJDIR_ELF_LDSO_PATH.
* support/test-container.c (main): Search for the ld.so
which is also used by the testsuite.

6 years agokl_GL: Fix spelling of Sunday, should be "sapaat" (bug 20209).
Rafal Luzynski [Tue, 2 Oct 2018 21:34:18 +0000 (23:34 +0200)]
kl_GL: Fix spelling of Sunday, should be "sapaat" (bug 20209).

Although CLDR says otherwise, it is confirmed by Oqaasileriffik, the
official Greenlandic language regulator, that this change is correct.

[BZ #20209]
* localedata/locales/kl_GL: (abday): Fix spelling of Sun (Sunday),
should be "sap" rather than "sab".
(day): Fix spelling of Sunday, should be "sapaat" rather than
"sabaat".

6 years agoAdd more fma tests.
Joseph Myers [Tue, 2 Oct 2018 17:17:15 +0000 (17:17 +0000)]
Add more fma tests.

In my review
<https://sourceware.org/ml/libc-alpha/2018-06/msg00375.html> of a
patch for bug 23584, I expressed concern that the proposed changes
didn't deal with certain cases similar to the ones in the bug but
where test coverage was missing.

This patch adds such tests of fma (Inf, finite, finite) and fma
(finite, Inf, finite) to libm-test-fma.inc.  It does *not* do anything
to fix the bug, simply adds test coverage to provide stronger evidence
of whether any proposed revised fix does address the cases I was
concerned with.

Tested for x86_64 and x86.

* math/libm-test-fma.inc (fma_test_data): Add more tests.

6 years agosysdeps/ieee754/soft-fp: ignore maybe-uninitialized with -O [BZ #19444]
Martin Jansa [Tue, 2 Oct 2018 15:38:43 +0000 (15:38 +0000)]
sysdeps/ieee754/soft-fp: ignore maybe-uninitialized with -O [BZ #19444]

* with -O, -O1, -Os it fails with:

In file included from ../soft-fp/soft-fp.h:318,
                 from ../sysdeps/ieee754/soft-fp/s_fdiv.c:28:
../sysdeps/ieee754/soft-fp/s_fdiv.c: In function '__fdiv':
../soft-fp/op-2.h:98:25: error: 'R_f1' may be used uninitialized in this function [-Werror=maybe-uninitialized]
        X##_f0 = (X##_f1 << (_FP_W_TYPE_SIZE - (N)) | X##_f0 >> (N) \
                         ^~
../sysdeps/ieee754/soft-fp/s_fdiv.c:38:14: note: 'R_f1' was declared here
   FP_DECL_D (R);
              ^
../soft-fp/op-2.h:37:36: note: in definition of macro '_FP_FRAC_DECL_2'
   _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT
                                    ^
../soft-fp/double.h:95:24: note: in expansion of macro '_FP_DECL'
 # define FP_DECL_D(X)  _FP_DECL (2, X)
                        ^~~~~~~~
../sysdeps/ieee754/soft-fp/s_fdiv.c:38:3: note: in expansion of macro 'FP_DECL_D'
   FP_DECL_D (R);
   ^~~~~~~~~
../soft-fp/op-2.h:101:17: error: 'R_f0' may be used uninitialized in this function [-Werror=maybe-uninitialized]
       : (X##_f0 << (_FP_W_TYPE_SIZE - (N))) != 0)); \
                 ^~
../sysdeps/ieee754/soft-fp/s_fdiv.c:38:14: note: 'R_f0' was declared here
   FP_DECL_D (R);
              ^
../soft-fp/op-2.h:37:14: note: in definition of macro '_FP_FRAC_DECL_2'
   _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT
              ^
../soft-fp/double.h:95:24: note: in expansion of macro '_FP_DECL'
 # define FP_DECL_D(X)  _FP_DECL (2, X)
                        ^~~~~~~~
../sysdeps/ieee754/soft-fp/s_fdiv.c:38:3: note: in expansion of macro 'FP_DECL_D'
   FP_DECL_D (R);
   ^~~~~~~~~

Build tested with Yocto for ARM, AARCH64, X86, X86_64, PPC, MIPS, MIPS64
with -O, -O1, -Os.
For AARCH64 it needs one more fix in locale for -Os.

[BZ #19444]
* sysdeps/ieee754/soft-fp/s_fdiv.c: Include <libc-diag.h> and use
DIAG_PUSH_NEEDS_COMMENT, DIAG_IGNORE_NEEDS_COMMENT and
DIAG_POP_NEEDS_COMMENT to disable -Wmaybe-uninitialized.

6 years agoFix build from commit 0b727ed
Adhemerval Zanella [Tue, 2 Oct 2018 15:26:53 +0000 (15:26 +0000)]
Fix build from commit 0b727ed

* sysdeps/unix/sysv/linux/fd_to_filename.h: Add missing includes.

6 years agox86: Use RTM intrinsics in pthread mutex lock elision
H.J. Lu [Tue, 2 Oct 2018 14:51:48 +0000 (07:51 -0700)]
x86: Use RTM intrinsics in pthread mutex lock elision

Since RTM intrinsics are supported in GCC 4.9, we can use them in
pthread mutex lock elision.

* sysdeps/unix/sysv/linux/x86/Makefile (CFLAGS-elision-lock.c):
Add -mrtm.
(CFLAGS-elision-unlock.c): Likewise.
(CFLAGS-elision-timed.c): Likewise.
(CFLAGS-elision-trylock.c): Likewise.
* sysdeps/unix/sysv/linux/x86/hle.h: Rewritten.

6 years agolibio: Flush stream at freopen (BZ#21037)
Adhemerval Zanella [Thu, 13 Jul 2017 19:43:24 +0000 (16:43 -0300)]
libio: Flush stream at freopen (BZ#21037)

As POSIX states [1] a freopen call should first flush the stream as if by a
call fflush.  C99 (n1256) and C11 (n1570) only states the function should
first close any file associated with the specific stream.  Although current
implementation only follow C specification, current BSD and other libc
implementation (musl) are in sync with POSIX and fflush the stream.

This patch change freopen{64} to fflush the stream before actually reopening
it (or returning if the stream does not support reopen).  It also changes the
Linux implementation to avoid a dynamic allocation on 'fd_to_filename'.

Checked on x86_64-linux-gnu.

[BZ #21037]
* libio/Makefile (tests): Add tst-memstream4 and tst-wmemstream4.
* libio/freopen.c (freopen): Sync stream before reopen and adjust to
new fd_to_filename interface.
* libio/freopen64.c (freopen64): Likewise.
* libio/tst-memstream.h: New file.
* libio/tst-memstream4.c: Likewise.
* libio/tst-wmemstream4.c: Likewise.
* sysdeps/generic/fd_to_filename.h (fd_to_filename): Change signature.
* sysdeps/unix/sysv/linux/fd_to_filename.h (fd_to_filename): Likewise
and remove internal dynamic allocation.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/

6 years agoMove MREMAP_* to bits/mman-shared.h.
Joseph Myers [Mon, 1 Oct 2018 20:30:57 +0000 (20:30 +0000)]
Move MREMAP_* to bits/mman-shared.h.

The MREMAP_* flags are identical between bits/mman-linux.h and the
hppa bits/mman.h; thus, they should be in bits/mman-shared.h instead
to avoid unnecessary duplication.  This patch moves them there.

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

* sysdeps/unix/sysv/linux/bits/mman-linux.h [__USE_GNU]
(MREMAP_MAYMOVE): Do not define here.
[__USE_GNU] (MREMAP_FIXED): Likewise.
* sysdeps/unix/sysv/linux/bits/mman-shared.h [__USE_GNU]
(MREMAP_MAYMOVE): Define here instead.
[__USE_GNU] (MREMAP_FIXED): Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/mman.h [__USE_GNU]
(MREMAP_MAYMOVE): Remove.
[__USE_GNU] (MREMAP_FIXED): Likewise.

6 years agoRemove unnecessary math_private.h includes.
Joseph Myers [Fri, 28 Sep 2018 21:53:33 +0000 (21:53 +0000)]
Remove unnecessary math_private.h includes.

After my changes to move various macros, inlines and other content
from math_private.h to more specific headers, many files including
math_private.h no longer need to do so.  Furthermore, since the
optimized inlines of various functions have been moved to
include/fenv.h or replaced by use of function names GCC inlines
automatically, a missing math_private.h include where one is
appropriate will reliably cause a build failure rather than possibly
causing code to be less well optimized while still building
successfully.  Thus, this patch removes includes of math_private.h
that are now unnecessary.  In the case of two RISC-V files, the
include is replaced by one of stdbool.h because the files in question
were relying on math_private.h to get a definition of bool.

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

* math/fromfp.h: Do not include <math_private.h>.
* math/s_cacosh_template.c: Likewise.
* math/s_casin_template.c: Likewise.
* math/s_casinh_template.c: Likewise.
* math/s_ccos_template.c: Likewise.
* math/s_cproj_template.c: Likewise.
* math/s_fdim_template.c: Likewise.
* math/s_fmaxmag_template.c: Likewise.
* math/s_fminmag_template.c: Likewise.
* math/s_iseqsig_template.c: Likewise.
* math/s_ldexp_template.c: Likewise.
* math/s_nextdown_template.c: Likewise.
* math/w_log1p_template.c: Likewise.
* math/w_scalbln_template.c: Likewise.
* sysdeps/aarch64/fpu/feholdexcpt.c: Likewise.
* sysdeps/aarch64/fpu/fesetround.c: Likewise.
* sysdeps/aarch64/fpu/fgetexcptflg.c: Likewise.
* sysdeps/aarch64/fpu/ftestexcept.c: Likewise.
* sysdeps/aarch64/fpu/s_llrint.c: Likewise.
* sysdeps/aarch64/fpu/s_llrintf.c: Likewise.
* sysdeps/aarch64/fpu/s_lrint.c: Likewise.
* sysdeps/aarch64/fpu/s_lrintf.c: Likewise.
* sysdeps/i386/fpu/s_atanl.c: Likewise.
* sysdeps/i386/fpu/s_f32xaddf64.c: Likewise.
* sysdeps/i386/fpu/s_f32xsubf64.c: Likewise.
* sysdeps/i386/fpu/s_fdim.c: Likewise.
* sysdeps/i386/fpu/s_logbl.c: Likewise.
* sysdeps/i386/fpu/s_rintl.c: Likewise.
* sysdeps/i386/fpu/s_significandl.c: Likewise.
* sysdeps/ia64/fpu/s_matherrf.c: Likewise.
* sysdeps/ia64/fpu/s_matherrl.c: Likewise.
* sysdeps/ieee754/dbl-64/s_atan.c: Likewise.
* sysdeps/ieee754/dbl-64/s_cbrt.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fma.c: Likewise.
* sysdeps/ieee754/dbl-64/s_fmaf.c: Likewise.
* sysdeps/ieee754/flt-32/s_cbrtf.c: Likewise.
* sysdeps/ieee754/k_standardf.c: Likewise.
* sysdeps/ieee754/k_standardl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_copysignl.c: Likewise.
* sysdeps/ieee754/ldbl-64-128/s_finitel.c: Likewise.
* sysdeps/ieee754/ldbl-64-128/s_fpclassifyl.c: Likewise.
* sysdeps/ieee754/ldbl-64-128/s_isinfl.c: Likewise.
* sysdeps/ieee754/ldbl-64-128/s_isnanl.c: Likewise.
* sysdeps/ieee754/ldbl-64-128/s_signbitl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_cbrtl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fma.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_fmal.c: Likewise.
* sysdeps/ieee754/s_signgam.c: Likewise.
* sysdeps/powerpc/power5+/fpu/s_modf.c: Likewise.
* sysdeps/powerpc/power5+/fpu/s_modff.c: Likewise.
* sysdeps/powerpc/power7/fpu/s_logbf.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_ceil.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_floor.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_nearbyint.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_round.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_roundeven.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_trunc.c: Likewise.
* sysdeps/riscv/rvd/s_finite.c: Likewise.
* sysdeps/riscv/rvd/s_fmax.c: Likewise.
* sysdeps/riscv/rvd/s_fmin.c: Likewise.
* sysdeps/riscv/rvd/s_fpclassify.c: Likewise.
* sysdeps/riscv/rvd/s_isinf.c: Likewise.
* sysdeps/riscv/rvd/s_isnan.c: Likewise.
* sysdeps/riscv/rvd/s_issignaling.c: Likewise.
* sysdeps/riscv/rvf/fegetround.c: Likewise.
* sysdeps/riscv/rvf/feholdexcpt.c: Likewise.
* sysdeps/riscv/rvf/fesetenv.c: Likewise.
* sysdeps/riscv/rvf/fesetround.c: Likewise.
* sysdeps/riscv/rvf/feupdateenv.c: Likewise.
* sysdeps/riscv/rvf/fgetexcptflg.c: Likewise.
* sysdeps/riscv/rvf/ftestexcept.c: Likewise.
* sysdeps/riscv/rvf/s_ceilf.c: Likewise.
* sysdeps/riscv/rvf/s_finitef.c: Likewise.
* sysdeps/riscv/rvf/s_floorf.c: Likewise.
* sysdeps/riscv/rvf/s_fmaxf.c: Likewise.
* sysdeps/riscv/rvf/s_fminf.c: Likewise.
* sysdeps/riscv/rvf/s_fpclassifyf.c: Likewise.
* sysdeps/riscv/rvf/s_isinff.c: Likewise.
* sysdeps/riscv/rvf/s_isnanf.c: Likewise.
* sysdeps/riscv/rvf/s_issignalingf.c: Likewise.
* sysdeps/riscv/rvf/s_nearbyintf.c: Likewise.
* sysdeps/riscv/rvf/s_roundevenf.c: Likewise.
* sysdeps/riscv/rvf/s_roundf.c: Likewise.
* sysdeps/riscv/rvf/s_truncf.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_rint.c: Include <stdbool.h> instead of
<math_private.h>.
* sysdeps/riscv/rvf/s_rintf.c: Likewise.

6 years agoi386: Use _dl_runtime_[resolve|profile]_shstk for SHSTK [BZ #23716]
H.J. Lu [Fri, 28 Sep 2018 20:31:19 +0000 (13:31 -0700)]
i386: Use _dl_runtime_[resolve|profile]_shstk for SHSTK [BZ #23716]

When elf_machine_runtime_setup is called to set up resolver, it should
use _dl_runtime_resolve_shstk or _dl_runtime_profile_shstk if SHSTK is
enabled by kernel.

Tested on i686 with and without --enable-cet as well as on CET emulator
with --enable-cet.

[BZ #23716]
* sysdeps/i386/dl-cet.c: Removed.
* sysdeps/i386/dl-machine.h (_dl_runtime_resolve_shstk): New
prototype.
(_dl_runtime_profile_shstk): Likewise.
(elf_machine_runtime_setup): Use _dl_runtime_profile_shstk or
_dl_runtime_resolve_shstk if SHSTK is enabled by kernel.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
6 years agoFix misreported errno on preadv2/pwritev2 (BZ#23579)
Adhemerval Zanella [Wed, 29 Aug 2018 19:36:44 +0000 (16:36 -0300)]
Fix misreported errno on preadv2/pwritev2 (BZ#23579)

The fallback code of Linux wrapper for preadv2/pwritev2 executes
regardless of the errno code for preadv2, instead of the case where
the syscall is not supported.

This fixes it by calling the fallback code iff errno is ENOSYS. The
patch also adds tests for both invalid file descriptor and invalid
iov_len and vector count.

The only discrepancy between preadv2 and fallback code regarding
error reporting is when an invalid flags are used.  The fallback code
bails out earlier with ENOTSUP instead of EINVAL/EBADF when the syscall
is used.

Checked on x86_64-linux-gnu on a 4.4.0 and 4.15.0 kernel.

[BZ #23579]
* misc/tst-preadvwritev2-common.c (do_test_with_invalid_fd): New
test.
* misc/tst-preadvwritev2.c, misc/tst-preadvwritev64v2.c (do_test):
Call do_test_with_invalid_fd.
* sysdeps/unix/sysv/linux/preadv2.c (preadv2): Use fallback code iff
errno is ENOSYS.
* sysdeps/unix/sysv/linux/preadv64v2.c (preadv64v2): Likewise.
* sysdeps/unix/sysv/linux/pwritev2.c (pwritev2): Likewise.
* sysdeps/unix/sysv/linux/pwritev64v2.c (pwritev64v2): Likewise.

6 years agoUse copysign functions not __copysign functions in glibc libm.
Joseph Myers [Thu, 27 Sep 2018 20:04:48 +0000 (20:04 +0000)]
Use copysign functions not __copysign functions in glibc libm.

Continuing the move to use, within libm, public names for libm
functions that can be inlined as built-in functions on many
architectures, this patch moves calls to __copysign functions to call
the corresponding copysign names instead, with asm redirection to
__copysign when the calls are not inlined (all cases are inlined
except for IBM long double for powerpc soft-float / e500v1).  This
eliminates the need for an inline function defining __copysign in
terms of __builtin_copysign.

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

* include/math.h [!_ISOMAC && !(__FINITE_MATH_ONLY__ &&
__FINITE_MATH_ONLY__ > 0) && !NO_MATH_REDIRECT]
(MATH_REDIRECT_BINARY_ARGS): New macro.
[!_ISOMAC && !(__FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0)
&& !NO_MATH_REDIRECT] (copysign): Redirect using MATH_REDIRECT.
* sysdeps/alpha/fpu/s_copysign.c: Define NO_MATH_REDIRECT before
header inclusion.
* sysdeps/alpha/fpu/s_copysignf.c: Likewise.
* sysdeps/ieee754/dbl-64/s_copysign.c: Likewise.
* sysdeps/ieee754/float128/s_copysignf128.c: Likewise.
* sysdeps/ieee754/flt-32/s_copysignf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_copysignl.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_copysignl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_copysignl.c: Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysign.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_copysignf.c:
Likewise.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysign.c: Likewise.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_copysignf.c: Likewise.
* sysdeps/riscv/rvd/s_copysign.c: Likewise.
* sysdeps/riscv/rvf/s_copysignf.c: Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysign.c:
Likewise.
* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/s_copysignf.c:
Likewise.
* sysdeps/generic/math_private_calls.h
[!__MATH_DECLARING_LONG_DOUBLE || !NO_LONG_DOUBLE] (__copysign):
Do not declare and define as an inline function.
* math/divtc3.c (__divtc3): Use copysign functions instead of
__copysign variants.
* math/multc3.c (__multc3): Likewise.
* sysdeps/generic/math-type-macros.h (M_COPYSIGN): Likewise.
* sysdeps/ieee754/dbl-64/e_atan2.c (signArctan2): Likewise.
* sysdeps/ieee754/dbl-64/e_atanh.c (__ieee754_atanh): Likewise.
* sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r):
Likewise.
* sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_jn): Likewise.
(__ieee754_yn): Likewise.
* sysdeps/ieee754/dbl-64/s_asinh.c (__asinh): Likewise.
* sysdeps/ieee754/dbl-64/s_atan.c (__signArctan): Likewise.
* sysdeps/ieee754/dbl-64/s_scalbln.c (__scalbln): Likewise.
* sysdeps/ieee754/dbl-64/s_scalbn.c (__scalbn): Likewise.
* sysdeps/ieee754/dbl-64/s_sin.c (do_sin): Likewise.
(__sin): Likewise.
* sysdeps/ieee754/dbl-64/s_sincos.c (__sincos): Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c (__nearbyint):
Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_scalbln.c (__scalbln):
Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_scalbn.c (__scalbn):
Likewise.
* sysdeps/ieee754/flt-32/e_atanhf.c (__ieee754_atanhf): Likewise.
* sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r):
Likewise.
* sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_jnf): Likewise.
(__ieee754_ynf): Likewise.
* sysdeps/ieee754/flt-32/s_asinhf.c (__asinhf): Likewise.
* sysdeps/ieee754/flt-32/s_scalbnf.c (__scalbnf): Likewise.
* sysdeps/ieee754/k_standard.c (__kernel_standard): Likewise.
* sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r):
Likewise.
* sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_jnl): Likewise.
(__ieee754_ynl): Likewise.
* sysdeps/ieee754/ldbl-128/s_scalblnl.c (__scalblnl): Likewise.
* sysdeps/ieee754/ldbl-128/s_scalbnl.c (__scalbnl): Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r):
Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_jnl.c (__ieee754_jnl): Likewise.
(__ieee754_ynl): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_fmal.c (__fmal): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_scalblnl.c (__scalblnl): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_scalbnl.c (__scalbnl): Likewise.
* sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r):
Likewise.
* sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_jnl): Likewise.
(__ieee754_ynl)
* sysdeps/ieee754/ldbl-96/s_asinhl.c (__asinhl): Likewise.
* sysdeps/ieee754/ldbl-96/s_scalblnl.c (__scalblnl): Likewise.
* sysdeps/ieee754/ldbl-opt/nldbl-copysign.c (copysignl): Likewise.
* sysdeps/powerpc/power5+/fpu/s_modf.c (__modf): Likewise.
* sysdeps/powerpc/power5+/fpu/s_modff.c (__modff): Likewise.

6 years agoUse round functions not __round functions in glibc libm.
Joseph Myers [Thu, 27 Sep 2018 12:35:23 +0000 (12:35 +0000)]
Use round functions not __round functions in glibc libm.

Continuing the move to use, within libm, public names for libm
functions that can be inlined as built-in functions on many
architectures, this patch moves calls to __round functions to call the
corresponding round names instead, with asm redirection to __round
when the calls are not inlined.

An additional complication arises in
sysdeps/ieee754/ldbl-128ibm/e_expl.c, where a call to roundl, with the
result converted to int, gets converted by the compiler to call
lroundl in the case of 32-bit long, so resulting in localplt test
failures.  It's logically correct to let the compiler make such an
optimization; an appropriate asm redirection of lroundl to __lroundl
is thus added to that file (it's not needed anywhere else).

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

* include/math.h [!_ISOMAC && !(__FINITE_MATH_ONLY__ &&
__FINITE_MATH_ONLY__ > 0) && !NO_MATH_REDIRECT] (round): Redirect
using MATH_REDIRECT.
* sysdeps/aarch64/fpu/s_round.c: Define NO_MATH_REDIRECT before
header inclusion.
* sysdeps/aarch64/fpu/s_roundf.c: Likewise.
* sysdeps/ieee754/dbl-64/s_round.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_round.c: Likewise.
* sysdeps/ieee754/float128/s_roundf128.c: Likewise.
* sysdeps/ieee754/flt-32/s_roundf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_roundl.c: Likewise.
* sysdeps/ieee754/ldbl-96/s_roundl.c: Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_round.c: Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_roundf.c: Likewise.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_round.c: Likewise.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_roundf.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_round.c: Likewise.
* sysdeps/riscv/rvf/s_roundf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_roundl.c: Likewise.
(round): Redirect to __round.
(__roundl): Call round instead of __round.
* sysdeps/powerpc/fpu/math_private.h [_ARCH_PWR5X] (__round):
Remove macro.
[_ARCH_PWR5X] (__roundf): Likewise.
* sysdeps/ieee754/dbl-64/e_gamma_r.c (gamma_positive): Use round
functions instead of __round variants.
* sysdeps/ieee754/flt-32/e_gammaf_r.c (gammaf_positive): Likewise.
* sysdeps/ieee754/ldbl-128/e_gammal_r.c (gammal_positive):
Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (gammal_positive):
Likewise.
* sysdeps/ieee754/ldbl-96/e_gammal_r.c (gammal_positive):
Likewise.
* sysdeps/x86/fpu/powl_helper.c (__powl_helper): Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_expl.c (lroundl): Redirect to
__lroundl.
(__ieee754_expl): Call roundl instead of __roundl.

6 years agoFix stack overflow in tst-setcontext9 (bug 23717)
Andreas Schwab [Thu, 27 Sep 2018 09:12:13 +0000 (11:12 +0200)]
Fix stack overflow in tst-setcontext9 (bug 23717)

The function f1a, executed on a stack of size 32k, allocates an object of
size 32k on the stack.  Make the stack variables static to reduce
excessive stack usage.

6 years agoAdd missing unwind information to ld.so on powerpc32 (bug 23707)
Andreas Schwab [Mon, 24 Sep 2018 23:22:22 +0000 (01:22 +0200)]
Add missing unwind information to ld.so on powerpc32 (bug 23707)

6 years agoShare MAP_* flags between more architectures.
Joseph Myers [Wed, 26 Sep 2018 12:33:14 +0000 (12:33 +0000)]
Share MAP_* flags between more architectures.

Continuing bits/mman.h unification between architectures using the
Linux kernel, this patch arranges for the common set of MAP_* flags to
be used by two more architectures.  That common set is moved to
bits/mman-map-flags-generic.h, which is included by bits/mman.h, to
allow architectures to use that common set even if they also have
architecture-specific additions to it.  As well as the generic
bits/mman.h, the versions for x86 and ia64 are also then made to
include bits/mman-map-flags-generic.h, so while they still need
architecture-specific bits/mman.h (for MAP_32BIT and MAP_GROWSUP
respectively), they do not need to duplicate the generic flag
definitions in there.

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

* sysdeps/unix/sysv/linux/bits/mman-map-flags-generic.h: New
file.  Most contents moved from ....
* sysdeps/unix/sysv/linux/bits/mman.h: ... here.  Move contents to
and include <bits/mman-map-flags-generic.h>.
* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
(sysdep_headers): Add bits/mman-map-flags-generic.h.
* sysdeps/unix/sysv/linux/ia64/bits/mman.h: Include
<bits/mman-map-flags-generic.h>.
[__USE_MISC] (MAP_GROWSUP): Only define this macro, not other
macros defined in <bits/mman-map-flags-generic.h>.
* sysdeps/unix/sysv/linux/x86/bits/mman.h: Include
<bits/mman-map-flags-generic.h>.
[__USE_MISC] (MAP_32BIT): Only define this macro, not other macros
defined in <bits/mman-map-flags-generic.h>.

6 years agoRemove leading space from testrun.sh
Andreas Schwab [Wed, 26 Sep 2018 08:11:43 +0000 (10:11 +0200)]
Remove leading space from testrun.sh

6 years agoFix ifunc support with DT_TEXTREL segments (BZ#20480)
Adhemerval Zanella [Mon, 27 Aug 2018 19:16:43 +0000 (16:16 -0300)]
Fix ifunc support with DT_TEXTREL segments (BZ#20480)

Currently, DT_TEXTREL is incompatible with IFUNC.  When DT_TEXTREL or
DF_TEXTREL is seen, the dynamic linker calls __mprotect on the segments
with PROT_READ|PROT_WRITE before applying dynamic relocations. It leads
to segfault when performing IFUNC resolution (which requires PROT_EXEC
as well for the IFUNC resolver).

This patch makes it call __mprotect with extra PROT_WRITE bit, which
will keep the PROT_EXEC bit if exists, and thus fixes the segfault.
FreeBSD rtld libexec/rtld-elf/rtld.c (reloc_textrel_prot) does the same.

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu,
sparc64-linux-gnu, sparcv9-linux-gnu, and armv8-linux-gnueabihf.

Adam J. Richte  <adam_richter2004@yahoo.com>
Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Fangrui Song  <maskray@google.com>

[BZ #20480]
* config.h.in (CAN_TEXTREL_IFUNC): New define.
* configure.ac: Add check if linker supports textrel relocation with
ifunc.
* elf/dl-reloc.c (_dl_relocate_object): Use all required flags on
DT_TEXTREL segments, not only PROT_READ and PROT_WRITE.
* elf/Makefile (ifunc-pie-tests): Add tst-ifunc-textrel.
(CFLAGS-tst-ifunc-textrel.c): New rule.
* elf/tst-ifunc-textrel.c: New file.

6 years agoComplete sys/procfs.h unification.
Joseph Myers [Tue, 25 Sep 2018 16:50:30 +0000 (16:50 +0000)]
Complete sys/procfs.h unification.

This patch completes the process of unifying sys/procfs.h headers for
architectures using the Linux kernel by making alpha use the generic
version.

That was previously deferred because alpha has different definitions
of prgregset_t and prfpregset_t from other architectures, so changing
to the common definitions would change C++ name mangling.  To avoid
such a change, a header bits/procfs-prregset.h is added, and alpha
gets its own version of that header.

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

* sysdeps/unix/sysv/linux/sys/procfs.h: Include
<bits/procfs-prregset.h>.
(prgregset_t): Define using __prgregset_t.
(prfpregset_t): Define using __prfpregset_t.
* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
(sysdep_headers): Add bits/procfs-prregset.h.
* sysdeps/unix/sysv/linux/bits/procfs-prregset.h: New file.
* sysdeps/unix/sysv/linux/alpha/bits/procfs-prregset.h: Likewise.
* sysdeps/unix/sysv/linux/alpha/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/alpha/sys/procfs.h: Remove file.

6 years agoUnify more sys/procfs.h headers.
Joseph Myers [Tue, 25 Sep 2018 16:49:25 +0000 (16:49 +0000)]
Unify more sys/procfs.h headers.

This patch continues the process of unifying sys/procfs.h headers for
architectures using the Linux kernel.

A bits/procfs-id.h header is added to define __pr_uid_t and __pr_gid_t
for the types of pr_uid and pr_gid; the default version of this header
uses unsigned int.  On some architectures, sys/procfs.h has copies of
32-bit structures for 64-bit builds; those move into a
bits/procfs-extra.h header (they can't go in bits/procfs.h because
they have to come *after* other declarations from sys/procfs.h).
Given appropriate versions of these headers, six more architectures
can then move to providing only bits/procfs*.h without duplicating the
rest of the contents of sys/procfs.h.  Only alpha needs a further
bits/ header to be added before it can stop having its own
sys/procfs.h.

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

* sysdeps/unix/sysv/linux/sys/procfs.h: Include
<bits/procfs-id.h> and <bits/procfs-extra.h>.
(struct elf_prpsinfo): Use __pr_uid_t and __pr_gid_t as types of
pr_uid and pr_gid.
* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
(sysdep_headers): Add bits/procfs-id.h and bits/procfs-extra.h.
* sysdeps/unix/sysv/linux/bits/procfs-extra.h: New file.
* sysdeps/unix/sysv/linux/bits/procfs-id.h: Likewise.
* sysdeps/unix/sysv/linux/arm/bits/procfs-id.h: Likewise.
* sysdeps/unix/sysv/linux/arm/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/m68k/bits/procfs-id.h: Likewise.
* sysdeps/unix/sysv/linux/m68k/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/procfs-extra.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/procfs-id.h: Likewise.
* sysdeps/unix/sysv/linux/s390/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/sh/bits/procfs-id.h: Likewise.
* sysdeps/unix/sysv/linux/sh/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/procfs-extra.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/procfs-id.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/x86/bits/procfs-id.h: Likewise.
* sysdeps/unix/sysv/linux/x86/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/arm/sys/procfs.h: Remove file.
* sysdeps/unix/sysv/linux/m68k/sys/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/s390/sys/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/sh/sys/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/sparc/sys/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/x86/sys/procfs.h: Likewise.

6 years agoUnify some sys/procfs.h headers.
Joseph Myers [Tue, 25 Sep 2018 16:48:15 +0000 (16:48 +0000)]
Unify some sys/procfs.h headers.

As per recent discussions, this patch unifies some of the sys/procfs.h
headers for architectures using the Linux kernel, producing a generic
version that can hopefully be used by all new architectures as well.

The new generic version is based on the AArch64 one.  The register
definitions, the only part that generally needs to vary by
architecture, go in a new bits/procfs.h header (which each
architecture using the generic version needs to provide); that header
also has any #includes that were in the architecture-specific
sys/procfs.h, where those includes went beyond the generic set.

The generic version is used for eight architectures where the generic
definitions were the same as the architecture-specific ones.  (Some of
those architectures had #if 0 fields, now removed; some defined types
or fields using different type names which were typedefs for the same
underlying types.)

Six of the remaining architectures with their own sys/procfs.h use
unsigned short for pr_uid / pr_gid in some cases; moving those to the
generic header will require a bits/ header to define a typedef for the
type of those fields.  In the case of alpha, the generic sys/procfs.h
uses elf_gregset_t (= unsigned long int[33]) to define prgregset_t and
elf_fpregset_t (= double[32]) to define prfpregset_t, but the alpha
version uses gregset_t (= long int[33]) and fpregset_t (= long
int[32]), so avoiding unnecessarily changing the underlying types (and
thus C++ name mangling) again means a bits/ header will need to be
able to define a different choice for those typedefs.

bits/procfs.h is included outside the __BEGIN_DECLS / __END_DECLS pair
(whereas the definitions it contains were previously inside that pair
in various sys/procfs.h headers), because it sometimes includes other
headers and putting those other #includes inside that pair seems
risky.  Because none of the declarations in bits/procfs.h are of
functions or variables or involve function types, I don't think it
makes any difference whether they are inside or outside an extern "C"
context.

Tested with build-many-glibcs.py (again, that does not provide much
validation for the correctness of this patch).

* sysdeps/unix/sysv/linux/sys/procfs.h: Replace with file based on
AArch64 version.  Include <bits/procfs.h>.
* sysdeps/unix/sysv/linux/Makefile [$(subdir) = misc]
(sysdep_headers): Add bits/procfs.h.
* sysdeps/unix/sysv/linux/bits/procfs.h: New file.
* sysdeps/unix/sysv/linux/aarch64/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/hppa/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/microblaze/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/mips/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/nios2/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/riscv/bits/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/aarch64/sys/procfs.h: Remove file.
* sysdeps/unix/sysv/linux/hppa/sys/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/ia64/sys/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/microblaze/sys/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/mips/sys/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/nios2/sys/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h: Likewise.
* sysdeps/unix/sysv/linux/riscv/sys/procfs.h: Likewise.

6 years agoUse libsupport for tst-spawn.c
Adhemerval Zanella [Wed, 19 Sep 2018 18:12:05 +0000 (11:12 -0700)]
Use libsupport for tst-spawn.c

No function changes is done.  Checked on x86_64-linux-gnu.

* posix/tst-spawn.c (do_prepare, handle_restart, do_test):
Use libsupport.

6 years agoClean up iconv/gconv_int.h for unnecessary declarations
Arjun Shankar [Tue, 25 Sep 2018 13:13:15 +0000 (15:13 +0200)]
Clean up iconv/gconv_int.h for unnecessary declarations

The variables __gconv_path_elem, __gconv_max_path_elem_len and function
__gconv_get_path declared in, as well as the type path_elem and macro
GCONV_NCHAR_GOAL defined in gconv_int.h are all used in only one iconv
compilation unit each. In addition, the extern declaration of the variable
__gconv_nmodules refers to a variable that does not exist any more.
Considering this, these symbols do not need to be exposed via a header file.

This patch removes the extern declarations from the header file and moves
the definitions to the compilation units where they are used.

6 years agoDon't build libnsl for new ABIs
Andreas Schwab [Wed, 18 Jul 2018 15:30:19 +0000 (17:30 +0200)]
Don't build libnsl for new ABIs

For architectures and ABIs that are added in version 2.29 or later the
option --enable-obsolete-nsl is no longer available, and no libnsl
compatibility library is built.

6 years agopowerpc: Only enable TLE with PPC_FEATURE2_HTM_NOSC
Adhemerval Zanella [Mon, 27 Aug 2018 12:42:50 +0000 (09:42 -0300)]
powerpc: Only enable TLE with PPC_FEATURE2_HTM_NOSC

Linux from 3.9 through 4.2 does not abort HTM transaction on syscalls,
instead it suspend and resume it when leaving the kernel.  The
side-effects of the syscall will always remain visible, even if the
transaction is aborted.  This is an issue when transaction is used along
with futex syscall, on pthread_cond_wait for instance, where the futex
call might succeed but the transaction is rolled back leading the
pthread_cond object in an inconsistent state.

Glibc used to prevent it by always aborting a transaction before issuing
a syscall.  Linux 4.2 also decided to abort active transaction in
syscalls which makes the glibc workaround superfluous.  Worse, glibc
transaction abortion leads to a performance issue on recent kernels
where the HTM state is saved/restore lazily (v4.9).  By aborting a
transaction on every syscalls, regardless whether a transaction has being
initiated before, GLIBS makes the kernel always save/restore HTM state
(it can not even lazily disable it after a certain number of syscall
iterations).

Because of this shortcoming, Transactional Lock Elision is just enabled
when it has been explicitly set (either by tunables of by a configure
switch) and if kernel aborts HTM transactions on syscalls
(PPC_FEATURE2_HTM_NOSC).  It is reported that using simple benchmark [1],
the context-switch is about 5% faster by not issuing a tabort in every
syscall in newer kernels.

Checked on powerpc64le-linux-gnu with 4.4.0 kernel (Ubuntu 16.04).

* NEWS: Add note about new TLE support on powerpc64le.
* sysdeps/powerpc/nptl/tcb-offsets.sym (TM_CAPABLE): Remove.
* sysdeps/powerpc/nptl/tls.h (tcbhead_t): Rename tm_capable to
__ununsed1.
(TLS_INIT_TP, TLS_DEFINE_INIT_TP): Remove tm_capable setup.
(THREAD_GET_TM_CAPABLE, THREAD_SET_TM_CAPABLE): Remove macros.
* sysdeps/powerpc/powerpc32/sysdep.h,
sysdeps/powerpc/powerpc64/sysdep.h (ABORT_TRANSACTION_IMPL,
ABORT_TRANSACTION): Remove macros.
* sysdeps/powerpc/sysdep.h (ABORT_TRANSACTION): Likewise.
* sysdeps/unix/sysv/linux/powerpc/elision-conf.c (elision_init): Set
__pthread_force_elision iff PPC_FEATURE2_HTM_NOSC is set.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h,
sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
sysdeps/unix/sysv/linux/powerpc/syscall.S (ABORT_TRANSACTION): Remove
usage.
* sysdeps/unix/sysv/linux/powerpc/not-errno.h: Remove file.

Reported-by: Breno Leitão <leitao@debian.org>
6 years agoit_CH/it_IT locales: Correct some LC_TIME formats (bug 10425).
Rafal Luzynski [Fri, 14 Sep 2018 20:43:02 +0000 (22:43 +0200)]
it_CH/it_IT locales: Correct some LC_TIME formats (bug 10425).

Synchronize some values with CLDR and apply some suggestions from Bugzilla.

[BZ #10425]
* localedata/locales/it_IT (d_t_fmt): Use "%a %-d %b %Y, %T".
(date_fmt): Use "%a %-d %b %Y, %T, %Z".
* localedata/locales/it_CH (d_t_fmt): Use "%a %-d %b %Y, %T"
which is the same as in it_IT.
(d_fmt): Use "%d.%m.%Y" which is the same as in de_CH.
(date_fmt): Use "%a %-d %b %Y, %T, %Z" which is the same as in it_IT.

6 years agoUse trunc functions not __trunc functions in glibc libm.
Joseph Myers [Thu, 20 Sep 2018 21:11:10 +0000 (21:11 +0000)]
Use trunc functions not __trunc functions in glibc libm.

Continuing the move to use, within libm, public names for libm
functions that can be inlined as built-in functions on many
architectures, this patch moves calls to __trunc functions to call the
corresponding trunc names instead, with asm redirection to __trunc
when the calls are not inlined.

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

* include/math.h [!_ISOMAC && !(__FINITE_MATH_ONLY__ &&
__FINITE_MATH_ONLY__ > 0) && !NO_MATH_REDIRECT] (trunc): Redirect
using MATH_REDIRECT.
* sysdeps/aarch64/fpu/s_trunc.c: Define NO_MATH_REDIRECT before
header inclusion.
* sysdeps/aarch64/fpu/s_truncf.c: Likewise.
* sysdeps/ieee754/dbl-64/wordsize-64/s_trunc.c: Likewise.
* sysdeps/ieee754/float128/s_truncf128.c: Likewise.
* sysdeps/ieee754/dbl-64/s_trunc.c: Likewise.
* sysdeps/ieee754/flt-32/s_truncf.c: Likewise.
* sysdeps/ieee754/ldbl-128/s_truncl.c: Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_trunc.c: Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_truncf.c: Likewise.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_trunc.c: Likewise.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_truncf.c: Likewise.
* sysdeps/riscv/rv64/rvd/s_trunc.c: Likewise.
* sysdeps/riscv/rvf/s_truncf.c: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_trunc.c: Likewise.
* sysdeps/sparc/sparc64/fpu/multiarch/s_truncf.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_trunc.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_truncf.c: Likewise.
* sysdeps/m68k/m680x0/fpu/s_trunc_template.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_truncl.c: Likewise.
(ceil): Redirect to __ceil.
(floor): Redirect to __floor.
(trunc): Redirect to __trunc.
(__truncl): Call trunc instead of __trunc.
* sysdeps/powerpc/fpu/math_private.h [_ARCH_PWR5X] (__trunc):
Remove macro.
[_ARCH_PWR5X] (__truncf): Likewise.
* sysdeps/ieee754/dbl-64/e_gamma_r.c (__ieee754_gamma_r): Use
trunc functions instead of __trunc variants.
* sysdeps/ieee754/flt-32/e_gammaf_r.c (__ieee754_gammaf_r):
Likewise.
* sysdeps/ieee754/ldbl-128/e_gammal_r.c (__ieee754_gammal_r):
Likewise.
* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c (__ieee754_gammal_r):
Likewise.
* sysdeps/ieee754/ldbl-96/e_gammal_r.c (__ieee754_gammal_r):
Likewise.