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 13:57:41 UTC

[GitHub] [incubator-nuttx] Donny9 opened a new pull request, #7449: mm/mm_heap: optimize MM_XX_SHIFT define

Donny9 opened a new pull request, #7449:
URL: https://github.com/apache/incubator-nuttx/pull/7449

   ## Summary
   1. using LOG2_CEIL to calc MM_MIN_SHIFT/MM_MAX_SHIFT at compile time.
   2. define MM_MASK_BIT to optimze code when using more significant bit of member preceding in furure.
   ## Impact
   optimize header file
   ## Testing
   local test
   


-- 
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


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

Posted by GitBox <gi...@apache.org>.
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


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

Posted by GitBox <gi...@apache.org>.
Donny9 commented on code in PR #7449:
URL: https://github.com/apache/incubator-nuttx/pull/7449#discussion_r1007562451


##########
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:
   ok, thank you.



##########
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 + \
+                FLS32((size_t)(n) >> 32) : FLS32(n))
+#else
+#define FLS(n) FLS32(n)

Review Comment:
   Done!



-- 
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


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

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7449:
URL: https://github.com/apache/incubator-nuttx/pull/7449#discussion_r1007362994


##########
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 + \
+                FLS32((size_t)(n) >> 32) : FLS32(n))
+#else
+#define FLS(n) FLS32(n)

Review Comment:
   ```suggestion
   #  define FLS(n) FLS32(n)
   ```



##########
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:
   yeah, but many places will need such update. `ull` should work for RV64 as well



##########
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) & 0xffffffff00000000ull ? 32 + \
   ```



-- 
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


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

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #7449:
URL: https://github.com/apache/incubator-nuttx/pull/7449#discussion_r1007689162


##########
mm/mm_heap/mm.h:
##########
@@ -60,38 +61,14 @@
  *   minor performance losses.
  */
 
+#define MM_MIN_SHIFT      (LOG2_CEIL(sizeof(struct mm_freenode_s)))

Review Comment:
   ```suggestion
   #define MM_MIN_SHIFT      LOG2_CEIL(sizeof(struct mm_freenode_s))
   ```
   



-- 
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


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

Posted by GitBox <gi...@apache.org>.
Donny9 commented on code in PR #7449:
URL: https://github.com/apache/incubator-nuttx/pull/7449#discussion_r1007902415


##########
mm/mm_heap/mm.h:
##########
@@ -60,38 +61,14 @@
  *   minor performance losses.
  */
 
+#define MM_MIN_SHIFT      (LOG2_CEIL(sizeof(struct mm_freenode_s)))

Review Comment:
   Done!



-- 
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


[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #7449: mm/mm_heap: optimize MM_XX_SHIFT define

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged PR #7449:
URL: https://github.com/apache/incubator-nuttx/pull/7449


-- 
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


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

Posted by GitBox <gi...@apache.org>.
Donny9 commented on code in PR #7449:
URL: https://github.com/apache/incubator-nuttx/pull/7449#discussion_r1007562531


##########
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:
   Done!



-- 
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