W-M-R commented on code in PR #15484:
URL: https://github.com/apache/nuttx/pull/15484#discussion_r1912647164


##########
mm/mm_heap/mm.h:
##########
@@ -173,7 +183,16 @@ typedef size_t mmsize_t;
 
 struct mm_allocnode_s
 {
+#ifdef CONFIG_MM_NODE_PENDING
+  union
+  {
+    mmsize_t preceding;                     /* Physical preceding chunk size */

Review Comment:
   It is invalid to do aligned_data(MM_ALIGN) on precding alone.
   ```
   #include <stdio.h>
   
   
   struct st0
   {
       char a;
       char b;
   }__attribute__((aligned(16)));
   
   struct st1
   {
       char a __attribute__((aligned(16)));
       char b;
   };
   
   struct st2
   {
       char a;
       char b __attribute__((aligned(16)));
   };
   
   struct st3
   {
       char a __attribute__((aligned(16)));
       char b __attribute__((aligned(16)));
       char d[15];
   }__attribute__((aligned(16)));
   
   struct st4
   {
       union
       {
           char a;
           char a_align[16];
       };
   
       union
       {
           char b;
           char b_align[16];
       };
   };
   
   #define OFFSET(struct, member) (&(((struct *)0)->member))
   
   #define PRINTF_STRUCT(struct) \
       printf("%s: ", #struct); \
       printf("size: %d\n", sizeof(struct)); \
       printf("member a: %d\n", OFFSET(struct, a)); \
       printf("member b: %d\n", OFFSET(struct, b));
   
   int main()
   {
       PRINTF_STRUCT(struct st0);
       PRINTF_STRUCT(struct st1);
       PRINTF_STRUCT(struct st2);
       PRINTF_STRUCT(struct st3);
       PRINTF_STRUCT(struct st4);
   }
   
   
   ```
   ```
   struct st0: size: 16
   member a: 0
   member b: 1
   struct st1: size: 16
   member a: 0
   member b: 1
   struct st2: size: 32
   member a: 0
   member b: 16
   struct st3: size: 32
   member a: 0
   member b: 16
   struct st4: size: 32
   member a: 0
   member b: 16
   ```
   My understanding is that the alignment of __attribute__((aligned(16))) is 
more about the alignment of the size of the entire structure, and the alignment 
of a single member is limited to the alignment of access, not size.



-- 
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-unsubscr...@nuttx.apache.org

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

Reply via email to