cpu: Use std::abs() in traffic_gen.cc.
When building with clang with the --without-tcmalloc flag set, the -fno-builtin flag is not used, and clang can then detect that the integer version of abs(), apparently the C version, is being used on a floating point value in traffic_gen.cc. This change takes clang's suggestion to use std::abs instead, and also includes a header file which will provide it. Change-Id: Ic28ed7454b2ac00c89328d9d0314aed74e946643 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/41597 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include <libgen.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
@@ -331,9 +332,10 @@ TrafficGen::parseConfig()
|
||||
}
|
||||
|
||||
// avoid comparing floating point numbers
|
||||
if (abs(sum - 1.0) > 0.001)
|
||||
if (std::fabs(sum - 1.0) > 0.001) {
|
||||
fatal("%s has transition probability != 1 for state %d\n",
|
||||
name(), i);
|
||||
}
|
||||
}
|
||||
|
||||
// close input file
|
||||
|
||||
Reference in New Issue
Block a user