]> git.ipfire.org Git - thirdparty/glibc.git/log
thirdparty/glibc.git
4 years agomalloc/tst-mallocfork2: Use process-shared barriers fw/tst-mallocfork2
Florian Weimer [Fri, 3 May 2019 15:46:36 +0000 (17:46 +0200)] 
malloc/tst-mallocfork2: Use process-shared barriers

This synchronization method has a lower overhead and makes
it more likely that the signal arrives during one of the critical
functions.

Also test for fork deadlocks explicitly.

4 years agomisc/tst-tsearch: Additional explicit error checking
Florian Weimer [Fri, 3 May 2019 07:22:33 +0000 (09:22 +0200)] 
misc/tst-tsearch: Additional explicit error checking

This avoids an undefined variable warning with certain GCC versions.

4 years agoAdd missing bug number on CL entry for BZ#24506 (b2af6fb2ed239)
Adhemerval Zanella [Thu, 2 May 2019 11:46:20 +0000 (08:46 -0300)] 
Add missing bug number on CL entry for BZ#24506 (b2af6fb2ed239)

4 years agoelf: Fix elf/tst-pldd with --enable-hardcoded-path-in-tests (BZ#24506)
Adhemerval Zanella [Tue, 30 Apr 2019 19:11:57 +0000 (16:11 -0300)] 
elf: Fix elf/tst-pldd with --enable-hardcoded-path-in-tests (BZ#24506)

The elf/tst-pldd (added by 1a4c27355e146 to fix BZ#18035) test does
not expect the hardcoded paths that are output by pldd when the test
is built with --enable-hardcoded-path-in-tests.  Instead of showing
the ABI installed library names for loader and libc (such as
ld-linux-x86-64.so.2 and libc.so.6 for x86_64), pldd shows the default
built ld.so and libc.so.

It makes the tests fail with an invalid expected loader/libc name.

This patch fixes the elf-pldd test by adding the canonical ld.so and
libc.so names in the expected list of possible outputs when parsing
the result output from pldd.  The test now handles both default
build and --enable-hardcoded-path-in-tests option.

Checked on x86_64-linux-gnu (built with and without
--enable-hardcoded-path-in-tests) and i686-linux-gnu.

* elf/tst-pldd.c (in_str_list): New function.
(do_test): Add default names for ld and libc as one option.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
4 years agomisc: Add twalk_r function
Florian Weimer [Thu, 2 May 2019 09:42:51 +0000 (11:42 +0200)] 
misc: Add twalk_r function

The twalk function is very difficult to use in a multi-threaded
program because there is no way to pass external state to the
iterator function.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
4 years agoMake mktime etc. compatible with __time64_t
Paul Eggert [Mon, 18 Mar 2019 21:14:15 +0000 (14:14 -0700)] 
Make mktime etc. compatible with __time64_t

Keep these functions compatible with Gnulib while adding
__time64_t support.  The basic idea is to move private API
declarations from include/time.h to time/mktime-internal.h, since
the former file cannot easily be shared with Gnulib whereas the
latter can.
Also, do some other minor cleanup while in the neighborhood.
* include/time.h: Include stdbool.h, time/mktime-internal.h.
(__mktime_internal): Move this prototype to time/mktime-internal.h,
since Gnulib needs it.
(__localtime64_r, __gmtime64_r) [__TIMESIZE == 64]:
Move these macros to time/mktime-internal.h, since Gnulib needs them.
(__mktime64, __timegm64) [__TIMESIZE != 64]: New prototypes.
(in_time_t_range): New static function.
* posix/bits/types.h (__time64_t) [__TIMESIZE == 64 && !defined __LIBC]:
Do not define as a macro in this case, so that portable code is
less tempted to use __time64_t.
* time/mktime-internal.h: Rewrite so that it does both glibc
and Gnulib work.  Include time.h if not _LIBC.
(mktime_offset_t) [!_LIBC]: Define for gnulib.
(__time64_t, __gmtime64_r, __localtime64_r, __mktime64, __timegm64)
[!_LIBC || __TIMESIZE == 64]: New macros, mostly moved here
from include/time.h.
(__gmtime_r, __localtime_r, __mktime_internal) [!_LIBC]:
New macros, taken from GNulib.
(__mktime_internal): New prototype, moved here from include/time.h.
* time/mktime.c (mktime_min, mktime_max, convert_time)
(ranged_convert, __mktime_internal, __mktime64):
* time/timegm.c (__timegm64):
Use __time64_t, not time_t.
* time/mktime.c: Stop worrying about whether time_t is floating-point.
(__mktime64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from mktime.
(mktime) [_LIBC && __TIMESIZE != 64]: New function.
* time/timegm.c [!_LIBC]: Include libc-config.h, not config.h,
for libc_hidden_def.
Include errno.h.
(__timegm64) [! (_LIBC && __TIMESIZE != 64)]:
Rename from timegm.
(timegm) [_LIBC && __TIMESIZE != 64]: New function.

First cut at publicizing __time64_t

4 years agoFix -O1 compilation errors with `__ddivl' and `__fdivl' [BZ #19444]
Maciej W. Rozycki [Tue, 30 Apr 2019 01:24:49 +0000 (02:24 +0100)] 
Fix -O1 compilation errors with `__ddivl' and `__fdivl' [BZ #19444]

Complementing commit 4a06ceea33ec ("sysdeps/ieee754/soft-fp: ignore
maybe-uninitialized with -O [BZ #19444]") and commit 27c5e756a2a8
("sysdeps/ieee754: prevent maybe-uninitialized errors with -O [BZ
#19444]") also fix compilation errors observed at -O1 in `__ddivl' and
`__fdivl' with GCC 9 and RISC-V targets:

In file included from ../soft-fp/soft-fp.h:318,
                 from ../sysdeps/ieee754/soft-fp/s_fdivl.c:27:
../sysdeps/ieee754/soft-fp/s_fdivl.c: In function '__fdivl':
../soft-fp/op-2.h:108:9: error: 'R_f1' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  108 |         : (X##_f1 << (2*_FP_W_TYPE_SIZE - (N)))) \
      |         ^
../sysdeps/ieee754/soft-fp/s_fdivl.c:37:14: note: 'R_f1' was declared here
   37 |   FP_DECL_Q (R);
      |              ^
../soft-fp/op-common.h:39:3: note: in expansion of macro '_FP_FRAC_DECL_2'
   39 |   _FP_FRAC_DECL_##wc (X)
      |   ^~~~~~~~~~~~~~
../soft-fp/quad.h:226:24: note: in expansion of macro '_FP_DECL'
  226 | # define FP_DECL_Q(X)  _FP_DECL (2, X)
      |                        ^~~~~~~~
../sysdeps/ieee754/soft-fp/s_fdivl.c:37:3: note: in expansion of macro 'FP_DECL_Q'
   37 |   FP_DECL_Q (R);
      |   ^~~~~~~~~
../soft-fp/op-2.h:109:8: error: 'R_f0' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  109 |        | X##_f0) != 0));    \
      |        ^
../sysdeps/ieee754/soft-fp/s_fdivl.c:37:14: note: 'R_f0' was declared here
   37 |   FP_DECL_Q (R);
      |              ^
../soft-fp/op-common.h:39:3: note: in expansion of macro '_FP_FRAC_DECL_2'
   39 |   _FP_FRAC_DECL_##wc (X)
      |   ^~~~~~~~~~~~~~
../soft-fp/quad.h:226:24: note: in expansion of macro '_FP_DECL'
  226 | # define FP_DECL_Q(X)  _FP_DECL (2, X)
      |                        ^~~~~~~~
../sysdeps/ieee754/soft-fp/s_fdivl.c:37:3: note: in expansion of macro 'FP_DECL_Q'
   37 |   FP_DECL_Q (R);
      |   ^~~~~~~~~
In file included from ../soft-fp/soft-fp.h:318,
                 from ../sysdeps/ieee754/soft-fp/s_ddivl.c:31:
../sysdeps/ieee754/soft-fp/s_ddivl.c: In function '__ddivl':
../soft-fp/op-2.h:98:25: error: 'R_f1' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   98 |        X##_f0 = (X##_f1 << (_FP_W_TYPE_SIZE - (N)) | X##_f0 >> (N) \
      |                         ^~
../sysdeps/ieee754/soft-fp/s_ddivl.c:41:14: note: 'R_f1' was declared here
   41 |   FP_DECL_Q (R);
      |              ^
../soft-fp/op-2.h:37:36: note: in definition of macro '_FP_FRAC_DECL_2'
   37 |   _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT
      |                                    ^
../soft-fp/quad.h:226:24: note: in expansion of macro '_FP_DECL'
  226 | # define FP_DECL_Q(X)  _FP_DECL (2, X)
      |                        ^~~~~~~~
../sysdeps/ieee754/soft-fp/s_ddivl.c:41:3: note: in expansion of macro 'FP_DECL_Q'
   41 |   FP_DECL_Q (R);
      |   ^~~~~~~~~
../soft-fp/op-2.h:101:17: error: 'R_f0' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  101 |       : (X##_f0 << (_FP_W_TYPE_SIZE - (N))) != 0)); \
      |                 ^~
../sysdeps/ieee754/soft-fp/s_ddivl.c:41:14: note: 'R_f0' was declared here
   41 |   FP_DECL_Q (R);
      |              ^
../soft-fp/op-2.h:37:14: note: in definition of macro '_FP_FRAC_DECL_2'
   37 |   _FP_W_TYPE X##_f0 _FP_ZERO_INIT, X##_f1 _FP_ZERO_INIT
      |              ^
../soft-fp/quad.h:226:24: note: in expansion of macro '_FP_DECL'
  226 | # define FP_DECL_Q(X)  _FP_DECL (2, X)
      |                        ^~~~~~~~
../sysdeps/ieee754/soft-fp/s_ddivl.c:41:3: note: in expansion of macro 'FP_DECL_Q'
   41 |   FP_DECL_Q (R);
      |   ^~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [.../sysd-rules:587: .../math/s_fdivl.o] Error 1
make[2]: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
make[2]: *** [.../sysd-rules:587: .../math/s_ddivl.o] Error 1

This comes from cases in _FP_DIV that return a result described as
FP_CLS_ZERO or FP_CLS_INF and do not initialize the fractional part,
which is then operated on unconditionally in FP_TRUNC_COOKED before
being ignored by _FP_PACK_CANONICAL.

Clearly at this optimization level GCC cannot guarantee to be able to
determine that the fractional part is ultimately unused, so ignore the
error as with the earlier commits referred, letting compilation proceed.

[BZ #19444]
* sysdeps/ieee754/soft-fp/s_ddivl.c (__ddivl): Ignore errors
from `-Wmaybe-uninitialized'.
* sysdeps/ieee754/soft-fp/s_fdivl.c (__fdivl): Likewise.

4 years agopowerpc: ceil/ceilf refactor
Adhemerval Zanella [Fri, 15 Mar 2019 18:42:00 +0000 (18:42 +0000)] 
powerpc: ceil/ceilf refactor

This patches consolidates all the powerpc ceil{f} implementations on
the generic sysdeps/powerpc/fpu/s_ceil{f}.  The generic implementation
uses either the compiler builts for ISA 2.03+ (which generates the frip
instruction) or a generic implementation which uses FP only operations.

It adds a generic implementation (round_to_integer.h) which is shared
with other rounding to integer routines.  The resulting code should be
similar in term os performance to previous assembly one.

The IFUNC organization for powerpc64 is also change to be enabled only
for powerpc64 and not for powerpc64le (since minium ISA of 2.08 does not
require the fallback generic implementation).

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

* sysdeps/powerpc/fpu/fenv_libc.h (__fesetround_inline_nocheck): New
function.
* sysdeps/powerpc/fpu/round_to_integer.h: New file.
* sysdeps/powerpc/fpu/s_ceil.c: Likewise.
* sysdeps/powerpc/fpu/s_ceilf.c: Likewise.
* sysdeps/powerpc/powerpc32/fpu/s_ceil.S: Remove file.
* sysdeps/powerpc/powerpc32/fpu/s_ceilf.S: Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/Makefile
(CFLAGS-s_ceil-power5+.c, CFLAGS-s_ceilf-power5+.c): New rule.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.S:
Remove file.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.S:
Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.S:
Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.S:
Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-power5+.c:
New file.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceil-ppc32.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-power5+.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/fpu/multiarch/s_ceilf-ppc32.c:
Likewise.
* sysdeps/powerpc/powerpc32/power5+/fpu/s_ceil.S: Remove file.
* sysdeps/powerpc/powerpc32/power5+/fpu/s_ceilf.S: Likewise.
* sysdeps/powerpc/powerpc64/be/fpu/multiarch/Makefile: New file.
* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-power5+.c:
Likewise.
* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil-ppc64.c:
Likewise.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil.c: Move to ...
* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceil.c: ... here.
* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-power5+.c: New
file.
* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf-ppc64.c:
Likewise.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf.c: Move to ...
* sysdeps/powerpc/powerpc64/be/fpu/multiarch/s_ceilf.c: ...
* here.
* sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
(libm-sysdep_routines): Remove s_ceil-power5+, s_ceil-ppc64,
s_ceilf-power5+, and s_ceilf-ppc64.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-power5+.S: Remove
file.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceil-ppc64.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-power5+.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/multiarch/s_ceilf-ppc64.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_ceil.S: Likewise.
* sysdeps/powerpc/powerpc64/fpu/s_ceilf.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_ceil.S: Likewise.
* sysdeps/powerpc/powerpc64/power5+/fpu/s_ceilf.S: Likewise.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
4 years agopowerpc: Remove power4 mpa optimization
Adhemerval Zanella [Wed, 20 Mar 2019 15:34:10 +0000 (15:34 +0000)] 
powerpc: Remove power4 mpa optimization

This patch removes the POWER4 optimized mpa optimization used currently
on all powerpc targets.  In fact for newer chips, GCC generates *worse*
code than generic implementation as below.  One possibilty would to
add ifunc variants for the mpa routines (as x86_64), but it will add
complexity only for older chips (and one would need to check if
power5, power5+, and power6 do benefict from this optimization),
and only for specific implementation (since most used one such
as sin, cos, exp, pow where optimized to avoid calling the slow
multiprecision path).

* POWER9 patched
$ ./testrun.sh benchtests/bench-atan
  "atan": {
   "": {
    "duration": 5.12565e+09,
    "iterations": 1.552e+08,
    "max": 100.552,
    "min": 7.799,
    "mean": 33.0261
   },
   "144bits": {
    "duration": 5.12745e+09,
    "iterations": 825000,
    "max": 7517.17,
    "min": 6186.3,
    "mean": 6215.09
   }
  }
$ ./testrun.sh benchtests/bench-acos
  "acos": {
   "": {
    "duration": 5.21741e+09,
    "iterations": 1.269e+08,
    "max": 191.738,
    "min": 7.931,
    "mean": 41.1144
   },
   "slow": {
    "duration": 5.25999e+09,
    "iterations": 198000,
    "max": 26681.7,
    "min": 26463.6,
    "mean": 26565.6
   }
  }

* POWER9 master
$ ./testrun.sh benchtests/bench-atan
  "atan": {
   "": {
    "duration": 5.12815e+09,
    "iterations": 1.552e+08,
    "max": 134.788,
    "min": 7.803,
    "mean": 33.0422
   },
   "144bits": {
    "duration": 5.1209e+09,
    "iterations": 447000,
    "max": 11615.8,
    "min": 11301.8,
    "mean": 11456.2
   }
  }
$ ./testrun.sh benchtests/bench-acos
  "acos": {
   "": {
    "duration": 5.22272e+09,
    "iterations": 1.269e+08,
    "max": 115.981,
    "min": 7.931,
    "mean": 41.1562
   },
   "slow": {
    "duration": 5.28723e+09,
    "iterations": 96000,
    "max": 55434.1,
    "min": 54820.6,
    "mean": 55075.3
   }
  }

* POWER8 patched
$ taskset -c 16 ./testrun.sh benchtests/bench-acos
  "acos": {
   "": {
    "duration": 5.16398e+09,
    "iterations": 9.99e+07,
    "max": 174.408,
    "min": 8.645,
    "mean": 51.6915
   },
   "slow": {
    "duration": 5.16982e+09,
    "iterations": 96000,
    "max": 54830.5,
    "min": 53703.8,
    "mean": 53852.3
   }
  }
* POWER8 master
$ taskset -c 16 ./testrun.sh benchtests/bench-acos
  "acos": {
   "": {
    "duration": 5.17019e+09,
    "iterations": 9.99e+07,
    "max": 186.127,
    "min": 8.633,
    "mean": 51.7537
   },
   "slow": {
    "duration": 5.34225e+09,
    "iterations": 90000,
    "max": 60353.2,
    "min": 59155.3,
    "mean": 59358.4
   }
  }

* POWER7 patched
$ taskset -c 16 benchtests/bench-asin
  "asin": {
   "": {
    "duration": 5.15559e+09,
    "iterations": 6.5e+07,
    "max": 193.335,
    "min": 12.227,
    "mean": 79.3168
   },
   "slow": {
    "duration": 5.20538e+09,
    "iterations": 80000,
    "max": 65705.2,
    "min": 64299.4,
    "mean": 65067.3
   }
  }
* POWER7 master
$ taskset -c 16 benchtests/bench-asin
  "asin": {
   "": {
    "duration": 5.15446e+09,
    "iterations": 6.5e+07,
    "max": 184.575,
    "min": 12.226,
    "mean": 79.2994
   },
   "slow": {
    "duration": 5.20616e+09,
    "iterations": 80000,
    "max": 65705.1,
    "min": 64336.6,
    "mean": 65076.9
   }
  }

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

* sysdeps/powerpc/power4/fpu/Makefile: Remove file.
* sysdeps/powerpc/power4/fpu/mpa-arch.h: Likewise.
* sysdeps/powerpc/power4/fpu/mpa.c: Likewise.

Reviewed-by: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
4 years ago<semaphore.h>: Add nonnull attributes
Yann Droneaud [Mon, 29 Apr 2019 08:11:35 +0000 (10:11 +0200)] 
<semaphore.h>: Add nonnull attributes

Except the following functions, NPTL implementation assume sem_t
argument (or other arguments) are not NULL, so they would benefit
from having the nonnull attribute.

- sem_close(): can cope with a NULL sem_t and return -1 with error EINVAL;
- sem_destroy(): does nothing at all

* sysdeps/pthread/semaphore.h (sem_init): Add __nonnull attribute.
(sem_destroy, sem_open, sem_close, sem_unlink): Likewise.
(sem_wait, sem_timedwait, sem_trywait, sem_post): Likewise.
(sem_getvalue): Likewise.

5 years agoelf: Link sotruss-lib.so with BIND_NOW for --enable-bind-now
Florian Weimer [Fri, 26 Apr 2019 05:16:56 +0000 (07:16 +0200)] 
elf: Link sotruss-lib.so with BIND_NOW for --enable-bind-now

The audit module itself can be linked with BIND_NOW; it does not
affect its functionality.

This should complete the leftovers from commit
2d6ab5df3b675e96ee587ae6a8c2ce004c6b1ba9 ("Document and fix
--enable-bind-now [BZ #21015]").

5 years agoMakeconfig: Move -Wl,-rpath-link options before library references
Florian Weimer [Fri, 26 Apr 2019 05:16:30 +0000 (07:16 +0200)] 
Makeconfig: Move -Wl,-rpath-link options before library references

Previously, the -Wl,-rpath-link options came after the libraries
injected using LDLIBS-* variables on the link editor command line for
main programs.  As a result, it could happen that installed libraries
that reference glibc libraries used the installed glibc from the system
directories, instead of the glibc from the build tree.  This can lead to
link failures if the wrong version of libpthread.so.0 is used, for
instance, due to differences in the internal GLIBC_PRIVATE interfaces,
as seen with memusagestat and -lgd after commit
f9b645b4b0a10c43753296ce3fa40053fa44606a ("memusagestat: use local glibc
when linking [BZ #18465]").

The isolation is necessarily imperfect because these installed
libraries are linked against the installed glibc in the system
directories.  However, in most cases, the built glibc will be newer
than the installed glibc, and this link is permitted because of the
ABI backwards compatibility glibc provides.

5 years agoMakeconfig: Move $(CC) to +link command variables
Florian Weimer [Fri, 26 Apr 2019 05:16:47 +0000 (07:16 +0200)] 
Makeconfig: Move $(CC) to +link command variables

This change is needed to add linker flags which come very early in the
command linke (before LDFLAGS) and are not applied to test programs
(only to installed programs).

5 years agoriscv: remove DL_RO_DYN_SECTION
David Abdurachmanov [Tue, 9 Apr 2019 11:25:29 +0000 (13:25 +0200)] 
riscv: remove DL_RO_DYN_SECTION

While working on enabling D front-end (GDC) in GCC we noticed that
druntime was segfaulting if it is linked dynamically. This was tracked
to DL_RO_DYN_SECTION.

DL_RO_DYN_SECTION lines seem to be copied from MIPS file (which is the
only user of it), but the comment doesn't apply to RISC-V. There is no
such requirement in RISC-V ABI.

        [BZ#24484]
* sysdeps/riscv/ldsodefs.h: Remove DL_RO_DYN_SECTION as it is not
required by RISC-V ABI.

5 years agobenchtests: Enable BIND_NOW if configured with --enable-bind-now
Florian Weimer [Thu, 25 Apr 2019 08:41:52 +0000 (10:41 +0200)] 
benchtests: Enable BIND_NOW if configured with --enable-bind-now

Benchmarks should reflect distribution build policies, so it makes
sense to honor the BIND_NOW configuration for them.

This commit keeps using $(+link-tests), so that the benchmarks are
linked according to the --enable-hardcoded-path-in-tests configure
option.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoExtend BIND_NOW to installed programs with --enable-bind-now
Florian Weimer [Thu, 25 Apr 2019 08:41:43 +0000 (10:41 +0200)] 
Extend BIND_NOW to installed programs with --enable-bind-now

Commit 2d6ab5df3b675e96ee587ae6a8c2ce004c6b1ba9 ("Document and fix
--enable-bind-now [BZ #21015]") extended BIND_NOW to all installed
shared objects.  This change also covers installed programs.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoReduce benchtests time
Wilco Dijkstra [Wed, 24 Apr 2019 14:38:49 +0000 (15:38 +0100)] 
Reduce benchtests time

Reduce the total time taken by benchtests.  The malloc thread test takes 4
minutes to run which is significantly more than most other tests. Reduce
this to a more reasonable 40 seconds.  The math tests take 10 seconds each,
eventhough all they do is loop on the same input.  Anything more than 1
second runtime is way overkill, so set the limit to 1 second.

* benchtests/Makefile (BENCH_DURATION): Set to 1 second.
* benchtests/bench-malloc-thread.c (BENCH_DURATION): Set to 10 seconds.

5 years agomemusagestat: use local glibc when linking [BZ #18465]
Mike Frysinger [Wed, 24 Apr 2019 11:32:22 +0000 (13:32 +0200)] 
memusagestat: use local glibc when linking [BZ #18465]

The memusagestat is the only binary that has its own link line which
causes it to be linked against the existing installed C library.  It
has been this way since it was originally committed in 1999, but I
don't see any reason as to why.  Since we want all the programs we
build locally to be against the new copy of glibc, change the build
to be like all other programs.

5 years agolocale/tst-locale-locpath: Run test only for $(run-built-tests) == yes
Florian Weimer [Wed, 24 Apr 2019 05:31:29 +0000 (07:31 +0200)] 
locale/tst-locale-locpath: Run test only for $(run-built-tests) == yes

5 years agoelf: Fix pldd (BZ#18035)
Adhemerval Zanella [Thu, 11 Apr 2019 21:12:00 +0000 (18:12 -0300)] 
elf: Fix pldd (BZ#18035)

Since 9182aa67994 (Fix vDSO l_name for GDB's, BZ#387) the initial link_map
for executable itself and loader will have both l_name and l_libname->name
holding the same value due:

 elf/dl-object.c

 95   new->l_name = *realname ? realname : (char *) newname->name + libname_len - 1;

Since newname->name points to new->l_libname->name.

This leads to pldd to an infinite call at:

 elf/pldd-xx.c

203     again:
204       while (1)
205         {
206           ssize_t n = pread64 (memfd, tmpbuf.data, tmpbuf.length, name_offset);

228           /* Try the l_libname element.  */
229           struct E(libname_list) ln;
230           if (pread64 (memfd, &ln, sizeof (ln), m.l_libname) == sizeof (ln))
231             {
232               name_offset = ln.name;
233               goto again;
234             }

Since the value at ln.name (l_libname->name) will be the same as previously
read. The straightforward fix is just avoid the check and read the new list
entry.

I checked also against binaries issues with old loaders with fix for BZ#387,
and pldd could dump the shared objects.

Checked on x86_64-linux-gnu, i686-linux-gnu, aarch64-linux-gnu, and
powerpc64le-linux-gnu.

[BZ #18035]
* elf/Makefile (tests-container): Add tst-pldd.
* elf/pldd-xx.c: Use _Static_assert in of pldd_assert.
(E(find_maps)): Avoid use alloca, use default read file operations
instead of explicit LFS names, and fix infinite loop.
* elf/pldd.c: Explicit set _FILE_OFFSET_BITS, cleanup headers.
(get_process_info): Use _Static_assert instead of assert, use default
directory operations instead of explicit LFS names, and free some
leadek pointers.
* elf/tst-pldd.c: New file.

5 years agoRemove do_set_mallopt_check prototype
H.J. Lu [Tue, 23 Apr 2019 20:12:13 +0000 (13:12 -0700)] 
Remove do_set_mallopt_check prototype

Remove do_set_mallopt_check prototype since it is unused.

* malloc/arena.c (do_set_mallopt_check): Removed.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
5 years agolocale: Add LOCPATH diagnostics to the locale program
Florian Weimer [Tue, 23 Apr 2019 16:16:26 +0000 (18:16 +0200)] 
locale: Add LOCPATH diagnostics to the locale program

The implementation of quote_string is based on support_quote_blob.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoFix NEWS entry from 9bf8e29ca136
Adhemerval Zanella [Sun, 21 Apr 2019 11:39:25 +0000 (08:39 -0300)] 
Fix NEWS entry from 9bf8e29ca136

* NEWS: Move memory allocation changes of BZ#23741 from 2.29
to 2.30 notes.

5 years agomalloc: make malloc fail with requests larger than PTRDIFF_MAX (BZ#23741)
Adhemerval Zanella [Tue, 18 Dec 2018 18:30:56 +0000 (16:30 -0200)] 
malloc: make malloc fail with requests larger than PTRDIFF_MAX (BZ#23741)

As discussed previously on libc-alpha [1], this patch follows up the idea
and add both the __attribute_alloc_size__ on malloc functions (malloc,
calloc, realloc, reallocarray, valloc, pvalloc, and memalign) and limit
maximum requested allocation size to up PTRDIFF_MAX (taking into
consideration internal padding and alignment).

This aligns glibc with gcc expected size defined by default warning
-Walloc-size-larger-than value which warns for allocation larger than
PTRDIFF_MAX.  It also aligns with gcc expectation regarding libc and
expected size, such as described in PR#67999 [2] and previously discussed
ISO C11 issues [3] on libc-alpha.

From the RFC thread [4] and previous discussion, it seems that consensus
is only to limit such requested size for malloc functions, not the system
allocation one (mmap, sbrk, etc.).

The implementation changes checked_request2size to check for both overflow
and maximum object size up to PTRDIFF_MAX. No additional checks are done
on sysmalloc, so it can still issue mmap with values larger than
PTRDIFF_T depending on the requested size.

The __attribute_alloc_size__ is for functions that return a pointer only,
which means it cannot be applied to posix_memalign (see remarks in GCC
PR#87683 [5]). The runtimes checks to limit maximum requested allocation
size does applies to posix_memalign.

Checked on x86_64-linux-gnu and i686-linux-gnu.

[1] https://sourceware.org/ml/libc-alpha/2018-11/msg00223.html
[2] https://gcc.gnu.org/bugzilla//show_bug.cgi?id=67999
[3] https://sourceware.org/ml/libc-alpha/2011-12/msg00066.html
[4] https://sourceware.org/ml/libc-alpha/2018-11/msg00224.html
[5] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87683

[BZ #23741]
* malloc/hooks.c (malloc_check, realloc_check): Use
__builtin_add_overflow on overflow check and adapt to
checked_request2size change.
* malloc/malloc.c (__libc_malloc, __libc_realloc, _mid_memalign,
__libc_pvalloc, __libc_calloc, _int_memalign): Limit maximum
allocation size to PTRDIFF_MAX.
(REQUEST_OUT_OF_RANGE): Remove macro.
(checked_request2size): Change to inline function and limit maximum
requested size to PTRDIFF_MAX.
(__libc_malloc, __libc_realloc, _int_malloc, _int_memalign): Limit
maximum allocation size to PTRDIFF_MAX.
(_mid_memalign): Use _int_memalign call for overflow check.
(__libc_pvalloc): Use __builtin_add_overflow on overflow check.
(__libc_calloc): Use __builtin_mul_overflow for overflow check and
limit maximum requested size to PTRDIFF_MAX.
* malloc/malloc.h (malloc, calloc, realloc, reallocarray, memalign,
valloc, pvalloc): Add __attribute_alloc_size__.
* stdlib/stdlib.h (malloc, realloc, reallocarray, valloc): Likewise.
* malloc/tst-malloc-too-large.c (do_test): Add check for allocation
larger than PTRDIFF_MAX.
* malloc/tst-memalign.c (do_test): Disable -Walloc-size-larger-than=
around tests of malloc with negative sizes.
* malloc/tst-posix_memalign.c (do_test): Likewise.
* malloc/tst-pvalloc.c (do_test): Likewise.
* malloc/tst-valloc.c (do_test): Likewise.
* malloc/tst-reallocarray.c (do_test): Replace call to reallocarray
with resulting size allocation larger than PTRDIFF_MAX with
reallocarray_nowarn.
(reallocarray_nowarn): New function.
* NEWS: Mention the malloc function semantic change.

5 years agopowerpc: Fix format issue from 3a16dd780eeba602
Adhemerval Zanella [Wed, 17 Apr 2019 21:32:01 +0000 (18:32 -0300)] 
powerpc: Fix format issue from 3a16dd780eeba602

* sysdeps/powerpc/fpu/s_fma.c: Fix format.
* sysdeps/powerpc/fpu/s_fmaf.c: Likewise.

5 years agopowerpc: fma using builtins
Adhemerval Zanella [Wed, 20 Mar 2019 04:14:28 +0000 (04:14 +0000)] 
powerpc: fma using builtins

This patch just refactor the assembly implementation to use compiler
builtins instead.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

* sysdeps/powerpc/fpu/s_fma.S: Remove file.
* sysdeps/powerpc/fpu/s_fmaf.S: Likewise.
* sysdeps/powerpc/fpu/s_fma.c: New file.
* sysdeps/powerpc/fpu/s_fmaf.c: Likewise.

5 years agopowerpc: Use generic fabs{f} implementations
Adhemerval Zanella [Wed, 20 Mar 2019 04:03:22 +0000 (04:03 +0000)] 
powerpc: Use generic fabs{f} implementations

Since be2e25bbd78f9fdf the generic ieee754 implementation uses
compiler builtin which generates fabs{f} for all supported targets.

Checked on powerpc-linux-gnu (built without --with-cpu, with
--with-cpu=power4 and with --with-cpu=power5+ and --disable-multi-arch),
powerpc64-linux-gnu (built without --with-cp and with --with-cpu=power5+
and --disable-multi-arch).

* sysdeps/powerpc/fpu/s_fabs.S: Remove file.
* sysdeps/powerpc/fpu/s_fabsf.S: Likewise.

5 years agomips: Remove rt_sigreturn usage on context function
Adhemerval Zanella [Fri, 15 Feb 2019 14:04:45 +0000 (12:04 -0200)] 
mips: Remove rt_sigreturn usage on context function

Similar to powerpc, mips also issues rt_sigreturn for setcontext
case the v0 value saved is not the one set by setcontext or
makecontext. As for powerpc, it is intention is no really supported
since setcontext is not async-signal-safe.

Checked the context tests on mips64-linux-gnu and mips-linux-gnu.

* sysdeps/unix/sysv/linux/mips/getcontext.S (__getcontext): Remove
the magic flag store.
* sysdeps/unix/sysv/linux/mips/makecontext.S (__makecontext):
Likewise.
* sysdeps/unix/sysv/linux/mips/swapcontext.S (__swapcontext):
Likewise.
* sysdeps/unix/sysv/linux/mips/setcontext.S (__setcontext):
Remove rt_sigreturn call.

5 years agopowerpc: Remove rt_sigreturn usage on context function
Adhemerval Zanella [Fri, 15 Feb 2019 13:55:16 +0000 (11:55 -0200)] 
powerpc: Remove rt_sigreturn usage on context function

As described in a recent glibc thread [1], the rt_sigreturn syscall
on setcontext and swapcontext is not used on default use and its
intention is no really supported since neither setcontext nor
swapcontext are async-signal-safe.

Checked on powerpc64-linux-gnu and powerpc-linux-gnu.

* sysdeps/unix/sysv/linux/powerpc/powerpc32/setcontext-common.S:
Remove rt_sigreturn call.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/swapcontext-common.S:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/setcontext.S: Likewie.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/swapcontext.S: Likewise.

[1] https://sourceware.org/ml/libc-alpha/2019-02/msg00367.html

5 years agosupport: Add support_capture_subprogram
Adhemerval Zanella [Fri, 12 Apr 2019 20:39:53 +0000 (17:39 -0300)] 
support: Add support_capture_subprogram

Its API is similar to support_capture_subprocess, but rather creates a
new process based on the input path and arguments.  Under the hoods it
uses posix_spawn to create the new process.

It also allows the use of other support_capture_* functions to check
for expected results and free the resources.

Checked on x86_64-linux-gnu.

* support/Makefile (libsupport-routines): Add support_subprocess,
xposix_spawn, xposix_spawn_file_actions_addclose, and
xposix_spawn_file_actions_adddup2.
(tst-support_capture_subprocess-ARGS): New rule.
* support/capture_subprocess.h (support_capture_subprogram): New
prototype.
* support/support_capture_subprocess.c (support_capture_subprocess):
Refactor to use support_subprocess and support_capture_poll.
(support_capture_subprogram): New function.
* support/tst-support_capture_subprocess.c (write_mode_to_str,
str_to_write_mode, test_common, parse_int, handle_restart,
do_subprocess, do_subprogram, do_multiple_tests): New functions.
(do_test): Add support_capture_subprogram tests.
* support/subprocess.h: New file.
* support/support_subprocess.c: Likewise.
* support/xposix_spawn.c: Likewise.
* support/xposix_spawn_file_actions_addclose.c: Likewise.
* support/xposix_spawn_file_actions_adddup2.c: Likewise.
* support/xspawn.h: Likewise.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agostdlib/tst-secure-getenv: handle >64 groups
Mike Gerow [Wed, 17 Apr 2019 09:45:34 +0000 (11:45 +0200)] 
stdlib/tst-secure-getenv: handle >64 groups

This test would fail unnecessarily if the user running it had more than
64 groups since getgroups returns EINVAL if the size provided is less
than the number of supplementary group IDs. Instead dynamically
determine the number of supplementary groups the user has.

5 years agoChangeLog: Correct excess and deficiency of spaces
TAMUKI Shoichi [Wed, 17 Apr 2019 03:44:26 +0000 (12:44 +0900)] 
ChangeLog: Correct excess and deficiency of spaces

5 years agoChangeLog: Convert leading spaces to tabs
TAMUKI Shoichi [Tue, 16 Apr 2019 01:17:24 +0000 (10:17 +0900)] 
ChangeLog: Convert leading spaces to tabs

5 years agonss_dns: Do not replace root domain with empty string
Florian Weimer [Thu, 11 Apr 2019 09:37:47 +0000 (11:37 +0200)] 
nss_dns: Do not replace root domain with empty string

The purpose of the bp[0] == '.' check is unclear.  Only the root domain
starts with '.'.  The empty string is accepted as a domain name in many
places, denoting the root, but using it implicitly is confusing.

5 years agoalloc_buffer: Return unqualified pointer type in alloc_buffer_next
Florian Weimer [Thu, 11 Apr 2019 07:43:16 +0000 (09:43 +0200)] 
alloc_buffer: Return unqualified pointer type in alloc_buffer_next

alloc_buffer_next is useful for peeking to the remaining part of the
buffer and update it, with subsequent allocation (once the length
is known) using alloc_buffer_alloc_bytes.  This is not as robust
as the other interfaces, but it allows using alloc_buffer with
string-writing interfaces such as snprintf and ns_name_ntop.

5 years agoAdd missing ChangeLog entry for commit 10dd69e9a00
Florian Weimer [Thu, 11 Apr 2019 07:41:08 +0000 (09:41 +0200)] 
Add missing ChangeLog entry for commit 10dd69e9a00

5 years agoAdd more bug numbers to historic ChangeLog entries
Florian Weimer [Thu, 11 Apr 2019 07:32:08 +0000 (09:32 +0200)] 
Add more bug numbers to historic ChangeLog entries

5 years agoAdd missing percent sign to conversion specifier
TAMUKI Shoichi [Thu, 11 Apr 2019 02:55:39 +0000 (11:55 +0900)] 
Add missing percent sign to conversion specifier

5 years agoAdd bug number to historic ChangeLog entry
Florian Weimer [Wed, 10 Apr 2019 07:12:39 +0000 (09:12 +0200)] 
Add bug number to historic ChangeLog entry

5 years agomalloc: Set and reset all hooks for tracing (Bug 16573)
Carlos O'Donell [Mon, 8 Apr 2019 21:35:05 +0000 (17:35 -0400)] 
malloc: Set and reset all hooks for tracing (Bug 16573)

If an error occurs during the tracing operation, particularly during a
call to lock_and_info() which calls _dl_addr, we may end up calling back
into the malloc-subsystem and relock the loader lock and deadlock. For
all intents and purposes the call to _dl_addr can call any of the malloc
family API functions and so we should disable all tracing before calling
such loader functions.  This is similar to the strategy that the new
malloc tracer takes when calling the real malloc, namely that all
tracing ceases at the boundary to the real function and any faults at
that point are the purvue of the library (though the new tracer does
this on a per-thread basis in an MT-safe fashion). Since the new tracer
and the hook deprecation are not yet complete we must fix these issues
where we can.

Tested on x86_64 with no regressions.

Co-authored-by: Kwok Cheung Yeung <kcy@codesourcery.com>
Reviewed-by: DJ Delorie <dj@redhat.com>
5 years agoImprove string benchtests
Wilco Dijkstra [Tue, 9 Apr 2019 10:54:34 +0000 (11:54 +0100)] 
Improve string benchtests

Replace slow byte-oriented tests in several string benchmarks with the
generic implementations from the string/ directory so the comparisons
are more realistic and useful.

* benchtests/bench-stpcpy.c (SIMPLE_STPCPY): Remove function.
(generic_stpcpy): New function.
* benchtests/bench-stpncpy.c (SIMPLE_STPNCPY): Remove function.
(generic_stpncpy): New function.
* benchtests/bench-strcat.c (SIMPLE_STRCAT): Remove function.
(generic_strcat): New function.
* benchtests/bench-strcpy.c (SIMPLE_STRCPY): Remove function.
(generic_strcpy): New function.
* benchtests/bench-strncat.c (SIMPLE_STRNCAT): Remove function.
(STUPID_STRNCAT): Remove function.
(generic_strncat): New function.
* benchtests/bench-strncpy.c (SIMPLE_STRNCPY): Remove function.
(STUPID_STRNCPY): Remove function.
(generic_strncpy): New function.
* benchtests/bench-strnlen.c (SIMPLE_STRNLEN): Remove function.
(generic_strnlen): New function.
(memchr_strnlen): New function.
* benchtests/bench-strlen.c (generic_strlen): Define for WIDE.
(memchr_strlen): Likewise.

5 years agoImprove bench-strstr
Wilco Dijkstra [Tue, 9 Apr 2019 10:49:18 +0000 (11:49 +0100)] 
Improve bench-strstr

Improve bench-strstr by using an extract from the manual as the input
to make the test more realistic.  Use the same input for both found and
fail cases rather than using a memset of '0' for most of the string,
which measures performance of strchr rather than strstr.  Add result
checking to catch potential errors.  Remove the repeated tests at slightly
different alignments and add more large needle and haystack testcases.

Replace stupid_strstr with an efficient basic implementation.  Add the
Two-way implementation to simplify comparisons with much faster generic
implementations.

* benchtests/bench-strstr.c (input): Add realistic input text.
(stupid_strstr): Remove function.
(basic_strstr): Add function.
(twoway_strstr): Add function.
(do_one_test): Add result checking.
(do_test): Use new input text.  Remove accidental early matches.
(test_main): Improve range of tests, reduce unaligned cases.

5 years agoImprove bench-memmem
Wilco Dijkstra [Tue, 9 Apr 2019 10:46:28 +0000 (11:46 +0100)] 
Improve bench-memmem

Improve bench-memmem by replacing simple_memmem with a more efficient
implementation.  Add the Two-way implementation to enable direct comparison
with the optimized memmem.

* benchtests/bench-memmem.c (simple_memmem): Remove function.
(basic_memmem): Add function.
(twoway_memmem): Add function.

5 years agoRemove TIMING_INIT
Wilco Dijkstra [Tue, 9 Apr 2019 10:38:24 +0000 (11:38 +0100)] 
Remove TIMING_INIT

Remove TIMING_INIT since it's no longer used.

* benchtests/bench-malloc-simple.c: Remove TIMING_INIT.
* benchtests/bench-malloc-thread.c: Likewise.
* benchtests/bench-skeleton.c: Likewise.
* benchtests/bench-strtod.c: Likewise.
* benchtests/bench-timing.h: Likewise.

5 years agoresolv: Remove RES_INSECURE1, RES_INSECURE2
Florian Weimer [Mon, 8 Apr 2019 09:19:38 +0000 (11:19 +0200)] 
resolv: Remove RES_INSECURE1, RES_INSECURE2

Always perform the associated security checks.

5 years agoresolv: Remove support for RES_USE_INET6 and the inet6 option
Florian Weimer [Mon, 8 Apr 2019 08:40:31 +0000 (10:40 +0200)] 
resolv: Remove support for RES_USE_INET6 and the inet6 option

This functionality was deprecated in glibc 2.25.

This commit only includes the core changes to remove the
functionality.  It does not remove the RES_USE_INET6 handling in the
individual NSS service modules and the res_use_inet6 function.
These changes will happen in future commits.

5 years agoaarch64: thunderx2 memcpy implementation cleanup and streamlining
Anton Youdkevitch [Fri, 5 Apr 2019 20:59:54 +0000 (13:59 -0700)] 
aarch64: thunderx2 memcpy implementation cleanup and streamlining

Here is the updated patch for improving the long unaligned
code path (the one using "ext" instruction).

1. Always taken conditional branch at the beginning is
removed.

2. Epilogue code is placed after the end of the loop to
reduce the number of branches.

3. The redundant "mov" instructions inside the loop are
gone due to the changed order of the registers in the "ext"
instructions inside the loop,  the prologue has additional
"ext" instruction.

4.Updating count in the prologue was hoisted out as
it is the same update for each prologue.

5. Invariant code of the loop epilogue was hoisted out.

6. As the current size of the ext chunk is exactly 16
instructions long "nop" was added at the beginning
of the code sequence so that the loop entry for all the
chunks be aligned.

* sysdeps/aarch64/multiarch/memcpy_thunderx2.S: Cleanup branching
and remove redundant code.

5 years agopowerpc: Use generic wcsrchr optimization
Adhemerval Zanella [Thu, 28 Feb 2019 11:33:40 +0000 (08:33 -0300)] 
powerpc: Use generic wcsrchr optimization

This patch removes the power6 wcsrchr optimization and uses generic
implementation instead.  Currently, both power6 and power7 IFUNC variant
resulting binary are essentially the same and the generic implementation
with unrolling loop set to 8 also results in similar performance.

Checked on powerpc64-linux-gnu.

* sysdeps/powerpc/Makefile [$(subdir) == wcsmbs] (CFLAGS-wcsrchr.c):
New rule.
* sysdeps/powerpc/power6/wcsrchr.c: Remove file.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power6.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power7.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/wcsrchr-ppc64.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c: Likewise.
* sysdeps/powerpc/powerpc64/power6/wcsrchr.c: Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
[$(subdir) == wcsmbs] (sysdeps_routines): Remove wcsrchr-power6 and
wcsrchr-power7.
(CFLAGS-wcsrchr-power7.c, CFLAGS-wcsrchr-power6.c): Remove rule.
* sysdeps/powerpc/powerpc64/multiarch/Makefile: Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c:
Remove wcsrchr optimizations.
* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c: Likewise.

5 years agowcsmbs: Use loop_unroll on wcsrchr
Adhemerval Zanella [Tue, 12 Mar 2019 13:05:49 +0000 (10:05 -0300)] 
wcsmbs: Use loop_unroll on wcsrchr

This allows an architecture to set explicit loop unrolling.

Checked on aarch64-linux-gnu.

* wcsmbs/wcsrchr.c (WCSRCHR): Use loop_unroll.h to parametrize
the loop unroll.

5 years agopowerpc: Use generic wcschr optimization
Adhemerval Zanella [Wed, 27 Feb 2019 18:15:51 +0000 (15:15 -0300)] 
powerpc: Use generic wcschr optimization

This patch removes the power6 wcschr optimization and uses generic
implementation instead.  Currently, both power6 and power7 IFUNC variant
resulting binary are essentially the same and the generic implementation
with unrolling loop set to 8 also results in similar performance.

Checked on powerpc64-linux-gnu.

* sysdeps/powerpc/Makefile [$(subdir) == wcsmbs] (CFLAGS-wcschr.c):
New rule.
* sysdeps/powerpc/power6/wcschr.c: Remove file.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power6.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-power7.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcschr-ppc32.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcschr.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/wcschr-power6.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/wcschr-power7.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/wcschr-ppc64.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/wcschr.c: Likewise.
* sysdeps/powerpc/powerpc64/power6/wcschr.c: Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
[$(subdir) == wcsmbs] (sysdeps_routines): Remove wcschr-power6 and
wcschr-power7.
(CFLAGS-wcschr-power7.c, CFLAGS-wcschr-power6.c): Remove rule.
* sysdeps/powerpc/powerpc64/multiarch/Makefile: Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c:
Remove wcschr optimizations.
* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c: Likewise.

5 years agowcsmbs: Use loop_unroll on wcschr
Adhemerval Zanella [Tue, 12 Mar 2019 12:33:03 +0000 (09:33 -0300)] 
wcsmbs: Use loop_unroll on wcschr

This allows an architecture to set explicit loop unrolling.

Checked on aarch64-linux-gnu.

* wcsmbs/wcschr.c (WCSCHR): Use loop_unroll.h to parametrize
the loop unroll.

5 years agopowerpc: Use generic wcscpy optimization
Adhemerval Zanella [Wed, 27 Feb 2019 14:21:35 +0000 (11:21 -0300)] 
powerpc: Use generic wcscpy optimization

This patch removes the power6 wcscpy optimization and uses generic
implementation instead.  Currently, both power6 and power7 IFUNC variant
resulting binary are essentially the same and the generic implementation
with unrolling loop set to 8 also results in similar performance.

Checked on powerpc64-linux-gnu.

* sysdeps/powerpc/Makefile [$(subdir) == wcsmbs] (CFLAGS-wcscpy.c):
New rule.
* sysdeps/powerpc/power6/wcscpy.c: Remove file.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power6.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-power7.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy-ppc32.c:
Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/wcscpy.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/wcscpy-power6.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/wcscpy-power7.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/wcscpy-ppc64.c: Likewise.
* sysdeps/powerpc/powerpc64/multiarch/wcscpy.c: Likewise.
* sysdeps/powerpc/powerpc64/power6/wcscpy.c: Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/Makefile
[$(subdir) == wcsmbs] (sysdeps_routines): Remove wcscpy-power6 and
wcscpy-power7.
(CFLAGS-wcscpy-power7.c, CFLAGS-wcscpy-power6.c): Remove rule.
* sysdeps/powerpc/powerpc64/multiarch/Makefile: Likewise.
* sysdeps/powerpc/powerpc32/power4/multiarch/ifunc-impl-list.c:
Remove wcscpy optimizations.
* sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c: Likewise.

5 years agowcsmbs: Add wcscpy loop unroll option
Adhemerval Zanella [Tue, 12 Mar 2019 02:39:15 +0000 (23:39 -0300)] 
wcsmbs: Add wcscpy loop unroll option

This allows an architecture to use the old generic implementation
and also set explicit loop unrolling.

Checked on aarch64-linux-gnu.

* include/loop_unroll.h: New file.
* wcsmbs/wcscpy (__wcscpy): Add option to use loop unrolling
besides generic implementation.

5 years agotime/tst-strftime3.c: Disable snprintf warning.
DJ Delorie [Wed, 3 Apr 2019 21:49:43 +0000 (17:49 -0400)] 
time/tst-strftime3.c: Disable snprintf warning.

snprintf will only truncate the output if the data its given
is corrupted, but a truncated buffer will not match the
"pristine" data's buffer, which is all we need.  So just
disable the warning via the DIAG macros.

5 years agoAdd Reiwa era tests to time/tst-strftime3.c
DJ Delorie [Mon, 1 Apr 2019 19:21:54 +0000 (15:21 -0400)] 
Add Reiwa era tests to time/tst-strftime3.c

Also fix printf warning

5 years agoja_JP locale: Add entry for the new Japanese era [BZ #22964]
TAMUKI Shoichi [Tue, 2 Apr 2019 07:46:55 +0000 (16:46 +0900)] 
ja_JP locale: Add entry for the new Japanese era [BZ #22964]

The Japanese era name will be changed on May 1, 2019.  The Japanese
government made a preliminary announcement on April 1, 2019.

The glibc ja_JP locale must be updated to include the new era name for
strftime's alternative year format support.

Checked on x86_64-linux-gnu.

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

[BZ #22964]
* localedata/locales/ja_JP (LC_TIME): Add entry for the new Japanese
era.
* time/tst-strftime2.c (dates): Add 2019-04-30 and 2019-05-01.
(mkreftable): Add rules for the new Japanese era and the new dates.

5 years agotime: Add tests for Minguo calendar [BZ #24293]
TAMUKI Shoichi [Tue, 2 Apr 2019 07:42:04 +0000 (16:42 +0900)] 
time: Add tests for Minguo calendar [BZ #24293]

Co-authored-by: Rafal Luzynski <digitalfreak@lingonborough.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
ChangeLog:

[BZ #24293]
* time/Makefile (LOCALES): Add zh_TW.UTF-8, cmn_TW.UTF-8,
hak_TW.UTF-8, nan_TW.UTF-8, and lzh_TW.UTF-8.
* time/tst-strftime2.c (locales): Likewise.
(dates): Add 1910-04-01, 1911-12-31, 1912-01-01, 1913-04-01,
2010-04-01, and 2011-04-01.
(mkreftable): Add rules for the new locales and the new dates.

5 years agotime/tst-strftime2.c: Make the file easier to maintain
TAMUKI Shoichi [Tue, 2 Apr 2019 07:37:03 +0000 (16:37 +0900)] 
time/tst-strftime2.c: Make the file easier to maintain

Express the years as full Gregorian years (e.g., 1988 instead of 88)
and months with natural numbers (1-12 rather than 0-11).

Compare actual dates rather than indexes when selecting the era name.

Declare the local variable era as a string character pointer rather
than an array of chars where the actual string is copied which might
lead to potential buffer overflows in future.

Co-authored-by: Rafal Luzynski <digitalfreak@lingonborough.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
ChangeLog:

* time/tst-strftime2.c (date_t): Explicitly define the type.
(dates): Use natural month and year numbers to express a date.
(is_before): New function to compare dates.
(mkreftable): Minor improvements to simplify maintenance.
(do_test): Reflect the changes in dates array.

5 years agoNEWS: Mention Minguo calendar support added [BZ #24293]
TAMUKI Shoichi [Tue, 2 Apr 2019 07:25:35 +0000 (16:25 +0900)] 
NEWS: Mention Minguo calendar support added [BZ #24293]

Co-authored-by: Rafal Luzynski <digitalfreak@lingonborough.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoAdd verbose comments to 'era' in ja_JP locale.
Carlos O'Donell [Thu, 28 Mar 2019 18:02:20 +0000 (14:02 -0400)] 
Add verbose comments to 'era' in ja_JP locale.

Reviewed-by: Rafal Luzynski <digitalfreak@lingonborough.com>
Reviewed-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
5 years agoFix strptime era handling, add more strftime tests [BZ #24394]
DJ Delorie [Wed, 27 Mar 2019 21:44:51 +0000 (17:44 -0400)] 
Fix strptime era handling, add more strftime tests [BZ #24394]

Test the transition points between all the currently listed Japanese
era name changes. This includes testing the transition between the
first year date and the second year date. This test will help test
the upcoming Japanese era name change.

Also fixes a fencepost error where the era name isn't properly parsed
by strptime in the last (partial) year of the era.

Example: if an era change happens in Feb 1990, and again in Aug 1995,
that's 5.5 years long, but the 0.5 year wasn't accounted for.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoalpha: Improve sysdeps/alpha/divqu.S and sysdeps/alpha/remqu.S
Uros Bizjak [Mon, 1 Apr 2019 08:58:37 +0000 (15:58 +0700)] 
alpha: Improve sysdeps/alpha/divqu.S and sysdeps/alpha/remqu.S

* sysdeps/alpha/divqu.S (__divqu): Move save of $f0 and excb after
conditional branch to DIVBYZERO.  Fix unwind info.
* sysdeps/alpha/remqu.S (__remqu): Move saves of $f0, $f1, $f2 and
excb after conditional branch to $powerof2.  Add missing unop
instructions and .align directives and reorder instructions to
match __divqu.

Signed-off-by: Uroš Bizjak <ubizjak@gmail.com>
5 years agoalpha: Do not redefine __NR_shmat or __NR_osf_shmat
Richard Henderson [Mon, 1 Apr 2019 08:54:00 +0000 (15:54 +0700)] 
alpha: Do not redefine __NR_shmat or __NR_osf_shmat

Fixes build using v5.1-rc1 headers.

The kernel has cleaned up how these are defined.  Previous behavior
was to define __NR_osf_shmat as 209 and not define __NR_shmat.
Current behavior is to define __NR_shmat as 209 and then define
__NR_osf_shmat as __NR_shmat.

* sysdeps/unix/sysv/linux/alpha/kernel-features.h (__NR_shmat):
Do not redefine.
* sysdeps/unix/sysv/linux/alpha/sysdep.h (__NR_osf_shmat):
Do not redefine.

5 years agoRISC-V: Fix `test' operand error with soft-float ABI being configured
Maciej W. Rozycki [Sat, 30 Mar 2019 01:11:31 +0000 (01:11 +0000)] 
RISC-V: Fix `test' operand error with soft-float ABI being configured

Fix a:

.../sysdeps/unix/sysv/linux/riscv/configure: line 181: test: =: unary operator expected

message produced by the RISC-V configure fragment with the soft-float
ABI selected, caused by $libc_cv_riscv_float_abi evaluating to nil in
the invocation of `test $libc_cv_riscv_float_abi = no'.

* sysdeps/unix/sysv/linux/riscv/configure.ac: Quote
$libc_cv_riscv_float_abi in `test' invocation.
* sysdeps/unix/sysv/linux/riscv/configure: Regenerate.

5 years ago[powerpc] Use __builtin_{mffs,mtfsf}
Paul A. Clarke [Sat, 30 Mar 2019 00:16:34 +0000 (19:16 -0500)] 
[powerpc] Use __builtin_{mffs,mtfsf}

Replace inline asm uses of the "mffs" and "mtfsf" instructions with
the analogous GCC builtins.

__builtin_mffs and __builtin_mtfsf are both available in GCC 5 and above.
Given the minimum GCC level for GLibC is now GCC 6.2, it is safe to use
these builtins without restriction.

2019-03-29  Paul A. Clarke  <pc@us.ibm.com>

* sysdeps/powerpc/fpu/fenv_libc.h (fegetenv_register): Replace inline
asm with builtin.
* sysdeps/powerpc/powerpc64/le/fpu/sfp-machine.h (FP_INIT_ROUNDMODE):
Likewise.
* sysdeps/powerpc/fpu/tst-setcontext-fpscr.c (_GET_DI_FPSCR): Likewise.
(_GET_SI_FPSCR): Likewise.
(_SET_SI_FPSCR): Likewise.

5 years agoChangeLog: Correct more dates.
Rafal Luzynski [Wed, 27 Mar 2019 23:58:53 +0000 (00:58 +0100)] 
ChangeLog: Correct more dates.

5 years agoChangeLog: Correct two dates.
Rafal Luzynski [Wed, 27 Mar 2019 11:46:24 +0000 (12:46 +0100)] 
ChangeLog: Correct two dates.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agomath: Enable some math builtins for clang
Adhemerval Zanella [Fri, 1 Feb 2019 12:39:57 +0000 (10:39 -0200)] 
math: Enable some math builtins for clang

This patch enable the builtin usage for clang for the C99 functions
fpclassify, isfinite, isnormal, isnan, isinf, and sigbit.  This allows
clang optimize the calls on frontend instead of call the appropriate
glibc symbols.

Checked on aarch64-linux-gnu and x86_64-linux-gnu. I checked the supported
version for each builtin based on released version from clang/llvm.

* math/math.h (fpclassify, isfinite, isnormal, isnan): Use builtin for
clang 2.8.
(signbit): Use builtin for clang 3.3.
(isinf): Use builtin for clang 3.7.

5 years agopowerpc: Remove ununsed s_float_bitwise.h
Adhemerval Zanella [Mon, 25 Mar 2019 18:34:50 +0000 (15:34 -0300)] 
powerpc: Remove ununsed s_float_bitwise.h

This file is not used anywhere since removal of {k,e}_rem_pio2f.c
(commit ca3aac57efa89).

Checked with a build for powerpc-linux-gnu (with --with-cpu=power4
and --with-cpu=power7), powerpc64-linux-gnu (with --with-cpu=power4
and --with-cpu=power7), and powerpc64le-linux (with --with-cpu=power8).

* sysdeps/powerpc/fpu/s_float_bitwise.h: Remove file.

5 years agonss/tst-nss-files-alias-leak: add missing opening quote in printf
Andreas K. Hüttel [Sun, 24 Mar 2019 14:49:03 +0000 (15:49 +0100)] 
nss/tst-nss-files-alias-leak: add missing opening quote in printf

5 years agonptl/tst-rwlock14: Test pthread_rwlock_timedwrlock correctly
Mike Crowe [Mon, 25 Mar 2019 12:29:50 +0000 (09:29 -0300)] 
nptl/tst-rwlock14: Test pthread_rwlock_timedwrlock correctly

5 years agonptl: Convert tst-sem5 & tst-sem13 to use libsupport
Mike Crowe [Mon, 25 Mar 2019 12:28:18 +0000 (09:28 -0300)] 
nptl: Convert tst-sem5 & tst-sem13 to use libsupport

Checked on x86_64-linux-gnu and i686-linux-gnu.

* nptl/tst-sem5.c: Remove unused headers. Add <support/check.h>.
(do_test) Use libsupport test macros rather than hand-coded
conditionals and error messages. Ensure that sem_init returns zero
rather than not -1. Use <support/test-driver.c> rather than
test-skeleton.c.

* nptl/tst-sem13.c: Add <support/check.h>. (do_test) Use libsupport
test macros rather than hand-coded conditionals and error messages.
Use <support/test-driver.c> rather than test-skeleton.c.

5 years agoAdd UDP_GRO from Linux 5.0 to netinet/udp.h.
Joseph Myers [Mon, 25 Mar 2019 13:16:46 +0000 (13:16 +0000)] 
Add UDP_GRO from Linux 5.0 to netinet/udp.h.

This patch adds the new constant UDP_GRO from Linux 5.0 to glibc.

Tested for x86_64.

* sysdeps/gnu/netinet/udp.h (UDP_GRO): New macro.

5 years agoAdd NT_ARM_PAC_MASK and NT_MIPS_MSA from Linux 5.0 to elf.h.
Joseph Myers [Mon, 25 Mar 2019 13:15:56 +0000 (13:15 +0000)] 
Add NT_ARM_PAC_MASK and NT_MIPS_MSA from Linux 5.0 to elf.h.

This patch adds two new NT_* macros from Linux 5.0 to elf.h.

Tested for x86_64.

* elf/elf.h (NT_ARM_PAC_MASK): New macro.
(NT_MIPS_MSA): Likewise.

5 years agoAdd generic hp-timing support
Wilco Dijkstra [Tue, 29 Jan 2019 17:43:45 +0000 (17:43 +0000)] 
Add generic hp-timing support

Add missing generic hp_timing support.  It uses clock_gettime (CLOCK_MONOTONIC)
which has unspecified starting time, nano-second accuracy, and should faster on
architectures that implementes the symbol as vDSO.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. I also
checked the builds for all afected ABIs.

* benchtests/Makefile (USE_CLOCK_GETTIME) Remove.
* benchtests/README: Update description.
* benchtests/bench-timing.h: Default to hp-timing.
* sysdeps/generic/hp-timing.h (HP_TIMING_DIFF, HP_TIMING_ACCUM_NT,
HP_TIMING_PRINT): Remove.
(HP_TIMING_NOW): Add generic implementation.
(hp_timing_t): Change to uint64_t.

5 years agoRefactor hp-timing rtld usage
Adhemerval Zanella [Thu, 24 Jan 2019 12:46:59 +0000 (12:46 +0000)] 
Refactor hp-timing rtld usage

This patch refactor how hp-timing is used on loader code for statistics
report.  The HP_TIMING_AVAIL and HP_SMALL_TIMING_AVAIL are removed and
HP_TIMING_INLINE is used instead to check for hp-timing avaliability.
For alpha, which only defines HP_SMALL_TIMING_AVAIL, the HP_TIMING_INLINE
is set iff for IS_IN(rtld).

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. I also
checked the builds for all afected ABIs.

* benchtests/bench-timing.h: Replace HP_TIMING_AVAIL with
HP_TIMING_INLINE.
* nptl/descr.h: Likewise.
* elf/rtld.c (RLTD_TIMING_DECLARE, RTLD_TIMING_NOW, RTLD_TIMING_DIFF,
RTLD_TIMING_ACCUM_NT, RTLD_TIMING_SET): Define.
(dl_start_final_info, _dl_start_final, dl_main, print_statistics):
Abstract hp-timing usage with RTLD_* macros.
* sysdeps/alpha/hp-timing.h (HP_TIMING_INLINE): Define iff IS_IN(rtld).
(HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL): Remove.
* sysdeps/generic/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL,
HP_TIMING_NONAVAIL): Likewise.
* sysdeps/ia64/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL):
Likewise.
* sysdeps/powerpc/powerpc32/power4/hp-timing.h (HP_TIMING_AVAIL,
HP_SMALL_TIMING_AVAIL): Likewise.
* sysdeps/powerpc/powerpc64/hp-timing.h (HP_TIMING_AVAIL,
HP_SMALL_TIMING_AVAIL): Likewise.
* sysdeps/sparc/sparc32/sparcv9/hp-timing.h (HP_TIMING_AVAIL,
HP_SMALL_TIMING_AVAIL): Likewise.
* sysdeps/sparc/sparc64/hp-timing.h (HP_TIMING_AVAIL,
HP_SMALL_TIMING_AVAIL): Likewise.
* sysdeps/x86/hp-timing.h (HP_TIMING_AVAIL, HP_SMALL_TIMING_AVAIL):
Likewise.
* sysdeps/generic/hp-timing-common.h: Update comment with
HP_TIMING_AVAIL removal.

5 years agoDo not use HP_TIMING_NOW for random bits
Adhemerval Zanella [Wed, 16 Jan 2019 18:10:56 +0000 (18:10 +0000)] 
Do not use HP_TIMING_NOW for random bits

This patch removes the HP_TIMING_BITS usage for fast random bits and replace
with clock_gettime (CLOCK_MONOTONIC).  It has unspecified starting time and
nano-second accuracy, so its randomness is significantly better than
gettimeofday.

Althoug it should incur in more overhead (specially for architecture that
support hp-timing), the symbol is also common implemented as a vDSO.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. I also
checked on a i686-gnu build.

* include/random-bits.h: New file.
* resolv/res_mkquery.c [HP_TIMING_AVAIL] (RANDOM_BITS,
(__res_context_mkquery): Remove usage hp-timing usage and replace with
random_bits.
* resolv/res_send.c [HP_TIMING_AVAIL] (nameserver_offset): Likewise.
* sysdeps/posix/tempname.c [HP_TIMING_AVAIL] (__gen_tempname):
Likewise.

5 years agoRemove __get_clockfreq
Adhemerval Zanella [Fri, 8 Feb 2019 16:53:40 +0000 (16:53 +0000)] 
Remove __get_clockfreq

With clock_getres, clock_gettime, and clock_settime refactor to remove the
generic CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID support through
hp-timing, there is no usage of internal __get_clockfreq.  This patch removes
both generic and Linux implementation..

Checked with a build against aarch64-linux-gnu, i686-linux-gnu, ia64-linux-gnu,
sparc64-linux-gnu, powerpc-linux-gnu-power4.

* include/libc-internal.h (__get_clockfreq): Remove prototype.
* rt/Makefile (clock-routines): Remove get_clockfreq.
* rt/get_clockfreq.c: Remove file.
* sysdeps/unix/sysv/linux/i386/get_clockfreq.c: Likewise.
* sysdeps/unix/sysv/linux/ia64/get_clockfreq.c: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c: Likewise.
* sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c: Move code to ...
* sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c: ... here.

5 years agolinux: Assume clock_getres CLOCK_{PROCESS,THREAD}_CPUTIME_ID
Adhemerval Zanella [Wed, 16 Jan 2019 17:30:07 +0000 (17:30 +0000)] 
linux: Assume clock_getres CLOCK_{PROCESS,THREAD}_CPUTIME_ID

The Linux 3.2 clock_getres kernel code (kernel/posix-cpu-timers.c)
issued for clock_getres CLOCK_PROCESS_CPUTIME_ID (process_cpu_clock_getres)
and CLOCK_THREAD_CPUTIME_ID (thread_cpu_clock_getres) call
posix_cpu_clock_getres. And it fails on check_clock only if an invalid
clock is used (not the case) or if we pass an invalid the pid/tid in
29 msb of clock_id (not the case either).

This patch assumes that clock_getres syscall always support
CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID, so there is no need
to fallback to hp-timing support for _SC_MONOTONIC_CLOCK neither to issue
the syscall to certify the clock_id is supported bt the kernel.  This
allows simplify the sysconf support to always use the syscall.

it also removes ia64 itc drift check and assume kernel handles it correctly.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.

* sysdeps/unix/sysv/linux/ia64/has_cpuclock.c: Remove file.
* sysdeps/unix/sysv/linux/ia64/sysconf.c: Likewise.
* sysdeps/unix/sysv/linux/sysconf.c (has_cpuclock): Remove function.
(__sysconf): Assume kernel support for _SC_MONOTONIC_CLOCK,
_SC_CPUTIME, and _SC_THREAD_CPUTIME.

5 years agonptl: Remove pthread_clock_gettime pthread_clock_settime
Adhemerval Zanella [Wed, 16 Jan 2019 16:22:29 +0000 (16:22 +0000)] 
nptl: Remove pthread_clock_gettime pthread_clock_settime

This patch removes CLOCK_THREAD_CPUTIME_ID and CLOCK_PROCESS_CPUTIME_ID support
from clock_gettime and clock_settime generic implementation.  For Linux, kernel
already provides supports through the syscall and Hurd HTL lacks
__pthread_clock_gettime and __pthread_clock_settime internal implementation.

As described in clock_gettime man-page [1] on 'Historical note for SMP
system', implementing CLOCK_{THREAD,PROCESS}_CPUTIME_ID with timer registers
is error-prone and susceptible to timing and accurary issues that the libc
can not deal without kernel support.

This allows removes unused code which, however, still incur in some runtime
overhead in thread creation (the struct pthread cpuclock_offset
initialization).

If hurd eventually wants to support them it should either either implement as
a kernel facility (or something related due its architecture) or in system
specific implementation.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. I also
checked on a i686-gnu build.

* nptl/Makefile (libpthread-routines): Remove pthread_clock_gettime and
pthread_clock_settime.
* nptl/pthreadP.h (__find_thread_by_id): Remove prototype.
* elf/dl-support.c [!HP_TIMING_NOAVAIL] (_dl_cpuclock_offset): Remove.
(_dl_non_dynamic_init): Remove _dl_cpuclock_offset setting.
* elf/rtld.c (_dl_start_final): Likewise.
* nptl/allocatestack.c (__find_thread_by_id): Remove function.
* sysdeps/generic/ldsodefs.h [!HP_TIMING_NOAVAIL] (_dl_cpuclock_offset):
Remove.
* sysdeps/mach/hurd/dl-sysdep.c [!HP_TIMING_NOAVAIL]
(_dl_cpuclock_offset): Remove.
* nptl/descr.h (struct pthread): Rename cpuclock_offset to
cpuclock_offset_ununsed.
* nptl/nptl-init.c (__pthread_initialize_minimal_internal): Remove
cpuclock_offset set.
* nptl/pthread_create.c (START_THREAD_DEFN): Likewise.
* sysdeps/nptl/fork.c (__libc_fork): Likewise.
* nptl/pthread_clock_gettime.c: Remove file.
* nptl/pthread_clock_settime.c: Likewise.
* sysdeps/unix/clock_gettime.c (hp_timing_gettime): Remove function.
[HP_TIMING_AVAIL] (realtime_gettime): Remove CLOCK_THREAD_CPUTIME_ID
and CLOCK_PROCESS_CPUTIME_ID support.
* sysdeps/unix/clock_settime.c (hp_timing_gettime): Likewise.
[HP_TIMING_AVAIL] (realtime_gettime): Likewise.
* sysdeps/posix/clock_getres.c (hp_timing_getres): Likewise.
[HP_TIMING_AVAIL] (__clock_getres): Likewise.
* sysdeps/unix/clock_nanosleep.c (CPUCLOCK_P, INVALID_CLOCK_P):
Likewise.
(__clock_nanosleep): Remove CPUCLOCK_P and INVALID_CLOCK_P usage.

[1] http://man7.org/linux/man-pages/man2/clock_gettime.2.html

5 years agoS390: Add arch13 memmem ifunc variant.
Stefan Liebler [Fri, 22 Mar 2019 10:14:09 +0000 (11:14 +0100)] 
S390: Add arch13 memmem ifunc variant.

This patch introduces the new arch13 ifunc variant for memmem.
For needles longer than 9 bytes it is relying on the common-code
implementation.  For shorter needles it is using the new vstrs instruction
which is able to search a substring within a vector register.

ChangeLog:

* sysdeps/s390/Makefile (sysdep_routines): Add memmem-arch13.
* sysdeps/s390/ifunc-memmem.h (HAVE_MEMMEM_ARCH13, MEMMEM_ARCH13,
MEMMEM_Z13_ONLY_USED_AS_FALLBACK, HAVE_MEMMEM_IFUNC_AND_ARCH13_SUPPORT):
New defines.
* sysdeps/s390/memmem-arch13.S: New file.
* sysdeps/s390/memmem-vx.c: Omit GI symbol for z13 memmem ifunc variant
if it is only used as fallback.
* sysdeps/s390/memmem.c (memmem): Add arch13 variant in ifunc selector.
* sysdeps/s390/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Add ifunc variant for arch13 memmem.

5 years agoS390: Add arch13 strstr ifunc variant.
Stefan Liebler [Fri, 22 Mar 2019 10:14:08 +0000 (11:14 +0100)] 
S390: Add arch13 strstr ifunc variant.

This patch introduces the new arch13 ifunc variant for strstr.
For needles longer than 9 charachters it is relying on the common-code
implementation.  For shorter needles it is using the new vstrs instruction
which is able to search a substring within a vector register.

ChangeLog:

* sysdeps/s390/Makefile (sysdep_routines): Add strstr-arch13.
* sysdeps/s390/ifunc-strstr.h (HAVE_STRSTR_ARCH13, STRSTR_ARCH13,
STRSTR_Z13_ONLY_USED_AS_FALLBACK, HAVE_STRSTR_IFUNC_AND_ARCH13_SUPPORT):
New defines.
* sysdeps/s390/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Add ifunc variant for arch13 strstr.
* sysdeps/s390/strstr-arch13.S: New file.
* sysdeps/s390/strstr-vx.c: Omit GI symbol for z13 strstr ifunc variant
if it is only used as fallback.
* sysdeps/s390/strstr.c (strstr): Add arch13 variant in ifunc selector.

5 years agoS390: Add arch13 memmove ifunc variant.
Stefan Liebler [Fri, 22 Mar 2019 10:14:08 +0000 (11:14 +0100)] 
S390: Add arch13 memmove ifunc variant.

This patch introduces the new arch13 ifunc variant for memmove.
For the forward or non-overlapping case it is just using memcpy.
For the backward case it relies on the new instruction mvcrl.
The instruction copies up to 256 bytes at once.
In case of an overlap, it copies the bytes like copying them
one by one starting from right to left.

ChangeLog:

* sysdeps/s390/ifunc-memcpy.h (HAVE_MEMMOVE_ARCH13, MEMMOVE_ARCH13
HAVE_MEMMOVE_IFUNC_AND_ARCH13_SUPPORT): New defines.
* sysdeps/s390/memcpy-z900.S: Add arch13 memmove implementation.
* sysdeps/s390/memmove.c (memmove): Add arch13 variant in
ifunc selector.
* sysdeps/s390/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Add ifunc variant for arch13 memmove.
* sysdeps/s390/multiarch/ifunc-resolve.h (S390_STFLE_BITS_ARCH13_MIE3,
S390_IS_ARCH13_MIE3): New defines.

5 years agoS390: Add configure check to detect support for arch13.
Stefan Liebler [Fri, 22 Mar 2019 10:14:08 +0000 (11:14 +0100)] 
S390: Add configure check to detect support for arch13.

Add two configure checks which detect if arch13 is supported
by the assembler at all - by explicitely setting the machine -
and if it is supported with default settings.

ChangeLog:

* config.h.in (HAVE_S390_MIN_ARCH13_ZARCH_ASM_SUPPORT,
HAVE_S390_ARCH13_ASM_SUPPORT): New undefine.
* sysdeps/s390/configure.ac: Add checks for arch13 support.
* sysdeps/s390/configure: Regenerated.

5 years agoS390: Add new hwcap values for new cpu architecture arch13.
Stefan Liebler [Fri, 22 Mar 2019 10:14:07 +0000 (11:14 +0100)] 
S390: Add new hwcap values for new cpu architecture arch13.

The new hwcap values indicate support for:
-"Vector-Enhancements Facility 2" (tag "vxe2", hwcap 2^15)
-"Vector-Packed-Decimal-Enhancement Facility" (tag "vxp", hwcap 2^16)
-"Enhanced-Sort Facility" (tag "sort", hwcap 2^17)
-"Deflate-Conversion Facility" (tag "dflt", hwcap 2^18)

The vxe2 hwcap is also marked as important hwcap.

ChangeLog:

* sysdeps/s390/dl-procinfo.c (_dl_s390_cap_flags):
Add vxe2, vxp, dflt, sort flags.
* sysdeps/s390/dl-procinfo.h: Add HWCAP_S390_VXRS_EXT2,
HWCAP_S390_VXRS_PDE, HWCAP_S390_SORT, HWCAP_S390_DFLT
capabilities.
(HWCAP_IMPORTANT): Add HWCAP_S390_VXRS_EXT2.
* sysdeps/unix/sysv/linux/s390/bits/hwcap.h
(HWCAP_S390_VXRS_EXT2, HWCAP_S390_VXRS_PDE, HWCAP_S390_SORT,
HWCAP_S390_DFLT): Define.

5 years agoFix parentheses error in iconvconfig.c and ld-collate.c [BZ #24372]
Gabriel F. T. Gomes [Thu, 21 Mar 2019 20:24:30 +0000 (17:24 -0300)] 
Fix parentheses error in iconvconfig.c and ld-collate.c [BZ #24372]

When -Werror=parentheses is in use, iconvconfig.c builds fail with:

  iconvconfig.c: In function ‘write_output’:
  iconvconfig.c:1084:34: error: suggest parentheses around ‘+’ inside ‘>>’ [-Werror=parentheses]
     hash_size = next_prime (nnames + nnames >> 1);
                             ~~~~~~~^~~~~~~~

This patch adds parentheses to the expression.  Not where suggested by
the compiler warning, but where it produces the expected result, i.e.:
where it has the effect of multiplying nnames by 1.5.

Likewise for elem_size in ld-collate.c.

Tested for powerpc64le.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoiconv, localedef: avoid floating point rounding differences [BZ #24372]
DJ Delorie [Thu, 21 Mar 2019 03:56:59 +0000 (23:56 -0400)] 
iconv, localedef: avoid floating point rounding differences [BZ #24372]

Two cases of "int * 1.4" may result in imprecise results, which
in at least one case resulted in i686 and x86-64 producing
different locale files.  This replaced that floating point multiply
with integer operations.  While the hash table margin is increased
from 40% to 50%, testing shows only 2% increase in overall size
of the locale archive.

https://bugzilla.redhat.com/show_bug.cgi?id=1311954

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agoS390: Mark vx and vxe as important hwcap.
Stefan Liebler [Thu, 21 Mar 2019 08:14:26 +0000 (09:14 +0100)] 
S390: Mark vx and vxe as important hwcap.

This patch adds vx and vxe as important hwcaps
which allows one to provide shared libraries
tuned for platforms with non-vx/-vxe, vx or vxe.

ChangeLog:

* sysdeps/s390/dl-procinfo.h (HWCAP_IMPORTANT):
Add HWCAP_S390_VX and HWCAP_S390_VXE.

5 years agott_RU: Fix orthographic mistakes in day and abday sections [BZ #24296]
mansayk [Sat, 16 Mar 2019 08:05:22 +0000 (11:05 +0300)] 
tt_RU: Fix orthographic mistakes in day and abday sections [BZ #24296]

This commit fixes some errors and converts all weekday names to lowercase.
The content is synchronized with CLDR-34 now, but trailing dots are removed
from abday values in order to maintain consistency with the previous values
and with many other locales which do the same.

[BZ #24296]
* localedata/locales/tt_RU (day): Update from CLDR-34, fix errors.
(abday): Likewise, but remove the trailing dots.

5 years agoAdd AArch64 HWCAPs from Linux 5.0.
Joseph Myers [Tue, 19 Mar 2019 14:02:17 +0000 (14:02 +0000)] 
Add AArch64 HWCAPs from Linux 5.0.

This patch adds new AArch64 HWCAPs from Linux 5.0 to the AArch64
bits/hwcap.h and dl-procinfo.c.

Tested (compilation only) with build-many-glibcs.py for
aarch64-linux-gnu.

* sysdeps/unix/sysv/linux/aarch64/bits/hwcap.h (HWCAP_SB): New
macro.
(HWCAP_PACA): Likewise.
(HWCAP_PACG): Likewise.
* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.c (_DL_HWCAP_COUNT):
Increase to 32.
(_dl_aarch64_cap_flags): Add new entries for new HWCAPs.

5 years ago* time/mktime.c: Update obsolete URL in comment.
Paul Eggert [Sun, 17 Mar 2019 23:26:07 +0000 (16:26 -0700)] 
* time/mktime.c: Update obsolete URL in comment.

5 years agoRecord CVE-2019-9169 in NEWS and ChangeLog [BZ #24114]
Aurelien Jarno [Sat, 16 Mar 2019 21:59:56 +0000 (22:59 +0100)] 
Record CVE-2019-9169 in NEWS and ChangeLog [BZ #24114]

5 years agohurd: Fix comment style
Samuel Thibault [Sat, 16 Mar 2019 18:44:04 +0000 (19:44 +0100)] 
hurd: Fix comment style

5 years agohurd: Document how EINTR should be handled in critical sections
Samuel Thibault [Wed, 17 Aug 2016 12:34:38 +0000 (14:34 +0200)] 
hurd: Document how EINTR should be handled in critical sections

* hurd/hurd/signal.h (_hurd_critical_section_lock): Document how EINTR
should be handled.

5 years agoUpdate syscall-names.list for Linux 5.0.
Joseph Myers [Fri, 15 Mar 2019 18:18:40 +0000 (18:18 +0000)] 
Update syscall-names.list for Linux 5.0.

This patch updates sysdeps/unix/sysv/linux/syscall-names.list for
Linux 5.0.  Based on testing with build-many-glibcs.py, the only new
entry needed is for old_getpagesize (a newly added __NR_* name for an
old syscall on ia64).  (Because 5.0 changes how syscall tables are
handled in the kernel, checking diffs wasn't a useful way of looking
for new syscalls in 5.0 as most of the syscall tables were moved to
the new representation without actually adding any syscalls to them.)

Tested with build-many-glibcs.py.

* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
version to 5.0.
(old_getpagesize): New syscall.

5 years agolocaledata: Add Minguo calendar support to Taiwanese locales [BZ #24293]
Felix Yan [Thu, 7 Mar 2019 09:40:02 +0000 (17:40 +0800)] 
localedata: Add Minguo calendar support to Taiwanese locales [BZ #24293]

Minguo calendar is the official calendar system, and very widely used in
Taiwan. This commit adds its support into glibc.

Some background information: The government website (www.gov.tw) uses it,
popular public services like Taiwan HSR also use this calendar system.

Link to Wikipedia: https://en.wikipedia.org/wiki/Minguo_calendar

        [BZ #24293]
        * localedata/locales/zh_TW (era): Add, support Minguo calendar.
        * localedata/locales/cmn_TW (era): Likewise.
        * localedata/locales/hak_TW (era): Likewise.
        * localedata/locales/lzh_TW (era): Likewise.
        * localedata/locales/nan_TW (era): Likewise.

5 years agomalloc: Check for large bin list corruption when inserting unsorted chunk
Adam Maris [Thu, 14 Mar 2019 20:51:16 +0000 (16:51 -0400)] 
malloc: Check for large bin list corruption when inserting unsorted chunk

Fixes bug 24216. This patch adds security checks for bk and bk_nextsize pointers
of chunks in large bin when inserting chunk from unsorted bin. It was possible
to write the pointer to victim (newly inserted chunk) to arbitrary memory
locations if bk or bk_nextsize pointers of the next large bin chunk
got corrupted.

5 years agoRemove obsolete, never-implemented XSI STREAMS declarations
Florian Weimer [Thu, 14 Mar 2019 14:44:14 +0000 (15:44 +0100)] 
Remove obsolete, never-implemented XSI STREAMS declarations

The stub implementations are turned into compat symbols.

Linux actually has two reserved system call numbers (for getpmsg
and putpmsg), but these system calls have never been implemented,
and there are no plans to implement them, so this patch replaces
the wrappers with the generic stubs.

According to <https://bugzilla.redhat.com/show_bug.cgi?id=436349>,
the presence of the XSI STREAMS declarations is a minor portability
hazard because they are not actually implemented.

This commit does not change the TIRPC support code in
sunrpc/rpc_svcout.c.  It uses additional XTI functionality and
therefore never worked with glibc.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
5 years agonss: Fix tst-nss-files-alias-truncated for default --as-needed linking
Florian Weimer [Thu, 14 Mar 2019 14:02:52 +0000 (15:02 +0100)] 
nss: Fix tst-nss-files-alias-truncated for default --as-needed linking

Linking to the NSS module directly does not work if the linker defaults
to --as-needed because it will remove the apparently unused DSO
reference and not generate a DT_NEEDED entry.  Use an explicit dlopen
call, like in the other chroot tests involving NSS modules.

5 years agoscripts/check-obsolete-constructs.py: Process all headers as UTF-8.
Zack Weinberg [Thu, 14 Mar 2019 13:44:22 +0000 (09:44 -0400)] 
scripts/check-obsolete-constructs.py: Process all headers as UTF-8.

A few of our installed headers contain UTF-8 in comments.
check-obsolete-constructs opened files without explicitly specifying
their encoding, so it would barf on these headers if “make check” was
run in a non-UTF-8 locale.

* scripts/check-obsolete-constructs.py (HeaderChecker.check):
Specify encoding="utf-8" when opening headers to check.