diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2015-09-09 08:50:20 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2015-09-15 17:56:17 -0700 |
commit | 2bff01f1cad298a11d5f28db61cc1f88629b50c9 (patch) | |
tree | 4af829c9e9393238d28dd300a4d243c13fd6840d /include | |
parent | 552e3ceaee84c8745ada3284fe940fb6e9a4b6a8 (diff) | |
download | chrome-ec-2bff01f1cad298a11d5f28db61cc1f88629b50c9.tar.gz |
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 <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/299515
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/math_util.h | 7 |
1 files changed, 5 insertions, 2 deletions
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); } /** |