From 2bff01f1cad298a11d5f28db61cc1f88629b50c9 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Wed, 9 Sep 2015 08:50:20 -0700 Subject: common: math: Stop using FP_BITS directly. To be able to use hardware FPUs, use fp_ functions instead of FP_BITS in application code. BRANCH=smaug BUG=chrome-os-partner:39900 TEST=compile. Change-Id: I8a1339140eb5ddab32dd3edc58fb5d3ccaef52e2 Signed-off-by: Gwendal Grignou Reviewed-on: https://chromium-review.googlesource.com/299515 Reviewed-by: Randall Spangler Reviewed-by: Alec Berg --- include/math_util.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include/math_util.h') diff --git a/include/math_util.h b/include/math_util.h index 5412655ec3..948d501033 100644 --- a/include/math_util.h +++ b/include/math_util.h @@ -11,6 +11,9 @@ /* Fixed-point type */ typedef int32_t fp_t; +/* Type used during fp operation */ +typedef int64_t fp_inter_t; + /* Number of bits left of decimal point for fixed-point */ #define FP_BITS 16 @@ -32,7 +35,7 @@ typedef int32_t fp_t; */ static inline fp_t fp_mul(fp_t a, fp_t b) { - return (fp_t)(((int64_t)a * b) >> FP_BITS); + return (fp_t)(((fp_inter_t)a * b) >> FP_BITS); } /** @@ -40,7 +43,7 @@ static inline fp_t fp_mul(fp_t a, fp_t b) */ static inline fp_t fp_div(fp_t a, fp_t b) { - return (fp_t)(((int64_t)a << FP_BITS) / b); + return (fp_t)(((fp_inter_t)a << FP_BITS) / b); } /** -- cgit v1.2.1