You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/27 15:21:53 UTC

[GitHub] [incubator-nuttx] gustavonihei commented on a diff in pull request #7449: mm/mm_heap: optimize MM_XX_SHIFT define

gustavonihei commented on code in PR #7449:
URL: https://github.com/apache/incubator-nuttx/pull/7449#discussion_r1007044127


##########
include/nuttx/lib/math32.h:
##########
@@ -29,6 +29,35 @@
 
 #include <stdint.h>
 
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Returns one plus the index of the most significant 1-bit of n,
+ * or if n is zero, returns zero.
+ */
+
+#if UINTPTR_MAX > UINT32_MAX
+#define FLS(n) ((n) & 0xffffffff00000000ull ? 32 + \

Review Comment:
   ```suggestion
   #define FLS(n) ((n) & UINT64_C(0xffffffff00000000) ? 32 + \
   ```
   Improve portability by using the conversion macros from `inttypes.h`.
   For 64-bit architectures (e.g. RV64) the `ul` should be sufficient.



##########
include/nuttx/lib/math32.h:
##########
@@ -29,6 +29,35 @@
 
 #include <stdint.h>
 
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Returns one plus the index of the most significant 1-bit of n,
+ * or if n is zero, returns zero.
+ */
+
+#if UINTPTR_MAX > UINT32_MAX
+#define FLS(n) ((n) & 0xffffffff00000000ull ? 32 + \

Review Comment:
   ```suggestion
   #define FLS(n) ((n) & UINT64_C(0xffffffff00000000) ? 32 + \
   ```
   Improve portability by using the conversion macros from `inttypes.h`.
   For 64-bit architectures (e.g. RV64) the `ul` suffix should be sufficient.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org