summaryrefslogtreecommitdiff
path: root/string/tester.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2010-07-26 08:37:08 -0700
committerUlrich Drepper <drepper@redhat.com>2010-07-26 08:37:08 -0700
commit24fb0f88ed29d21b6034559e9c55545f22556bc0 (patch)
tree51b61ee2442da648a3fc724437188b2a99aadcff /string/tester.c
parent8e96b93aa7855683d0be3c65ce81e66d0786ba84 (diff)
downloadglibc-24fb0f88ed29d21b6034559e9c55545f22556bc0.tar.gz
Add optimized x86-64 implementation of strnlen.
While at it, beef up the test suite for strnlen and add performance tests for it, too.
Diffstat (limited to 'string/tester.c')
-rw-r--r--string/tester.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/string/tester.c b/string/tester.c
index 773e969a35..01da0465da 100644
--- a/string/tester.c
+++ b/string/tester.c
@@ -1,5 +1,5 @@
/* Tester for string functions.
- Copyright (C) 1995-2001, 2003, 2005, 2008 Free Software Foundation, Inc.
+ Copyright (C) 1995-2001, 2003, 2005, 2008, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -441,20 +441,21 @@ test_strnlen (void)
check (strnlen ("", 10) == 0, 1); /* Empty. */
check (strnlen ("a", 10) == 1, 2); /* Single char. */
check (strnlen ("abcd", 10) == 4, 3); /* Multiple chars. */
- check (strnlen ("foo", (size_t)-1) == 3, 4); /* limits of n. */
-
- {
- char buf[4096];
- int i;
- char *p;
- for (i=0; i < 0x100; i++)
- {
- p = (char *) ((unsigned long int)(buf + 0xff) & ~0xff) + i;
- strcpy (p, "OK");
- strcpy (p+3, "BAD/WRONG");
- check (strnlen (p, 100) == 2, 5+i);
- }
- }
+ check (strnlen ("foo", (size_t) -1) == 3, 4); /* limits of n. */
+ check (strnlen ("abcd", 0) == 0, 5); /* Restricted. */
+ check (strnlen ("abcd", 1) == 1, 6); /* Restricted. */
+ check (strnlen ("abcd", 2) == 2, 7); /* Restricted. */
+ check (strnlen ("abcd", 3) == 3, 8); /* Restricted. */
+ check (strnlen ("abcd", 4) == 4, 9); /* Restricted. */
+
+ char buf[4096];
+ for (int i = 0; i < 0x100; ++i)
+ {
+ char *p = (char *) ((unsigned long int)(buf + 0xff) & ~0xff) + i;
+ strcpy (p, "OK");
+ strcpy (p + 3, "BAD/WRONG");
+ check (strnlen (p, 100) == 2, 10 + i);
+ }
}
static void
@@ -988,7 +989,7 @@ test_memcmp (void)
int cnt = 1;
char one[21];
char two[21];
-
+
it = "memcmp";
check(memcmp("a", "a", 1) == 0, cnt++); /* Identity. */
check(memcmp("abc", "abc", 3) == 0, cnt++); /* Multicharacter. */