platform/upstream/glibc.git
3 years agoio: Add closefrom [BZ #10353]
Adhemerval Zanella [Wed, 10 Mar 2021 15:26:32 +0000 (12:26 -0300)]
io: Add closefrom [BZ #10353]

The function closes all open file descriptors greater than or equal to
input argument.  Negative values are clamped to 0, i.e, it will close
all file descriptors.

As indicated by the bug report, this is a common symbol provided by
different systems (Solaris, OpenBSD, NetBSD, FreeBSD) and, although
its has inherent issues with not taking in consideration internal libc
file descriptors (such as syslog), this is also a common feature used
in multiple projects [1][2][3][4][5].

The Linux fallback implementation iterates over /proc and close all
file descriptors sequentially.  Although it was raised the questioning
whether getdents on /proc/self/fd might return disjointed entries
when file descriptor are closed; it does not seems the case on my
testing on multiple kernel (v4.18, v5.4, v5.9) and the same strategy
is used on different projects [1][2][3][5].

Also, the interface is set a fail-safe meaning that a failure in the
fallback results in a process abort.

Checked on x86_64-linux-gnu and i686-linux-gnu on kernel 5.11 and 4.15.

[1] https://github.com/systemd/systemd/blob/5238e9575906297608ff802a27e2ff9effa3b338/src/basic/fd-util.c#L217
[2] https://github.com/lxc/lxc/blob/ddf4b77e11a4d08f09b7b9cd13e593f8c047edc5/src/lxc/start.c#L236
[3] https://github.com/python/cpython/blob/9e4f2f3a6b8ee995c365e86d976937c141d867f8/Modules/_posixsubprocess.c#L220
[4] https://github.com/rust-lang/rust/blob/5f47c0613ed4eb46fca3633c1297364c09e5e451/src/libstd/sys/unix/process2.rs#L303-L308
[5] https://github.com/openjdk/jdk/blob/master/src/java.base/unix/native/libjava/childproc.c#L82

3 years agolinux: Add close_range
Adhemerval Zanella [Wed, 10 Mar 2021 15:26:31 +0000 (12:26 -0300)]
linux: Add close_range

It was added on Linux 5.9 (278a5fbaed89) with CLOSE_RANGE_CLOEXEC
added on 5.11 (582f1fb6b721f).  Although FreeBSD has added the same
syscall, this only adds the symbol on Linux ports.  This syscall is
required to provided a fail-safe way to implement the closefrom
symbol (BZ #10353).

Checked on x86_64-linux-gnu and i686-linux-gnu on kernel 5.11 and 4.15.

3 years agosupport: Add support_stack_alloc
Adhemerval Zanella [Wed, 10 Mar 2021 15:26:29 +0000 (12:26 -0300)]
support: Add support_stack_alloc

The code to allocate a stack from xsigstack is refactored so it can
be more generic.  The new support_stack_alloc() also set PROT_EXEC
if DEFAULT_STACK_PERMS has PF_X.  This is required on some
 architectures (hppa for instance) and trying to access the rtld
global from testsuite will require more intrusive refactoring
in the ldsodefs.h header.

Checked on x86_64-linux-gnu and i686-linux-gnu.  I also ran
tst-xsigstack on both hppa and ia64.

3 years ago_int_realloc is static
Siddhesh Poyarekar [Wed, 7 Jul 2021 09:31:20 +0000 (15:01 +0530)]
_int_realloc is static

_int_realloc is correctly declared at the top to be static, but
incorrectly defined without the static keyword.  Fix that.  The
generated binaries have identical code.

3 years agoMove mcheck symbol from stdlib to malloc
Siddhesh Poyarekar [Wed, 7 Jul 2021 13:44:00 +0000 (19:14 +0530)]
Move mcheck symbol from stdlib to malloc

It is defined in malloc, so it belongs there.  Verified on x86_64 that
the built libraries are identical despite this change.

3 years agonss: Do not install static linker input files for libnss_files
Florian Weimer [Thu, 8 Jul 2021 12:06:53 +0000 (14:06 +0200)]
nss: Do not install static linker input files for libnss_files

3 years agoelf/tests: Make thrlock and noload depend on libm
Siddhesh Poyarekar [Thu, 8 Jul 2021 08:09:19 +0000 (13:39 +0530)]
elf/tests: Make thrlock and noload depend on libm

Both tests try to dlopen libm.so at runtime, so make them depend on it
so that they're executed if libm.so has been updated.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 years agoHarden tcache double-free check
Siddhesh Poyarekar [Wed, 7 Jul 2021 17:32:46 +0000 (23:02 +0530)]
Harden tcache double-free check

The tcache allocator layer uses the tcache pointer as a key to
identify a block that may be freed twice.  Since this is in the
application data area, an attacker exploiting a use-after-free could
potentially get access to the entire tcache structure through this
key.  A detailed write-up was provided by Awarau here:

https://awaraucom.wordpress.com/2020/07/19/house-of-io-remastered/

Replace this static pointer use for key checking with one that is
generated at malloc initialization.  The first attempt is through
getrandom with a fallback to random_bits(), which is a simple
pseudo-random number generator based on the clock.  The fallback ought
to be sufficient since the goal of the randomness is only to make the
key arbitrary enough that it is very unlikely to collide with user
data.

Co-authored-by: Eyal Itkin <eyalit@checkpoint.com>
3 years agonss: Access nss_files through direct references
Florian Weimer [Wed, 7 Jul 2021 16:33:52 +0000 (18:33 +0200)]
nss: Access nss_files through direct references

This partially fixes static-only NSS support (bug 27959): The files
module no longer needs dlopen.  Support for the dns module remains
to be added, and also support for disabling dlopen altogether.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonss_files: Move into libc
Florian Weimer [Wed, 7 Jul 2021 16:33:52 +0000 (18:33 +0200)]
nss_files: Move into libc

This is the first step towards fixing bug 27959.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonss_files: Add generic code for set*ent, end*ent and file open
Florian Weimer [Wed, 7 Jul 2021 16:33:52 +0000 (18:33 +0200)]
nss_files: Add generic code for set*ent, end*ent and file open

This reduces RSS usage if nss_files is not actually used, and can
be used later to make NSS data thread-specific.  It also results in
a small code size reduction.

Before:

   text    data     bss     dec     hex filename
   2288       0      72    2360     938 nss/files-alias.os
   1807       0      72    1879     757 nss/files-ethers.os
   1371       0      72    1443     5a3 nss/files-grp.os
   6246       0      72    6318    18ae nss/files-hosts.os
    869       0       0     869     365 nss/files-initgroups.os
    666       0       0     666     29a nss/files-init.os
   1934       0       0    1934     78e nss/files-netgrp.os
   2353       0      72    2425     979 nss/files-network.os
   2130       0      72    2202     89a nss/files-proto.os
   1372       0      72    1444     5a4 nss/files-pwd.os
   2124       0      72    2196     894 nss/files-rpc.os
   2265       0      72    2337     921 nss/files-service.os
   1125       0      72    1197     4ad nss/files-sgrp.os
   1124       0      72    1196     4ac nss/files-spwd.os

After:

   text    data     bss     dec     hex filename
   2040       0       0    2040     7f8 nss/files-alias.os
   1599       0       0    1599     63f nss/files-ethers.os
   1155       0       0    1155     483 nss/files-grp.os
   6010       0       0    6010    177a nss/files-hosts.os
    869       0       0     869     365 nss/files-initgroups.os
    666       0       0     666     29a nss/files-init.os
   1934       0       0    1934     78e nss/files-netgrp.os
   2129       0       0    2129     851 nss/files-network.os
   1914       0       0    1914     77a nss/files-proto.os
   1156       0       0    1156     484 nss/files-pwd.os
   1908       0       0    1908     774 nss/files-rpc.os
   2057       0       0    2057     809 nss/files-service.os
    909       0       0     909     38d nss/files-sgrp.os
    908       0       0     908     38c nss/files-spwd.os
   1090       0       8    1098     44a nss/nss_files_data.os

27674 code bytes before, 26344 code bytes after, so it is an overall
win despite the extra initialization code.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonss_files: Allocate nscd file registration data on the heap
Florian Weimer [Wed, 7 Jul 2021 16:33:52 +0000 (18:33 +0200)]
nss_files: Allocate nscd file registration data on the heap

This is only needed if nss_files is loaded by nscd.

Before:

   text    data     bss     dec     hex filename
    767       0   24952   25719    6477 nss/files-init.os

After:

   text    data     bss     dec     hex filename
    666       0       0     666     29a nss/files-init.os

Using PATH_MAX bytes unconditionally for the directory name
is wasteful, but fixing that would constitute another break
of this semi-public ABI.  (The other issue is that with
symbolic links, an arbitrary set of parent directories may need
watching, not just a single one.)

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agolibio: Replace internal _IO_getdelim symbol with __getdelim
Florian Weimer [Wed, 7 Jul 2021 16:33:52 +0000 (18:33 +0200)]
libio: Replace internal _IO_getdelim symbol with __getdelim

__getdelim is exported, _IO_getdelim is not.  Add a hidden prototype
for __getdelim.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agolibio: Add hidden prototype for ungetc
Florian Weimer [Wed, 7 Jul 2021 16:33:52 +0000 (18:33 +0200)]
libio: Add hidden prototype for ungetc

And make ungetc the primary symbol, with _IO_ungetc as an alias.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoinet: Add hidden prototype for __inet_network
Florian Weimer [Wed, 7 Jul 2021 16:33:52 +0000 (18:33 +0200)]
inet: Add hidden prototype for __inet_network

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoUpdate MIPS libm-test-ulps
Joseph Myers [Wed, 7 Jul 2021 15:50:18 +0000 (15:50 +0000)]
Update MIPS libm-test-ulps

3 years agoUpdate powerpc-nofpu libm-test-ulps
Joseph Myers [Wed, 7 Jul 2021 15:35:04 +0000 (15:35 +0000)]
Update powerpc-nofpu libm-test-ulps

3 years agosoft-fp: Add __extendhfsf2/__extendhfdf2, __truncsfhf2/__truncdfhf2, __eqhf2/__nehf2
liuhongt [Wed, 7 Jul 2021 02:07:59 +0000 (10:07 +0800)]
soft-fp: Add __extendhfsf2/__extendhfdf2, __truncsfhf2/__truncdfhf2, __eqhf2/__nehf2

1. Add __extendhfdf2/__extendhfsf2 to return an IEEE half converted to IEEE double/single.
2. Add __truncdfhf2/__extendsfhf2 to truncate IEEE double/single into IEEE half.
3. Add __eqhf2/__nehf2 to return 0 if a == b and a,b are not NAN, otherwise return 1.

These are needed by x86 _Float16:

https://software.intel.com/content/www/us/en/develop/download/intel-avx512-fp16-architecture-specification.html

support in GCC.

3 years agoUpdate kernel version to 5.13 in tst-mman-consts.py
Joseph Myers [Wed, 7 Jul 2021 13:24:05 +0000 (13:24 +0000)]
Update kernel version to 5.13 in tst-mman-consts.py

This patch updates the kernel version in the test tst-mman-consts.py
to 5.13.  (There are no new MAP_* constants covered by this test in
5.13 that need any other header changes.)

Tested with build-many-glibcs.py.

3 years agotests-exclude-mcheck: Fix typo
Siddhesh Poyarekar [Wed, 7 Jul 2021 07:55:49 +0000 (13:25 +0530)]
tests-exclude-mcheck: Fix typo

It's tst-realloc, not tst-posix-realloc.  Verified this time to ensure
that the total number of tests reduced by 1.

Reported-by: Stefan Liebler <stli@linux.ibm.com>
3 years agoelf: Clean up GLIBC_PRIVATE exports of internal libdl symbols
Florian Weimer [Wed, 7 Jul 2021 06:40:41 +0000 (08:40 +0200)]
elf: Clean up GLIBC_PRIVATE exports of internal libdl symbols

They are no longer needed after everything has been moved into
libc.  The _dl_vsym test has to be removed because the symbol
cannot be used outside libc anymore.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Reduce the GLIBC_PRIVATE ABI
Florian Weimer [Wed, 7 Jul 2021 06:40:41 +0000 (08:40 +0200)]
nptl: Reduce the GLIBC_PRIVATE ABI

The remaining symbols are mostly used by libthread_db.
__pthread_get_minstack has to remain exported even though unused.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Remove GLIBC_2.34 versions of __pthread_mutex_lock, __pthread_mutex_unlock
Florian Weimer [Wed, 7 Jul 2021 06:40:41 +0000 (08:40 +0200)]
nptl: Remove GLIBC_2.34 versions of __pthread_mutex_lock, __pthread_mutex_unlock

Now that there are no internal users anymore, these new symbol
versions can be removed from the public ABI.  The compatibility
symbols remain.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl: Use internal low-level lock type for !IS_IN (libc)
Florian Weimer [Wed, 7 Jul 2021 06:40:41 +0000 (08:40 +0200)]
nptl: Use internal low-level lock type for !IS_IN (libc)

This avoids an ABI hazard (types changing between different modules
of glibc) without introducing linknamespace issues. In particular,
NSS modules now call __lll_lock_wait_private@@GLIBC_PRIVATE to wait
on internal locks (the unlock path is inlined and performs a direct
system call).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoglibc.malloc.check: Fix nit in documentation
Siddhesh Poyarekar [Wed, 7 Jul 2021 01:32:13 +0000 (07:02 +0530)]
glibc.malloc.check: Fix nit in documentation

The tunable will not work with *any* non-zero tunable value since its
list of allowed values is 0-3.  Fix the documentation to reflect that.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoExclude tst-realloc from tests-mcheck
Siddhesh Poyarekar [Tue, 6 Jul 2021 18:01:58 +0000 (23:31 +0530)]
Exclude tst-realloc from tests-mcheck

The realloc (NULL, 0) test in tst-realloc fails with gcc 7.x but
passes with newer gcc.  This is because a newer gcc transforms the
realloc call to malloc (0), thus masking the bug in mcheck.

Disable the test with mcheck for now.  The malloc removal patchset
will fix this and then remove this test from the exclusion list.

Reported-by: Stefan Liebler <stli@linux.ibm.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agolinux: Fix setsockopt fallback
Adhemerval Zanella [Mon, 5 Jul 2021 12:48:48 +0000 (12:48 +0000)]
linux: Fix setsockopt fallback

The final 2 arguments for SO_TIMESTAMP/SO_TIMESTAMPNS are being set
wrongly.

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

3 years agolinux: Use the expected size for SO_TIMESTAMP{NS} convertion
Adhemerval Zanella [Sat, 3 Jul 2021 19:26:11 +0000 (16:26 -0300)]
linux: Use the expected size for SO_TIMESTAMP{NS} convertion

Kernel returns 32-bit values for COMPAT_SO_TIMESTAMP{NS}_OLD,
not 64-bit values.

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

3 years agolinux: Consolidate Linux setsockopt implementation
Adhemerval Zanella [Mon, 5 Jul 2021 13:01:24 +0000 (13:01 +0000)]
linux: Consolidate Linux setsockopt implementation

This patch consolidates the setsockopt implementation on
sysdeps/unix/sysv/linux/getsockopt.c.  The changes are:

  1. Remove it from auto-generation syscalls.list on all architectures.

  2. Add __ASSUME_SETSOCKOPT_SYSCALL as default and undef if for
     specific kernel versions on some architectures.

This also fix a potential issue where 32-bit time_t ABI should use the
linux setsockopt which overrides the underlying SO_* constants used for
socket timestamping for _TIME_BITS=64.

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

3 years agolinux: Consolidate Linux getsockopt implementation
Adhemerval Zanella [Mon, 5 Jul 2021 16:44:26 +0000 (13:44 -0300)]
linux: Consolidate Linux getsockopt implementation

This patch consolidates the getsockopt Linux syscall implementation on
sysdeps/unix/sysv/linux/getsockopt.c.  The changes are:

  1. Remove it from auto-generation syscalls.list on all architectures.

  2. Add __ASSUME_GETSOCKOPT_SYSCALL as default and undef if for
     specific kernel versions on some architectures.

This also fix a potential issue where 32-bit time_t ABI should use the
linux getsockopt which overrides the underlying SO_* constants used for
socket timestamping for _TIME_BITS=64.

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

3 years agomanual: fix description for preadv()
Armin Brauns [Tue, 6 Jul 2021 10:54:48 +0000 (12:54 +0200)]
manual: fix description for preadv()

3 years agoelf: Call free from base namespace on error in dl-libc.c [BZ #27646]
Florian Weimer [Tue, 6 Jul 2021 11:22:01 +0000 (13:22 +0200)]
elf: Call free from base namespace on error in dl-libc.c [BZ #27646]

In dlerror_run, free corresponds to the local malloc in the
namespace, but GLRO (dl_catch_error) uses the malloc from the base
namespace.  elf/tst-dlmopen-gethostbyname triggers this mismatch,
but it does not crash, presumably because of a fastbin deallocation.

Fixes commit c2059edce20c124d1a99f1a94cc52e83b77a917a ("elf: Use
_dl_catch_error from base namespace in dl-libc.c [BZ #27646]") and
commit b2964eb1d9a6b8ab1250e8a881cf406182da5875 ("dlfcn: Failures
after dlmopen should not terminate process [BZ #24772]").

3 years agolinux: Check for null value msghdr struct before use
Khem Raj [Fri, 2 Jul 2021 20:28:10 +0000 (13:28 -0700)]
linux: Check for null value msghdr struct before use

This avoids crashes in libc when cmsg is null and refrencing msg
structure when it is null

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agohooks.c: Remove incorrect comment
Siddhesh Poyarekar [Sun, 4 Jul 2021 12:45:18 +0000 (18:15 +0530)]
hooks.c: Remove incorrect comment

The comment about different values of glibc.malloc.check is no longer
valid.

3 years agomtrace: Add attribute nocommon to mallwatch
Tulio Magno Quites Machado Filho [Fri, 2 Jul 2021 21:12:13 +0000 (18:12 -0300)]
mtrace: Add attribute nocommon to mallwatch

Avoid compilation errors GCC versions that do not default to
-fno-common, e.g. GCC <= 9.

Fixes commit 00d28960c5388a582a0485e07629b553c32dde49 ("mtrace:
Deprecate mallwatch and tr_break").

Suggested-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Suggested-by: Florian Weimer <fweimer@redhat.com>
3 years agoMove glibc.malloc.check implementation into its own file
Siddhesh Poyarekar [Fri, 2 Jul 2021 19:18:12 +0000 (00:48 +0530)]
Move glibc.malloc.check implementation into its own file

Separate the malloc check implementation from the malloc hooks.  They
still use the hooks but are now maintained in a separate file.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agomtrace: Deprecate mallwatch and tr_break
Siddhesh Poyarekar [Fri, 2 Jul 2021 19:17:34 +0000 (00:47 +0530)]
mtrace: Deprecate mallwatch and tr_break

The variable and function pair appear to provide a way for users to
set conditional breakpoints in mtrace when a specific address is
returned by the allocator.  This can be achieved by using conditional
breakpoints in gdb so it is redundant.  There is no documentation of
this interface in the manual either, so it appears to have been a hack
that got added to debug malloc.  Deprecate these symbols and do not
call tr_break anymore.

Reviewed-by: DJ Delorie <dj@redhat.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoDrop source dependencies on hooks.c and arena.c
Siddhesh Poyarekar [Fri, 2 Jul 2021 19:16:46 +0000 (00:46 +0530)]
Drop source dependencies on hooks.c and arena.c

Dependencies on hooks.c and arena.c get auto-computed when generating
malloc.o{,s}.d so there is no need to add them manually.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Andreas Schwab <schwab@linux-m68k.org>
3 years agomalloc: Initiate tcache shutdown even without allocations [BZ #28028]
JeffyChen [Fri, 2 Jul 2021 15:39:24 +0000 (17:39 +0200)]
malloc: Initiate tcache shutdown even without allocations [BZ #28028]

After commit 1e26d35193efbb29239c710a4c46a64708643320 ("malloc: Fix
tcache leak after thread destruction [BZ #22111]"),
tcache_shutting_down is still not early enough.  When we detach a
thread with no tcache allocated, tcache_shutting_down would still be
false.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoAdd mcheck tests to malloc
Siddhesh Poyarekar [Fri, 2 Jul 2021 02:25:10 +0000 (07:55 +0530)]
Add mcheck tests to malloc

Like malloc-check, add generic rules to run all tests in malloc by
linking with libmcheck.a so as to provide coverage for mcheck().
Currently the following 12 tests fail:

FAIL: malloc/tst-malloc-backtrace-mcheck
FAIL: malloc/tst-malloc-fork-deadlock-mcheck
FAIL: malloc/tst-malloc-stats-cancellation-mcheck
FAIL: malloc/tst-malloc-tcache-leak-mcheck
FAIL: malloc/tst-malloc-thread-exit-mcheck
FAIL: malloc/tst-malloc-thread-fail-mcheck
FAIL: malloc/tst-malloc-usable-static-mcheck
FAIL: malloc/tst-malloc-usable-static-tunables-mcheck
FAIL: malloc/tst-malloc-usable-tunables-mcheck
FAIL: malloc/tst-malloc_info-mcheck
FAIL: malloc/tst-memalign-mcheck
FAIL: malloc/tst-posix_memalign-mcheck

and they have been added to tests-exclude-mcheck for now to keep
status quo.  At least the last two can be attributed to bugs in
mcheck() but I haven't fixed them here since they should be fixed by
removing malloc hooks.  Others need to be triaged to check if they're
due to mcheck bugs or due to actual bugs.

Reviewed-by: DJ Delorie <dj@redhat.com>
3 years agoiconvconfig: Use the public feof_unlocked
Siddhesh Poyarekar [Fri, 2 Jul 2021 11:23:25 +0000 (16:53 +0530)]
iconvconfig: Use the public feof_unlocked

Build of iconvconfig failed with CFLAGS=-Os since __feof_unlocked is
not a public symbol.  Replace with feof_unlocked (defined to
__feof_unlocked when IS_IN (libc)) to fix this.

Reported-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
3 years agoresolv: Move libanl into libc (if libpthread is in libc)
Florian Weimer [Fri, 2 Jul 2021 09:45:00 +0000 (11:45 +0200)]
resolv: Move libanl into libc (if libpthread is in libc)

The symbols gai_cancel, gai_error, gai_suspend, getaddrinfo_a,
__gai_suspend_time64 were moved using scripts/move-symbol-to-libc.py.

For Hurd (which remains !PTHREAD_IN_LIBC), a few #define redirects
had to be added because several pthread functions are not available
under __.  (Linux uses __ prefixes for most hidden aliases, and has
to in some cases to avoid linknamespace issues.)

3 years agopowerpc: optimize strcpy/stpcpy for POWER9/10
Pedro Franco de Carvalho [Wed, 30 Jun 2021 15:36:07 +0000 (12:36 -0300)]
powerpc: optimize strcpy/stpcpy for POWER9/10

This patch modifies the current POWER9 implementation of strcpy and
stpcpy to optimize it for POWER9/10.

Since no new POWER10 instructions are used, the original POWER9 strcpy is
modified instead of creating a new implementation for POWER10.  This
implementation is based on both the original POWER9 implementation of
strcpy and the preamble of the new POWER10 implementation of strlen.

The changes also affect stpcpy, which uses the same implementation with
some additional code before returning.

On POWER9, averaging improvements across the benchmark
inputs (length/source alignment/destination alignment), for an
experiment that ran the benchmark five times, bench-strcpy showed an
improvement of 5.23%, and bench-stpcpy showed an improvement of 6.59%.

On POWER10, bench-strcpy showed 13.16%, and bench-stpcpy showed 13.59%.

The changes are:

1. Removed the null string optimization.

   Although this results in a few extra cycles for the null string, in
   combination with the second change, this resulted in improvements for
   for other cases.

2. Adapted the preamble from strlen for POWER10.

   This is the part of the function that handles up to the first 16 bytes
   of the string.

3. Increased number of unrolled iterations in the main loop to 6.

Reviewed-by: Matheus Castanho <msc@linux.ibm.com>
Tested-by: Matheus Castanho <msc@linux.ibm.com>
3 years agosoft-fp: Add __extendhfxf2 and __truncxfhf2
H.J. Lu [Thu, 1 Jul 2021 15:35:28 +0000 (08:35 -0700)]
soft-fp: Add __extendhfxf2 and __truncxfhf2

1. Add __extendhfxf2 to return an IEEE half converted to IEEE extended.
2. Add __truncxfhf2 to truncate IEEE extended into IEEE half.

These are needed by x86 _Float16:

https://software.intel.com/content/www/us/en/develop/download/intel-avx512-fp16-architecture-specification.html

support in GCC.

3 years agox86: Check RTM_ALWAYS_ABORT for RTM [BZ #28033]
H.J. Lu [Wed, 30 Jun 2021 17:47:06 +0000 (10:47 -0700)]
x86: Check RTM_ALWAYS_ABORT for RTM [BZ #28033]

From

https://www.intel.com/content/www/us/en/support/articles/000059422/processors.html

* Intel TSX will be disabled by default.
* The processor will force abort all Restricted Transactional Memory (RTM)
  transactions by default.
* A new CPUID bit CPUID.07H.0H.EDX[11](RTM_ALWAYS_ABORT) will be enumerated,
  which is set to indicate to updated software that the loaded microcode is
  forcing RTM abort.
* On processors that enumerate support for RTM, the CPUID enumeration bits
  for Intel TSX (CPUID.07H.0H.EBX[11] and CPUID.07H.0H.EBX[4]) continue to
  be set by default after microcode update.
* Workloads that were benefited from Intel TSX might experience a change
  in performance.
* System software may use a new bit in Model-Specific Register (MSR) 0x10F
  TSX_FORCE_ABORT[TSX_CPUID_CLEAR] functionality to clear the Hardware Lock
  Elision (HLE) and RTM bits to indicate to software that Intel TSX is
  disabled.

1. Add RTM_ALWAYS_ABORT to CPUID features.
2. Set RTM usable only if RTM_ALWAYS_ABORT isn't set.  This skips the
string/tst-memchr-rtm etc. testcases on the affected processors, which
always fail after a microcde update.
3. Check RTM feature, instead of usability, against /proc/cpuinfo.

This fixes BZ #28033.

3 years agoUpdate syscall lists for Linux 5.13
Joseph Myers [Thu, 1 Jul 2021 17:37:36 +0000 (17:37 +0000)]
Update syscall lists for Linux 5.13

Linux 5.13 has three new syscalls (landlock_create_ruleset,
landlock_add_rule, landlock_restrict_self).  Update syscall-names.list
and regenerate the arch-syscall.h headers with build-many-glibcs.py
update-syscalls.

Tested with build-many-glibcs.py.

3 years agos390: Fix MEMCHR_Z900_G5 ifunc-variant if n>=0x80000000 [BZ #28024]
Stefan Liebler [Tue, 29 Jun 2021 09:37:28 +0000 (11:37 +0200)]
s390: Fix MEMCHR_Z900_G5 ifunc-variant if n>=0x80000000 [BZ #28024]

On s390 (31bit), the pointer to the first byte after s always wraps
around with n >= 0x80000000 and can lead to stop searching before
end of s.

Thus this patch just use NULL as byte after s in this case and
the srst instruction stops searching with "not found" when wrapping
around from top address to zero.

This is observable with testcase string/test-memchr
starting with commit "String: Add overflow tests for strnlen, memchr,
and strncat [BZ #27974]"
https://sourceware.org/git/?p=glibc.git;a=commit;h=da5a6fba0febbfc90896ce1b2eb75c6d8a88a72d

3 years agoFix extra PLT reference in libc.so due to __glob64_time64 if build with gcc 7.5 on...
Stefan Liebler [Wed, 30 Jun 2021 14:17:37 +0000 (16:17 +0200)]
Fix extra PLT reference in libc.so due to __glob64_time64 if build with gcc 7.5 on 32bit.

Starting with recent commit 84f7ce84474c1648ce96884f1c91ca7b97ca3fc2
"posix: Add glob64 with 64-bit time_t support", elf/check-localplt
fails due to extra PLT reference __glob64_time64 in __glob64_time64
itself.

This is observable with gcc 7.5 on x86_64 with -m32 or s390x with
-m31.  E.g. if build with gcc 10, gcc is generating a call to
__glob64_time64.localalias.

This patch is adding a hidden version of __glob64_time64 in the
same way as for __globfree64_time64.

3 years agoAArch64: Add hp-timing.h
Wilco Dijkstra [Thu, 1 Jul 2021 14:42:05 +0000 (15:42 +0100)]
AArch64: Add hp-timing.h

Add hp-timing.h using the cntvct_el0 counter. Return timing in nanoseconds
so it is fully compatible with generic hp-timing. Don't set HP_TIMING_INLINE
in the dynamic linker since it adds unnecessary overheads and some ancient
kernels may not handle emulating cntcvt correctly. Currently cntvct_el0 is
only used for timing in the benchtests.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
3 years agoAArch64: Improve strnlen performance
Wilco Dijkstra [Thu, 1 Jul 2021 14:30:42 +0000 (15:30 +0100)]
AArch64: Improve strnlen performance

Optimize strnlen by avoiding UMINV which is slow on most cores. On Neoverse N1
large strings are 1.8x faster than the current version, and bench-strnlen is
50% faster overall. This version is MTE compatible.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
3 years agoLinux: Avoid calling malloc indirectly from __get_nprocs
Florian Weimer [Wed, 30 Jun 2021 15:41:38 +0000 (17:41 +0200)]
Linux: Avoid calling malloc indirectly from __get_nprocs

malloc initialization depends on __get_nprocs, so using
scratch buffers in __get_nprocs may result in infinite recursion.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agoUse Linux 5.13 in build-many-glibcs.py
Joseph Myers [Wed, 30 Jun 2021 13:29:08 +0000 (13:29 +0000)]
Use Linux 5.13 in build-many-glibcs.py

This patch makes build-many-glibcs.py use Linux 5.13.

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).

3 years agologin: Move libutil into libc
Florian Weimer [Wed, 30 Jun 2021 05:21:14 +0000 (07:21 +0200)]
login: Move libutil into libc

The symbols forkpty, login, login_tty, logout, logwtmp, openpty
were moved using scripts/move-symbol-to-libc.py.

This is a single commit because most of the symbols are tied together
via forkpty, for example.

Several changes to use hidden prototypes are needed.  This commit
also updates pseudoterminal terminology on modified lines.

For 390 (31-bit), this commit follows the existing style for the
compat symbol version creation.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agologin: Rework hidden prototypes for __setutent, __utmpname, __endutent
Florian Weimer [Wed, 30 Jun 2021 05:21:13 +0000 (07:21 +0200)]
login: Rework hidden prototypes for __setutent, __utmpname, __endutent

Replace attribute_hidden with a regular combination of
libc_hidden_proto and libc_hidden_def.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agologin: Hidden prototypes for _getpt, __ptsname_r, grantpt, unlockpt
Florian Weimer [Wed, 30 Jun 2021 05:21:13 +0000 (07:21 +0200)]
login: Hidden prototypes for _getpt, __ptsname_r, grantpt, unlockpt

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonptl_db: Re-use the ELF-to-abilist converter for ABI checking
Florian Weimer [Tue, 29 Jun 2021 20:17:05 +0000 (22:17 +0200)]
nptl_db: Re-use the ELF-to-abilist converter for ABI checking

The previous approach uses readelf -DWs, which does not produce
a stable output format (older binutils versions do not include
symbol version information).  This commit re-uses scripts/abilist.awk
with a tweak to include GLIBC_PRIVATE symbols.  This awk script
is based on objdump -T output, which appears to be stable over time.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
3 years agoAdd RFC 8335 Definitions from Linux 5.13
Andreas Roeseler [Thu, 3 Jun 2021 14:26:04 +0000 (09:26 -0500)]
Add RFC 8335 Definitions from Linux 5.13

RFC 8335 defines the network utility PROBE, which builds off of the
capabilities of Ping to query more detailed interface information from
networking nodes.

The definitions included in this patchset have been accepted into the
linux net-next branch and will be included in Linux 5.13. This
patchset adds the same definitions to the glibc for use in the
iputils package.

The relevant commits for the Linux definitions can be found here:
https://github.com/torvalds/linux/commit/e542d29ca81d005651680a0a697b72ca13ddc4cc
https://github.com/torvalds/linux/commit/750f4fc2a12f6632b5aa04526bf57fa06bfe8467

These changes have been tested by running the glibc tests on x86_64

Signed-off-by: Andreas Roeseler <andreas.a.roeseler@gmail.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agonss: Fix NSS_DECLARE_MODULE_FUNCTIONS handling of _nss_*_endnetgrent
Florian Weimer [Tue, 29 Jun 2021 10:06:40 +0000 (12:06 +0200)]
nss: Fix NSS_DECLARE_MODULE_FUNCTIONS handling of _nss_*_endnetgrent

The old version had an additional underscore, making the declaration
ineffective.

3 years agos390x: Update math: redirect roundeven function
Stefan Liebler [Mon, 28 Jun 2021 11:01:07 +0000 (13:01 +0200)]
s390x: Update math: redirect roundeven function

After recent commit
447954a206837b5f153869cfeeeab44631c3fac9
"math: redirect roundeven function", building on
s390x fails with:
Error: symbol `__roundevenl' is already defined

Similar to aarch64/riscv fix, this patch redirects target
specific functions for s390x:
commit 3213ed770cbc5821920d16caa93c85e92dd7b9f6
"Update math: redirect roundeven function"

3 years agoposix: Add _Fork [BZ #4737]
Adhemerval Zanella [Tue, 19 Jan 2021 12:26:31 +0000 (09:26 -0300)]
posix: Add _Fork [BZ #4737]

Austin Group issue 62 [1] dropped the async-signal-safe requirement
for fork and provided a async-signal-safe _Fork replacement that
does not run the atfork handlers.  It will be included in the next
POSIX standard.

It allow to close a long standing issue to make fork AS-safe (BZ#4737).
As indicated on the bug, besides the internal lock for the atfork
handlers itself; there is no guarantee that the handlers itself will
not introduce more AS-safe issues.

The idea is synchronize fork with the required internal locks to allow
children in multithread processes to use mostly of standard function
(even though POSIX states only AS-safe function should be used).  On
signal handles, _Fork should be used intead and only AS-safe functions
should be used.

For testing, the new tst-_Fork only check basic usage.  I also added
a new tst-mallocfork3 which uses the same strategy to check for
deadlock of tst-mallocfork2 but using threads instead of subprocesses
(and it does deadlock if it replaces _Fork with fork).

[1] https://austingroupbugs.net/view.php?id=62

3 years agonptl: Add glibc.pthread.stack_cache_size tunable
Florian Weimer [Mon, 28 Jun 2021 13:48:58 +0000 (15:48 +0200)]
nptl: Add glibc.pthread.stack_cache_size tunable

The valgrind/helgrind test suite needs a way to make stack dealloction
more prompt, and this feature seems to be generally useful.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
3 years agonptl: Export libthread_db-used symbols under GLIBC_PRIVATE
Florian Weimer [Mon, 28 Jun 2021 12:33:53 +0000 (14:33 +0200)]
nptl: Export libthread_db-used symbols under GLIBC_PRIVATE

This allows distributions to strip debugging information from
libc.so.6 without impacting the debugging experience.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agonptl: Rename nptl_version to __nptl_version
Florian Weimer [Mon, 28 Jun 2021 12:33:53 +0000 (14:33 +0200)]
nptl: Rename nptl_version to __nptl_version

This prepares it for exporting as a dynamic symbol.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agonptl_db: Clean up main/rtld variable handling
Florian Weimer [Mon, 28 Jun 2021 12:33:53 +0000 (14:33 +0200)]
nptl_db: Clean up main/rtld variable handling

Most symbols are now in libc.so.6.  The "main" (exempted from
coverage checks) status is therefore not necessary.  Use
DB_MAIN_VARIABLE for the remaining separate symbol,
__nptl_initial_report_events.  DB_RTLD_VARIABLE is now unused, so
remove it.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoarm: align stack in clone [BZ 28020]
Szabolcs Nagy [Fri, 25 Jun 2021 18:58:59 +0000 (19:58 +0100)]
arm: align stack in clone [BZ 28020]

The arm PCS requires 8 byte aligned stack at function entry.
Previously unaligned stack could crash the clone child.

Fixes bug 28020.

3 years agoLinux: Cleanups after librt move
Florian Weimer [Mon, 28 Jun 2021 07:51:01 +0000 (09:51 +0200)]
Linux: Cleanups after librt move

librt.so is no longer installed for PTHREAD_IN_LIBC, and tests
are not linked against it.  $(librt) is introduced globally for
shared tests that need to be linked for both PTHREAD_IN_LIBC
and !PTHREAD_IN_LIBC.

GLIBC_PRIVATE symbols that were needed during the transition are
removed again.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoLinux: Move timer_settime, __timer_settime64 from librt to libc
Florian Weimer [Mon, 28 Jun 2021 07:51:01 +0000 (09:51 +0200)]
Linux: Move timer_settime, __timer_settime64 from librt to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

The way the ABI intransition is implemented is changed with this
commit: the implementation is now consolidated in one file with a
TIMER_T_WAS_INT_COMPAT check.

The shared librt is now empty, so this commit adds a placeholder
symbol at the base version, GLIBC_2.2, and potentially at the
GLIBC_2.3.3 version as well (the leftover from the int/timer_t ABI
transition).

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move timer_gettime, __timer_gettime64 from librt to libc
Florian Weimer [Mon, 28 Jun 2021 07:51:01 +0000 (09:51 +0200)]
Linux: Move timer_gettime, __timer_gettime64 from librt to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

The way the ABI intransition is implemented is changed with this
commit: the implementation is now consolidated in one file with a
TIMER_T_WAS_INT_COMPAT check.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move timer_getoverrun from librt to libc
Florian Weimer [Mon, 28 Jun 2021 07:51:00 +0000 (09:51 +0200)]
Linux: Move timer_getoverrun from librt to libc

The symbol was moved using scripts/move-symbol-to-libc.py.

The way the ABI intransition is implemented is changed with this
commit: the implementation is now consolidated in one file with a
TIMER_T_WAS_INT_COMPAT check.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move timer_create, timer_delete from librt to libc
Florian Weimer [Mon, 28 Jun 2021 07:51:00 +0000 (09:51 +0200)]
Linux: Move timer_create, timer_delete from librt to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

timer_create and timer_delete are tied together via the int/timer_t
compatibility code.  The way the ABI intransition is implemented
is changed with this commit: the implementation is now consolidated
in one file with a TIMER_T_WAS_INT_COMPAT check.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Define TIMER_T_WAS_INT_COMPAT in kernel-posix-timers.h
Florian Weimer [Mon, 28 Jun 2021 07:51:00 +0000 (09:51 +0200)]
Linux: Define TIMER_T_WAS_INT_COMPAT in kernel-posix-timers.h

This is almost equivalent to __WORDSIZE == 64
&& OTHER_SHLIB_COMPAT (librt, GLIBC_2_1, GLIBC_2_3_3), except
that this expression is true for mips64/n64 targets as well,
even though those did not undergo the timer_t transition.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
3 years agoInstall shared objects under their ABI names
Florian Weimer [Mon, 28 Jun 2021 06:33:57 +0000 (08:33 +0200)]
Install shared objects under their ABI names

Previously, the installed objects were named like libc-2.33.so,
and the ABI soname libc.so.6 was just a symbolic link.

The Makefile targets to install these symbolic links are no longer
needed after this, so they are removed with this commit.  The more
general $(make-link) command (which invokes scripts/rellns-sh) is
retained because other symbolic links are still needed.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@rehdat.com>
3 years agoelf: Generalize name-based DSO recognition in ldconfig
Florian Weimer [Mon, 28 Jun 2021 06:33:57 +0000 (08:33 +0200)]
elf: Generalize name-based DSO recognition in ldconfig

This introduces <dl-is_dso.h> and the _dl_is_dso function.  A
test ensures that the official names of libc.so, ld.so, and their
versioned names are recognized.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoMakerules: Remove lib-version, $(subdir-version)
Florian Weimer [Mon, 28 Jun 2021 06:33:57 +0000 (08:33 +0200)]
Makerules: Remove lib-version, $(subdir-version)

Also clarify that the "versioned" term refers to the soname, not the glibc
version (which also ends up in the installed file name).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agonptl_db: Install libthread_db under a regular implementation name
Florian Weimer [Mon, 28 Jun 2021 06:33:57 +0000 (08:33 +0200)]
nptl_db: Install libthread_db under a regular implementation name

Currently, the name is always libthread_db-1.0.so.  It does not change
with the glibc version, like the other libraries.

GDB hard-codes libthread_db.so.1 (the soname), so this change does not
affect loading libthread_db.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
3 years agoiconvconfig: Fix multiple issues
Siddhesh Poyarekar [Mon, 28 Jun 2021 03:45:55 +0000 (09:15 +0530)]
iconvconfig: Fix multiple issues

It was noticed on big-endian systems that msgfmt would fail with the
following error:

msgfmt: gconv_builtin.c:70: __gconv_get_builtin_trans: Assertion `cnt < sizeof (map) / sizeof (map[0])' failed.
Aborted (core dumped)

This is only seen on installed systems because it was due to a
corrupted gconv-modules.cache.  iconvconfig had the following issues
(it was specifically freeing fulldir that caused this issue, but other
cleanups are also needed) that this patch fixes.

- Add prefix only if dir starts with '/'
- Use asprintf instead of mempcpy so that the directory string is NULL
  terminated
- Make a copy of the directory reference in new_module so that fulldir
  can be freed within the same scope in handle_dir.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
3 years agowordexp: handle overflow in positional parameter number (bug 28011)
Andreas Schwab [Fri, 25 Jun 2021 13:02:47 +0000 (15:02 +0200)]
wordexp: handle overflow in positional parameter number (bug 28011)

Use strtoul instead of atoi so that overflow can be detected.

3 years agoUpdate math: redirect roundeven function
H.J. Lu [Wed, 23 Jun 2021 20:29:41 +0000 (13:29 -0700)]
Update math: redirect roundeven function

Redirect target specific roundeven functions for aarch64, ldbl-128ibm
and riscv.

3 years agoUse GCC builtins for roundeven functions if desired.
Shen-Ta Hsieh [Mon, 24 May 2021 01:43:12 +0000 (09:43 +0800)]
Use GCC builtins for roundeven functions if desired.

This patch is using the corresponding GCC builtin for roundevenf,
roundeven and roundevenl if the USE_FUNCTION_BUILTIN macros are defined
to one in math-use-builtins.h.

These builtin functions is supported since GCC 10.

The code of the generic implementation is not changed.

Signed-off-by: Shen-Ta Hsieh <ibmibmibm.tw@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agox86_64: roundeven with sse4.1 support
Shen-Ta Hsieh [Mon, 24 May 2021 01:43:11 +0000 (09:43 +0800)]
x86_64: roundeven with sse4.1 support

This patch adds support for the sse4.1 hardware floating point
roundeven.

Here is some benchmark results on my systems:

=AMD Ryzen 9 3900X 12-Core Processor=

* benchmark result before this commit
|            |    roundeven |   roundevenf |
|------------|--------------|--------------|
| duration   |  3.75587e+09 |  3.75114e+09 |
| iterations |  3.93053e+08 |  4.35402e+08 |
| max        | 52.592       | 58.71        |
| min        |  7.98        |  7.22        |
| mean       |  9.55563     |  8.61535     |

* benchmark result after this commit
|            |     roundeven |   roundevenf |
|------------|---------------|--------------|
| duration   |   3.73815e+09 |  3.73738e+09 |
| iterations |   5.82692e+08 |  5.91498e+08 |
| max        |  56.468       | 51.642       |
| min        |   6.27        |  6.156       |
| mean       |   6.41532     |  6.3185      |

=Intel(R) Pentium(R) CPU D1508 @ 2.20GHz=

* benchmark result before this commit
|            |    roundeven |   roundevenf |
|------------|--------------|--------------|
| duration   |  2.18208e+09 |  2.18258e+09 |
| iterations |  2.39932e+08 |  2.46924e+08 |
| max        | 96.378       | 98.035       |
| min        |  6.776       |  5.94        |
| mean       |  9.09456     |  8.83907     |

* benchmark result after this commit
|            |    roundeven |   roundevenf |
|------------|--------------|--------------|
| duration   |  2.17415e+09 |  2.17005e+09 |
| iterations |  3.56193e+08 |  4.09824e+08 |
| max        | 51.693       | 97.192       |
| min        |  5.926       |  5.093       |
| mean       |  6.10385     |  5.29507     |

Signed-off-by: Shen-Ta Hsieh <ibmibmibm.tw@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agomath: redirect roundeven function
Shen-Ta Hsieh [Mon, 24 May 2021 01:43:10 +0000 (09:43 +0800)]
math: redirect roundeven function

This patch redirect roundeven function for futhermore changes.

Signed-off-by: Shen-Ta Hsieh <ibmibmibm.tw@gmail.com>
Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
3 years agoLinux: Move timer helper routines from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:51:31 +0000 (10:51 +0200)]
Linux: Move timer helper routines from librt to libc

This adds several temporary GLIBC_PRIVATE exports.  The symbol names
are changed so that they all start with __timer_.

It is now possible to invoke the fork handler directly, so
pthread_atfork is no longer necessary.  The associated error cannot
happen anymore, and cancellation handling can be removed from
the helper thread routine.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_unlink from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:42:54 +0000 (10:42 +0200)]
Linux: Move mq_unlink from librt to libc

The symbol was moved using scripts/move-symbol-to-libc.py.
A placeholder symbol is needed on some architectures for the
GLIBC_2.3.4 version.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_send, mq_timedsend, __mq_timedsend_time64 to libc
Florian Weimer [Fri, 25 Jun 2021 08:42:54 +0000 (10:42 +0200)]
Linux: Move mq_send, mq_timedsend, __mq_timedsend_time64 to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_receive, mq_timedreceive, __mq_timedreceive_time64 to libc
Florian Weimer [Fri, 25 Jun 2021 08:42:54 +0000 (10:42 +0200)]
Linux: Move mq_receive, mq_timedreceive, __mq_timedreceive_time64 to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_open, __mq_open_2 from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:42:54 +0000 (10:42 +0200)]
Linux: Move mq_open, __mq_open_2 from librt to libc

The symbols were moved using scripts/move-symbol-to-libc.py.
A placeholder symbol is required to keep the GLIBC_2.7 version.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_notify from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:42:52 +0000 (10:42 +0200)]
Linux: Move mq_notify from librt to libc

The symbol was moved using scripts/move-symbol-to-libc.py.

An explicit call from fork into the mq_notify implementation replaces
the previous use of pthread_atfork.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_getattr from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move mq_getattr from librt to libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_setattr from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move mq_setattr from librt to libc

The symbol was moved using scripts/move-symbol-to-libc.py.

To introduce the proper symbol versioning, the implementation of
the system call wrapper us moved to a C file.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move mq_close from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move mq_close from librt to libc

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move lio_listio, lio_listio64 from librt to libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move lio_listio, lio_listio64 from librt to libc

The symbols were moved using scripts/move-symbol-to-libc.py.
Placeholder symbols are needed on some architectures, to keep the
GLIBC_2.1 and GLIBC_2.4 symbol versions around.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agort: Rework lio_listio implementation
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
rt: Rework lio_listio implementation

Move the common code into rt/lio_listio-common.c and include
the file in both rt/lio_listio.c and rt/lio_listio64.c.  The common
code automatically defines both public symbols for __WORDSIZE == 64.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_write, aio_write64 into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_write, aio_write64 into libc

Both symbols have to be moved at the same time because they
are intertwined for __WORDSIZE == 64.  The treatment of this case
is also changed to match more closely how the other files suppress
the declaration of the *64 identifier.

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_suspend, aio_suspend64, __aio_suspend_time64 to libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_suspend, aio_suspend64, __aio_suspend_time64 to libc

The symbols were moved using scripts/move-symbol-to-libc.py.

There is a minor oddity here: This is generic code shared with Hurd,
and Hurd does not have time64 support.  This is why the
versioned_symbol export for __aio_suspend_time64 is restricted to
the PTHREAD_IN_LIBC code.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_return, aio_return64 into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_return, aio_return64 into libc

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_read, aio_read64 into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_read, aio_read64 into libc

Both symbols have to be moved at the same time because they
are intertwined for __WORDSIZE == 64.  The treatment of this case
is also changed to match more closely how the other files suppress
the declaration of the *64 identifier.

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_fsync, aio_fsync64 into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_fsync, aio_fsync64 into libc

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_error, aio_error64 into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_error, aio_error64 into libc

The symbols were moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
3 years agoLinux: Move aio_cancel, aio_cancel64 into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:36 +0000 (10:30 +0200)]
Linux: Move aio_cancel, aio_cancel64 into libc

The symbols were moved using scripts/move-symbol-to-libc.py.

A version placeholder symbol is needed on alpha and sparc because
of the additional symbols formerly at version GLIBC_2.3.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>:
3 years agoLinux: Move aio_init from librt into libc
Florian Weimer [Fri, 25 Jun 2021 08:30:35 +0000 (10:30 +0200)]
Linux: Move aio_init from librt into libc

This commit also moves the aio_misc and aio_sigquue helper,
so GLIBC_PRIVATE exports need to be added.

The symbol was moved using scripts/move-symbol-to-libc.py.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>