[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r6236 - in /fsf/trunk/libc: ./ libio/ resolv/ stdio-common/ string/
- To: commits@xxxxxxxxxx
- Subject: [commits] r6236 - in /fsf/trunk/libc: ./ libio/ resolv/ stdio-common/ string/
- From: eglibc@xxxxxxxxxx
- Date: Sun, 25 May 2008 07:04:46 -0000
Author: eglibc
Date: Sun May 25 00:04:42 2008
New Revision: 6236
Log:
Import glibc-mainline for 2008-05-25
Added:
fsf/trunk/libc/stdio-common/scanf16.c
fsf/trunk/libc/stdio-common/scanf17.c
fsf/trunk/libc/string/test-memmem.c
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/libio/stdio.h
fsf/trunk/libc/resolv/res_send.c
fsf/trunk/libc/stdio-common/Makefile
fsf/trunk/libc/stdio-common/scanf14.c
fsf/trunk/libc/stdio-common/scanf15.c
fsf/trunk/libc/string/Makefile
fsf/trunk/libc/string/test-string.h
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Sun May 25 00:04:42 2008
@@ -1,3 +1,26 @@
+2008-05-24 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * string/Makefile (strop-tests): Add memmem.
+ * string/test-memmem.c: New file.
+ * string/test-string.h (BUF1PAGES): Define to 1 if undefined.
+ (test_init): Size buf1 according to BUF1PAGES.
+
+2008-05-24 Jakub Jelinek <jakub@xxxxxxxxxx>
+
+ * libio/stdio.h (vscanf): Fix -std=c99 redirect.
+ * stdio-common/Makefile (tests): Add scanf16 and scanf17.
+ (CFLAGS-scanf17.c): New.
+ * stdio-common/scanf14.c (main): Add fscanf and scanf tests.
+ * stdio-common/scanf15.c (main): Likewise.
+ * stdio-common/scanf16.c: New file.
+ * stdio-common/scanf17.c: New file.
+
+2008-05-24 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * resolv/res_send.c (send_dg): If we already have one of two
+ answers and the server reports SERVFAIL, NOTIMP, or REFUSED, then
+ use the one answer insted of failing.
+
2008-02-20 Ryan S. Arnold <rsa@xxxxxxxxxx>
* math/libm-test.inc (exp_test): Exclude expl(1000.0L) from
@@ -36,7 +59,7 @@
* sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h
(__SYSCALL_CLOBBERS): Likewise.
* scripts/data/localplt-sparc-linux-gnu.data: New file.
- * scripts/data/localplt-sparc64-linux-gnu.data: Likewise.
+ * scripts/data/localplt-sparc64-linux-gnu.data: New file.
2008-05-21 Jakub Jelinek <jakub@xxxxxxxxxx>
Modified: fsf/trunk/libc/libio/stdio.h
==============================================================================
--- fsf/trunk/libc/libio/stdio.h (original)
+++ fsf/trunk/libc/libio/stdio.h Sun May 25 00:04:42 2008
@@ -475,7 +475,7 @@
__isoc99_vfscanf)
__attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
extern int __REDIRECT (vscanf, (__const char *__restrict __format,
- _G_va_list __arg), __isoc99_vfscanf)
+ _G_va_list __arg), __isoc99_vscanf)
__attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
extern int __REDIRECT (vsscanf,
(__const char *__restrict __s,
Modified: fsf/trunk/libc/resolv/res_send.c
==============================================================================
--- fsf/trunk/libc/resolv/res_send.c (original)
+++ fsf/trunk/libc/resolv/res_send.c Sun May 25 00:04:42 2008
@@ -1001,12 +1001,12 @@
need_recompute = 1;
}
if (n == 0) {
- Dprint(statp->options & RES_DEBUG, (stdout,
- ";; timeout sending\n"));
- if (recvresp1)
- return resplen;
- if (buf2 != NULL && recvresp2)
- return 1;
+ Dprint(statp->options & RES_DEBUG, (stdout, ";; timeout\n"));
+ if (recvresp1 || (buf2 != NULL && recvresp2))
+ {
+ *resplen2 = 1;
+ return resplen;
+ }
*gotsomewhere = 1;
return (0);
@@ -1184,6 +1184,24 @@
thisansp,
(*thisresplen > *thisanssiz)
? *thisanssiz : *thisresplen);
+
+ if (recvresp1 || (buf2 != NULL && recvresp2))
+ {
+ *resplen2 = 1;
+ return resplen;
+ }
+ if (buf2 != NULL)
+ {
+ /* We are waiting for a possible second reply. */
+ resplen = 1;
+ if (hp->id == anhp->id)
+ recvresp1 = 1;
+ else
+ recvresp2 = 1;
+
+ goto wait;
+ }
+
next_ns:
__res_iclose(statp, false);
/* don't retry if called from dig */
Modified: fsf/trunk/libc/stdio-common/Makefile
==============================================================================
--- fsf/trunk/libc/stdio-common/Makefile (original)
+++ fsf/trunk/libc/stdio-common/Makefile Sun May 25 00:04:42 2008
@@ -57,7 +57,8 @@
tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \
tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \
tst-fwrite bug16 bug17 tst-swscanf tst-sprintf2 bug18 bug18a \
- bug19 bug19a tst-popen2 scanf13 scanf14 scanf15 bug20 bug21 bug22
+ bug19 bug19a tst-popen2 scanf13 scanf14 scanf15 bug20 bug21 bug22 \
+ scanf16 scanf17
test-srcs = tst-unbputc tst-printf
@@ -109,10 +110,12 @@
CFLAGS-errlist.c = $(fno-unit-at-a-time)
CFLAGS-siglist.c = $(fno-unit-at-a-time)
-# The following is a hack since we must compile scanf15.c without any
+# The following is a hack since we must compile scanf1{5,7}.c without any
# GNU extension. The latter are needed, though, when internal headers
# are used. So made sure we see the installed headers first.
CFLAGS-scanf15.c = -I../libio -I../stdlib -I../wcsmbs -I../time -I../string \
+ -I../wctype
+CFLAGS-scanf17.c = -I../libio -I../stdlib -I../wcsmbs -I../time -I../string \
-I../wctype
# We know the test has a format string problem.
Modified: fsf/trunk/libc/stdio-common/scanf14.c
==============================================================================
--- fsf/trunk/libc/stdio-common/scanf14.c (original)
+++ fsf/trunk/libc/stdio-common/scanf14.c Sun May 25 00:04:42 2008
@@ -59,5 +59,58 @@
else if (d != 5.25 || memcmp (c, " x", 2) != 0)
FAIL ();
+ const char *tmpdir = getenv ("TMPDIR");
+ if (tmpdir == NULL || tmpdir[0] == '\0')
+ tmpdir = "/tmp";
+
+ char fname[strlen (tmpdir) + sizeof "/tst-scanf14.XXXXXX"];
+ sprintf (fname, "%s/tst-scanf14.XXXXXX", tmpdir);
+ if (fname == NULL)
+ FAIL ();
+
+ /* Create a temporary file. */
+ int fd = mkstemp (fname);
+ if (fd == -1)
+ FAIL ();
+
+ FILE *fp = fdopen (fd, "w+");
+ if (fp == NULL)
+ FAIL ();
+ else
+ {
+ if (fputs (" 1.25s x", fp) == EOF)
+ FAIL ();
+ if (fseek (fp, 0, SEEK_SET) != 0)
+ FAIL ();
+ if (fscanf (fp, "%as%2c", &sp, c) != 2)
+ FAIL ();
+ else
+ {
+ if (strcmp (sp, "1.25s") != 0 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+ memset (sp, 'x', sizeof "1.25s");
+ free (sp);
+ }
+
+ if (freopen (fname, "r", stdin) == NULL)
+ FAIL ();
+ else
+ {
+ if (scanf ("%as%2c", &sp, c) != 2)
+ FAIL ();
+ else
+ {
+ if (strcmp (sp, "1.25s") != 0 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+ memset (sp, 'x', sizeof "1.25s");
+ free (sp);
+ }
+ }
+
+ fclose (fp);
+ }
+
+ remove (fname);
+
return result;
}
Modified: fsf/trunk/libc/stdio-common/scanf15.c
==============================================================================
--- fsf/trunk/libc/stdio-common/scanf15.c (original)
+++ fsf/trunk/libc/stdio-common/scanf15.c Sun May 25 00:04:42 2008
@@ -50,5 +50,48 @@
else if (d != 5.25 || memcmp (c, " x", 2) != 0)
FAIL ();
+ const char *tmpdir = getenv ("TMPDIR");
+ if (tmpdir == NULL || tmpdir[0] == '\0')
+ tmpdir = "/tmp";
+
+ char fname[strlen (tmpdir) + sizeof "/tst-scanf15.XXXXXX"];
+ sprintf (fname, "%s/tst-scanf15.XXXXXX", tmpdir);
+ if (fname == NULL)
+ FAIL ();
+
+ /* Create a temporary file. */
+ int fd = mkstemp (fname);
+ if (fd == -1)
+ FAIL ();
+
+ FILE *fp = fdopen (fd, "w+");
+ if (fp == NULL)
+ FAIL ();
+ else
+ {
+ if (fputs (" 1.25s x", fp) == EOF)
+ FAIL ();
+ if (fseek (fp, 0, SEEK_SET) != 0)
+ FAIL ();
+ if (fscanf (fp, "%as%2c", &f, c) != 2)
+ FAIL ();
+ else if (f != 1.25 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+
+ if (freopen (fname, "r", stdin) == NULL)
+ FAIL ();
+ else
+ {
+ if (scanf ("%as%2c", &f, c) != 2)
+ FAIL ();
+ else if (f != 1.25 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+ }
+
+ fclose (fp);
+ }
+
+ remove (fname);
+
return result;
}
Added: fsf/trunk/libc/stdio-common/scanf16.c
==============================================================================
--- fsf/trunk/libc/stdio-common/scanf16.c (added)
+++ fsf/trunk/libc/stdio-common/scanf16.c Sun May 25 00:04:42 2008
@@ -1,0 +1,147 @@
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+#define FAIL() \
+ do { \
+ result = 1; \
+ printf ("test at line %d failed\n", __LINE__); \
+ } while (0)
+
+static int
+xsscanf (const char *str, const char *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ int ret = vsscanf (str, fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+static int
+xscanf (const char *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ int ret = vscanf (fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+static int
+xfscanf (FILE *f, const char *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ int ret = vfscanf (f, fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+int
+main (void)
+{
+ wchar_t *lsp;
+ char *sp;
+ float f;
+ double d;
+ char c[8];
+ int result = 0;
+
+ if (xsscanf (" 0.25s x", "%e%3c", &f, c) != 2)
+ FAIL ();
+ else if (f != 0.25 || memcmp (c, "s x", 3) != 0)
+ FAIL ();
+ if (xsscanf (" 1.25s x", "%as%2c", &sp, c) != 2)
+ FAIL ();
+ else
+ {
+ if (strcmp (sp, "1.25s") != 0 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+ memset (sp, 'x', sizeof "1.25s");
+ free (sp);
+ }
+ if (xsscanf (" 2.25s x", "%las%2c", &d, c) != 2)
+ FAIL ();
+ else if (d != 2.25 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+ if (xsscanf (" 3.25S x", "%4aS%3c", &lsp, c) != 2)
+ FAIL ();
+ else
+ {
+ if (wcscmp (lsp, L"3.25") != 0 || memcmp (c, "S x", 3) != 0)
+ FAIL ();
+ memset (lsp, 'x', sizeof L"3.25");
+ free (lsp);
+ }
+ if (xsscanf ("4.25[0-9.] x", "%a[0-9.]%8c", &sp, c) != 2)
+ FAIL ();
+ else
+ {
+ if (strcmp (sp, "4.25") != 0 || memcmp (c, "[0-9.] x", 8) != 0)
+ FAIL ();
+ memset (sp, 'x', sizeof "4.25");
+ free (sp);
+ }
+ if (xsscanf ("5.25[0-9.] x", "%la[0-9.]%2c", &d, c) != 2)
+ FAIL ();
+ else if (d != 5.25 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+
+ const char *tmpdir = getenv ("TMPDIR");
+ if (tmpdir == NULL || tmpdir[0] == '\0')
+ tmpdir = "/tmp";
+
+ char fname[strlen (tmpdir) + sizeof "/tst-scanf16.XXXXXX"];
+ sprintf (fname, "%s/tst-scanf16.XXXXXX", tmpdir);
+ if (fname == NULL)
+ FAIL ();
+
+ /* Create a temporary file. */
+ int fd = mkstemp (fname);
+ if (fd == -1)
+ FAIL ();
+
+ FILE *fp = fdopen (fd, "w+");
+ if (fp == NULL)
+ FAIL ();
+ else
+ {
+ if (fputs (" 1.25s x", fp) == EOF)
+ FAIL ();
+ if (fseek (fp, 0, SEEK_SET) != 0)
+ FAIL ();
+ if (xfscanf (fp, "%as%2c", &sp, c) != 2)
+ FAIL ();
+ else
+ {
+ if (strcmp (sp, "1.25s") != 0 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+ memset (sp, 'x', sizeof "1.25s");
+ free (sp);
+ }
+
+ if (freopen (fname, "r", stdin) == NULL)
+ FAIL ();
+ else
+ {
+ if (xscanf ("%as%2c", &sp, c) != 2)
+ FAIL ();
+ else
+ {
+ if (strcmp (sp, "1.25s") != 0 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+ memset (sp, 'x', sizeof "1.25s");
+ free (sp);
+ }
+ }
+
+ fclose (fp);
+ }
+
+ remove (fname);
+
+ return result;
+}
Added: fsf/trunk/libc/stdio-common/scanf17.c
==============================================================================
--- fsf/trunk/libc/stdio-common/scanf17.c (added)
+++ fsf/trunk/libc/stdio-common/scanf17.c Sun May 25 00:04:42 2008
@@ -1,0 +1,128 @@
+#undef _GNU_SOURCE
+#define _XOPEN_SOURCE 600
+/* The following macro definitions are a hack. They word around disabling
+ the GNU extension while still using a few internal headers. */
+#define u_char unsigned char
+#define u_short unsigned short
+#define u_int unsigned int
+#define u_long unsigned long
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <wchar.h>
+
+#define FAIL() \
+ do { \
+ result = 1; \
+ printf ("test at line %d failed\n", __LINE__); \
+ } while (0)
+
+static int
+xsscanf (const char *str, const char *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ int ret = vsscanf (str, fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+static int
+xscanf (const char *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ int ret = vscanf (fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+static int
+xfscanf (FILE *f, const char *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ int ret = vfscanf (f, fmt, ap);
+ va_end (ap);
+ return ret;
+}
+
+int
+main (void)
+{
+ float f;
+ double d;
+ char c[8];
+ int result = 0;
+
+ if (xsscanf (" 0.25s x", "%e%3c", &f, c) != 2)
+ FAIL ();
+ else if (f != 0.25 || memcmp (c, "s x", 3) != 0)
+ FAIL ();
+ if (xsscanf (" 1.25s x", "%as%2c", &f, c) != 2)
+ FAIL ();
+ else if (f != 1.25 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+ if (xsscanf (" 2.25s x", "%las%2c", &d, c) != 2)
+ FAIL ();
+ else if (d != 2.25 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+ if (xsscanf (" 3.25S x", "%4aS%2c", &f, c) != 2)
+ FAIL ();
+ else if (f != 3.25 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+ if (xsscanf (" 4.25[0-9.] x", "%a[0-9.]%2c", &f, c) != 2)
+ FAIL ();
+ else if (f != 4.25 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+ if (xsscanf (" 5.25[0-9.] x", "%la[0-9.]%2c", &d, c) != 2)
+ FAIL ();
+ else if (d != 5.25 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+
+ const char *tmpdir = getenv ("TMPDIR");
+ if (tmpdir == NULL || tmpdir[0] == '\0')
+ tmpdir = "/tmp";
+
+ char fname[strlen (tmpdir) + sizeof "/tst-scanf17.XXXXXX"];
+ sprintf (fname, "%s/tst-scanf17.XXXXXX", tmpdir);
+ if (fname == NULL)
+ FAIL ();
+
+ /* Create a temporary file. */
+ int fd = mkstemp (fname);
+ if (fd == -1)
+ FAIL ();
+
+ FILE *fp = fdopen (fd, "w+");
+ if (fp == NULL)
+ FAIL ();
+ else
+ {
+ if (fputs (" 1.25s x", fp) == EOF)
+ FAIL ();
+ if (fseek (fp, 0, SEEK_SET) != 0)
+ FAIL ();
+ if (xfscanf (fp, "%as%2c", &f, c) != 2)
+ FAIL ();
+ else if (f != 1.25 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+
+ if (freopen (fname, "r", stdin) == NULL)
+ FAIL ();
+ else
+ {
+ if (xscanf ("%as%2c", &f, c) != 2)
+ FAIL ();
+ else if (f != 1.25 || memcmp (c, " x", 2) != 0)
+ FAIL ();
+ }
+
+ fclose (fp);
+ }
+
+ remove (fname);
+
+ return result;
+}
Modified: fsf/trunk/libc/string/Makefile
==============================================================================
--- fsf/trunk/libc/string/Makefile (original)
+++ fsf/trunk/libc/string/Makefile Sun May 25 00:04:42 2008
@@ -48,7 +48,7 @@
strop-tests := memchr memcmp memcpy memmove mempcpy memset memccpy \
stpcpy stpncpy strcat strchr strcmp strcpy strcspn \
- strlen strncmp strncpy strpbrk strrchr strspn
+ strlen strncmp strncpy strpbrk strrchr strspn memmem
tests := tester inl-tester noinl-tester testcopy test-ffs \
tst-strlen stratcliff tst-svc tst-inlcall \
bug-strncat1 bug-strspn1 bug-strpbrk1 tst-bswap \
Added: fsf/trunk/libc/string/test-memmem.c
==============================================================================
--- fsf/trunk/libc/string/test-memmem.c (added)
+++ fsf/trunk/libc/string/test-memmem.c Sun May 25 00:04:42 2008
@@ -1,0 +1,185 @@
+/* Test and measure memmem functions.
+ Copyright (C) 2008 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Written by Ulrich Drepper <drepper@xxxxxxxxxx>, 2008.
+
+ 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
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#define TEST_MAIN
+#define BUF1PAGES 20
+#define ITERATIONS 500
+#include "test-string.h"
+
+typedef char *(*proto_t) (const void *, size_t, const void *, size_t);
+void *simple_memmem (const void *, size_t, const void *, size_t);
+
+IMPL (simple_memmem, 0)
+IMPL (memmem, 1)
+
+void *
+simple_memmem (const void *haystack, size_t haystack_len, const void *needle,
+ size_t needle_len)
+{
+ const char *begin;
+ const char *const last_possible
+ = (const char *) haystack + haystack_len - needle_len;
+
+ if (needle_len == 0)
+ /* The first occurrence of the empty string is deemed to occur at
+ the beginning of the string. */
+ return (void *) haystack;
+
+ /* Sanity check, otherwise the loop might search through the whole
+ memory. */
+ if (__builtin_expect (haystack_len < needle_len, 0))
+ return NULL;
+
+ for (begin = (const char *) haystack; begin <= last_possible; ++begin)
+ if (begin[0] == ((const char *) needle)[0] &&
+ !memcmp ((const void *) &begin[1],
+ (const void *) ((const char *) needle + 1),
+ needle_len - 1))
+ return (void *) begin;
+
+ return NULL;
+}
+
+static void
+do_one_test (impl_t *impl, const void *haystack, size_t haystack_len,
+ const void *needle, size_t needle_len, const void *expected)
+{
+ void *res;
+
+ res = CALL (impl, haystack, haystack_len, needle, needle_len);
+ if (res != expected)
+ {
+ error (0, 0, "Wrong result in function %s %p %p", impl->name,
+ res, expected);
+ ret = 1;
+ return;
+ }
+
+ if (HP_TIMING_AVAIL)
+ {
+ hp_timing_t start __attribute ((unused));
+ hp_timing_t stop __attribute ((unused));
+ hp_timing_t best_time = ~ (hp_timing_t) 0;
+ size_t i;
+
+ for (i = 0; i < 32; ++i)
+ {
+ HP_TIMING_NOW (start);
+ CALL (impl, haystack, haystack_len, needle, needle_len);
+ HP_TIMING_NOW (stop);
+ HP_TIMING_BEST (best_time, start, stop);
+ }
+
+ printf ("\t%zd", (size_t) best_time);
+ }
+}
+
+static void
+do_test (const char *str, size_t len, size_t idx)
+{
+ char tmpbuf[len];
+
+ memcpy (tmpbuf, buf1 + idx, len);
+ memcpy (buf1 + idx, str, len);
+
+ if (HP_TIMING_AVAIL)
+ printf ("String %s, offset %zd:", str, idx);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, buf1, BUF1PAGES * page_size, str, len, buf1 + idx);
+
+ memcpy (buf1 + idx, tmpbuf, len);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+}
+
+static void
+do_random_tests (void)
+{
+ for (size_t n = 0; n < ITERATIONS; ++n)
+ {
+ char tmpbuf[32];
+
+ size_t shift = random () % 11;
+ size_t rel = random () % ((2 << (shift + 1)) * 64);
+ size_t idx = MIN ((2 << shift) * 64 + rel, BUF1PAGES * page_size - 2);
+ size_t len = random () % (sizeof (tmpbuf) - 1) + 1;
+ len = MIN (len, BUF1PAGES * page_size - idx - 1);
+ memcpy (tmpbuf, buf1 + idx, len);
+ for (size_t i = random () % len / 2 + 1; i > 0; --i)
+ {
+ size_t off = random () % len;
+ char ch = '0' + random () % 10;
+
+ buf1[idx + off] = ch;
+ }
+
+ if (HP_TIMING_AVAIL)
+ printf ("String %.*s, offset %zd:", (int) len, buf1 + idx, idx);
+
+ FOR_EACH_IMPL (impl, 0)
+ do_one_test (impl, buf1, BUF1PAGES * page_size, buf1 + idx, len,
+ buf1 + idx);
+
+ if (HP_TIMING_AVAIL)
+ putchar ('\n');
+
+ memcpy (buf1 + idx, tmpbuf, len);
+ }
+}
+
+
+static const char *const strs[] =
+ {
+ "00000", "00112233", "0123456789", "0000111100001111",
+ "00000111110000022222", "012345678901234567890",
+ "abc0", "aaaa0", "abcabc0"
+ };
+
+
+int
+test_main (void)
+{
+ size_t i;
+
+ test_init ();
+
+ printf ("%23s", "");
+ FOR_EACH_IMPL (impl, 0)
+ printf ("\t%s", impl->name);
+ putchar ('\n');
+
+ for (i = 0; i < BUF1PAGES * page_size; ++i)
+ buf1[i] = 60 + random () % 32;
+
+ for (i = 0; i < sizeof (strs) / sizeof (strs[0]); ++i)
+ for (size_t j = 0; j < 120; j += 7)
+ {
+ size_t len = strlen (strs[i]);
+
+ do_test (strs[i], len, j);
+ }
+
+ do_random_tests ();
+ return ret;
+}
+
+#include "../test-skeleton.c"
Modified: fsf/trunk/libc/string/test-string.h
==============================================================================
--- fsf/trunk/libc/string/test-string.h (original)
+++ fsf/trunk/libc/string/test-string.h Sun May 25 00:04:42 2008
@@ -1,5 +1,5 @@
/* Test and measure string and memory functions.
- Copyright (C) 1999, 2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2002, 2004, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Written by Jakub Jelinek <jakub@xxxxxxxxxx>, 1999.
@@ -118,6 +118,10 @@
} \
while (0)
+#ifndef BUF1PAGES
+# define BUF1PAGES 1
+#endif
+
static void
test_init (void)
{
@@ -126,11 +130,11 @@
if (page_size < MIN_PAGE_SIZE)
page_size = MIN_PAGE_SIZE;
#endif
- buf1 = mmap (0, 2 * page_size, PROT_READ | PROT_WRITE,
+ buf1 = mmap (0, (BUF1PAGES + 1) * page_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
if (buf1 == MAP_FAILED)
error (EXIT_FAILURE, errno, "mmap failed");
- if (mprotect (buf1 + page_size, page_size, PROT_NONE))
+ if (mprotect (buf1 + BUF1PAGES * page_size, page_size, PROT_NONE))
error (EXIT_FAILURE, errno, "mprotect failed");
buf2 = mmap (0, 2 * page_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON, -1, 0);
@@ -145,7 +149,7 @@
srandom (seed);
}
- memset (buf1, 0xa5, page_size);
+ memset (buf1, 0xa5, BUF1PAGES * page_size);
memset (buf2, 0x5a, page_size);
}