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:
Gabe Black
2021-02-18 02:35:38 -08:00
parent 11f0fe0283
commit 3c23c3f075

View File

@@ -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