summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorReinhard Panhuber <[email protected]>2022-03-19 13:37:54 +0100
committerReinhard Panhuber <[email protected]>2022-03-19 13:37:54 +0100
commitfdfde8883ff6d929f44706d1fd3ee3cec8702bac (patch)
tree09de3d1d7578b0c27447d2d01aa80adab044cc4d /src/common
parentceac9d64c07b95d2c34263386e212e5480cda97c (diff)
Implement power of two, shift, and float calculation
Diffstat (limited to 'src/common')
-rw-r--r--src/common/tusb_common.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h
index 58591f0be..bcdf8933a 100644
--- a/src/common/tusb_common.h
+++ b/src/common/tusb_common.h
@@ -149,6 +149,16 @@ static inline uint8_t tu_log2(uint32_t value)
return result;
}
+//static inline uint8_t tu_log2(uint32_t value)
+//{
+// return sizeof(uint32_t) * CHAR_BIT - __builtin_clz(x) - 1;
+//}
+
+static inline bool tu_is_power_of_two(uint32_t value)
+{
+ return (value != 0) && ((value & (value - 1)) == 0);
+}
+
//------------- Unaligned Access -------------//
#if TUP_ARCH_STRICT_ALIGN