about summary refs log tree commit diff
path: root/string/stratcliff.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2009-04-07 14:53:04 +0000
committerUlrich Drepper <drepper@redhat.com>2009-04-07 14:53:04 +0000
commitddba0f17007795ac53ee2f82e6e954dc1a50d104 (patch)
tree62715ca2e6a1422c4a196ed13d80ef2496488a19 /string/stratcliff.c
parent4bcb2658ff02d72aa83640cf76ac65a430f17004 (diff)
downloadglibc-ddba0f17007795ac53ee2f82e6e954dc1a50d104.tar.gz
glibc-ddba0f17007795ac53ee2f82e6e954dc1a50d104.tar.xz
glibc-ddba0f17007795ac53ee2f82e6e954dc1a50d104.zip
* string/stratcliff.c (do_test): Add memchr tests..
	* sysdeps/x86_64/memchr.S: Fix handling of end of buffer after
	first read quad word.
Diffstat (limited to 'string/stratcliff.c')
-rw-r--r--string/stratcliff.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/string/stratcliff.c b/string/stratcliff.c
index 77fe2bcca9..f90616c260 100644
--- a/string/stratcliff.c
+++ b/string/stratcliff.c
@@ -1,5 +1,5 @@
 /* Test for string function add boundaries of usable memory.
-   Copyright (C) 1996,1997,1999-2002,2003,2007 Free Software Foundation, Inc.
+   Copyright (C) 1996,1997,1999-2003,2007, 2009 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -46,6 +46,7 @@
 # define STPNCPY stpncpy
 # define MEMCPY memcpy
 # define MEMPCPY mempcpy
+# define MEMCHR memchr
 #endif
 
 
@@ -205,6 +206,37 @@ do_test (void)
 	    }
         }
 
+      /* memchr test */
+      for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer)
+        {
+	  for (middle = MAX (outer, nchars - 64); middle < nchars; ++middle)
+	    {
+	      adr[middle] = L('V');
+
+	      CHAR *cp = MEMCHR (&adr[outer], L('V'), 3 * size);
+
+	      if (cp - &adr[outer] != middle - outer)
+		{
+		  printf ("%s flunked for outer = %d, middle = %d\n",
+			  STRINGIFY (MEMCHR), outer, middle);
+		  result = 1;
+		}
+
+	      adr[middle] = L('T');
+	    }
+        }
+      for (outer = nchars - 1; outer >= MAX (0, nchars - 128); --outer)
+        {
+	  CHAR *cp = MEMCHR (&adr[outer], L('V'), nchars - outer);
+
+	  if (cp != NULL)
+	    {
+	      printf ("%s flunked for outer = %d\n",
+		      STRINGIFY (MEMCHR), outer);
+	      result = 1;
+	    }
+        }
+
       /* This function only exists for single-byte characters.  */
 #ifndef WCSTEST
       /* rawmemchr test */