diff --git a/include/nuttx/addrenv.h b/include/nuttx/addrenv.h index c51216f69e..d8f0d7d462 100644 --- a/include/nuttx/addrenv.h +++ b/include/nuttx/addrenv.h @@ -29,7 +29,6 @@ #ifdef CONFIG_BUILD_KERNEL # include -# include #endif #include @@ -283,6 +282,8 @@ typedef CODE void (*addrenv_sigtramp_t)(_sa_sigaction_t sighand, int signo, FAR siginfo_t *info, FAR void *ucontext); +struct mm_heaps_s; /* Forward reference */ + /* This structure describes the format of the .bss/.data reserved area */ struct addrenv_reserve_s diff --git a/include/nuttx/mm/mm.h b/include/nuttx/mm/mm.h index 193888f3f5..01e7d7a284 100644 --- a/include/nuttx/mm/mm.h +++ b/include/nuttx/mm/mm.h @@ -25,7 +25,9 @@ * Included Files ****************************************************************************/ +#include #include +#include #include #include @@ -101,6 +103,36 @@ #define mm_memdump_s malltask +#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) +/* In the kernel build, there are multiple user heaps; one for each task + * group. In this build configuration, the user heap structure lies + * in a reserved region at the beginning of the .bss/.data address + * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by + * ARCH_DATA_RESERVE_SIZE + */ + +# define USR_HEAP (ARCH_DATA_RESERVE->ar_usrheap) + +#elif defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) +/* In the protected mode, there are two heaps: A kernel heap and a single + * user heap. Kernel code must obtain the address of the user heap data + * structure from the userspace interface. + */ + +# define USR_HEAP (*USERSPACE->us_heap) + +#else +/* Otherwise, the user heap data structures are in common .bss */ + +# define USR_HEAP g_mmheap +#endif + +#ifdef CONFIG_MM_KERNEL_HEAP +# define MM_INTERNAL_HEAP(heap) ((heap) == USR_HEAP || (heap) == g_kmmheap) +#else +# define MM_INTERNAL_HEAP(heap) ((heap) == USR_HEAP) +#endif + /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c index 1567326a8c..e5b81aca7b 100644 --- a/mm/mm_heap/mm_malloc.c +++ b/mm/mm_heap/mm_malloc.c @@ -267,7 +267,7 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) #endif } #ifdef CONFIG_DEBUG_MM - else + else if (MM_INTERNAL_HEAP(heap)) { #ifdef CONFIG_MM_DUMP_ON_FAILURE struct mallinfo minfo; diff --git a/mm/umm_heap/umm_heap.h b/mm/umm_heap/umm_heap.h index 7d74ea94e1..fb42938145 100644 --- a/mm/umm_heap/umm_heap.h +++ b/mm/umm_heap/umm_heap.h @@ -27,38 +27,12 @@ #include -#include -#include #include /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) -/* In the kernel build, there are multiple user heaps; one for each task - * group. In this build configuration, the user heap structure lies - * in a reserved region at the beginning of the .bss/.data address - * space (CONFIG_ARCH_DATA_VBASE). The size of that region is given by - * ARCH_DATA_RESERVE_SIZE - */ - -# define USR_HEAP (ARCH_DATA_RESERVE->ar_usrheap) - -#elif defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) -/* In the protected mode, there are two heaps: A kernel heap and a single - * user heap. Kernel code must obtain the address of the user heap data - * structure from the userspace interface. - */ - -# define USR_HEAP (*USERSPACE->us_heap) - -#else -/* Otherwise, the user heap data structures are in common .bss */ - -# define USR_HEAP g_mmheap -#endif - /**************************************************************************** * Public Function Prototypes ****************************************************************************/