From c97a1282a4d9ff5d462fa5d8f20797ded3629500 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Mon, 21 Mar 2011 05:35:38 -0400 Subject: Handle page boundaries in x86 SSE4.2 strncmp. --- string/test-strncmp.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'string') diff --git a/string/test-strncmp.c b/string/test-strncmp.c index 3687879c25..11c681e7e1 100644 --- a/string/test-strncmp.c +++ b/string/test-strncmp.c @@ -199,6 +199,27 @@ do_test (size_t align1, size_t align2, size_t len, size_t n, int max_char, putchar ('\n'); } +static void +do_page_test (size_t offset1, size_t offset2, char *s2) +{ + char *s1; + int exp_result; + + if (offset1 >= page_size || offset2 >= page_size) + return; + + s1 = (char *) (buf1 + offset1); + s2 += offset2; + + exp_result= *s1; + + FOR_EACH_IMPL (impl, 0) + { + check_result (impl, s1, s2, page_size, -exp_result); + check_result (impl, s2, s1, page_size, exp_result); + } +} + static void do_random_tests (void) { @@ -312,6 +333,25 @@ check1 (void) } } +static void +check2 (void) +{ + size_t i; + char *s1, *s2; + + s1 = (char *) buf1; + for (i = 0; i < page_size - 1; i++) + s1[i] = 23; + s1[i] = 0; + + s2 = strdup (s1); + + for (i = 0; i < 64; ++i) + do_page_test (3990 + i, 2635, s2); + + free (s2); +} + int test_main (void) { @@ -320,6 +360,7 @@ test_main (void) test_init (); check1 (); + check2 (); printf ("%23s", ""); FOR_EACH_IMPL (impl, 0) -- cgit 1.4.1