Commit graph

17 commits

Author SHA1 Message Date
Zack Weinberg ea1bd74def New string function explicit_bzero (from OpenBSD).
explicit_bzero(s, n) is the same as memset(s, 0, n), except that the
compiler is not allowed to delete a call to explicit_bzero even if the
memory pointed to by 's' is dead after the call.  Right now, this effect
is achieved externally by having explicit_bzero be a function whose
semantics are unknown to the compiler, and internally, with a no-op
asm statement that clobbers memory.  This does mean that small
explicit_bzero operations cannot be expanded inline as small memset
operations can, but on the other hand, small memset operations do get
deleted by the compiler.  Hopefully full compiler support for
explicit_bzero will happen relatively soon.

There are two new tests: test-explicit_bzero.c verifies the
visible semantics in the same way as the existing test-bzero.c,
and tst-xbzero-opt.c verifies the not-being-optimized-out property.
The latter is conceptually based on a test written by Matthew Dempsky
for the OpenBSD regression suite.

The crypt() implementation has an immediate use for this new feature.
We avoid having to add a GLIBC_PRIVATE alias for explicit_bzero
by running all of libcrypt's calls through the fortified variant,
__explicit_bzero_chk, which is in the impl namespace anyway.  Currently
I'm not aware of anything in libc proper that needs this, but the
glue is all in place if it does become necessary.  The legacy DES
implementation wasn't bothering to clear its buffers, so I added that,
mostly for consistency's sake.

	* string/explicit_bzero.c: New routine.
	* string/test-explicit_bzero.c, string/tst-xbzero-opt.c: New tests.
	* string/Makefile (routines, strop-tests, tests): Add them.
	* string/test-memset.c: Add ifdeffage for testing explicit_bzero.
	* string/string.h [__USE_MISC]: Declare explicit_bzero.

	* debug/explicit_bzero_chk.c: New routine.
	* debug/Makefile (routines): Add it.
	* debug/tst-chk1.c: Test fortification of explicit_bzero.
	* string/bits/string3.h: Fortify explicit_bzero.

	* manual/string.texi: Document explicit_bzero.
	* NEWS: Mention addition of explicit_bzero.

	* crypt/crypt-entry.c (__crypt_r): Clear key-dependent intermediate
	data before returning, using explicit_bzero.
	* crypt/md5-crypt.c (__md5_crypt_r): Likewise.
	* crypt/sha256-crypt.c (__sha256_crypt_r): Likewise.
	* crypt/sha512-crypt.c (__sha512_crypt_r): Likewise.

	* include/string.h: Redirect internal uses of explicit_bzero
	to __explicit_bzero_chk[_internal].
	* string/Versions [GLIBC_2.25]: Add explicit_bzero.
	* debug/Versions [GLIBC_2.25]: Add __explicit_bzero_chk.
	* sysdeps/arm/nacl/libc.abilist
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist
	* sysdeps/unix/sysv/linux/alpha/libc.abilist
	* sysdeps/unix/sysv/linux/arm/libc.abilist
	* sysdeps/unix/sysv/linux/hppa/libc.abilist
	* sysdeps/unix/sysv/linux/i386/libc.abilist
	* sysdeps/unix/sysv/linux/ia64/libc.abilist
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
	* sysdeps/unix/sysv/linux/nios2/libc.abilist
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
	* sysdeps/unix/sysv/linux/sh/libc.abilist
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist:
	Add entries for explicit_bzero and __explicit_bzero_chk.
2016-12-16 16:21:54 -05:00
Joseph Myers f7a9f785e5 Update copyright dates with scripts/update-copyrights. 2016-01-04 16:05:18 +00:00
Stefan Liebler 2e9e166761 S390: Optimize wmemset.
This patch provides optimized version of wmemset with the z13 vector
instructions.

ChangeLog:

	* sysdeps/s390/multiarch/wmemset-c.c: New File.
	* sysdeps/s390/multiarch/wmemset-vx.S: Likewise.
	* sysdeps/s390/multiarch/wmemset.c: Likewise.
	* sysdeps/s390/multiarch/Makefile
	(sysdep_routines): Add wmemset functions.
	* sysdeps/s390/multiarch/ifunc-impl-list-common.c
	(__libc_ifunc_impl_list_common): Add ifunc test for wmemset.
	* wcsmbs/wmemset.c: Use WMEMSET if defined.
	* string/test-memset.c: Add wmemset support.
	* wcsmbs/test-wmemset.c: New File.
	* wcsmbs/Makefile (strop-tests): Add wmemset.
	* benchtests/bench-memset.c: Add wmemset support.
	* benchtests/bench-wmemset.c: New File.
	* benchtests/Makefile (wcsmbs-bench): Add wmemset.
2015-08-26 10:26:25 +02:00
Joseph Myers b168057aaa Update copyright dates with scripts/update-copyrights. 2015-01-02 16:29:47 +00:00
Allan McRae d4697bc93d Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
Adhemerval Zanella 85c2e6110c Fix loop construction to functions calls
Check wheter the compiler has the option -fno-tree-loop-distribute-patterns
to inhibit loop transformation to library calls and uses it on memset
and memmove default implementation to avoid recursive calls.
2013-06-20 19:42:05 -05:00
Siddhesh Poyarekar fec799f823 Remove performance-related bits from string tests 2013-06-11 15:08:13 +05:30
Joseph Myers 568035b787 Update copyright notices with scripts/update-copyrights. 2013-01-02 19:05:09 +00:00
H.J. Lu 69f07e5fd1 Add string IFUNC tests 2012-10-19 22:10:16 -07:00
H.J. Lu 9a387d1f78 Use IFUNC memmove/memset in x86-64 bcopy/bzero
Also add separate tests for bcopy and bzero.
2012-10-11 13:58:16 -07:00
Paul Eggert 59ba27a63a Replace FSF snail mail address with URLs. 2012-02-09 23:18:22 +00:00
Ulrich Drepper 09987e425c * string/test-memset.c (test_main): Use negative byte value is
test.
2005-07-25 01:40:59 +00:00
Ulrich Drepper c158fc76d9 (do_one_test): Compare effect of call, not only return value.
Add a few cassts to avoid warnings.
2005-07-24 23:06:44 +00:00
Ulrich Drepper a334319f65 (CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4. 2004-12-22 20:10:10 +00:00
Jakub Jelinek 0ecb606cb6 2.5-18.1 2007-07-12 18:26:36 +00:00
Ulrich Drepper c9df3df9d2 Update.
* string/test-memchr.c: Likewise.
	* string/test-memcmp.c: Likewise.
	* string/test-memcpy.c: Likewise.
	* string/test-memmove.c: Likewise.
	* string/test-memset.c: Likewise.
	* string/test-strcat.c: Likewise.
	* string/test-strchr.c: Likewise.
	* string/test-strcmp.c: Likewise.
	* string/test-strcpy.c: Likewise.
	* string/test-strlen.c: Likewise.
	* string/test-strncmp.c: Likewise.
	* string/test-strpbrk.c: Likewise.
	* string/test-strrchr.c: Likewise.
	* string/test-strspn.c: Likewise.
2003-04-17 17:38:38 +00:00
Roland McGrath 58ef9ef7bc * string/test-string.h: New file.
* string/test-strlen.c: New file.
	* string/test-string.h: New file.
	* string/test-strcmp.c: New file.
	* string/test-strchr.c: New file.
	* string/test-strrchr.c: New file.
	* string/test-strcpy.c: New file.
	* string/test-stpcpy.c: New file.
	* string/test-strncpy.c: New file.
	* string/test-stpncpy.c: New file.
	* string/test-strpbrk.c: New file.
	* string/test-strcspn.c: New file.
	* string/test-strspn.c: New file.
	* string/test-strcat.c: New file.
	* string/test-strncmp.c: New file.
	* string/test-memchr.c: New file.
	* string/test-memcmp.c: New file.
	* string/test-memset.c: New file.
	* string/test-memcpy.c: New file.
	* string/test-mempcpy.c: New file.
	* string/test-memmove.c: New file.
	* string/Makefile (strop-tests): New variable.
	(tests): Add strop-tests.
	(distribute): Add test-string.h.
2002-11-07 19:15:01 +00:00