2015-08-26 16:26:25 +08:00
|
|
|
/* Test memset functions.
|
2024-01-02 02:12:26 +08:00
|
|
|
Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
2002-11-08 03:15:01 +08:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-10 07:18:22 +08:00
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
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
2019-09-07 13:40:42 +08:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2002-11-08 03:15:01 +08:00
|
|
|
|
|
|
|
#define TEST_MAIN
|
2012-10-20 13:04:19 +08:00
|
|
|
#ifdef TEST_BZERO
|
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-09-15 19:29:44 +08:00
|
|
|
# ifdef TEST_EXPLICIT_BZERO
|
|
|
|
# define TEST_NAME "explicit_bzero"
|
|
|
|
# else
|
|
|
|
# define TEST_NAME "bzero"
|
|
|
|
# endif
|
2012-10-20 13:04:19 +08:00
|
|
|
#else
|
2015-08-26 16:26:25 +08:00
|
|
|
# ifndef WIDE
|
|
|
|
# define TEST_NAME "memset"
|
|
|
|
# else
|
|
|
|
# define TEST_NAME "wmemset"
|
|
|
|
# endif /* WIDE */
|
|
|
|
#endif /* !TEST_BZERO */
|
2002-11-08 03:15:01 +08:00
|
|
|
#define MIN_PAGE_SIZE 131072
|
|
|
|
#include "test-string.h"
|
|
|
|
|
2015-08-26 16:26:25 +08:00
|
|
|
#ifndef WIDE
|
|
|
|
# define MEMSET memset
|
|
|
|
# define CHAR char
|
|
|
|
# define UCHAR unsigned char
|
|
|
|
# define SIMPLE_MEMSET simple_memset
|
|
|
|
# define MEMCMP memcmp
|
|
|
|
# define BIG_CHAR CHAR_MAX
|
|
|
|
#else
|
|
|
|
# include <wchar.h>
|
|
|
|
# define MEMSET wmemset
|
|
|
|
# define CHAR wchar_t
|
|
|
|
# define UCHAR wchar_t
|
|
|
|
# define SIMPLE_MEMSET simple_wmemset
|
|
|
|
# define MEMCMP wmemcmp
|
|
|
|
# define BIG_CHAR WCHAR_MAX
|
|
|
|
#endif /* WIDE */
|
|
|
|
|
2012-10-12 04:58:16 +08:00
|
|
|
#ifdef TEST_BZERO
|
|
|
|
typedef void (*proto_t) (char *, size_t);
|
2022-04-06 23:23:24 +08:00
|
|
|
# ifdef TEST_EXPLICIT_BZERO
|
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-09-15 19:29:44 +08:00
|
|
|
IMPL (explicit_bzero, 1)
|
2022-04-06 23:23:24 +08:00
|
|
|
# else
|
2012-10-12 04:58:16 +08:00
|
|
|
IMPL (bzero, 1)
|
2022-04-06 23:23:24 +08:00
|
|
|
# endif
|
2012-10-12 04:58:16 +08:00
|
|
|
#else
|
2015-08-26 16:26:25 +08:00
|
|
|
typedef CHAR *(*proto_t) (CHAR *, int, size_t);
|
|
|
|
IMPL (MEMSET, 1)
|
|
|
|
#endif /* !TEST_BZERO */
|
2012-10-12 04:58:16 +08:00
|
|
|
|
2022-04-06 23:23:24 +08:00
|
|
|
/* Naive implementation to verify results. */
|
2015-08-26 16:26:25 +08:00
|
|
|
CHAR *
|
2013-06-21 08:40:55 +08:00
|
|
|
inhibit_loop_to_libcall
|
2015-08-26 16:26:25 +08:00
|
|
|
SIMPLE_MEMSET (CHAR *s, int c, size_t n)
|
2002-11-08 03:15:01 +08:00
|
|
|
{
|
2015-08-26 16:26:25 +08:00
|
|
|
CHAR *r = s, *end = s + n;
|
2002-11-08 03:15:01 +08:00
|
|
|
while (r < end)
|
|
|
|
*r++ = c;
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2022-02-14 09:40:37 +08:00
|
|
|
do_one_test (impl_t *impl, CHAR *s, int c __attribute ((unused)), size_t n, int space_below, int space_above)
|
2002-11-08 03:15:01 +08:00
|
|
|
{
|
2022-02-14 09:40:37 +08:00
|
|
|
CHAR buf[n];
|
|
|
|
CHAR sentinel = ~c;
|
|
|
|
if (space_below)
|
|
|
|
s[-1] = sentinel;
|
|
|
|
if (space_above)
|
|
|
|
s[n] = sentinel;
|
|
|
|
SIMPLE_MEMSET(s, ~c, n);
|
2012-10-12 04:58:16 +08:00
|
|
|
#ifdef TEST_BZERO
|
2022-04-06 23:23:24 +08:00
|
|
|
SIMPLE_MEMSET (buf, 0, n);
|
2012-10-12 04:58:16 +08:00
|
|
|
CALL (impl, s, n);
|
2022-02-14 09:40:37 +08:00
|
|
|
if (memcmp (s, buf, n) != 0
|
|
|
|
|| (space_below && s[-1] != sentinel)
|
|
|
|
|| (space_above && s[n] != sentinel))
|
2012-10-12 04:58:16 +08:00
|
|
|
#else
|
2015-08-26 16:26:25 +08:00
|
|
|
CHAR *res = CALL (impl, s, c, n);
|
2005-07-25 07:06:44 +08:00
|
|
|
if (res != s
|
2022-02-14 09:40:37 +08:00
|
|
|
|| SIMPLE_MEMSET (buf, c, n) != buf
|
|
|
|
|| MEMCMP (s, buf, n) != 0
|
|
|
|
|| (space_below && s[-1] != sentinel)
|
|
|
|
|| (space_above && s[n] != sentinel))
|
2015-08-26 16:26:25 +08:00
|
|
|
#endif /* !TEST_BZERO */
|
2002-11-08 03:15:01 +08:00
|
|
|
{
|
2005-07-25 07:06:44 +08:00
|
|
|
error (0, 0, "Wrong result in function %s", impl->name);
|
2002-11-08 03:15:01 +08:00
|
|
|
ret = 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
do_test (size_t align, int c, size_t len)
|
|
|
|
{
|
2022-02-14 09:40:37 +08:00
|
|
|
int space_below, space_above;
|
2021-04-20 05:48:11 +08:00
|
|
|
align &= 4095;
|
2015-08-26 16:26:25 +08:00
|
|
|
if ((align + len) * sizeof (CHAR) > page_size)
|
2002-11-08 03:15:01 +08:00
|
|
|
return;
|
|
|
|
|
2022-02-14 09:40:37 +08:00
|
|
|
space_below = !!align;
|
|
|
|
space_above = !((align + len + 1) * sizeof (CHAR) > page_size);
|
|
|
|
|
2002-11-08 03:15:01 +08:00
|
|
|
FOR_EACH_IMPL (impl, 0)
|
2022-02-14 09:40:37 +08:00
|
|
|
do_one_test (impl, (CHAR *) (buf1) + align, c, len, space_below, space_above);
|
2002-11-08 03:15:01 +08:00
|
|
|
}
|
|
|
|
|
2012-10-12 04:58:16 +08:00
|
|
|
#ifndef TEST_BZERO
|
2002-11-08 03:15:01 +08:00
|
|
|
static void
|
|
|
|
do_random_tests (void)
|
|
|
|
{
|
|
|
|
size_t i, j, k, n, align, len, size;
|
|
|
|
int c, o;
|
2015-08-26 16:26:25 +08:00
|
|
|
UCHAR *p, *res;
|
|
|
|
UCHAR *p2 = (UCHAR *) buf2;
|
2002-11-08 03:15:01 +08:00
|
|
|
|
2015-08-26 16:26:25 +08:00
|
|
|
for (i = 0; i < 65536 / sizeof (CHAR); ++i)
|
|
|
|
p2[i] = random () & BIG_CHAR;
|
2002-11-08 03:15:01 +08:00
|
|
|
|
|
|
|
for (n = 0; n < ITERATIONS; n++)
|
|
|
|
{
|
|
|
|
if ((random () & 31) == 0)
|
2015-08-26 16:26:25 +08:00
|
|
|
size = 65536 / sizeof (CHAR);
|
2002-11-08 03:15:01 +08:00
|
|
|
else
|
|
|
|
size = 512;
|
2015-08-26 16:26:25 +08:00
|
|
|
p = (UCHAR *) (buf1 + page_size) - size;
|
2002-11-08 03:15:01 +08:00
|
|
|
len = random () & (size - 1);
|
|
|
|
align = size - len - (random () & 31);
|
|
|
|
if (align > size)
|
|
|
|
align = size - len;
|
|
|
|
if ((random () & 7) == 0)
|
|
|
|
align &= ~63;
|
|
|
|
if ((random () & 7) == 0)
|
|
|
|
c = 0;
|
|
|
|
else
|
2015-08-26 16:26:25 +08:00
|
|
|
c = random () & BIG_CHAR;
|
|
|
|
o = random () & BIG_CHAR;
|
2002-11-08 03:15:01 +08:00
|
|
|
if (o == c)
|
2015-08-26 16:26:25 +08:00
|
|
|
o = (c + 1) & BIG_CHAR;
|
2002-11-08 03:15:01 +08:00
|
|
|
j = len + align + 128;
|
|
|
|
if (j > size)
|
|
|
|
j = size;
|
|
|
|
if (align >= 128)
|
|
|
|
k = align - 128;
|
|
|
|
else
|
|
|
|
k = 0;
|
|
|
|
for (i = k; i < align; ++i)
|
|
|
|
p[i] = o;
|
|
|
|
for (i = align + len; i < j; ++i)
|
|
|
|
p[i] = o;
|
|
|
|
|
|
|
|
FOR_EACH_IMPL (impl, 1)
|
|
|
|
{
|
|
|
|
for (i = 0; i < len; ++i)
|
|
|
|
{
|
2015-08-26 16:26:25 +08:00
|
|
|
p[i + align] = p2[i];
|
2002-11-08 03:15:01 +08:00
|
|
|
if (p[i + align] == c)
|
|
|
|
p[i + align] = o;
|
|
|
|
}
|
2015-08-26 16:26:25 +08:00
|
|
|
res = (UCHAR *) CALL (impl, (CHAR *) p + align, c, len);
|
2002-11-08 03:15:01 +08:00
|
|
|
if (res != p + align)
|
|
|
|
{
|
|
|
|
error (0, 0, "Iteration %zd - wrong result in function %s (%zd, %d, %zd) %p != %p",
|
|
|
|
n, impl->name, align, c, len, res, p + align);
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
for (i = k; i < align; ++i)
|
|
|
|
if (p[i] != o)
|
|
|
|
{
|
|
|
|
error (0, 0, "Iteration %zd - garbage before %s (%zd, %d, %zd)",
|
|
|
|
n, impl->name, align, c, len);
|
|
|
|
ret = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (; i < align + len; ++i)
|
|
|
|
if (p[i] != c)
|
|
|
|
{
|
|
|
|
error (0, 0, "Iteration %zd - not cleared correctly %s (%zd, %d, %zd)",
|
|
|
|
n, impl->name, align, c, len);
|
|
|
|
ret = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
for (; i < j; ++i)
|
|
|
|
if (p[i] != o)
|
|
|
|
{
|
|
|
|
error (0, 0, "Iteration %zd - garbage after %s (%zd, %d, %zd)",
|
|
|
|
n, impl->name, align, c, len);
|
|
|
|
ret = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-08-26 16:26:25 +08:00
|
|
|
#endif /* !TEST_BZERO */
|
2002-11-08 03:15:01 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
test_main (void)
|
|
|
|
{
|
|
|
|
size_t i;
|
2012-10-12 04:58:16 +08:00
|
|
|
int c = 0;
|
2002-11-08 03:15:01 +08:00
|
|
|
|
|
|
|
test_init ();
|
|
|
|
|
|
|
|
printf ("%24s", "");
|
|
|
|
FOR_EACH_IMPL (impl, 0)
|
|
|
|
printf ("\t%s", impl->name);
|
|
|
|
putchar ('\n');
|
|
|
|
|
2012-10-12 04:58:16 +08:00
|
|
|
#ifndef TEST_BZERO
|
2005-07-25 09:40:59 +08:00
|
|
|
for (c = -65; c <= 130; c += 65)
|
2012-10-12 04:58:16 +08:00
|
|
|
#endif
|
2002-11-08 03:15:01 +08:00
|
|
|
{
|
|
|
|
for (i = 0; i < 18; ++i)
|
|
|
|
do_test (0, c, 1 << i);
|
2021-04-20 05:48:11 +08:00
|
|
|
for (i = 1; i < 64; ++i)
|
2002-11-08 03:15:01 +08:00
|
|
|
{
|
|
|
|
do_test (i, c, i);
|
2021-04-20 05:48:11 +08:00
|
|
|
do_test (4096 - i, c, i);
|
|
|
|
do_test (4095, c, i);
|
2002-11-08 03:15:01 +08:00
|
|
|
if (i & (i - 1))
|
|
|
|
do_test (0, c, i);
|
|
|
|
}
|
|
|
|
do_test (1, c, 14);
|
|
|
|
do_test (3, c, 1024);
|
|
|
|
do_test (4, c, 64);
|
|
|
|
do_test (2, c, 25);
|
|
|
|
}
|
|
|
|
|
2012-10-12 04:58:16 +08:00
|
|
|
#ifndef TEST_BZERO
|
2002-11-08 03:15:01 +08:00
|
|
|
do_random_tests ();
|
2012-10-12 04:58:16 +08:00
|
|
|
#endif
|
|
|
|
|
2002-11-08 03:15:01 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2017-03-23 22:32:17 +08:00
|
|
|
#include <support/test-driver.c>
|