about summary refs log tree commit diff
path: root/string
diff options
context:
space:
mode:
Diffstat (limited to 'string')
-rw-r--r--string/tst-xbzero-opt.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index aab4a7f715..898345b288 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -97,6 +97,17 @@ static const unsigned char test_pattern[16] =
 
 static ucontext_t uc_main, uc_co;
 
+static __attribute__ ((noinline, noclone)) int
+use_test_buffer (unsigned char *buf)
+{
+  unsigned int sum = 0;
+
+  for (unsigned int i = 0; i < PATTERN_REPS; i++)
+    sum += buf[i * PATTERN_SIZE];
+
+  return (sum == 2 * PATTERN_REPS) ? 0 : 1;
+}
+
 /* Always check the test buffer immediately after filling it; this
    makes externally visible side effects depend on the buffer existing
    and having been filled in.  */
@@ -116,6 +127,10 @@ prepare_test_buffer (unsigned char *buf)
 
   if (swapcontext (&uc_co, &uc_main))
     abort ();
+
+  /* Force the compiler to really copy the pattern to buf.  */
+  if (use_test_buffer (buf))
+    abort ();
 }
 
 static void