diff --git a/arch/sim/src/sim/sim_sectionheap.c b/arch/sim/src/sim/sim_sectionheap.c index 8a9e0b3625be4..5e3db77fd1a7f 100644 --- a/arch/sim/src/sim/sim_sectionheap.c +++ b/arch/sim/src/sim/sim_sectionheap.c @@ -33,7 +33,9 @@ * Private Data ****************************************************************************/ +#ifdef CONFIG_ARCH_USE_TEXT_HEAP static struct mm_heap_s *g_textheap; +#endif static struct mm_heap_s *g_dataheap; /**************************************************************************** @@ -48,6 +50,7 @@ static struct mm_heap_s *g_dataheap; * ****************************************************************************/ +#ifdef CONFIG_ARCH_USE_TEXT_HEAP #ifdef CONFIG_ARCH_USE_SEPARATED_SECTION void *up_textheap_memalign(const char *sectname, size_t align, size_t size) #else @@ -92,6 +95,7 @@ bool up_textheap_heapmember(void *p) { return g_textheap != NULL && mm_heapmember(g_textheap, p); } +#endif /* CONFIG_ARCH_USE_TEXT_HEAP */ /**************************************************************************** * Name: up_dataheap_memalign diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index e1a598c222b2d..2d705f5fc197d 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -847,6 +847,11 @@ void up_extraheaps_init(void); * Description: * Allocate memory for text with the specified alignment and sectname. * + * If the architecture does not provide a separate text heap + * (CONFIG_ARCH_USE_TEXT_HEAP is not set), the text heap API falls back + * to the normal kernel heap: on flat-memory architectures the kernel + * heap is executable, so no separate allocator is needed. + * ****************************************************************************/ #if defined(CONFIG_ARCH_USE_TEXT_HEAP) @@ -856,6 +861,12 @@ FAR void *up_textheap_memalign(FAR const char *sectname, # else FAR void *up_textheap_memalign(size_t align, size_t size); # endif +#else +# if defined(CONFIG_ARCH_USE_SEPARATED_SECTION) +# define up_textheap_memalign(s,a,z) kmm_memalign(a,z) +# else +# define up_textheap_memalign(a,z) kmm_memalign(a,z) +# endif #endif /**************************************************************************** @@ -868,6 +879,8 @@ FAR void *up_textheap_memalign(size_t align, size_t size); #if defined(CONFIG_ARCH_USE_TEXT_HEAP) void up_textheap_free(FAR void *p); +#else +# define up_textheap_free(p) kmm_free(p) #endif /**************************************************************************** @@ -880,6 +893,8 @@ void up_textheap_free(FAR void *p); #if defined(CONFIG_ARCH_USE_TEXT_HEAP) bool up_textheap_heapmember(FAR void *p); +#else +# define up_textheap_heapmember(p) kmm_heapmember(p) #endif /**************************************************************************** @@ -900,13 +915,12 @@ bool up_textheap_heapmember(FAR void *p); * ****************************************************************************/ -#if defined(CONFIG_ARCH_USE_TEXT_HEAP) -#if defined(CONFIG_ARCH_HAVE_TEXT_HEAP_SEPARATE_DATA_ADDRESS) +#if defined(CONFIG_ARCH_USE_TEXT_HEAP) && \ + defined(CONFIG_ARCH_HAVE_TEXT_HEAP_SEPARATE_DATA_ADDRESS) FAR void *up_textheap_data_address(FAR void *p); #else #define up_textheap_data_address(p) ((FAR void *)p) #endif -#endif /**************************************************************************** * Name: up_textheap_data_sync @@ -918,13 +932,12 @@ FAR void *up_textheap_data_address(FAR void *p); * ****************************************************************************/ -#if defined(CONFIG_ARCH_USE_TEXT_HEAP) -#if defined(CONFIG_ARCH_HAVE_TEXT_HEAP_SEPARATE_DATA_ADDRESS) +#if defined(CONFIG_ARCH_USE_TEXT_HEAP) && \ + defined(CONFIG_ARCH_HAVE_TEXT_HEAP_SEPARATE_DATA_ADDRESS) void up_textheap_data_sync(void); #else #define up_textheap_data_sync() do {} while (0) #endif -#endif /**************************************************************************** * Name: up_dataheap_memalign