This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH][benchtests] Append volatile keyword to type instead of prepending
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Thu, 5 Dec 2013 11:01:36 +0530
- Subject: [PATCH][benchtests] Append volatile keyword to type instead of prepending
- Authentication-results: sourceware.org; auth=none
- References: <20131204074418 dot GP14845 at spoyarek dot pnq dot redhat dot com> <Pine dot LNX dot 4 dot 64 dot 1312041432130 dot 17948 at digraph dot polyomino dot org dot uk>
On Wed, Dec 04, 2013 at 02:34:27PM +0000, Joseph S. Myers wrote:
> On Wed, 4 Dec 2013, Siddhesh Poyarekar wrote:
>
> > which I am unable to currently avoid because I need the volatile in
> > place to prevent gcc from inlining the math functions. I'll figure
> > out a way to fix this warning later if that is OK.
>
> The logical equivalent for strtod would be const char *volatile - making
> the pointer itself volatile - so make sure that "volatile" is being used
> correctly to qualify whatever the relevant type is, regardless of the
> syntax used for that type, rather than simply being concatenated with a
> type name.
Thanks, since the current use cases for the input file are limited to
constant input data, i.e. numbers and strings and (maybe) structures
(and not their pointers), I believe we really only need const 'char *
volatile'. Also, given that we can write 'volatile int' as 'int
volatile' and that we don't need more complicated semantics like 'char
volatile *' or similar, we could just append the volatile keyword to
the type instead of prepending. Does that look OK? I have verified
that it fixes the build warnings and the benchmark outputs are still
OK.
Siddhesh
* scripts/bench.pl: Append volatile keyword to type.
diff --git a/scripts/bench.pl b/scripts/bench.pl
index 90441e1..10f0ba4 100755
--- a/scripts/bench.pl
+++ b/scripts/bench.pl
@@ -98,7 +98,7 @@ my $bench_func = "#define CALL_BENCH_FUNC(v, i) $func (";
my $outvars = "";
if ($ret ne "void") {
- $outvars = "static volatile $ret ret;\n";
+ $outvars = "static $ret volatile ret;\n";
}
# Print the definitions and macros.
@@ -139,7 +139,7 @@ if (@args > 0) {
$bench_func = "$bench_func &out$num";
}
else {
- $arg_struct = "$arg_struct volatile $arg arg$num;";
+ $arg_struct = "$arg_struct $arg volatile arg$num;";
$bench_func = "$bench_func variants[v].in[i].arg$num";
}