I love/hate conditional compilation
This commit is contained in:
parent
0c8cc8c691
commit
b05f29dbfe
|
@ -133,7 +133,7 @@ static int get_pgtable(FAR group_addrenv_t *addrenv, uintptr_t vaddr)
|
|||
* region as part of the implementation of user sbrk().
|
||||
*/
|
||||
|
||||
DEBUGASSERT(vadddr >= CONFIG_ARCH_HEAP_VBASE && vaddr < ARCH_HEAP_VEND);
|
||||
DEBUGASSERT(vaddr >= CONFIG_ARCH_HEAP_VBASE && vaddr < ARCH_HEAP_VEND);
|
||||
|
||||
/* Get the current level 1 entry corresponding to this vaddr */
|
||||
|
||||
|
@ -222,7 +222,7 @@ uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages)
|
|||
* space and (2) extending the kernel memory regions as well.
|
||||
*/
|
||||
|
||||
DEBUGASSERT((group->flags & GROUP_FLAG_ADDRENV) != 0);
|
||||
DEBUGASSERT((group->tg_flags & GROUP_FLAG_ADDRENV) != 0);
|
||||
|
||||
/* brkaddr = 0 means that no heap has yet been allocated */
|
||||
|
||||
|
@ -231,7 +231,7 @@ uintptr_t pgalloc(uintptr_t brkaddr, unsigned int npages)
|
|||
brkaddr = CONFIG_ARCH_HEAP_VBASE;
|
||||
}
|
||||
|
||||
DEBUGASSERT(vadddr >= CONFIG_ARCH_HEAP_VBASE && brkaddr < ARCH_HEAP_VEND);
|
||||
DEBUGASSERT(brkaddr >= CONFIG_ARCH_HEAP_VBASE && brkaddr < ARCH_HEAP_VEND);
|
||||
DEBUGASSERT(MM_ISALIGNED(brkaddr));
|
||||
|
||||
for (; npages > 0; npages--)
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdbool.h>
|
||||
#include <semaphore.h>
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -262,8 +263,7 @@ extern "C"
|
|||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#if (!defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)) || \
|
||||
(defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__))
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
/* User heap structure:
|
||||
*
|
||||
* - Flat build: In the FLAT build, the user heap structure is a globally
|
||||
|
@ -297,7 +297,7 @@ void mm_addregion(FAR struct mm_heap_s *heap, FAR void *heapstart,
|
|||
|
||||
/* Functions contained in umm_initialize.c **********************************/
|
||||
|
||||
#ifdef MM_KERNEL_USRHEAP_INIT
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
void umm_initialize(FAR void *heap_start, size_t heap_size);
|
||||
#endif
|
||||
|
||||
|
@ -309,7 +309,7 @@ void kmm_initialize(FAR void *heap_start, size_t heap_size);
|
|||
|
||||
/* Functions contained in umm_addregion.c ***********************************/
|
||||
|
||||
#ifdef MM_KERNEL_USRHEAP_INIT
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
void umm_addregion(FAR void *heapstart, size_t heapsize);
|
||||
#endif
|
||||
|
||||
|
@ -328,8 +328,10 @@ void mm_givesemaphore(FAR struct mm_heap_s *heap);
|
|||
|
||||
/* Functions contained in umm_sem.c ****************************************/
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
int umm_trysemaphore(void);
|
||||
void umm_givesemaphore(void);
|
||||
#endif
|
||||
|
||||
/* Functions contained in kmm_sem.c ****************************************/
|
||||
|
||||
|
@ -412,7 +414,9 @@ FAR void *mm_brkaddr(FAR struct mm_heap_s *heap, int region);
|
|||
|
||||
/* Functions contained in umm_brkaddr.c *************************************/
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
FAR void *umm_brkaddr(int region);
|
||||
#endif
|
||||
|
||||
/* Functions contained in kmm_brkaddr.c *************************************/
|
||||
|
||||
|
@ -442,7 +446,9 @@ void mm_extend(FAR struct mm_heap_s *heap, FAR void *mem, size_t size,
|
|||
|
||||
/* Functions contained in umm_extend.c **************************************/
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
void umm_extend(FAR void *mem, size_t size, int region);
|
||||
#endif
|
||||
|
||||
/* Functions contained in kmm_extend.c **************************************/
|
||||
|
||||
|
|
|
@ -39,6 +39,10 @@
|
|||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#if defined(CONFIG_MM_KERNEL_HEAP) && defined(CONFIG_DEBUG)
|
||||
|
||||
/************************************************************************
|
||||
|
|
|
@ -63,7 +63,11 @@
|
|||
FAR void *mm_brkaddr(FAR struct mm_heap_s *heap, int region)
|
||||
{
|
||||
uintptr_t brkaddr;
|
||||
#if CONFIG_MM_REGIONS > 1
|
||||
DEBUGASSERT(heap && region < heap->mm_nregions);
|
||||
#else
|
||||
DEBUGASSERT(heap && region == 0);
|
||||
#endif
|
||||
|
||||
brkaddr = (uintptr_t)heap->mm_heapend[region];
|
||||
return brkaddr ? (FAR void *)(brkaddr + SIZEOF_MM_ALLOCNODE) : 0;
|
||||
|
|
|
@ -73,7 +73,11 @@ void mm_extend(FAR struct mm_heap_s *heap, FAR void *mem, size_t size,
|
|||
/* Make sure that we were passed valid parameters */
|
||||
|
||||
DEBUGASSERT(heap && mem);
|
||||
#if CONFIG_MM_REGIONS > 1
|
||||
DEBUGASSERT(size >= MIN_EXTEND && (unsigned)region < heap->mm_nregions);
|
||||
#else
|
||||
DEBUGASSERT(size >= MIN_EXTEND && (unsigned)region == 0);
|
||||
#endif
|
||||
|
||||
/* Make sure that the memory region are properly aligned */
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#ifdef MM_KERNEL_USRHEAP_INIT
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
|
||||
/************************************************************************
|
||||
* Pre-processor definition
|
||||
|
@ -102,4 +102,4 @@ void umm_addregion(FAR void *heap_start, size_t heap_size)
|
|||
mm_addregion(USR_HEAP, heap_start, heap_size);
|
||||
}
|
||||
|
||||
#endif /* MM_KERNEL_USRHEAP_INIT */
|
||||
#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
@ -80,3 +82,5 @@ FAR void *umm_brkaddr(int region)
|
|||
{
|
||||
return mm_brkaddr(USR_HEAP, region);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
@ -80,3 +82,5 @@ FAR void *calloc(size_t n, size_t elem_size)
|
|||
{
|
||||
return mm_calloc(USR_HEAP, n, elem_size);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
@ -79,3 +81,5 @@ void umm_extend(FAR void *mem, size_t size, int region)
|
|||
{
|
||||
mm_extend(USR_HEAP, mem, size, region);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
@ -85,3 +87,5 @@ void free(FAR void *mem)
|
|||
{
|
||||
mm_free(USR_HEAP, mem);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#ifdef MM_KERNEL_USRHEAP_INIT
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
|
||||
/************************************************************************
|
||||
* Pre-processor definition
|
||||
|
@ -109,4 +109,4 @@ void umm_initialize(FAR void *heap_start, size_t heap_size)
|
|||
mm_initialize(USR_HEAP, heap_start, heap_size);
|
||||
}
|
||||
|
||||
#endif /* MM_KERNEL_USRHEAP_INIT */
|
||||
#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
@ -102,3 +104,4 @@ int mallinfo(struct mallinfo *info)
|
|||
}
|
||||
|
||||
#endif /* CONFIG_CAN_PASS_STRUCTS */
|
||||
#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
@ -135,3 +137,5 @@ FAR void *malloc(size_t size)
|
|||
return mm_malloc(USR_HEAP, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
@ -89,3 +91,5 @@ FAR void *memalign(size_t alignment, size_t size)
|
|||
{
|
||||
return mm_memalign(USR_HEAP, alignment, size);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
@ -91,3 +93,5 @@ FAR void *realloc(FAR void *oldmem, size_t size)
|
|||
{
|
||||
return mm_realloc(USR_HEAP, oldmem, size);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */
|
||||
|
|
|
@ -45,7 +45,8 @@
|
|||
#include <nuttx/pgalloc.h>
|
||||
|
||||
#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_MM_PGALLOC) && \
|
||||
defined(CONFIG_ARCH_USE_MMU)
|
||||
defined(CONFIG_ARCH_USE_MMU) && (!defined(CONFIG_BUILD_PROTECTED) || \
|
||||
!defined(__KERNEL__))
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
|
@ -109,4 +110,4 @@ FAR void *sbrk(intptr_t incr)
|
|||
return mm_sbrk(USR_HEAP, incr, CONFIG_ARCH_STACK_NPAGES << MM_PGSHIFT);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ARCH_ADDRENV && CONFIG_MM_PGALLOC && CONFIG_ARCH_USE_MMU */
|
||||
#endif /* CONFIG_ARCH_ADDRENV && CONFIG_MM_PGALLOC && ... */
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
|
||||
/************************************************************************
|
||||
* Pre-processor definition
|
||||
************************************************************************/
|
||||
|
@ -119,3 +121,5 @@ void umm_givesemaphore(void)
|
|||
{
|
||||
mm_givesemaphore(USR_HEAP);
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */
|
||||
|
|
|
@ -44,6 +44,8 @@
|
|||
|
||||
#include <nuttx/mm.h>
|
||||
|
||||
#if !defined(CONFIG_BUILD_PROTECTED) || !defined(__KERNEL__)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
@ -102,3 +104,5 @@ FAR void *zalloc(size_t size)
|
|||
return mm_zalloc(USR_HEAP, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* !CONFIG_BUILD_PROTECTED || !__KERNEL__ */
|
||||
|
|
Loading…
Reference in New Issue