From b6b6d39bb6cdba024c64d070f1497f76faf383af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=C3=85berg?= Date: Fri, 22 Jan 2021 12:50:14 +0100 Subject: [PATCH] lib/os/heap: introduce option to force big heap mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This option allows forcing big heap mode. Useful on for getting 8-byte aligned blocks on 32-bit machines. Signed-off-by: Martin Ã…berg --- arch/sparc/Kconfig | 4 ++++ lib/os/Kconfig | 10 ++++++++++ lib/os/heap.h | 3 +++ 3 files changed, 17 insertions(+) diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index bc3a6ac118e..d15b4a57f8a 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig @@ -13,6 +13,10 @@ config SPARC_NWIN help Number of implemented register windows. +# ISA requires 8-byte alignment for 64-bit data access +config SYS_HEAP_ALWAYS_BIG_MODE + default y + config GEN_ISR_TABLES default y diff --git a/lib/os/Kconfig b/lib/os/Kconfig index dfffc03b976..6db8af8e115 100644 --- a/lib/os/Kconfig +++ b/lib/os/Kconfig @@ -46,6 +46,16 @@ config SYS_HEAP_ALLOC_LOOPS keeps the maximum runtime at a tight bound so that the heap is useful in locked or ISR contexts. +config SYS_HEAP_ALWAYS_BIG_MODE + bool "Always use the heap big chunks mode" + help + The sys_heap allocator by default returns pointers to blocks + which are guaranteed to be aligned to the pointer size. + By enabling the "big chunks" mode, the returned blocks are + guaranteed to be 8 byte aligned, also on 32-bit platforms. + If this option is enabled, the "big chunks" mode will always + be used by sys_heap. + config PRINTK64 bool "Enable 64 bit printk conversions (DEPRECATED)" help diff --git a/lib/os/heap.h b/lib/os/heap.h index d2b0d6d049c..aca5403e811 100644 --- a/lib/os/heap.h +++ b/lib/os/heap.h @@ -66,6 +66,9 @@ struct z_heap { static inline bool big_heap_chunks(size_t chunks) { + if (IS_ENABLED(CONFIG_SYS_HEAP_ALWAYS_BIG_MODE)) { + return 1; + } return sizeof(void *) > 4U || chunks > 0x7fffU; }