public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/maskray/grte] Forestall optimization-out of a buffer.
@ 2021-08-27 23:25 Fangrui Song
  0 siblings, 0 replies; only message in thread
From: Fangrui Song @ 2021-08-27 23:25 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=40513af8adceabbfbfd7c64631c0fb6e57373c23

commit 40513af8adceabbfbfd7c64631c0fb6e57373c23
Author: Stan Shebs <stanshebs@google.com>
Date:   Wed May 9 11:26:35 2018 -0700

    Forestall optimization-out of a buffer.

Diff:
---
 string/tst-xbzero-opt.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index cf7041f37a..e9c411b2ef 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -110,11 +110,17 @@ prepare_test_buffer (unsigned char *buf)
     abort ();
 }
 
+/* Use a volatile global to ensure that aggressive compilers don't
+   decide that the test buffer is unused and evaporate it.  */
+
+volatile unsigned char *vol_glob;
+
 static void
 setup_no_clear (void)
 {
   unsigned char buf[TEST_BUFFER_SIZE];
   prepare_test_buffer (buf);
+  vol_glob = buf;
 }
 
 static void
@@ -123,6 +129,7 @@ setup_ordinary_clear (void)
   unsigned char buf[TEST_BUFFER_SIZE];
   prepare_test_buffer (buf);
   memset (buf, 0, TEST_BUFFER_SIZE);
+  vol_glob = buf;
 }
 
 static void


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-27 23:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-27 23:25 [glibc/maskray/grte] Forestall optimization-out of a buffer Fangrui Song

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).