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/08/12 12:23:26 UTC

[GitHub] [incubator-nuttx] davids5 commented on a diff in pull request #6834: modify iob to support header padding and alignment features

davids5 commented on code in PR #6834:
URL: https://github.com/apache/incubator-nuttx/pull/6834#discussion_r944409428


##########
mm/iob/iob_initialize.c:
##########
@@ -30,14 +30,36 @@
 
 #include "iob.h"
 
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define ROUNDUP(x, y)     (((x) + (y) - 1) / (y) * (y))
+
+/* Fix the I/O Buffer size with specified alignment size */
+
+#define IOB_ALIGN_SIZE    ROUNDUP(sizeof(struct iob_s), CONFIG_IOB_ALIGNMENT)
+#define IOB_BUFFER_SIZE   (IOB_ALIGN_SIZE * CONFIG_IOB_NBUFFERS + \
+                           CONFIG_IOB_ALIGNMENT - 1)
+
 /****************************************************************************
  * Private Data
  ****************************************************************************/
 
-/* This is a pool of pre-allocated I/O buffers */
+/* Following raw buffer will be divided into iob_s instances, the initial
+ * procedure will ensure that the member io_head of each iob_s is aligned
+ * to the CONFIG_IOB_ALIGNMENT memory boundary.
+ */
+
+static uint8_t g_iob_buffer[IOB_BUFFER_SIZE]
+#ifdef CONFIG_IOB_SECTION

Review Comment:
   Would you object to a #define IOB_LOCATION the is defined in Pre-processor Definitions 
   ```
   #ifdef CONFIG_IOB_SECTION
   #  define   IOB_LOCATION locate_data(CONFIG_IOB_SECTION)
   #else
   #  define   IOB_LOCATTION 
   #endif
   ```
   and used here?
   
   ```static uint8_t g_iob_buffer[IOB_BUFFER_SIZE] IOB_LOCATION;```
   
   
   



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