summaryrefslogtreecommitdiff
path: root/include/math_util.h
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@google.com>2021-09-24 09:37:27 -0600
committerCommit Bot <commit-bot@chromium.org>2021-09-27 23:15:52 +0000
commit43e1a59c047bd28917251d13e47e00594624b277 (patch)
tree10d995002f921fb35c73c00ccc2f152884a1cddd /include/math_util.h
parentb6afc9e875cc6494ed6adb79c579f73093cff0c2 (diff)
downloadchrome-ec-43e1a59c047bd28917251d13e47e00594624b277.tar.gz
math_util: add creation of 64 bit bitmasks
32 bit processors don't all allow left shift of 64 bit values. So add this to make it work with 32 and 64 bit processors. uint64_t bitmask_uint64(int offset); BUG=none BRANCH=none TEST=make buildall Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I114111c4774bb935a35c7711821b1f2f2f9c037d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3182630 Tested-by: Denis Brockus <dbrockus@chromium.org> Auto-Submit: Denis Brockus <dbrockus@chromium.org> Commit-Queue: Yuval Peress <peress@google.com> Reviewed-by: Yuval Peress <peress@google.com>
Diffstat (limited to 'include/math_util.h')
-rw-r--r--include/math_util.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/math_util.h b/include/math_util.h
index b78523de54..9ee075839e 100644
--- a/include/math_util.h
+++ b/include/math_util.h
@@ -9,6 +9,7 @@
#define __CROS_EC_MATH_UTIL_H
#include <stdint.h>
+#include "limits.h"
#ifdef CONFIG_FPU
typedef float fp_t;
@@ -230,4 +231,13 @@ void rotate_inv(const intv3_t v, const mat33_fp_t R, intv3_t res);
*/
int round_divide(int64_t dividend, int divisor);
+/**
+ * Create a 64 bit bitmask of 2^offset
+ */
+#if ULONG_MAX == 0xFFFFFFFFUL
+uint64_t bitmask_uint64(int offset);
+#else
+#define bitmask_uint64(o) ((uint64_t)1 << (o))
+#endif
+
#endif /* __CROS_EC_MATH_UTIL_H */