lib/os/heap: introduce option to force big heap mode

This option allows forcing big heap mode. Useful on for getting 8-byte
aligned blocks on 32-bit machines.

Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
This commit is contained in:
Martin Åberg 2021-01-22 12:50:14 +01:00 committed by Anas Nashif
commit b6b6d39bb6
3 changed files with 17 additions and 0 deletions

View file

@ -13,6 +13,10 @@ config SPARC_NWIN
help help
Number of implemented register windows. 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 config GEN_ISR_TABLES
default y default y

View file

@ -46,6 +46,16 @@ config SYS_HEAP_ALLOC_LOOPS
keeps the maximum runtime at a tight bound so that the heap keeps the maximum runtime at a tight bound so that the heap
is useful in locked or ISR contexts. 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 config PRINTK64
bool "Enable 64 bit printk conversions (DEPRECATED)" bool "Enable 64 bit printk conversions (DEPRECATED)"
help help

View file

@ -66,6 +66,9 @@ struct z_heap {
static inline bool big_heap_chunks(size_t chunks) 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; return sizeof(void *) > 4U || chunks > 0x7fffU;
} }