Skip to content

Commit b6b6d39

Browse files
tbr-ttnashif
authored andcommitted
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 <[email protected]>
1 parent 80b9080 commit b6b6d39

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

arch/sparc/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ config SPARC_NWIN
1313
help
1414
Number of implemented register windows.
1515

16+
# ISA requires 8-byte alignment for 64-bit data access
17+
config SYS_HEAP_ALWAYS_BIG_MODE
18+
default y
19+
1620
config GEN_ISR_TABLES
1721
default y
1822

lib/os/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ config SYS_HEAP_ALLOC_LOOPS
4646
keeps the maximum runtime at a tight bound so that the heap
4747
is useful in locked or ISR contexts.
4848

49+
config SYS_HEAP_ALWAYS_BIG_MODE
50+
bool "Always use the heap big chunks mode"
51+
help
52+
The sys_heap allocator by default returns pointers to blocks
53+
which are guaranteed to be aligned to the pointer size.
54+
By enabling the "big chunks" mode, the returned blocks are
55+
guaranteed to be 8 byte aligned, also on 32-bit platforms.
56+
If this option is enabled, the "big chunks" mode will always
57+
be used by sys_heap.
58+
4959
config PRINTK64
5060
bool "Enable 64 bit printk conversions (DEPRECATED)"
5161
help

lib/os/heap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ struct z_heap {
6666

6767
static inline bool big_heap_chunks(size_t chunks)
6868
{
69+
if (IS_ENABLED(CONFIG_SYS_HEAP_ALWAYS_BIG_MODE)) {
70+
return 1;
71+
}
6972
return sizeof(void *) > 4U || chunks > 0x7fffU;
7073
}
7174

0 commit comments

Comments
 (0)