about summary refs log tree commit diff
path: root/string
Commit message (Collapse)AuthorAgeFilesLines
* test-strnlen.c: Check that strnlen won't go beyond the maximum lengthH.J. Lu2021-03-271-0/+30
| | | | | Place strings ending at page boundary without the null byte. If an implementation goes beyond EXP_LEN, it will trigger the segfault.
* test-strnlen.c: Initialize wchar_t string with wmemset [BZ #27655]H.J. Lu2021-03-271-1/+3
| | | | Use wmemset to initialize wchar_t string.
* string: Work around GCC PR 98512 in rawmemchrFlorian Weimer2021-02-191-11/+15
|
* strchr: Add additional benchmarks and testsnoah2021-02-081-1/+25
| | | | | | This patch adds additional benchmarks and tests for string size of 4096 and several benchmarks for string size 256 with different alignments.
* Update copyright dates with scripts/update-copyrightsPaul Eggert2021-01-02139-139/+139
| | | | | | | | | | | | | | | | I used these shell commands: ../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright (cd ../glibc && git commit -am"[this commit message]") and then ignored the output, which consisted lines saying "FOO: warning: copyright statement not found" for each of 6694 files FOO. I then removed trailing white space from benchtests/bench-pthread-locks.c and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this diagnostic from Savannah: remote: *** pre-commit check failed ... remote: *** error: lines with trailing whitespace found remote: error: hook declined to update refs/heads/master
* string: Enable __FORTIFY_LEVEL=3Siddhesh Poyarekar2020-12-312-13/+22
| | | | | | This change enhances fortified string functions to use __builtin_dynamic_object_size under _FORTIFY_SOURCE=3 whenever the compiler supports it.
* treewide: fix incorrect spelling of indices in commentsDmitry V. Levin2020-12-111-1/+1
| | | | | | Replace 'indeces' with 'indices', the most annoying of these typos were those found in elf.h which is a public header file copied to other projects.
* Don't use nested function in test-ffsSiddhesh Poyarekar2020-11-121-22/+14
| | | | | There is no real need to use a nested function in that test, so break it out so that it can build with clang too.
* Use __builtin___stpncpy_chk when availableSiddhesh Poyarekar2020-11-121-1/+8
| | | | | | | | | | | | The builtin has been available in gcc since 4.7.0 and in clang since 2.6. This fixes stpncpy fortification with clang since it does a better job of plugging in __stpncpy_chk in the right place than the header hackery. This has been tested by building and running all tests with gcc 10.2.1 and also with clang tip as of a few days ago (just the tests in debug/ since running all tests don't work with clang at the moment) to make sure that both compilers pass the stpncpy tests.
* Remove __warn_memset_zero_len [BZ #25399]Siddhesh Poyarekar2020-11-051-15/+0
| | | | | | | | | | | | | | Non-gcc compilers (clang and possibly other compilers that do not masquerade as gcc 5.0 or later) are unable to use __warn_memset_zero_len since the symbol is no longer available on glibc built with gcc 5.0 or later. While it was likely an oversight that caused this omission, the fact that it wasn't noticed until recently (when clang closed the gap on _FORTIFY_SUPPORT) that the symbol was missing. Given that both gcc and clang are capable of doing this check in the compiler, drop all remaining signs of __warn_memset_zero_len from glibc so that no more objects are built with this symbol in future.
* Amend grammar and add a descriptionJonny Grant2020-10-261-3/+4
| | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* strcmp: Add a testcase for page boundaryH.J. Lu2020-09-241-0/+33
| | | | | Add a strcmp testcase to cover cases where both strings end on the page boundary.
* strncmp: Add a testcase for page boundary [BZ #25933]H.J. Lu2020-09-241-0/+33
| | | | | | | | | | | | | | Add a strncmp testcase to cover cases where one of strings ends on the page boundary with the maximum string length less than the number bytes of each AVX2 loop iteration and different offsets from page boundary. The updated string/test-strncmp fails on Intel Core i7-8559U without ommit 1c6432316bc434a72108d7b0c7cfbfdde64c3124 Author: Sunil K Pandey <skpgkp1@gmail.com> Date: Fri Jun 12 08:57:16 2020 -0700 Fix avx2 strncmp offset compare condition check [BZ #25933]
* Disable -Wstringop-overread for some string testsJoseph Myers2020-09-072-0/+11
| | | | | | | | | | Similarly to Maciej's changes to fix the build of rawmemchr in the presence of GCC 11's -Wstringop-overread, also disable that option in two string function tests that have similar warnings and other string function warnings already disabled. Tested with build-many-glibcs.py for aarch64-linux-gnu and arm-linux-gnueabi that it fixes building the glibc testsuite.
* string: Fix GCC 11 `-Werror=stringop-overread' errorMaciej W. Rozycki2020-09-071-0/+4
| | | | | | | | | | | | | | | Fix a compilation error: In function '__rawmemchr', inlined from '__rawmemchr' at rawmemchr.c:27:1: rawmemchr.c:36:12: error: 'memchr' specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overread] 36 | return memchr (s, c, (size_t)-1); | ^~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors ../o-iterator.mk:9: recipe for target '.../string/rawmemchr.o' failed introduced with GCC 11 commit d14c547abd48 ("Add -Wstringop-overread for reading past the end by string functions.").
* string: test strncasecmp and strncpy near page boundariesRaphael Moreira Zinsly2020-08-262-0/+78
| | | | | | Add tests to check if strings placed at page boundaries are handled correctly by strncasecmp and strncpy similar to tests for strncmp and strnlen.
* string: Make tst-strerror/tst-strsignal unsupported if msgfmt is not installedAdhemerval Zanella2020-07-133-1/+14
| | | | | | | | | | | | | Without msgfmt libc.mo files are not generated and its loading failure is silent ignored with xsetlocale. Also unset LANGUAGE environment variable to avoid it taking precedence when loading the message catalog. Although not strictly required (since the test is issued with test-container and it sets a strict environment variable) it follows other tests that deal with translation. Checked on x86_64-linux-gnu.
* string: Move tst-strsignal tst-strerror to tests-containerAdhemerval Zanella2020-07-081-1/+3
| | | | | | | Both tests require libc.mo translation files which might not be installed on the system. Checked on x86_64-linux-gnu.
* string: Fix prototype mismatch in sigabbrev_np, __sigdescr_npFlorian Weimer2020-07-082-2/+2
| | | | GCC 6 does not ignore the const specifier on the return type.
* tst-strsignal: fix checking for RT signals supportSamuel Thibault2020-07-071-4/+8
| | | | | | * string/tst-strsignal.c (do_test): Actually check that RT signals are available by comparing SIGRTMAX to SIGRTMIN. Check that SIGRTMAX is 64 before testing for a message reporting 65 for SIGRTMAX+1.
* string: Add strerrorname_np and strerrordesc_npAdhemerval Zanella2020-07-075-1/+61
| | | | | | | | | | | | | | | | | The strerrorname_np returns error number name (e.g. "EINVAL" for EINVAL) while strerrordesc_np returns string describing error number (e.g "Invalid argument" for EINVAL). Different than strerror, strerrordesc_np does not attempt to translate the return description, both functions return NULL for an invalid error number. They should be used instead of sys_errlist and sys_nerr, both are thread and async-signal safe. These functions are GNU extensions. Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, and s390x-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* string: Add sigabbrev_np and sigdescr_npAdhemerval Zanella2020-07-077-9/+134
| | | | | | | | | | | | | | | | | | The sigabbrev_np returns the abbreviated signal name (e.g. "HUP" for SIGHUP) while sigdescr_np returns the string describing the error number (e.g "Hangup" for SIGHUP). Different than strsignal, sigdescr_np does not attempt to translate the return description and both functions return NULL for an invalid signal number. They should be used instead of sys_siglist or sys_sigabbrev and they are both thread and async-signal safe. They are added as GNU extensions on string.h header (same as strsignal). Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, and s390x-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* string: Add strerror_l on test-strerror-errnoAdhemerval Zanella2020-07-071-0/+5
| | | | | | | | Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, and s390x-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* string: Add strerror, strerror_r, and strerror_l testAdhemerval Zanella2020-07-072-1/+78
| | | | | | | | Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, and s390x-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* string: Add strsignal testAdhemerval Zanella2020-07-072-2/+61
| | | | | | | | Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, and s390x-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* string: Simplify strerror_rAdhemerval Zanella2020-07-071-39/+2
| | | | | | | | | | | | Use snprintf instead of mempcpy plus itoa_word and remove unused definitions. There is no potential for infinite recursion because snprintf only use strerror_r for the %m specifier. Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, and s390x-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* string: Use tls-internal on strerror_lAdhemerval Zanella2020-07-071-15/+6
| | | | | | | | | | The buffer allocation uses the same strategy of strsignal. Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, and s390x-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* string: Implement strerror in terms of strerror_lAdhemerval Zanella2020-07-072-25/+12
| | | | | | | | | | | | | | If the thread is terminated then __libc_thread_freeres will free the storage via __glibc_tls_internal_free. It is only within the calling thread that this matters. It makes strerror MT-safe. Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, and s390x-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* string: Remove old TLS usage on strsignalAdhemerval Zanella2020-07-071-91/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The per-thread state is refactored two use two strategies: 1. The default one uses a TLS structure, which will be placed in the static TLS space (using __thread keyword). 2. Linux allocates via struct pthread and access it through THREAD_* macros. The default strategy has the disadvantage of increasing libc.so static TLS consumption and thus decreasing the possible surplus used in some scenarios (which might be mitigated by BZ#25051 fix). It is used only on Hurd, where accessing the thread storage in the in single thread case is not straightforward (afaiu, Hurd developers could correct me here). The fallback static allocation used for allocation failure is also removed: defining its size is problematic without synchronizing with translated messages (to avoid partial translation) and the resulting usage is not thread-safe. Checked on x86-64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, and s390x-linux-gnu. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* signal: Move sys_errlist to a compat symbolAdhemerval Zanella2020-07-073-16/+7
| | | | | | | | | | | | | | | | | | | | The symbol is deprecated by strerror since its usage imposes some issues such as copy relocations. Its internal name is also changed to _sys_errlist_internal to avoid static linking usage. The compat code is also refactored by removing the over enginered errlist-compat.c generation from manual entried and extra comment token in linker script file. It disantangle the code generation from manual and simplify both Linux and Hurd compat code. The definitions from errlist.c are moved to errlist.h and a new test is added to avoid a new errno entry without an associated one in manual. Checked on x86_64-linux-gnu and i686-linux-gnu. I also run a check-abi on all affected platforms. Tested-by: Carlos O'Donell <carlos@redhat.com> Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* signal: Move sys_siglist to a compat symbolAdhemerval Zanella2020-07-071-1/+1
| | | | | | | | | | | | | | | | | | | The symbol was deprecated by strsignal and its usage imposes issues such as copy relocations. Its internal name is changed to __sys_siglist and __sys_sigabbrev to avoid static linking usage. The compat code is also refactored, since both Linux and Hurd usage the same strategy: export the same array with different object sizes. The libSegfault change avoids calling strsignal on the SIGFAULT signal handler (the current usage is already sketchy, adding a call that potentially issue locale internal function is even sketchier). Checked on x86_64-linux-gnu and i686-linux-gnu. I also run a check-abi on all affected platforms. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* string: Fix string/tst-memmove-overflow to compile with GCC 7Florian Weimer2020-05-141-2/+2
| | | | | | | | | | GCC 8 relaxed what kind of expressions can be used in initializers, and the previous use of static const variables relied on that. Switch to wide (non-int) enum constants instead, which is another GCC extension that is more widely implemented. Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* arm: XFAIL string/tst-memmove-overflow due to bug 25620Florian Weimer2020-05-131-2/+21
| | | | | | | Also reduce the amount of output in case of a large-scale mismatch in the copied data. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* string: Add string/tst-memmove-overflow, a test case for bug 25620Florian Weimer2020-05-122-1/+156
| | | | | Reviewed-by: Carlos O'Donell <carlos@redhat.com> Tested-by: Carlos O'Donell <carlos@redhat.com>
* improve out-of-bounds checking with GCC 10 attribute access [BZ #25219]Martin Sebor2020-05-042-14/+24
| | | | | | | | Adds the access attribute newly introduced in GCC 10 to the subset of function declarations that are already covered by _FORTIFY_SOURCE and that don't have corresponding GCC built-in equivalents. Reviewed-by: DJ Delorie <dj@redhat.com>
* Update copyright dates with scripts/update-copyrights.Joseph Myers2020-01-01131-131/+131
|
* <string.h>: Define __CORRECT_ISO_CPP_STRING_H_PROTO for Clang [BZ #25232]Kamlesh Kumar2019-12-051-1/+2
| | | | | | | | | | | Without the asm redirects, strchr et al. are not const-correct. libc++ has a wrapper header that works with and without __CORRECT_ISO_CPP_STRING_H_PROTO (using a Clang extension). But when Clang is used with libstdc++ or just C headers, the overloaded functions with the correct types are not declared. This change does not impact current GCC (with libstdc++ or libc++).
* S390: Fix handling of needles crossing a page in strstr z15 ifunc-variant. ↵Stefan Liebler2019-11-271-6/+35
| | | | | | | | | | | | | | | | | [BZ #25226] If the specified needle crosses a page-boundary, the s390-z15 ifunc variant of strstr truncates the needle which results in invalid results. This is fixed by loading the needle beyond the page boundary to v18 instead of v16. The bug is sometimes observable in test-strstr.c in check1 and check2 as the haystack and needle is stored on stack. Thus the needle can be on a page boundary. check2 is now extended to test haystack / needles located on stack, at end of page and on two pages. This bug was introduced with commit 6f47401bd5fc71209219779a0426170a9a7395b0 ("S390: Add arch13 strstr ifunc variant.") and is already released in glibc 2.30.
* Change most internal uses of time to __clock_gettime.Adhemerval Zanella2019-10-301-2/+2
| | | | | | | | | | | | | | | | | As for gettimeofday, time will be implemented based on clock_gettime on all platforms and internal code should use clock_gettime directly. In addition to removing a layer of indirection, this will allow us to remove the PLT-bypass gunk for gettimeofday. The changed code always assumes __clock_gettime (CLOCK_REALTIME) or __clock_gettime (CLOCK_REALTIME_COARSE) (for Linux case) cannot fail, using the same rationale for gettimeofday change. And internal helper was added (time_now). Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, and powerpc-linux-gnu. Reviewed-by: Lukasz Majewski <lukma@denx.de>
* string/endian.h: Restore the __USE_MISC conditionalsAlistair Francis2019-10-021-5/+7
| | | | | | | | | | | | | Commit 69fd157a3 "time: Add padding for the timespec if required" caused a breakage in the glibc tests as the endian.h include file was kept in the networking headers while the __USE_MISC #ifdefs had been removed. This resulted in namespace violations in the networking headers. This patche restores the __USE_MISC conditionals in endian.h to fix the test failures. * string/endian.h: Restore the __USE_MISC conditionals.
* Disable warnings in string/tester.c at top level.Joseph Myers2019-10-021-114/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | string/tester.c contains code that correctly triggers various GCC warnings about dubious uses of string functions (uses that are being deliberately tested there), and duly disables those warnings around the relevant code. A change in GCC mainline resulted in this code failing to compile with a -Warray-bounds error, despite the location with the error having -Warray-bounds already disabled. This has been reported as <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91890>. This patch avoids that problem and possible future issues with these diagnostics by moving all the warning disabling in this file to top level, as suggested by Florian in <https://sourceware.org/ml/libc-alpha/2019-10/msg00033.html>, rather than only doing it locally around specific function calls. Tested with build-many-glibcs.py for aarch64-linux-gnu with GCC mainline (with only the conform/ failures noted in <https://sourceware.org/ml/libc-alpha/2019-10/msg00043.html>). * string/tester.c: Ignore -Warray-bounds and -Wmemset-transposed-args at top level. [__GNUC_PREREQ (7, 0)]: Ignore -Wrestrict and -Wstringop-overflow= at top level. [__GNUC_PREREQ (8, 0)]: Ignore -Wstringop-truncation at top level. (test_stpncpy): Do not ignore warnings here. (test_strncat): Likewise. (test_strncpy): Likewise. (test_memset): Likewise.
* Split up endian.h to minimize exposure of BYTE_ORDER.Alistair Francis2019-10-013-34/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With only two exceptions (sys/types.h and sys/param.h, both of which historically might have defined BYTE_ORDER) the public headers that include <endian.h> only want to be able to test __BYTE_ORDER against __*_ENDIAN. This patch creates a new bits/endian.h that can be included by any header that wants to be able to test __BYTE_ORDER and/or __FLOAT_WORD_ORDER against the __*_ENDIAN constants, or needs __LONG_LONG_PAIR. It only defines macros in the implementation namespace. The existing bits/endian.h (which could not be included independently of endian.h, and only defines __BYTE_ORDER and maybe __FLOAT_WORD_ORDER) is renamed to bits/endianness.h. I also took the opportunity to canonicalize the form of this header, which we are stuck with having one copy of per architecture. Since they are so short, this means git doesn’t understand that they were renamed from existing headers, sigh. endian.h itself is a nonstandard header and its only remaining use from a standard header is guarded by __USE_MISC, so I dropped the __USE_MISC conditionals from around all of the public-namespace things it defines. (This means, an application that requests strict library conformance but includes endian.h will still see the definition of BYTE_ORDER.) A few changes to specific bits/endian(ness).h variants deserve mention: - sysdeps/unix/sysv/linux/ia64/bits/endian.h is moved to sysdeps/ia64/bits/endianness.h. If I remember correctly, ia64 did have selectable endianness, but we have assembly code in sysdeps/ia64 that assumes it’s little-endian, so there is no reason to treat the ia64 endianness.h as linux-specific. - The C-SKY port does not fully support big-endian mode, the compile will error out if __CSKYBE__ is defined. - The PowerPC port had extra logic in its bits/endian.h to detect a broken compiler, which strikes me as unnecessary, so I removed it. - The only files that defined __FLOAT_WORD_ORDER always defined it to the same value as __BYTE_ORDER, so I removed those definitions. The SH bits/endian(ness).h had comments inconsistent with the actual setting of __FLOAT_WORD_ORDER, which I also removed. - I *removed* copyright boilerplate from the few bits/endian(ness).h headers that had it; these files record a single fact in a fashion dictated by an external spec, so I do not think they are copyrightable. As long as I was changing every copy of ieee754.h in the tree, I noticed that only the MIPS variant includes float.h, because it uses LDBL_MANT_DIG to decide among three different versions of ieee854_long_double. This patch makes it not include float.h when GCC’s intrinsic __LDBL_MANT_DIG__ is available. * string/endian.h: Unconditionally define LITTLE_ENDIAN, BIG_ENDIAN, PDP_ENDIAN, and BYTE_ORDER. Condition byteswapping macros only on !__ASSEMBLER__. Move the definitions of __BIG_ENDIAN, __LITTLE_ENDIAN, __PDP_ENDIAN, __FLOAT_WORD_ORDER, and __LONG_LONG_PAIR to... * string/bits/endian.h: ...this new file, which includes the renamed header bits/endianness.h for the definition of __BYTE_ORDER and possibly __FLOAT_WORD_ORDER. * string/Makefile: Install bits/endianness.h. * include/bits/endian.h: New wrapper. * bits/endian.h: Rename to bits/endianness.h. Add multiple-include guard. Rewrite the comment explaining what the machine-specific variants of this file should do. * sysdeps/unix/sysv/linux/ia64/bits/endian.h: Move to sysdeps/ia64. * sysdeps/aarch64/bits/endian.h * sysdeps/alpha/bits/endian.h * sysdeps/arm/bits/endian.h * sysdeps/csky/bits/endian.h * sysdeps/hppa/bits/endian.h * sysdeps/ia64/bits/endian.h * sysdeps/m68k/bits/endian.h * sysdeps/microblaze/bits/endian.h * sysdeps/mips/bits/endian.h * sysdeps/nios2/bits/endian.h * sysdeps/powerpc/bits/endian.h * sysdeps/riscv/bits/endian.h * sysdeps/s390/bits/endian.h * sysdeps/sh/bits/endian.h * sysdeps/sparc/bits/endian.h * sysdeps/x86/bits/endian.h: Rename to endianness.h; canonicalize form of file; remove redundant definitions of __FLOAT_WORD_ORDER. * sysdeps/powerpc/bits/endianness.h: Remove logic to check for broken compilers. * ctype/ctype.h * sysdeps/aarch64/nptl/bits/pthreadtypes-arch.h * sysdeps/arm/nptl/bits/pthreadtypes-arch.h * sysdeps/csky/nptl/bits/pthreadtypes-arch.h * sysdeps/ia64/ieee754.h * sysdeps/ieee754/ieee754.h * sysdeps/ieee754/ldbl-128/ieee754.h * sysdeps/ieee754/ldbl-128ibm/ieee754.h * sysdeps/m68k/nptl/bits/pthreadtypes-arch.h * sysdeps/microblaze/nptl/bits/pthreadtypes-arch.h * sysdeps/mips/ieee754/ieee754.h * sysdeps/mips/nptl/bits/pthreadtypes-arch.h * sysdeps/nios2/nptl/bits/pthreadtypes-arch.h * sysdeps/nptl/pthread.h * sysdeps/riscv/nptl/bits/pthreadtypes-arch.h * sysdeps/sh/nptl/bits/pthreadtypes-arch.h * sysdeps/sparc/sparc32/ieee754.h * sysdeps/unix/sysv/linux/generic/bits/stat.h * sysdeps/unix/sysv/linux/generic/bits/statfs.h * sysdeps/unix/sysv/linux/sys/acct.h * wctype/bits/wctype-wchar.h: Include bits/endian.h, not endian.h. * sysdeps/unix/sysv/linux/hppa/pthread.h: Don’t include endian.h. * sysdeps/mips/ieee754/ieee754.h: Use __LDBL_MANT_DIG__ in ifdefs, instead of LDBL_MANT_DIG. Only include float.h when __LDBL_MANT_DIG__ is not predefined, in which case define __LDBL_MANT_DIG__ to equal LDBL_MANT_DIG.
* Prefer https to http for gnu.org and fsf.org URLsPaul Eggert2019-09-07130-130/+130
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Also, change sources.redhat.com to sourceware.org. This patch was automatically generated by running the following shell script, which uses GNU sed, and which avoids modifying files imported from upstream: sed -ri ' s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g ' \ $(find $(git ls-files) -prune -type f \ ! -name '*.po' \ ! -name 'ChangeLog*' \ ! -path COPYING ! -path COPYING.LIB \ ! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \ ! -path manual/texinfo.tex ! -path scripts/config.guess \ ! -path scripts/config.sub ! -path scripts/install-sh \ ! -path scripts/mkinstalldirs ! -path scripts/move-if-change \ ! -path INSTALL ! -path locale/programs/charmap-kw.h \ ! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \ ! '(' -name configure \ -execdir test -f configure.ac -o -f configure.in ';' ')' \ ! '(' -name preconfigure \ -execdir test -f preconfigure.ac ';' ')' \ -print) and then by running 'make dist-prepare' to regenerate files built from the altered files, and then executing the following to cleanup: chmod a+x sysdeps/unix/sysv/linux/riscv/configure # Omit irrelevant whitespace and comment-only changes, # perhaps from a slightly-different Autoconf version. git checkout -f \ sysdeps/csky/configure \ sysdeps/hppa/configure \ sysdeps/riscv/configure \ sysdeps/unix/sysv/linux/csky/configure # Omit changes that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines git checkout -f \ sysdeps/powerpc/powerpc64/ppc-mcount.S \ sysdeps/unix/sysv/linux/s390/s390-64/syscall.S # Omit change that caused a pre-commit check to fail like this: # remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
* Use generic memset/memcpy/memmove in benchtestsWilco Dijkstra2019-08-302-6/+10
| | | | | | | | | | | | | | | | | | | | | | | Use the generic C memset/memcpy/memmove in benchtests since comparing against a slow byte-oriented implementation makes no sense. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> 2019-08-29 Wilco Dijkstra <wdijkstr@arm.com> * benchtests/bench-memcpy.c (simple_memcpy): Remove. (generic_memcpy): Include generic C memcpy. * benchtests/bench-memmove.c (simple_memmove): Remove. (generic_memmove): Include generic C memmove. * benchtests/bench-memset.c (simple_memset): Remove. (generic_memset): Include generic C memset. * benchtests/bench-memset-large.c (simple_memset): Remove. (generic_memset): Include generic C memset. * benchtests/bench-memset-walk.c (simple_memset): Remove. (generic_memset): Include generic C memset. * string/memcpy.c (MEMCPY): Add defines to enable redirection. * string/memset.c (MEMSET): Likewise. * sysdeps/x86_64/memcopy.h: Remove empty file.
* Fix spellings of contributor names in comments and docPaul Eggert2019-08-231-1/+1
|
* Don't use the argument to time.Zack Weinberg2019-08-211-1/+1
| | | | | | | | | | | | | | | | | | | It doesn't make sense to remove all the internal uses of time. It's still a standard ISO C function, and its callers don't need sub-second resolution and would be unnecessarily complicated if they had to declare a struct timespec instead of just a time_t. However, a handful of places were using the vestigial "result" argument instead of the return value, which is slightly less efficient and also looks strange. Correct this. * misc/syslog.c (__vsyslog_internal) * time/getdate.c (__getdate_r) * time/tst_wcsftime.c (main): Use return value of time, not its argument. * string/strfry.c (strfry) * sysdeps/mach/sleep.c (__sleep): Remove unnecessary casts of NULL in calls to time.
* Declare memccpy, strdup, strndup for C2X.Joseph Myers2019-08-131-3/+3
| | | | | | | | | | | | C2X adds the memccpy, strdup and strndup functions. This patch duly adds __GLIBC_USE (ISOC2X) to the conditions under which <string.h> declares them. Tested for x86_64. * string/string.h (memccpy): Also declare if [__GLIBC_USE (ISOC2X)]. (strdup): Likewise. (strndup): Likewise.
* Fix gcc 9 build errors for make xcheck. [BZ #24556]Stefan Liebler2019-06-192-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes the following gcc 9 warnings for "make xcheck" / "make bench": -string/tst-strcasestr.c: ../include/bits/../../misc/bits/error.h:42:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=] -argp/argp-test.c: argp-test.c:130:20: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Werror=format-overflow=] argp-test.c:130:19: note: directive argument in the range [-2147483648, 122] argp-test.c:130:5: note: ‘sprintf’ output between 2 and 12 bytes into a destination of size 10 -nss/tst-field.c: tst-field.c:52:7: error: ‘%s’ directive argument is null [-Werror=format-overflow=] -benchtests/bench-strstr.c: ../include/bits/../../misc/bits/error.h:42:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=] -benchtests/bench-malloc-simple.c: bench-malloc-simple.c:93:16: error: iteration 3 invokes undefined behavior [-Werror=aggressive-loop-optimizations] ChangeLog: [BZ #24556] * string/test-strcasestr.c (check_result): Add NULL check. * nss/tst-field.c (check_rewrite): Likewise. * benchtests/bench-strstr.c (do_one_test): Likewise. * string/test-strstr.c (check_result): Likewise. * argp/argp-test.c (popt): Increase size of buf to 12. * benchtests/bench-malloc-simple.c (bench): Do not initialize tests array out of bounds.
* Improve performance of memmemWilco Dijkstra2019-06-121-42/+85
| | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Improve performance of strstrWilco Dijkstra2019-06-122-51/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.