This is an automated email from the ASF dual-hosted git repository.

jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 3e971d2e6d mm_heap: double malloced memory default alignment (4 -> 8, 
8 -> 16)
3e971d2e6d is described below

commit 3e971d2e6d753519985a3e044d4dd21026ec1d12
Author: wangbowen6 <[email protected]>
AuthorDate: Mon Mar 6 16:10:31 2023 +0800

    mm_heap: double malloced memory default alignment (4 -> 8, 8 -> 16)
    
    Base on the gnu libc standard:
    
https://www.gnu.org/software/libc/manual/html_node/Aligned-Memory-Blocks.html
    
    Change the default memory aligment to 8 bytes for 32-bit system and
    16 bytes for 64-bit system.
    
    Signed-off-by: wangbowen6 <[email protected]>
---
 mm/Kconfig      | 2 +-
 mm/mm_heap/mm.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/Kconfig b/mm/Kconfig
index 71a95c80fa..6d702f7629 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -63,7 +63,7 @@ config MM_KERNEL_HEAPSIZE
 
 config MM_DFAULT_ALIGNMENT
        int "Memory default alignment in bytes"
-       default 8
+       default 0
        range 0 64
        ---help---
                The memory default alignment in bytes, if this value is 0, the 
real
diff --git a/mm/mm_heap/mm.h b/mm/mm_heap/mm.h
index adc6f24d28..c787ace6af 100644
--- a/mm/mm_heap/mm.h
+++ b/mm/mm_heap/mm.h
@@ -111,7 +111,7 @@
 #define MM_NNODES        (MM_MAX_SHIFT - MM_MIN_SHIFT + 1)
 
 #if CONFIG_MM_DFAULT_ALIGNMENT == 0
-#  define MM_ALIGN       sizeof(uintptr_t)
+#  define MM_ALIGN       (2 * sizeof(uintptr_t))
 #else
 #  define MM_ALIGN       CONFIG_MM_DFAULT_ALIGNMENT
 #endif

Reply via email to