Commit Graph

23546 Commits

Author SHA1 Message Date
Florian Weimer
cfa611447b libio: freopen of default streams crashes in old programs [BZ #24632]
As seen with very old i386 GCC binaries.
2019-06-12 14:48:33 +02:00
Florian Weimer
744e829637 Linux: Deprecate <sys/sysctl.h> and sysctl
Now that there are no internal users of __sysctl left, it is possible
to add an unconditional deprecation warning to <sys/sysctl.h>.

To avoid a test failure due this warning in check-install-headers,
skip the test for sys/sysctl.h.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2019-06-12 14:32:08 +02:00
Florian Weimer
5dad6ffbb2 <sys/stat.h>: Use Linux UAPI header for statx if available and useful
This will automatically import new STATX_* constants.  It also avoids
a conflict between <sys/stat.h> and <linux/stat.h>.
2019-06-12 13:04:43 +02:00
Florian Weimer
4e75c2a43b <sys/cdefs.h>: Add __glibc_has_include macro 2019-06-12 13:04:43 +02:00
Wilco Dijkstra
680942b016 Improve performance of memmem
This patch significantly improves performance of memmem using a novel
modified Horspool algorithm.  Needles up to size 256 use a bad-character
table indexed by hashed pairs of characters to quickly skip past mismatches.
Long needles use a self-adapting filtering step to avoid comparing the whole
needle repeatedly.

By limiting the needle length to 256, the shift table only requires 8 bits
per entry, lowering preprocessing overhead and minimizing cache effects.
This limit also implies worst-case performance is linear.

Small needles up to size 2 use a dedicated linear search.  Very long needles
use the Two-Way algorithm (to avoid increasing stack size or slowing down
the common case, inlining is disabled).

The performance gain is 6.6 times on English text on AArch64 using random
needles with average size 8.

Tested against GLIBC testsuite and randomized tests.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>

	* string/memmem.c (__memmem): Rewrite to improve performance.
2019-06-12 11:42:34 +01:00
Wilco Dijkstra
5e0a7ecb66 Improve performance of strstr
This patch significantly improves performance of strstr using a novel
modified Horspool algorithm.  Needles up to size 256 use a bad-character
table indexed by hashed pairs of characters to quickly skip past mismatches.
Long needles use a self-adapting filtering step to avoid comparing the whole
needle repeatedly.

By limiting the needle length to 256, the shift table only requires 8 bits
per entry, lowering preprocessing overhead and minimizing cache effects.
This limit also implies worst-case performance is linear.

Small needles up to size 3 use a dedicated linear search.  Very long needles
use the Two-Way algorithm.

The performance gain using the improved bench-strstr on Cortex-A72 is 5.8
times basic_strstr and 3.7 times twoway_strstr.

Tested against GLIBC testsuite, randomized tests and the GNULIB strstr test
(https://git.savannah.gnu.org/cgit/gnulib.git/tree/tests/test-strstr.c).

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>

	* string/str-two-way.h (two_way_short_needle): Add inline to avoid
	warning.
	(two_way_long_needle): Block inlining.
	* string/strstr.c (strstr2): Add new function.
	(strstr3): Likewise.
	(STRSTR): Completely rewrite strstr to improve performance.
2019-06-12 11:38:52 +01:00
Wilco Dijkstra
80b2bfb535 Benchmark strstr hard needles
Benchmark needles which exhibit worst-case performance.  This shows that
basic_strstr is quadratic and thus unsuitable for large needles.
On the other hand the Two-way and new strstr implementations are linear with
increasing needle sizes.  The slowest cases of the two implementations are
within a factor of 2 on several different microarchitectures.  Two-way is
slowest on inputs which cause a branch mispredict on almost every character.
The new strstr is slowest on inputs which almost match and result in many
calls to memcmp.  Thanks to Szabolcs for providing various hard needles.

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

	* benchtests/bench-strstr.c (test_hard_needle): New function.
2019-06-11 15:52:21 +01:00
Joseph Myers
e6e2424390 Fix malloc tests build with GCC 10.
GCC mainline has recently added warn_unused_result attributes to some
malloc-like built-in functions, where glibc previously had them in its
headers only for __USE_FORTIFY_LEVEL > 0.  This results in those
attributes being newly in effect for building the glibc testsuite, so
resulting in new warnings that break the build where tests
deliberately call such functions and ignore the result.  Thus patch
duly adds calls to DIAG_* macros around those calls to disable the
warning.

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

	* malloc/tst-calloc.c: Include <libc-diag.h>.
	(null_test): Ignore -Wunused-result around calls to calloc.
	* malloc/tst-mallocfork.c: Include <libc-diag.h>.
	(do_test): Ignore -Wunused-result around call to malloc.
2019-06-10 22:12:08 +00:00
Florian Weimer
51ea67d548 Linux: Add getdents64 system call
No 32-bit system call wrapper is added because the interface
is problematic because it cannot deal with 64-bit inode numbers
and 64-bit directory hashes.

A future commit will deprecate the undocumented getdirentries
and getdirentries64 functions.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2019-06-07 09:27:01 +02:00
Paul A. Clarke
de751ebc9e [powerpc] get_rounding_mode: utilize faster method to get rounding mode
Add support to use 'mffsl' instruction if compiled for POWER9 (or later).

Also, mask the result to avoid bleeding unrelated bits into the result of
_FPU_GET_RC().

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2019-06-06 14:11:56 -05:00
Florian Weimer
28dd393922 riscv: Do not use __has_include__
The user-visible preprocessor construct is called __has_include.
2019-06-06 11:24:32 +02:00
Paul A. Clarke
0158473d8f [powerpc] fegetexcept: utilize function instead of duplicating code
fegetexcept() included code which exactly duplicates the code in
fenv_reg_to_exceptions().  Replace with a call to that function.

2019-06-05  Paul A. Clarke  <pc@us.ibm.com>

	* sysdeps/powerpc/fpu/fegetexcept.c (__fegetexcept): Replace code
	with call to equivalent function.
2019-06-05 19:38:10 -05:00
Florian Weimer
e863dbf6b2 iconv: Use __twalk_r in __gconv_release_shlib 2019-06-04 14:13:44 +02:00
Andreas Schwab
4802be92c8 Fix iconv buffer handling with IGNORE error handler (bug #18830) 2019-06-04 14:03:04 +02:00
Joseph Myers
dc91a19e6f Add INADDR_ALLSNOOPERS_GROUP from Linux 5.1 to netinet/in.h.
This patch adds INADDR_ALLSNOOPERS_GROUP from Linux 5.1 to
netinet/in.h.

Tested for x86_64.

	* inet/netinet/in.h (INADDR_ALLSNOOPERS_GROUP): New macro.
2019-06-03 11:16:02 +00:00
Florian Weimer
6a1a9a495a Fix data of ChangeLog entry 2019-06-01 14:41:37 +02:00
Florian Weimer
6b33f373c7 arm: Remove ioperm/iopl/inb/inw/inl/outb/outw/outl support
Linux only supports the required ISA sysctls on StrongARM devices,
which are armv4 and no longer tested during glibc development
and probably bit-rotted by this point.  (No reported test results,
and the last discussion of armv4 support was in the glibc 2.19
release notes.)
2019-06-01 13:33:49 +02:00
Florian Weimer
0bb8f8c791 Linux: Add oddly-named arm syscalls to syscall-names.list
<asm/unistd.h> on arm defines the following macros:

#define __ARM_NR_breakpoint             (__ARM_NR_BASE+1)
#define __ARM_NR_cacheflush             (__ARM_NR_BASE+2)
#define __ARM_NR_usr26                  (__ARM_NR_BASE+3)
#define __ARM_NR_usr32                  (__ARM_NR_BASE+4)
#define __ARM_NR_set_tls                (__ARM_NR_BASE+5)
#define __ARM_NR_get_tls                (__ARM_NR_BASE+6)

These do not follow the regular __NR_* naming convention and
have so far been ignored by the syscall-names.list consistency
checks.  This commit adds these names to the file, preparing
for the availability of these names in the regular __NR_*
namespace.
2019-06-01 13:33:49 +02:00
Gabriel F. T. Gomes
9250e6610f powerpc: Fix build failures with current GCC
Since GCC commit 271500 (svn), also known as the following commit on the
git mirror:

commit 61edec870f9fdfb5df3fa4e40f28cbaede28a5b1
Author: amodra <amodra@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed May 22 04:34:26 2019 +0000

    [RS6000] Don't pass -many to the assembler

glibc builds are failing when an assembly implementation does not
declare the correct '.machine' directive, or when no such directive is
declared at all.  For example, when a POWER6 instruction is used, but
'.machine power6' is not declared, the assembler will fail with an error
similar to the following:

    ../sysdeps/powerpc/powerpc64/power8/strcmp.S: Assembler messages:
     24 ../sysdeps/powerpc/powerpc64/power8/strcmp.S:55: Error: unrecognized opcode: `cmpb'

This patch adds '.machine powerN' directives where none existed, as well
as it updates '.machine power7' directives on POWER8 files, because the
minimum binutils version required to build glibc (binutils 2.25) now
provides this machine version.  It also adds '-many' to the assembler
command used to build tst-set_ppr.c.

Tested for powerpc, powerpc64, and powerpc64le, as well as with
build-many-glibcs.py for powerpc targets.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2019-05-30 11:10:48 -03:00
Adhemerval Zanella
fbd6c928bb Remove unused get_clockfreq files
The patch 6e8ba7fd57 meant to remove the all get_clockfreq.c.  This
patch removes the missing files for sparcv9 and x86_64.

Checked against a build to x86_64-linux-gnu and sparcv9-linux-gnu.

	* sysdeps/unix/sysv/linux/sparc/sparc32/sparcv9/get_clockfreq.c:
	Remove file.
	* sysdeps/unix/sysv/linux/x86_64/get_clockfreq.c: Likewise.
2019-05-29 10:26:30 -03:00
Adhemerval Zanella
e47308c98d powerpc: generic nearbyint/nearbyintf
This patches consolidates all the powerpc nearbyint{f} implementations
on the generic sysdeps/powerpc/fpu/s_nearbyint{f}.

	* sysdeps/powerpc/fpu/round_to_integer.h (set_fenv_mode): Add
	NEARBYINT handling.
	* sysdeps/powerpc/fpu/s_nearbyint.c: New file.
	* sysdeps/powerpc/fpu/s_nearbyintf.c: Likewise.
	* sysdeps/powerpc/powerpc32/fpu/s_nearbyint.S: Remove file.
	* sysdeps/powerpc/powerpc32/fpu/s_nearbyintf.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_nearbyint.S: Likewise.
	* sysdeps/powerpc/powerpc64/fpu/s_nearbyintf.S: Likewise.
2019-05-28 18:16:48 -03:00
mansayk
157cda1ff0 tt_RU: Add lang_name [BZ #24370]
This commit adds a lang_name according to CLDR-35.1.

	[BZ #24370]
	* localedata/locales/tt_RU (lang_name): Add from CLDR-35.1.
2019-05-28 22:13:32 +02:00
mansayk
182a3746b8 tt_RU: Fix orthographic mistakes in mon and abmon sections [BZ #24369]
This commit fixes some errors and converts all month names to lowercase.
The content is synchronized with CLDR-35.1 now but trailing dots are
removed from abmon values in order to maintain consistency with the
previous values and with many other locales which do the same.

	[BZ #24369]
	* localedata/locales/tt_RU (mon): Update from CLDR-35.1, fix errors.
	(abmon): Likewise, but remove the trailing dots.
2019-05-28 22:11:22 +02:00
Joseph Myers
c6df1ce3d5 Add IGMP_MRDISC_ADV from Linux 5.1 to netinet/igmp.h.
This patch adds the IGMP_MRDISC_ADV macro from Linux 5.1 to
netinet/igmp.h.

Tested for x86_64.

	* inet/netinet/igmp.h (IGMP_MRDISC_ADV): New macro.
2019-05-28 12:01:12 +00:00
Florian Weimer
85188d8211 nptl: Add comment to __pthread_get_minstack about external users 2019-05-27 12:57:45 +02:00
Florian Weimer
5c23c82195 nss_dns: Check for proper A/AAAA address alignment
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2019-05-24 22:14:04 +02:00
Joseph Myers
bee1f2c413 Add F_SEAL_FUTURE_WRITE from Linux 5.1 to bits/fcntl-linux.h.
This patch adds the new F_SEAL_FUTURE_WRITE constant from Linux 5.1 to
bits/fcntl-linux.h.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/bits/fcntl-linux.h [__USE_GNU]
	(F_SEAL_FUTURE_WRITE): New macro.
2019-05-23 13:20:48 +00:00
Alexandra Hájková
481c30cb95 elf: Add tst-ldconfig-bad-aux-cache test [BZ #18093]
This test corrupts /var/cache/ldconfig/aux-cache and executes ldconfig
to check it will not segfault using the corrupted aux_cache. The test
uses the test-in-container framework. Verified no regressions on
x86_64.
2019-05-23 11:49:44 +02:00
Zack Weinberg
cb755eede7
Add ChangeLog entry for previous commit. 2019-05-22 15:09:32 -04:00
Wilco Dijkstra
46ae07324b Improve string benchtest timing
Improve string benchtest timing.  Many tests run for 0.01s which is way too
short to give accurate results.  Other tests take over 40 seconds which is
way too long.  Significantly increase the iterations of the short running
tests.  Reduce number of alignment variations in the long running memcpy walk
tests so they take less than 5 seconds.

As a result most tests take at least 0.1s and all finish within 5 seconds.

	* benchtests/bench-memcpy-random.c (do_one_test): Use medium iterations.
	* benchtests/bench-memcpy-walk.c (test_main): Reduce alignment tests.
	* benchtests/bench-memmem.c (do_one_test): Use small iterations.
	* benchtests/bench-memmove-walk.c (test_main): Reduce alignment tests.
	* benchtests/bench-memset-walk.c (test_main): Reduce alignment tests.
	* benchtests/bench-strcasestr.c (do_one_test): Use small iterations.
	* benchtests/bench-string.h (INNER_LOOP_ITERS): Increase iterations.
	(INNER_LOOP_ITERS_MEDIUM): New define.
	(INNER_LOOP_ITERS_SMALL): New define.
	* benchtests/bench-strpbrk.c (do_one_test): Use medium iterations.
	* benchtests/bench-strsep.c (do_one_test): Use small iterations.
	* benchtests/bench-strspn.c (do_one_test): Use medium iterations.
	* benchtests/bench-strstr.c (do_one_test): Use small iterations.
	* benchtests/bench-strtok.c (do_one_test): Use small iterations.
2019-05-21 15:19:06 +01:00
Adhemerval Zanella
004e52febf sysvipc: Add missing bit of semtimedop s390 consolidation
This patch add the missing SEMTIMEDOP_IPC_ARGS definions on powerpc
and sparc ipc_priv.h.

Checked on powerpc64le-linux-gnu and with a build for sparc64-linux-gnu.

	* sysdeps/unix/sysv/linux/powerpc/ipc_priv.h (SEMTIMEDOP_IPC_ARGS):
	New define.
	* sysdeps/unix/sysv/linux/sparc/sparc64/ipc_priv.h
	(SEMTIMEDOP_IPC_ARGS): Likewise.
2019-05-21 10:43:10 -03:00
Florian Weimer
c9c15ac316 wcsmbs: Fix data race in __wcsmbs_clone_conv [BZ #24584]
This also adds an overflow check and documents the synchronization
requirement in <gconv.h>.
2019-05-21 12:04:55 +02:00
Florian Weimer
7e740ab2e7 libio: Fix gconv-related memory leak [BZ #24583]
struct gconv_fcts for the C locale is statically allocated,
and __gconv_close_transform deallocates the steps object.
Therefore this commit introduces __wcsmbs_close_conv to avoid
freeing the statically allocated steps objects.
2019-05-21 12:03:54 +02:00
Florian Weimer
09e1b0e3f6 libio: Remove codecvt vtable [BZ #24588]
The codecvt vtable is not a real vtable because it also contains the
conversion state data.  Furthermore, wide stream support was added to
GCC 3.0, after a C++ ABI bump, so there is no compatibility
requirement with libstdc++.

This change removes several unmangled function pointers which could
be used with a corrupted FILE object to redirect execution.  (libio
vtable verification did not cover the codecvt vtable.)

Reviewed-by: Yann Droneaud <ydroneaud@opteya.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2019-05-20 21:54:57 +02:00
Florian Weimer
75c51570c7 support: Expose sbindir as support_sbindir_prefix 2019-05-20 21:15:35 +02:00
Mike Crowe
b62bb3bc68 support: Add missing EOL terminators on timespec
The original implementations of test_timespec_before_impl and
test_timespec_equal_or_after in 5198399651
were missing the backslash required for a newline.

Checked on x86_64-linux-gnu.

	* support/timespec.c: Add backslash to correct newline in failure
	message.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2019-05-20 15:06:17 -03:00
Mike Crowe
ff6bec7d47 support: Correct confusing comment
* support/timespec.h: Correct confusing comment.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2019-05-20 15:05:35 -03:00
Adhemerval Zanella
236c18e568 sysvipc: Consolidate semtimedop s390
This patch consolidates the s390-32 semtimedop implementation by defining
a arch-specific SEMTIMEDOP_IPC_ARGS to rearrange the arguments expected
by s390 Linux kABI.  The idea is to avoid have multiples semtimedop
implementation changes for Linux v5.1 change to enable wire-up sysvipc
support.

Checked with a s390-linux-gnu and s390x-linux-gnu and checking that
resulting semtimedop objects did not change.

	* sysdeps/unix/sysv/linux/ipc_priv.h (SEMTIMEDOP_IPC_ARGS): New
	define.
	* sysdpes/unix/sysv/linux/s390/ipc_priv.h: New file.
	* sysdeps/unix/sysv/linux/s390/semtimedop.c: Remove file.
	* sysdeps/unix/sysv/linux/semtimedop.c (semtimedop): Use
	SEMTIMEDOP_IPC_ARGS for calls with __NR_ipc.
2019-05-20 12:25:31 -03:00
Adhemerval Zanella
dfba907fed sysvipc: Fix compat msgctl (BZ#24570)
The __IPC64 flags is meant to be used to enable the new sysv struct
format when the architectures supports it (ARCH_WANT_IPC_PARSE_VERSION
config flag on Linux kernel).

This currently issue only affects alpha.

	[BZ #24570]
	* sysdeps/unix/sysv/linux/msgctl.c (__old_msgctl): Remove __IPC_64
	usage.
2019-05-20 12:25:28 -03:00
Joseph Myers
1388600877 Add NT_ARM_PACA_KEYS and NT_ARM_PACG_KEYS from Linux 5.1 to elf.h.
This patch adds the new NT_ARM_PACA_KEYS and NT_ARM_PACG_KEYS from
Linux 5.1 to glibc's elf.h.

Tested for x86_64.

	* elf/elf.h (NT_ARM_PACA_KEYS): New macro.
	(NT_ARM_PACG_KEYS): Likewise.
2019-05-20 11:51:58 +00:00
Wilco Dijkstra
1f50f2ad85 Small tcache improvements
Change the tcache->counts[] entries to uint16_t - this removes
the limit set by char and allows a larger tcache.  Remove a few
redundant asserts.

bench-malloc-thread with 4 threads is ~15% faster on Cortex-A72.

Reviewed-by: DJ Delorie <dj@redhat.com>

	* malloc/malloc.c (MAX_TCACHE_COUNT): Increase to UINT16_MAX.
	(tcache_put): Remove redundant assert.
	(tcache_get): Remove redundant asserts.
	(__libc_malloc): Check tcache count is not zero.
	* manual/tunables.texi (glibc.malloc.tcache_count): Update maximum.
2019-05-17 18:16:20 +01:00
Florian Weimer
fef7c63cd5 manual: Document O_DIRECTORY 2019-05-17 11:14:52 +02:00
Joseph Myers
5f161b2398 Update kernel-features.h files for Linux 5.1.
Linux 5.1 adds missing syscalls to the syscall table for many Linux
kernel architectures.  This patch updates the kernel-features.h
headers accordingly.  __ASSUME_DIRECT_SYSVIPC_SYSCALLS is not updated
because of the differences between new and old syscalls described in
<https://sourceware.org/ml/libc-alpha/2019-05/msg00235.html>.  The
statfs64 structure used by alpha matches what the new kernel syscalls
use.

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/alpha/kernel-features.h
	(__ASSUME_STATFS64): Only undefine if [__LINUX_KERNEL_VERSION <
	0x050100].
	* sysdeps/unix/sysv/linux/ia64/kernel-features.h (__ASSUME_STATX):
	Likewise.
	* sysdeps/unix/sysv/linux/sh/kernel-features.h
	(__ASSUME_STATX): Likewise.
2019-05-16 20:03:39 +00:00
Florian Weimer
ec255a97a2 nss_nis, nss_nisplus: Remove RES_USE_INET6 handling
Since commit 3f8b44be0a ("resolv:
Remove support for RES_USE_INET6 and the inet6 option"),
res_use_inet6 () always evaluates to false.
2019-05-16 17:23:23 +02:00
Florian Weimer
9c02d0784d nss_files: Remove RES_USE_INET6 from hosts processing
Since commit 3f8b44be0a ("resolv:
Remove support for RES_USE_INET6 and the inet6 option"),
res_use_inet6 () always evaluates to false.
2019-05-16 15:11:23 +02:00
Florian Weimer
85b0e1e8a6 support: Report NULL blobs explicitly in TEST_COMPARE
Provide an explicit diagnostic if the length is positive, and
do not just crash with a null pointer dereference.  Null pointers
are only valid if the length is zero, so this can only happen with
a faulty test.
2019-05-16 14:50:15 +02:00
Mark Wielaard
11b451c886 dlfcn: Guard __dlerror_main_freeres with __libc_once_get (once) [BZ# 24476]
dlerror.c (__dlerror_main_freeres) will try to free resources which only
have been initialized when init () has been called. That function is
called when resources are needed using __libc_once (once, init) where
once is a __libc_once_define (static, once) in the dlerror.c file.
Trying to free those resources if init () hasn't been called will
produce errors under valgrind memcheck. So guard the freeing of those
resources using __libc_once_get (once) and make sure we have a valid
key. Also add a similar guard to __dlerror ().

	* dlfcn/dlerror.c (__dlerror_main_freeres): Guard using
	__libc_once_get (once) and static_bug == NULL.
	(__dlerror): Check we have a valid key, set result to static_buf
	otherwise.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2019-05-15 23:34:55 +02:00
DJ Delorie
5dde9ef79a Add missing Changelog entry
For 5b06f538c5
2019-05-15 12:11:12 -04:00
Andreas Schwab
32ff397533 Fix crash in _IO_wfile_sync (bug 20568)
When computing the length of the converted part of the stdio buffer, use
the number of consumed wide characters, not the (negative) distance to the
end of the wide buffer.
2019-05-15 16:47:09 +02:00
Florian Weimer
a9368c34d7 nss: Turn __nss_database_lookup into a compatibility symbol
The function uses the internal service_user type, so it is not
really usable from the outside of glibc.  Rename the function
to __nss_database_lookup2 for internal use, and change
__nss_database_lookup to always indicate failure to the caller.

__nss_next already was a compatibility symbol.  The new
implementation always fails and no longer calls __nss_next2.

unscd, the alternative nscd implementation, does not use
__nss_database_lookup, so it is not affected by this change.
2019-05-15 15:07:49 +02:00