From 3c23c3f075cd26e1bdae3e75c3228af9279bea55 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 18 Feb 2021 02:35:38 -0800 Subject: [PATCH] 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 Maintainer: Andreas Sandberg Tested-by: kokoro --- src/cpu/testers/traffic_gen/traffic_gen.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cpu/testers/traffic_gen/traffic_gen.cc b/src/cpu/testers/traffic_gen/traffic_gen.cc index 1ea4d5eab8..6e1a00a304 100644 --- a/src/cpu/testers/traffic_gen/traffic_gen.cc +++ b/src/cpu/testers/traffic_gen/traffic_gen.cc @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -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