base: Fix base/cprintftime.cc.
The compiler is unhappy that one of the parameters in a call to sprintf is also the buffer it's supposed to output to, when that parameter is marked "restrict", which means it shouldn't alias to other arguments. Also, this code can't go inside the gem5 namespace, since it has a main() function in it. The linker will look for main(), not gem5::main(). Change-Id: Ib17c601aefdc3e7201eba021dafb1c51204d54bc Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48423 Maintainer: Gabe Black <gabe.black@gmail.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -36,9 +36,6 @@
|
||||
|
||||
#include "base/cprintf.hh"
|
||||
|
||||
namespace gem5
|
||||
{
|
||||
|
||||
volatile int stop = false;
|
||||
|
||||
void
|
||||
@@ -65,30 +62,31 @@ main()
|
||||
do_test(10);
|
||||
while (!stop) {
|
||||
std::stringstream result;
|
||||
ccprintf(result,
|
||||
"this is a %s of %d iterations %3.2f %p\n",
|
||||
"test", iterations, 51.934, &result);
|
||||
gem5::ccprintf(result,
|
||||
"this is a %s of %d iterations %3.2f %p\n",
|
||||
"test", iterations, 51.934, &result);
|
||||
|
||||
iterations += 1;
|
||||
}
|
||||
|
||||
cprintf("completed %d iterations of ccprintf in 10s, %f iterations/s\n",
|
||||
gem5::cprintf(
|
||||
"completed %d iterations of ccprintf in 10s, %f iterations/s\n",
|
||||
iterations, iterations / 10.0);
|
||||
|
||||
do_test(10);
|
||||
while (!stop) {
|
||||
char result[1024];
|
||||
int dummy;
|
||||
sprintf(result,
|
||||
"this is a %s of %d iterations %3.2f %p\n",
|
||||
"test", iterations, 51.934, &result);
|
||||
"test", iterations, 51.934, &dummy);
|
||||
|
||||
iterations += 1;
|
||||
}
|
||||
|
||||
cprintf("completed %d iterations of sprintf in 10s, %f iterations/s\n",
|
||||
gem5::cprintf(
|
||||
"completed %d iterations of sprintf in 10s, %f iterations/s\n",
|
||||
iterations, iterations / 10.0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace gem5
|
||||
|
||||
Reference in New Issue
Block a user