From eca70597858bc619d3114901d16e4a30f1ebffbe Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 30 Apr 2020 03:21:23 +0800 Subject: [PATCH] Refine __KERNEL__ and CONFIG_BUILD_xxx usage in the code base Signed-off-by: Xiang Xiao --- arch/arm/src/armv6-m/arm_signal_dispatch.c | 5 ++- arch/arm/src/armv7-a/arm_signal_dispatch.c | 5 ++- arch/arm/src/armv7-m/arm_signal_dispatch.c | 5 ++- arch/arm/src/armv7-r/arm_signal_dispatch.c | 5 ++- arch/arm/src/armv8-m/arm_signal_dispatch.c | 5 ++- arch/arm/src/common/arm_createstack.c | 10 ++---- arch/arm/src/common/arm_pthread_start.c | 6 ++-- arch/arm/src/common/arm_releasestack.c | 14 +------- arch/arm/src/common/arm_task_start.c | 4 +-- arch/avr/src/avr32/up_createstack.c | 2 +- arch/avr/src/common/up_releasestack.c | 2 +- arch/hc/src/common/up_createstack.c | 2 +- arch/hc/src/common/up_releasestack.c | 2 +- arch/mips/src/common/mips_createstack.c | 2 +- arch/mips/src/common/mips_releasestack.c | 2 +- arch/misoc/src/lm32/lm32_createstack.c | 2 +- arch/misoc/src/lm32/lm32_releasestack.c | 2 +- arch/misoc/src/minerva/minerva_createstack.c | 2 +- arch/misoc/src/minerva/minerva_releasestack.c | 2 +- arch/or1k/src/common/up_createstack.c | 10 ++---- arch/or1k/src/common/up_pthread_start.c | 6 ++-- arch/or1k/src/common/up_releasestack.c | 10 +----- arch/or1k/src/common/up_task_start.c | 4 +-- arch/renesas/src/common/up_createstack.c | 2 +- arch/renesas/src/common/up_releasestack.c | 2 +- arch/risc-v/src/common/riscv_createstack.c | 2 +- arch/risc-v/src/common/riscv_pthread_start.c | 6 ++-- arch/risc-v/src/common/riscv_releasestack.c | 2 +- arch/risc-v/src/common/riscv_task_start.c | 4 +-- .../risc-v/src/rv64gc/riscv_signal_dispatch.c | 5 ++- arch/x86/src/i486/up_createstack.c | 2 +- arch/x86/src/i486/up_releasestack.c | 2 +- arch/x86_64/src/intel64/up_createstack.c | 2 +- arch/x86_64/src/intel64/up_releasestack.c | 2 +- arch/xtensa/src/common/xtensa_createstack.c | 2 +- arch/xtensa/src/common/xtensa_releasestack.c | 2 +- arch/xtensa/src/esp32/esp32_user.c | 2 +- arch/z80/src/common/z80_createstack.c | 2 +- arch/z80/src/common/z80_releasestack.c | 2 +- fs/vfs/fs_fdopen.c | 3 +- include/aio.h | 2 +- include/dsp.h | 4 --- include/errno.h | 22 +++---------- include/nuttx/arch.h | 12 +++---- include/nuttx/clock.h | 13 +++----- include/nuttx/kmalloc.h | 26 ++------------- include/nuttx/mm/mm.h | 17 +++------- include/nuttx/sched.h | 3 +- include/nuttx/userspace.h | 4 +-- include/nuttx/wqueue.h | 33 +++++++------------ include/stdio.h | 4 +-- libs/libc/dlfcn/lib_dlsymtab.c | 18 +++++----- libs/libc/libc.h | 3 +- libs/libc/misc/lib_stream.c | 27 ++++++--------- libs/libc/misc/lib_utsname.c | 5 ++- libs/libc/pthread/pthread_attr_init.c | 3 +- libs/libc/pthread/pthread_startup.c | 5 ++- libs/libc/stdio/lib_libdtoa.c | 11 ------- libs/libc/unistd/lib_gethostname.c | 3 +- libs/libc/unistd/lib_sethostname.c | 5 ++- libs/libc/wqueue/Make.defs | 23 ++----------- libs/libnx/nxcontext.h | 3 +- libs/libxx/libxx.hxx | 3 +- mm/mm_heap/mm_free.c | 3 +- mm/mm_heap/mm_malloc.c | 6 ++-- mm/umm_heap/umm_globals.c | 2 +- mm/umm_heap/umm_heap.h | 2 +- mm/umm_heap/umm_malloc.c | 2 +- sched/group/Make.defs | 6 +--- sched/group/group_create.c | 6 ++-- sched/group/group_free.c | 5 ++- sched/group/group_leave.c | 14 ++------ sched/group/group_malloc.c | 5 ++- sched/group/group_zalloc.c | 7 ++-- sched/init/nx_start.c | 9 ++--- sched/pthread/pthread_create.c | 6 ++-- sched/sched/sched_getstreams.c | 3 +- sched/signal/sig_deliver.c | 2 +- sched/task/task_exithook.c | 3 +- sched/task/task_start.c | 2 +- tools/Directories.mk | 4 +-- tools/Makefile.unix | 4 +-- tools/Makefile.win | 4 +-- 83 files changed, 158 insertions(+), 339 deletions(-) diff --git a/arch/arm/src/armv6-m/arm_signal_dispatch.c b/arch/arm/src/armv6-m/arm_signal_dispatch.c index d7280572a1..8f3d3f2ec4 100644 --- a/arch/arm/src/armv6-m/arm_signal_dispatch.c +++ b/arch/arm/src/armv6-m/arm_signal_dispatch.c @@ -43,8 +43,7 @@ #include "svcall.h" #include "arm_internal.h" -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) /**************************************************************************** * Public Functions @@ -88,4 +87,4 @@ void up_signal_dispatch(_sa_sigaction_t sighand, int signo, (uintptr_t)info, (uintptr_t)ucontext); } -#endif /* (CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL) && !CONFIG_DISABLE_PTHREAD */ +#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ */ diff --git a/arch/arm/src/armv7-a/arm_signal_dispatch.c b/arch/arm/src/armv7-a/arm_signal_dispatch.c index 10be736367..773729212d 100644 --- a/arch/arm/src/armv7-a/arm_signal_dispatch.c +++ b/arch/arm/src/armv7-a/arm_signal_dispatch.c @@ -44,8 +44,7 @@ #include "pgalloc.h" #include "arm_internal.h" -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) /**************************************************************************** * Public Functions @@ -104,4 +103,4 @@ void up_signal_dispatch(_sa_sigaction_t sighand, int signo, } } -#endif /* CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL */ +#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ */ diff --git a/arch/arm/src/armv7-m/arm_signal_dispatch.c b/arch/arm/src/armv7-m/arm_signal_dispatch.c index 6b21c320ac..e50236a56c 100644 --- a/arch/arm/src/armv7-m/arm_signal_dispatch.c +++ b/arch/arm/src/armv7-m/arm_signal_dispatch.c @@ -28,8 +28,7 @@ #include "svcall.h" #include "arm_internal.h" -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) /**************************************************************************** * Public Functions @@ -73,4 +72,4 @@ void up_signal_dispatch(_sa_sigaction_t sighand, int signo, (uintptr_t)info, (uintptr_t)ucontext); } -#endif /* (CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL) && !CONFIG_DISABLE_PTHREAD */ +#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ */ diff --git a/arch/arm/src/armv7-r/arm_signal_dispatch.c b/arch/arm/src/armv7-r/arm_signal_dispatch.c index 6718795c03..f6a0d373a8 100644 --- a/arch/arm/src/armv7-r/arm_signal_dispatch.c +++ b/arch/arm/src/armv7-r/arm_signal_dispatch.c @@ -44,8 +44,7 @@ #include "pgalloc.h" #include "arm_internal.h" -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_PROTECTED) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) /**************************************************************************** * Public Functions @@ -104,4 +103,4 @@ void up_signal_dispatch(_sa_sigaction_t sighand, int signo, } } -#endif /* CONFIG_BUILD_PROTECTED || CONFIG_BUILD_PROTECTED */ +#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ */ diff --git a/arch/arm/src/armv8-m/arm_signal_dispatch.c b/arch/arm/src/armv8-m/arm_signal_dispatch.c index eef30d74c5..4d3b7730b8 100755 --- a/arch/arm/src/armv8-m/arm_signal_dispatch.c +++ b/arch/arm/src/armv8-m/arm_signal_dispatch.c @@ -28,8 +28,7 @@ #include "svcall.h" #include "arm_internal.h" -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) /**************************************************************************** * Public Functions @@ -73,4 +72,4 @@ void up_signal_dispatch(_sa_sigaction_t sighand, int signo, (uintptr_t)info, (uintptr_t)ucontext); } -#endif /* (CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL) && !CONFIG_DISABLE_PTHREAD */ +#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ */ diff --git a/arch/arm/src/common/arm_createstack.c b/arch/arm/src/common/arm_createstack.c index 3ee27ec088..ce3dffd24d 100644 --- a/arch/arm/src/common/arm_createstack.c +++ b/arch/arm/src/common/arm_createstack.c @@ -46,12 +46,6 @@ /* Configuration */ -#undef HAVE_KERNEL_HEAP -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) -# define HAVE_KERNEL_HEAP 1 -#endif - /* For use with EABI and floating point, the stack must be aligned to 8-byte * addresses. */ @@ -146,7 +140,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) */ #ifdef CONFIG_TLS -#ifdef HAVE_KERNEL_HEAP +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) @@ -164,7 +158,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) } #else /* CONFIG_TLS */ -#ifdef HAVE_KERNEL_HEAP +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/arm/src/common/arm_pthread_start.c b/arch/arm/src/common/arm_pthread_start.c index 9607c9180d..080ed30649 100644 --- a/arch/arm/src/common/arm_pthread_start.c +++ b/arch/arm/src/common/arm_pthread_start.c @@ -44,8 +44,8 @@ #include "svcall.h" #include "arm_internal.h" -#if ((defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL)) && !defined(CONFIG_DISABLE_PTHREAD) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) && \ + !defined(CONFIG_DISABLE_PTHREAD) /**************************************************************************** * Public Functions @@ -84,4 +84,4 @@ void up_pthread_start(pthread_startroutine_t entrypt, pthread_addr_t arg) PANIC(); } -#endif /* (CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL) && !CONFIG_DISABLE_PTHREAD */ +#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ && !CONFIG_DISABLE_PTHREAD */ diff --git a/arch/arm/src/common/arm_releasestack.c b/arch/arm/src/common/arm_releasestack.c index e7bc25a57e..76204a2f7c 100644 --- a/arch/arm/src/common/arm_releasestack.c +++ b/arch/arm/src/common/arm_releasestack.c @@ -47,18 +47,6 @@ #include "arm_internal.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/* Configuration */ - -#undef HAVE_KERNEL_HEAP -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) -# define HAVE_KERNEL_HEAP 1 -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -100,7 +88,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#ifdef HAVE_KERNEL_HEAP +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/arm/src/common/arm_task_start.c b/arch/arm/src/common/arm_task_start.c index ce2a137e63..1182b9f6c4 100644 --- a/arch/arm/src/common/arm_task_start.c +++ b/arch/arm/src/common/arm_task_start.c @@ -43,7 +43,7 @@ #include "svcall.h" #include "arm_internal.h" -#if defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL) +#ifndef CONFIG_BUILD_FLAT /**************************************************************************** * Public Functions @@ -84,4 +84,4 @@ void up_task_start(main_t taskentry, int argc, FAR char *argv[]) PANIC(); } -#endif /* CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL */ +#endif /* !CONFIG_BUILD_FLAT */ diff --git a/arch/avr/src/avr32/up_createstack.c b/arch/avr/src/avr32/up_createstack.c index 2244e9ba4e..bcfb34847a 100644 --- a/arch/avr/src/avr32/up_createstack.c +++ b/arch/avr/src/avr32/up_createstack.c @@ -125,7 +125,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * then create a zeroed stack to make stack dumps easier to trace. */ -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/avr/src/common/up_releasestack.c b/arch/avr/src/common/up_releasestack.c index 5b8ae83b98..77181da91e 100644 --- a/arch/avr/src/common/up_releasestack.c +++ b/arch/avr/src/common/up_releasestack.c @@ -96,7 +96,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/hc/src/common/up_createstack.c b/arch/hc/src/common/up_createstack.c index 5f954588f3..d9aa7f7f3f 100644 --- a/arch/hc/src/common/up_createstack.c +++ b/arch/hc/src/common/up_createstack.c @@ -122,7 +122,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * then create a zeroed stack to make stack dumps easier to trace. */ -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/hc/src/common/up_releasestack.c b/arch/hc/src/common/up_releasestack.c index e8830fa755..6d006947bd 100644 --- a/arch/hc/src/common/up_releasestack.c +++ b/arch/hc/src/common/up_releasestack.c @@ -96,7 +96,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/mips/src/common/mips_createstack.c b/arch/mips/src/common/mips_createstack.c index cd43235e9c..1e1ba2840a 100644 --- a/arch/mips/src/common/mips_createstack.c +++ b/arch/mips/src/common/mips_createstack.c @@ -143,7 +143,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * then create a zeroed stack to make stack dumps easier to trace. */ -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/mips/src/common/mips_releasestack.c b/arch/mips/src/common/mips_releasestack.c index 21a66b7f5f..c3eca9e7ab 100644 --- a/arch/mips/src/common/mips_releasestack.c +++ b/arch/mips/src/common/mips_releasestack.c @@ -96,7 +96,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/misoc/src/lm32/lm32_createstack.c b/arch/misoc/src/lm32/lm32_createstack.c index a9aa3143a1..7da441f518 100644 --- a/arch/misoc/src/lm32/lm32_createstack.c +++ b/arch/misoc/src/lm32/lm32_createstack.c @@ -143,7 +143,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * then create a zeroed stack to make stack dumps easier to trace. */ -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/misoc/src/lm32/lm32_releasestack.c b/arch/misoc/src/lm32/lm32_releasestack.c index d9bebc5903..434d217334 100644 --- a/arch/misoc/src/lm32/lm32_releasestack.c +++ b/arch/misoc/src/lm32/lm32_releasestack.c @@ -89,7 +89,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/misoc/src/minerva/minerva_createstack.c b/arch/misoc/src/minerva/minerva_createstack.c index 782cc0750e..dbe6aec0d2 100644 --- a/arch/misoc/src/minerva/minerva_createstack.c +++ b/arch/misoc/src/minerva/minerva_createstack.c @@ -135,7 +135,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * create a zeroed stack to make stack dumps easier to trace. */ -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/misoc/src/minerva/minerva_releasestack.c b/arch/misoc/src/minerva/minerva_releasestack.c index 27dd597593..2812e72f94 100644 --- a/arch/misoc/src/minerva/minerva_releasestack.c +++ b/arch/misoc/src/minerva/minerva_releasestack.c @@ -89,7 +89,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/or1k/src/common/up_createstack.c b/arch/or1k/src/common/up_createstack.c index bcb6d83b62..1775a606a1 100644 --- a/arch/or1k/src/common/up_createstack.c +++ b/arch/or1k/src/common/up_createstack.c @@ -61,12 +61,6 @@ /* Configuration */ -#undef HAVE_KERNEL_HEAP -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) -# define HAVE_KERNEL_HEAP 1 -#endif - /* For use with EABI and floating point, the stack must be aligned to 8-byte * addresses. */ @@ -161,7 +155,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) */ #ifdef CONFIG_TLS -#ifdef HAVE_KERNEL_HEAP +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) @@ -179,7 +173,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) } #else /* CONFIG_TLS */ -#ifdef HAVE_KERNEL_HEAP +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/or1k/src/common/up_pthread_start.c b/arch/or1k/src/common/up_pthread_start.c index 15880ad702..79404e8ece 100644 --- a/arch/or1k/src/common/up_pthread_start.c +++ b/arch/or1k/src/common/up_pthread_start.c @@ -44,8 +44,8 @@ #include "svcall.h" #include "up_internal.h" -#if ((defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL)) && !defined(CONFIG_DISABLE_PTHREAD) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) && \ + !defined(CONFIG_DISABLE_PTHREAD) /**************************************************************************** * Public Functions @@ -86,4 +86,4 @@ void up_pthread_start(pthread_startroutine_t entrypt, pthread_addr_t arg) PANIC(); } -#endif /* (CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL) && !CONFIG_DISABLE_PTHREAD */ +#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ && !CONFIG_DISABLE_PTHREAD */ diff --git a/arch/or1k/src/common/up_releasestack.c b/arch/or1k/src/common/up_releasestack.c index 9ef5598db0..9e622b1bf6 100644 --- a/arch/or1k/src/common/up_releasestack.c +++ b/arch/or1k/src/common/up_releasestack.c @@ -51,14 +51,6 @@ * Pre-processor Definitions ****************************************************************************/ -/* Configuration */ - -#undef HAVE_KERNEL_HEAP -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) -# define HAVE_KERNEL_HEAP 1 -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -100,7 +92,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#ifdef HAVE_KERNEL_HEAP +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/or1k/src/common/up_task_start.c b/arch/or1k/src/common/up_task_start.c index d44b9f9755..7833b6c6e0 100644 --- a/arch/or1k/src/common/up_task_start.c +++ b/arch/or1k/src/common/up_task_start.c @@ -43,7 +43,7 @@ #include "svcall.h" #include "up_internal.h" -#if defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL) +#ifndef CONFIG_BUILD_FLAT /**************************************************************************** * Public Functions @@ -86,4 +86,4 @@ void up_task_start(main_t taskentry, int argc, FAR char *argv[]) PANIC(); } -#endif /* CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL */ +#endif /* !CONFIG_BUILD_FLAT */ diff --git a/arch/renesas/src/common/up_createstack.c b/arch/renesas/src/common/up_createstack.c index f4461a08b3..5ba05515da 100644 --- a/arch/renesas/src/common/up_createstack.c +++ b/arch/renesas/src/common/up_createstack.c @@ -122,7 +122,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * then create a zeroed stack to make stack dumps easier to trace. */ -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/renesas/src/common/up_releasestack.c b/arch/renesas/src/common/up_releasestack.c index 913002cbb6..0d318f2fae 100644 --- a/arch/renesas/src/common/up_releasestack.c +++ b/arch/renesas/src/common/up_releasestack.c @@ -96,7 +96,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/risc-v/src/common/riscv_createstack.c b/arch/risc-v/src/common/riscv_createstack.c index b8c09cabc0..da674e56cb 100644 --- a/arch/risc-v/src/common/riscv_createstack.c +++ b/arch/risc-v/src/common/riscv_createstack.c @@ -143,7 +143,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * then create a zeroed stack to make stack dumps easier to trace. */ -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/risc-v/src/common/riscv_pthread_start.c b/arch/risc-v/src/common/riscv_pthread_start.c index b27df8b833..f66b1740c6 100644 --- a/arch/risc-v/src/common/riscv_pthread_start.c +++ b/arch/risc-v/src/common/riscv_pthread_start.c @@ -29,8 +29,8 @@ #include "svcall.h" #include "riscv_internal.h" -#if ((defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL)) && !defined(CONFIG_DISABLE_PTHREAD) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) && \ + !defined(CONFIG_DISABLE_PTHREAD) /**************************************************************************** * Public Functions @@ -69,4 +69,4 @@ void up_pthread_start(pthread_startroutine_t entrypt, pthread_addr_t arg) PANIC(); } -#endif /* (CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL) && !CONFIG_DISABLE_PTHREAD */ +#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ && !CONFIG_DISABLE_PTHREAD */ diff --git a/arch/risc-v/src/common/riscv_releasestack.c b/arch/risc-v/src/common/riscv_releasestack.c index 219062d5c7..dab871037b 100644 --- a/arch/risc-v/src/common/riscv_releasestack.c +++ b/arch/risc-v/src/common/riscv_releasestack.c @@ -96,7 +96,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/risc-v/src/common/riscv_task_start.c b/arch/risc-v/src/common/riscv_task_start.c index 37b3252baa..f1783c18e2 100644 --- a/arch/risc-v/src/common/riscv_task_start.c +++ b/arch/risc-v/src/common/riscv_task_start.c @@ -28,7 +28,7 @@ #include "svcall.h" #include "riscv_internal.h" -#if defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL) +#ifndef CONFIG_BUILD_FLAT /**************************************************************************** * Public Functions @@ -69,4 +69,4 @@ void up_task_start(main_t taskentry, int argc, FAR char *argv[]) PANIC(); } -#endif /* CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL */ +#endif /* !CONFIG_BUILD_FLAT */ diff --git a/arch/risc-v/src/rv64gc/riscv_signal_dispatch.c b/arch/risc-v/src/rv64gc/riscv_signal_dispatch.c index 1aa1298a12..3dadf009ec 100644 --- a/arch/risc-v/src/rv64gc/riscv_signal_dispatch.c +++ b/arch/risc-v/src/rv64gc/riscv_signal_dispatch.c @@ -28,8 +28,7 @@ #include "svcall.h" #include "riscv_internal.h" -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) /**************************************************************************** * Public Functions @@ -73,4 +72,4 @@ void up_signal_dispatch(_sa_sigaction_t sighand, int signo, (uintptr_t)info, (uintptr_t)ucontext); } -#endif /* (CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL) && !CONFIG_DISABLE_PTHREAD */ +#endif /* !CONFIG_BUILD_FLAT && __KERNEL__ */ diff --git a/arch/x86/src/i486/up_createstack.c b/arch/x86/src/i486/up_createstack.c index 8173457e80..eb667a624f 100644 --- a/arch/x86/src/i486/up_createstack.c +++ b/arch/x86/src/i486/up_createstack.c @@ -124,7 +124,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * then create a zeroed stack to make stack dumps easier to trace. */ -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/x86/src/i486/up_releasestack.c b/arch/x86/src/i486/up_releasestack.c index 43acbf3629..11760a9443 100644 --- a/arch/x86/src/i486/up_releasestack.c +++ b/arch/x86/src/i486/up_releasestack.c @@ -96,7 +96,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/x86_64/src/intel64/up_createstack.c b/arch/x86_64/src/intel64/up_createstack.c index d13c0ec715..10e2b08f47 100644 --- a/arch/x86_64/src/intel64/up_createstack.c +++ b/arch/x86_64/src/intel64/up_createstack.c @@ -109,7 +109,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * then create a zeroed stack to make stack dumps easier to trace. */ -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/x86_64/src/intel64/up_releasestack.c b/arch/x86_64/src/intel64/up_releasestack.c index 23a2fbf1c1..2a66060831 100644 --- a/arch/x86_64/src/intel64/up_releasestack.c +++ b/arch/x86_64/src/intel64/up_releasestack.c @@ -86,7 +86,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/xtensa/src/common/xtensa_createstack.c b/arch/xtensa/src/common/xtensa_createstack.c index 9cb3dc8415..b96633dfec 100644 --- a/arch/xtensa/src/common/xtensa_createstack.c +++ b/arch/xtensa/src/common/xtensa_createstack.c @@ -150,7 +150,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * then create a zeroed stack to make stack dumps easier to trace. */ -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/xtensa/src/common/xtensa_releasestack.c b/arch/xtensa/src/common/xtensa_releasestack.c index 4b2c4170bf..fb6ef6e470 100644 --- a/arch/xtensa/src/common/xtensa_releasestack.c +++ b/arch/xtensa/src/common/xtensa_releasestack.c @@ -88,7 +88,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/xtensa/src/esp32/esp32_user.c b/arch/xtensa/src/esp32/esp32_user.c index 5de680c141..d2b8026feb 100644 --- a/arch/xtensa/src/esp32/esp32_user.c +++ b/arch/xtensa/src/esp32/esp32_user.c @@ -54,7 +54,7 @@ extern uint32_t _emodtext; #ifdef CONFIG_ENDIAN_BIG #error not implemented #endif -#if defined(CONFIG_BUILD_PROTECTED) || defined (CONFIG_BUILD_KERNEL) +#ifndef CONFIG_BUILD_FLAT #error permission check not implemented #endif diff --git a/arch/z80/src/common/z80_createstack.c b/arch/z80/src/common/z80_createstack.c index 3f62467f97..ba557e8dc1 100644 --- a/arch/z80/src/common/z80_createstack.c +++ b/arch/z80/src/common/z80_createstack.c @@ -107,7 +107,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype) * then create a zeroed stack to make stack dumps easier to trace. */ -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/arch/z80/src/common/z80_releasestack.c b/arch/z80/src/common/z80_releasestack.c index 234218626f..a94b0b10d0 100644 --- a/arch/z80/src/common/z80_releasestack.c +++ b/arch/z80/src/common/z80_releasestack.c @@ -81,7 +81,7 @@ void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype) if (dtcb->stack_alloc_ptr) { -#if defined(CONFIG_BUILD_KERNEL) && defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /* Use the kernel allocator if this is a kernel thread */ if (ttype == TCB_FLAG_TTYPE_KERNEL) diff --git a/fs/vfs/fs_fdopen.c b/fs/vfs/fs_fdopen.c index a2ba6e181b..bc40a1343b 100644 --- a/fs/vfs/fs_fdopen.c +++ b/fs/vfs/fs_fdopen.c @@ -194,8 +194,7 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb) /* Get the stream list from the TCB */ -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP slist = tcb->group->tg_streamlist; #else slist = &tcb->group->tg_streamlist; diff --git a/include/aio.h b/include/aio.h index b139d2ed82..10b25f7f4b 100644 --- a/include/aio.h +++ b/include/aio.h @@ -54,7 +54,7 @@ /* Configuration ************************************************************/ /* These interfaces are not available to kernel code */ -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && defined(__KERNEL__) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) # undef CONFIG_FS_AIO #endif diff --git a/include/dsp.h b/include/dsp.h index ebbd3e5206..b83264c444 100644 --- a/include/dsp.h +++ b/include/dsp.h @@ -53,10 +53,6 @@ * Pre-processor Definitions ****************************************************************************/ -#ifndef CONFIG_BUILD_FLAT -# error "Only flat build supported for now" -#endif - /* Disable DEBUGASSERT macro if LIBDSP debug is not enabled */ #ifdef CONFIG_LIBDSP_DEBUG diff --git a/include/errno.h b/include/errno.h index 595f5fe2d7..90de7d5d2a 100644 --- a/include/errno.h +++ b/include/errno.h @@ -48,7 +48,7 @@ /* How can we access the errno variable? */ -#if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL) +#ifdef CONFIG_BUILD_FLAT /* Flat build */ # if defined(CONFIG_LIB_SYSCALL) && !defined(__KERNEL__) @@ -66,31 +66,17 @@ # define __DIRECT_ERRNO_ACCESS 1 # endif -#elif defined(CONFIG_BUILD_PROTECTED) +#else # if defined(__KERNEL__) - /* Kernel portion of protected build. Kernel code has direct access */ + /* Kernel portion of protected/kernel build. Kernel code has direct access */ # define __DIRECT_ERRNO_ACCESS 1 # else - /* User portion of protected build. Application code has only indirect + /* User portion of protected/kernel build. Application code has only indirect * access */ -# undef __DIRECT_ERRNO_ACCESS -# endif - -#elif defined(CONFIG_BUILD_KERNEL) && !defined(__KERNEL__) -# if defined(__KERNEL__) - /* Kernel build. Kernel code has direct access */ - -# define __DIRECT_ERRNO_ACCESS 1 - -# else - /* User libraries for the kernel. Only indirect access from user - * libraries - */ - # undef __DIRECT_ERRNO_ACCESS # endif #endif diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index c57bc42003..4551a10e0f 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -551,8 +551,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver); * ****************************************************************************/ -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) void up_task_start(main_t taskentry, int argc, FAR char *argv[]) noreturn_function; #endif @@ -581,8 +580,8 @@ void up_task_start(main_t taskentry, int argc, FAR char *argv[]) * ****************************************************************************/ -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) && !defined(CONFIG_DISABLE_PTHREAD) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) && \ + !defined(CONFIG_DISABLE_PTHREAD) void up_pthread_start(pthread_startroutine_t entrypt, pthread_addr_t arg) noreturn_function; #endif @@ -615,8 +614,7 @@ void up_pthread_start(pthread_startroutine_t entrypt, pthread_addr_t arg) * ****************************************************************************/ -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) void up_signal_dispatch(_sa_sigaction_t sighand, int signo, FAR siginfo_t *info, FAR void *ucontext); #endif @@ -640,7 +638,7 @@ void up_signal_dispatch(_sa_sigaction_t sighand, int signo, * ****************************************************************************/ -#if (defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__)) +#if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__) void up_signal_handler(_sa_sigaction_t sighand, int signo, FAR siginfo_t *info, FAR void *ucontext) noreturn_function; diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h index 6a6027f2e8..d209130aa0 100644 --- a/include/nuttx/clock.h +++ b/include/nuttx/clock.h @@ -74,15 +74,10 @@ #if defined(CONFIG_SCHED_TICKLESS) /* Case 1: There is no global timer data */ -#elif defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) - /* Case 3: Kernel mode of protected kernel build */ +#elif defined(__KERNEL__) + /* Case 3: Kernel mode of protected/kernel build */ -# define __HAVE_KERNEL_GLOBALS 1 - -#elif defined(CONFIG_BUILD_KERNEL) && defined(__KERNEL__) - /* Case 3: Kernel only build */ - -# define __HAVE_KERNEL_GLOBALS 1 +# define __HAVE_KERNEL_GLOBALS 1 #elif defined(CONFIG_LIB_SYSCALL) /* Case 4: Building with SYSCALLs enabled, but not part of a kernel build */ @@ -90,7 +85,7 @@ #else /* Case 2: Un-protected, non-kernel build */ -# define __HAVE_KERNEL_GLOBALS 1 +# define __HAVE_KERNEL_GLOBALS 1 #endif /* If CONFIG_SYSTEM_TIME64 is selected and the CPU supports long long types, diff --git a/include/nuttx/kmalloc.h b/include/nuttx/kmalloc.h index 6ea4d8e532..a8a3b04ba7 100644 --- a/include/nuttx/kmalloc.h +++ b/include/nuttx/kmalloc.h @@ -34,8 +34,6 @@ #include #include -#if !defined(CONFIG_BUILD_PROTECTED) || defined(__KERNEL__) - /**************************************************************************** * Public Types ****************************************************************************/ @@ -84,25 +82,7 @@ extern "C" /* This family of allocators is used to manage kernel protected memory */ -#if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_MM_KERNEL_HEAP) -/* If this is not a kernel build, then these map to the same interfaces - * as were used for the user-mode function. - */ - -# define kmm_initialize(h,s) /* Initialization done by kumm_initialize */ -# define kmm_addregion(h,s) umm_addregion(h,s) -# define kmm_trysemaphore() umm_trysemaphore() -# define kmm_givesemaphore() umm_givesemaphore() - -# define kmm_calloc(n,s) calloc(n,s); -# define kmm_malloc(s) malloc(s) -# define kmm_zalloc(s) zalloc(s) -# define kmm_realloc(p,s) realloc(p,s) -# define kmm_memalign(a,s) memalign(a,s) -# define kmm_free(p) free(p) -# define kmm_mallinfo() mallinfo() - -#elif !defined(CONFIG_MM_KERNEL_HEAP) +#ifndef CONFIG_MM_KERNEL_HEAP /* If this the kernel phase of a kernel build, and there are only user-space * allocators, then the following are defined in userspace.h as macros that * call into user-space via a header at the beginning of the user-space blob. @@ -128,8 +108,7 @@ extern "C" #endif -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /**************************************************************************** * Group memory management * @@ -169,5 +148,4 @@ void group_free(FAR struct task_group_s *group, FAR void *mem); } #endif -#endif /* !CONFIG_BUILD_PROTECTED || __KERNEL__ */ #endif /* __INCLUDE_NUTTX_KMALLOC_H */ diff --git a/include/nuttx/mm/mm.h b/include/nuttx/mm/mm.h index f448138dca..f42c48a7ee 100644 --- a/include/nuttx/mm/mm.h +++ b/include/nuttx/mm/mm.h @@ -84,9 +84,7 @@ */ #undef MM_KERNEL_USRHEAP_INIT -#if defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) -# define MM_KERNEL_USRHEAP_INIT 1 -#elif !defined(CONFIG_BUILD_KERNEL) +#if !defined(CONFIG_BUILD_KERNEL) && defined(__KERNEL__) # define MM_KERNEL_USRHEAP_INIT 1 #endif @@ -285,7 +283,6 @@ extern "C" * no global user heap structure. */ -#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) /* In the kernel build, there a 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 @@ -293,13 +290,12 @@ extern "C" * ARCH_DATA_RESERVE_SIZE */ -#elif defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) /* In the protected mode, there are two heaps: A kernel heap and a single * user heap. In that case the user heap structure lies in the user space * (with a reference in the userspace interface). */ -#else +#if defined(CONFIG_BUILD_FLAT) || !defined(__KERNEL__) /* Otherwise, the user heap data structures are in common .bss */ EXTERN struct mm_heap_s g_mmheap; @@ -443,9 +439,7 @@ 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 *************************************/ @@ -455,8 +449,7 @@ FAR void *kmm_brkaddr(int region); /* Functions contained in mm_sbrk.c *****************************************/ -#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_MM_PGALLOC) && \ - defined(CONFIG_ARCH_USE_MMU) +#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_MM_PGALLOC) FAR void *mm_sbrk(FAR struct mm_heap_s *heap, intptr_t incr, uintptr_t maxbreak); #endif @@ -464,7 +457,7 @@ FAR void *mm_sbrk(FAR struct mm_heap_s *heap, intptr_t incr, /* Functions contained in kmm_sbrk.c ****************************************/ #if defined(CONFIG_MM_KERNEL_HEAP) && defined(CONFIG_ARCH_ADDRENV) && \ - defined(CONFIG_MM_PGALLOC) && defined(CONFIG_ARCH_USE_MMU) + defined(CONFIG_MM_PGALLOC) FAR void *kmm_sbrk(intptr_t incr); #endif @@ -475,9 +468,7 @@ 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 **************************************/ diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index 4c49248861..60564c2fa1 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -554,8 +554,7 @@ struct task_group_s * allocated using a user-space allocator. */ -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP FAR struct streamlist *tg_streamlist; #else struct streamlist tg_streamlist; /* Holds C buffered I/O info */ diff --git a/include/nuttx/userspace.h b/include/nuttx/userspace.h index d5e9243705..1a1e4fa33b 100644 --- a/include/nuttx/userspace.h +++ b/include/nuttx/userspace.h @@ -165,7 +165,7 @@ extern "C" * ****************************************************************************/ -#if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__) +#ifndef __KERNEL__ void task_startup(main_t entrypt, int argc, FAR char *argv[]) noreturn_function; #endif @@ -185,7 +185,7 @@ void task_startup(main_t entrypt, int argc, FAR char *argv[]) noreturn_function; * ****************************************************************************/ -#if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__) && !defined(CONFIG_DISABLE_PTHREAD) +#if !defined(__KERNEL__) && !defined(CONFIG_DISABLE_PTHREAD) void pthread_startup(pthread_startroutine_t entrypt, pthread_addr_t arg); #endif diff --git a/include/nuttx/wqueue.h b/include/nuttx/wqueue.h index f4e7260166..d353772677 100644 --- a/include/nuttx/wqueue.h +++ b/include/nuttx/wqueue.h @@ -100,38 +100,29 @@ * priority worker thread. Default: 2048. */ -/* Is this a protected build (CONFIG_BUILD_PROTECTED=y) */ +/* Is this a flat build (CONFIG_BUILD_FLAT=y) */ -#if defined(CONFIG_BUILD_PROTECTED) +#if defined(CONFIG_BUILD_FLAT) - /* Yes.. kernel worker threads are not built in a kernel build when we are + /* Yes.. user-space worker threads are not built in a flat build */ + +# undef CONFIG_LIB_USRWORK + +#elif !defined(__KERNEL__) + + /* Kernel worker threads are not built in a kernel build when we are * building the user-space libraries. */ -# ifndef __KERNEL__ - -# undef CONFIG_SCHED_HPWORK -# undef CONFIG_SCHED_LPWORK -# undef CONFIG_SCHED_WORKQUEUE +# undef CONFIG_SCHED_HPWORK +# undef CONFIG_SCHED_LPWORK +# undef CONFIG_SCHED_WORKQUEUE /* User-space worker threads are not built in a kernel build when we are * building the kernel-space libraries (but we still need to know that it * is configured). */ -# endif - -#elif defined(CONFIG_BUILD_KERNEL) - /* The kernel only build is equivalent to the kernel part of the protected - * build. - */ - -#else - /* User-space worker threads are not built in a flat build - * (CONFIG_BUILD_PROTECTED=n && CONFIG_BUILD_KERNEL=n) - */ - -# undef CONFIG_LIB_USRWORK #endif /* High priority, kernel work queue configuration ***************************/ diff --git a/include/stdio.h b/include/stdio.h index 3cc81ae7f7..f9be618dd2 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -213,10 +213,10 @@ FAR char *tempnam(FAR const char *dir, FAR const char *pfx); int remove(FAR const char *path); /* Shell operations. These are not actually implemented in the OS. See - * apps/system/open for implementation. + * apps/system/popen for implementation. */ -#if !defined(CONFIG_BUILD_KERNEL) && !defined(__KERNEL__) +#ifndef __KERNEL__ FILE *popen(FAR const char *command, FAR const char *mode); int pclose(FILE *stream); #endif diff --git a/libs/libc/dlfcn/lib_dlsymtab.c b/libs/libc/dlfcn/lib_dlsymtab.c index 68ca34598e..a3d1343c6b 100644 --- a/libs/libc/dlfcn/lib_dlsymtab.c +++ b/libs/libc/dlfcn/lib_dlsymtab.c @@ -68,15 +68,7 @@ int dlsymtab(FAR const struct symtab_s *symtab, int nsymbols) { -#if defined(CONFIG_BUILD_FLAT) || defined(CONFIG_BUILD_PROTECTED) - /* Set the symbol take information that will be used by this instance of - * the module library. - */ - - modlib_setsymtab(symtab, nsymbols); - return OK; - -#else /* if defined(CONFIG_BUILD_KERNEL) */ +#ifdef CONFIG_BUILD_KERNEL /* The KERNEL build is considerably more complex: In order to be shared, * the .text portion of the module must be (1) build for PIC/PID operation * and (2) must like in a shared memory region accessible from all @@ -88,5 +80,13 @@ int dlsymtab(FAR const struct symtab_s *symtab, int nsymbols) #warning Missing logic return -ENOSYS; + +#else + /* Set the symbol take information that will be used by this instance of + * the module library. + */ + + modlib_setsymtab(symtab, nsymbols); + return OK; #endif } diff --git a/libs/libc/libc.h b/libs/libc/libc.h index e76da6c3c6..a467d4d55a 100644 --- a/libs/libc/libc.h +++ b/libs/libc/libc.h @@ -81,8 +81,7 @@ * mode is supported. */ -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) # include /* Domain-specific allocations */ diff --git a/libs/libc/misc/lib_stream.c b/libs/libc/misc/lib_stream.c index 6d05d1db3e..2aa48c99c9 100644 --- a/libs/libc/misc/lib_stream.c +++ b/libs/libc/misc/lib_stream.c @@ -52,8 +52,7 @@ #include "libc.h" -#if (!defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)) || \ - defined(__KERNEL__) +#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) /**************************************************************************** * Public Functions @@ -74,8 +73,7 @@ void lib_stream_initialize(FAR struct task_group_s *group) FAR struct streamlist *list; int i; -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP DEBUGASSERT(group && group->tg_streamlist); list = group->tg_streamlist; #else @@ -124,12 +122,9 @@ void lib_stream_initialize(FAR struct task_group_s *group) void lib_stream_release(FAR struct task_group_s *group) { FAR struct streamlist *list; -#ifndef CONFIG_STDIO_DISABLE_BUFFERING int i; -#endif -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP DEBUGASSERT(group && group->tg_streamlist); list = group->tg_streamlist; #else @@ -157,11 +152,7 @@ void lib_stream_release(FAR struct task_group_s *group) if (stream->fs_bufstart != NULL && (stream->fs_flags & __FS_FLAG_UBF) == 0) { -#ifndef CONFIG_BUILD_KERNEL - /* Release memory from the user heap */ - - kumm_free(stream->fs_bufstart); -#else +#ifdef CONFIG_BUILD_KERNEL /* If the exiting group is unprivileged, then it has an address * environment. Don't bother to release the memory in this case... * There is no point since the memory lies in the user heap which @@ -171,14 +162,16 @@ void lib_stream_release(FAR struct task_group_s *group) */ if ((group->tg_flags & GROUP_FLAG_PRIVILEGED) != 0) - { - kmm_free(stream->fs_bufstart); - } #endif + { + group_free(group, stream->fs_bufstart); + } } } #endif + + UNUSED(i); } #endif /* CONFIG_NFILE_STREAMS > 0 */ -#endif /* (!CONFIG_BUILD_PROTECTED && !CONFIG_BUILD_KERNEL) || __KERNEL__ */ +#endif /* CONFIG_BUILD_FLAT || __KERNEL__ */ diff --git a/libs/libc/misc/lib_utsname.c b/libs/libc/misc/lib_utsname.c index c14bab0605..03c91b3bdc 100644 --- a/libs/libc/misc/lib_utsname.c +++ b/libs/libc/misc/lib_utsname.c @@ -52,8 +52,7 @@ * a kernel system call. */ -#if (!defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)) || \ - defined(__KERNEL__) +#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) /**************************************************************************** * Pre-processor Definitions @@ -125,4 +124,4 @@ int uname(FAR struct utsname *name) return ret; } -#endif /* (!CONFIG_BUILD_PROTECTED) && !CONFIG_BUILD_KERNEL) || __KERNEL__ */ +#endif /* CONFIG_BUILD_FLAT || __KERNEL__ */ diff --git a/libs/libc/pthread/pthread_attr_init.c b/libs/libc/pthread/pthread_attr_init.c index cd89b20514..ef08b0a4c9 100644 --- a/libs/libc/pthread/pthread_attr_init.c +++ b/libs/libc/pthread/pthread_attr_init.c @@ -56,8 +56,7 @@ * the user address space. */ -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - !defined(__KERNEL__) +#if !defined(CONFIG_BUILD_FLAT) && !defined(__KERNEL__) const pthread_attr_t g_default_pthread_attr = PTHREAD_ATTR_INITIALIZER; #endif diff --git a/libs/libc/pthread/pthread_startup.c b/libs/libc/pthread/pthread_startup.c index f30f4a9da8..8b0003394b 100644 --- a/libs/libc/pthread/pthread_startup.c +++ b/libs/libc/pthread/pthread_startup.c @@ -44,8 +44,7 @@ #include -#if (defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__)) || \ - !defined(CONFIG_BUILD_KERNEL) +#if !defined(CONFIG_BUILD_FLAT) && !defined(__KERNEL__) /**************************************************************************** * Pre-processor Definitions @@ -106,4 +105,4 @@ void pthread_startup(pthread_startroutine_t entrypt, pthread_addr_t arg) pthread_exit(exit_status); } -#endif /* (CONFIG_BUILD_PROTECTED && !__KERNEL__) && !CONFIG_BUILD_KERNEL */ +#endif /* !CONFIG_BUILD_FLAT && !__KERNEL__ */ diff --git a/libs/libc/stdio/lib_libdtoa.c b/libs/libc/stdio/lib_libdtoa.c index ae215298f7..99f1b943e0 100644 --- a/libs/libc/stdio/lib_libdtoa.c +++ b/libs/libc/stdio/lib_libdtoa.c @@ -170,17 +170,6 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec, int dsgn; /* Unused sign indicator */ int i; -#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) - /* This function may *NOT* be called within interrupt level logic. That is - * because the logic in __dtoa may attempt to allocate memory. That will - * lead to cryptic failures down the road within the memory manager. - * Better to explicitly assert upstream here. Rule: Don't use floating - * point formats on any output from interrupt handling logic. - */ - - DEBUGASSERT(up_interrupt_context() == false); -#endif - /* Set to default precision if none specified */ notrailing = false; diff --git a/libs/libc/unistd/lib_gethostname.c b/libs/libc/unistd/lib_gethostname.c index fc986c2681..9ed6f44ad1 100644 --- a/libs/libc/unistd/lib_gethostname.c +++ b/libs/libc/unistd/lib_gethostname.c @@ -105,8 +105,7 @@ int gethostname(FAR char *name, size_t namelen) * function. */ -#if (!defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)) || \ - defined(__KERNEL__) +#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) irqstate_t flags; diff --git a/libs/libc/unistd/lib_sethostname.c b/libs/libc/unistd/lib_sethostname.c index f2cb1fc71f..00f9ae2c70 100644 --- a/libs/libc/unistd/lib_sethostname.c +++ b/libs/libc/unistd/lib_sethostname.c @@ -52,8 +52,7 @@ * function only be called from user space is only via a kernel system call. */ -#if (!defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)) || \ - defined(__KERNEL__) +#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) /**************************************************************************** * Pre-processor Definitions @@ -124,4 +123,4 @@ int sethostname(FAR const char *name, size_t size) return 0; } -#endif /* (!CONFIG_BUILD_PROTECTED && !CONFIG_BUILD_KERNEL) || __KERNEL__ */ +#endif /* CONFIG_BUILD_FLAT || __KERNEL__ */ diff --git a/libs/libc/wqueue/Make.defs b/libs/libc/wqueue/Make.defs index db96583f92..4b8a5b7714 100644 --- a/libs/libc/wqueue/Make.defs +++ b/libs/libc/wqueue/Make.defs @@ -37,25 +37,8 @@ ifeq ($(CONFIG_LIB_USRWORK),y) # Add the work queue C files to the build -WORK_CSRCS += work_usrthread.c work_queue.c work_cancel.c work_signal.c -WORK_CSRCS += work_lock.c - -# Protected mode - -ifeq ($(CONFIG_BUILD_PROTECTED),y) -CSRCS += $(WORK_CSRCS) - -# Add the wqueue directory to the build - -DEPPATH += --dep-path wqueue -VPATH += :wqueue - -else - -# Kernel mode - -ifeq ($(CONFIG_BUILD_KERNEL),y) -CSRCS += $(WORK_CSRCS) +CSRCS += work_usrthread.c work_queue.c work_cancel.c work_signal.c +CSRCS += work_lock.c # Add the wqueue directory to the build @@ -63,5 +46,3 @@ DEPPATH += --dep-path wqueue VPATH += :wqueue endif -endif -endif diff --git a/libs/libnx/nxcontext.h b/libs/libnx/nxcontext.h index 910c9cc54c..9d36dc425f 100644 --- a/libs/libnx/nxcontext.h +++ b/libs/libnx/nxcontext.h @@ -60,8 +60,7 @@ * mode is supported. */ -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) # include diff --git a/libs/libxx/libxx.hxx b/libs/libxx/libxx.hxx index 758f4f5c20..ed2d739124 100644 --- a/libs/libxx/libxx.hxx +++ b/libs/libxx/libxx.hxx @@ -52,8 +52,7 @@ // built as separated kernel- and user-space modules, then only the first // mode is supported. -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) +#if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__) # include # define lib_malloc(s) kmm_malloc(s) # define lib_zalloc(s) kmm_zalloc(s) diff --git a/mm/mm_heap/mm_free.c b/mm/mm_heap/mm_free.c index bfac73f37b..7a1be11ad8 100644 --- a/mm/mm_heap/mm_free.c +++ b/mm/mm_heap/mm_free.c @@ -84,10 +84,9 @@ void mm_free(FAR struct mm_heap_s *heap, FAR void *mem) FAR struct mm_freenode_s *node; FAR struct mm_freenode_s *prev; FAR struct mm_freenode_s *next; -#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) int ret; -#endif + UNUSED(ret); minfo("Freeing %p\n", mem); /* Protect against attempts to free a NULL reference */ diff --git a/mm/mm_heap/mm_malloc.c b/mm/mm_heap/mm_malloc.c index e83bff84c9..71a5c5af81 100644 --- a/mm/mm_heap/mm_malloc.c +++ b/mm/mm_heap/mm_malloc.c @@ -59,9 +59,9 @@ * Private Functions ****************************************************************************/ -#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) static void mm_free_delaylist(FAR struct mm_heap_s *heap) { +#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) FAR struct mm_delaynode_s *tmp; irqstate_t flags; @@ -91,8 +91,8 @@ static void mm_free_delaylist(FAR struct mm_heap_s *heap) mm_free(heap, address); } -} #endif +} /**************************************************************************** * Public Functions @@ -116,11 +116,9 @@ FAR void *mm_malloc(FAR struct mm_heap_s *heap, size_t size) void *ret = NULL; int ndx; -#if defined(CONFIG_BUILD_FLAT) || defined(__KERNEL__) /* Firstly, free mm_delaylist */ mm_free_delaylist(heap); -#endif /* Ignore zero-length allocations */ diff --git a/mm/umm_heap/umm_globals.c b/mm/umm_heap/umm_globals.c index 2052e98102..8a423c61fc 100644 --- a/mm/umm_heap/umm_globals.c +++ b/mm/umm_heap/umm_globals.c @@ -47,7 +47,7 @@ * Public Data ****************************************************************************/ -#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) +#if defined(CONFIG_ARCH_ADDRENV) && defined(__KERNEL__) /* In the kernel build, there a 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 diff --git a/mm/umm_heap/umm_heap.h b/mm/umm_heap/umm_heap.h index 963c309b87..ee10403399 100644 --- a/mm/umm_heap/umm_heap.h +++ b/mm/umm_heap/umm_heap.h @@ -48,7 +48,7 @@ * Pre-processor Definitions ****************************************************************************/ -#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) +#if defined(CONFIG_ARCH_ADDRENV) && defined(__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 diff --git a/mm/umm_heap/umm_malloc.c b/mm/umm_heap/umm_malloc.c index ea2f13eeaf..261cd92c91 100644 --- a/mm/umm_heap/umm_malloc.c +++ b/mm/umm_heap/umm_malloc.c @@ -66,7 +66,7 @@ FAR void *malloc(size_t size) { -#ifdef CONFIG_BUILD_KERNEL +#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL) FAR void *brkaddr; FAR void *mem; diff --git a/sched/group/Make.defs b/sched/group/Make.defs index a8039475e7..18c1ba664b 100644 --- a/sched/group/Make.defs +++ b/sched/group/Make.defs @@ -64,12 +64,8 @@ ifeq ($(CONFIG_BINFMT_LOADABLE),y) CSRCS += group_exitinfo.c endif -ifeq ($(CONFIG_BUILD_PROTECTED),y) +ifneq ($(CONFIG_BUILD_FLAT),y) CSRCS += group_malloc.c group_zalloc.c group_free.c -else -ifeq ($(CONFIG_BUILD_KERNEL),y) -CSRCS += group_malloc.c group_zalloc.c group_free.c -endif endif # Include group build support diff --git a/sched/group/group_create.c b/sched/group/group_create.c index 6ab4c9dbc1..821233f23d 100644 --- a/sched/group/group_create.c +++ b/sched/group/group_create.c @@ -225,8 +225,7 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype) return -ENOMEM; } -#if CONFIG_NFILE_STREAMS > 0 && (defined(CONFIG_BUILD_PROTECTED) || \ - defined(CONFIG_BUILD_KERNEL)) && defined(CONFIG_MM_KERNEL_HEAP) +#if CONFIG_NFILE_STREAMS > 0 && defined(CONFIG_MM_KERNEL_HEAP) /* If this group is being created for a privileged thread, then all elements * of the group must be created for privileged access. */ @@ -276,8 +275,7 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype) ret = env_dup(group); if (ret < 0) { -#if CONFIG_NFILE_STREAMS > 0 && (defined(CONFIG_BUILD_PROTECTED) || \ - defined(CONFIG_BUILD_KERNEL)) && defined(CONFIG_MM_KERNEL_HEAP) +#if CONFIG_NFILE_STREAMS > 0 && defined(CONFIG_MM_KERNEL_HEAP) group_free(group, group->tg_streamlist); #endif kmm_free(group); diff --git a/sched/group/group_free.c b/sched/group/group_free.c index 532648530b..1ee8494e00 100644 --- a/sched/group/group_free.c +++ b/sched/group/group_free.c @@ -47,8 +47,7 @@ #include "sched/sched.h" #include "group/group.h" -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /**************************************************************************** * Public Functions @@ -92,4 +91,4 @@ void group_free(FAR struct task_group_s *group, FAR void *mem) } } -#endif /* CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL) && CONFIG_MM_KERNEL_HEAP */ +#endif /* CONFIG_MM_KERNEL_HEAP */ diff --git a/sched/group/group_leave.c b/sched/group/group_leave.c index 0194000dbf..ac08163bc7 100644 --- a/sched/group/group_leave.c +++ b/sched/group/group_leave.c @@ -229,14 +229,7 @@ static inline void group_release(FAR struct task_group_s *group) * freed here. */ -# if defined(CONFIG_BUILD_PROTECTED) - /* In the protected build, the task's stream list is always allocated - * and freed from the single, global user allocator. - */ - - kumm_free(group->tg_streamlist); - -# elif defined(CONFIG_BUILD_KERNEL) +# ifdef CONFIG_BUILD_KERNEL /* In the kernel build, the unprivileged process's stream list will be * allocated from with its per-process, private user heap. But in that * case, there is no reason to do anything here: That allocation resides @@ -245,16 +238,15 @@ static inline void group_release(FAR struct task_group_s *group) */ if ((group->tg_flags & GROUP_FLAG_PRIVILEGED) != 0) +# endif { /* But kernel threads are different in this build configuration: Their * stream lists were allocated from the common, global kernel heap and * must explicitly freed here. */ - kmm_free(group->tg_streamlist); + group_free(group, group->tg_streamlist); } - -# endif #endif #ifdef CONFIG_BINFMT_LOADABLE diff --git a/sched/group/group_malloc.c b/sched/group/group_malloc.c index 861207152b..4ab09a0305 100644 --- a/sched/group/group_malloc.c +++ b/sched/group/group_malloc.c @@ -47,8 +47,7 @@ #include "sched/sched.h" #include "group/group.h" -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /**************************************************************************** * Public Functions @@ -95,4 +94,4 @@ FAR void *group_malloc(FAR struct task_group_s *group, size_t nbytes) } } -#endif /* CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL) && CONFIG_MM_KERNEL_HEAP */ +#endif /* CONFIG_MM_KERNEL_HEAP */ diff --git a/sched/group/group_zalloc.c b/sched/group/group_zalloc.c index 50b883f687..0115ef4463 100644 --- a/sched/group/group_zalloc.c +++ b/sched/group/group_zalloc.c @@ -43,15 +43,14 @@ #include "group/group.h" -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: group_malloc + * Name: group_zalloc * * Description: * Allocate memory and clear appropriate for the group type. If the @@ -72,4 +71,4 @@ FAR void *group_zalloc(FAR struct task_group_s *group, size_t nbytes) return mem; } -#endif /* CONFIG_BUILD_PROTECTED || CONFIG_BUILD_KERNEL) && CONFIG_MM_KERNEL_HEAP */ +#endif /* CONFIG_MM_KERNEL_HEAP */ diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c index c74b09944a..75abaddb56 100644 --- a/sched/init/nx_start.c +++ b/sched/init/nx_start.c @@ -545,8 +545,6 @@ void nx_start(void) nxsem_initialize(); -#if defined(MM_KERNEL_USRHEAP_INIT) || defined(CONFIG_MM_KERNEL_HEAP) || \ - defined(CONFIG_MM_PGALLOC) /* Initialize the memory manager */ { @@ -571,10 +569,6 @@ void nx_start(void) kmm_initialize(heap_start, heap_size); #endif -#ifdef CONFIG_ARCH_USE_MODULE_TEXT - up_module_text_init(); -#endif - #ifdef CONFIG_MM_PGALLOC /* If there is a page allocator in the configuration, then get the page * heap information from the platform-specific code and configure the @@ -585,6 +579,9 @@ void nx_start(void) mm_pginitialize(heap_start, heap_size); #endif } + +#ifdef CONFIG_ARCH_USE_MODULE_TEXT + up_module_text_init(); #endif #ifdef CONFIG_MM_IOB diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index d748439050..e2e20033a8 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -204,11 +204,11 @@ static void pthread_start(void) * to switch to user-mode before calling into the pthread. */ -#if defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL) +#ifdef CONFIG_BUILD_FLAT + exit_status = (*ptcb->cmn.entry.pthread)(ptcb->arg); +#else up_pthread_start(ptcb->cmn.entry.pthread, ptcb->arg); exit_status = NULL; -#else - exit_status = (*ptcb->cmn.entry.pthread)(ptcb->arg); #endif /* The thread has returned (should never happen in the kernel mode case) */ diff --git a/sched/sched/sched_getstreams.c b/sched/sched/sched_getstreams.c index 3c727bffb7..958eb9b257 100644 --- a/sched/sched/sched_getstreams.c +++ b/sched/sched/sched_getstreams.c @@ -70,8 +70,7 @@ FAR struct streamlist *sched_getstreams(void) DEBUGASSERT(group); -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP return group->tg_streamlist; #else return &group->tg_streamlist; diff --git a/sched/signal/sig_deliver.c b/sched/signal/sig_deliver.c index 10db415677..599c539315 100644 --- a/sched/signal/sig_deliver.c +++ b/sched/signal/sig_deliver.c @@ -136,7 +136,7 @@ void nxsig_deliver(FAR struct tcb_s *stcb) SIGNO2SET(sigq->info.si_signo); stcb->sigprocmask = newsigprocmask; -#if defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL) +#ifndef CONFIG_BUILD_FLAT /* In the kernel build this has to be handled differently if we are * dispatching to a signal handler in a user-space task or thread; we * have to switch to user-mode before calling the task. diff --git a/sched/task/task_exithook.c b/sched/task/task_exithook.c index 078871dc19..a7646358f0 100644 --- a/sched/task/task_exithook.c +++ b/sched/task/task_exithook.c @@ -570,8 +570,7 @@ static inline void nxtask_flushstreams(FAR struct tcb_s *tcb) if (group && group->tg_nmembers == 1) { -#if (defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL)) && \ - defined(CONFIG_MM_KERNEL_HEAP) +#ifdef CONFIG_MM_KERNEL_HEAP lib_flushall(tcb->group->tg_streamlist); #else lib_flushall(&tcb->group->tg_streamlist); diff --git a/sched/task/task_start.c b/sched/task/task_start.c index 54b1bb9bdb..ccb3315529 100644 --- a/sched/task/task_start.c +++ b/sched/task/task_start.c @@ -134,7 +134,7 @@ void nxtask_start(void) * we have to switch to user-mode before calling the task. */ -#if defined(CONFIG_BUILD_PROTECTED) || defined(CONFIG_BUILD_KERNEL) +#ifndef CONFIG_BUILD_FLAT if ((tcb->cmn.flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL) { up_task_start(tcb->cmn.entry.main, argc, tcb->argv); diff --git a/tools/Directories.mk b/tools/Directories.mk index 70a07ab70f..f63fb03013 100644 --- a/tools/Directories.mk +++ b/tools/Directories.mk @@ -64,13 +64,11 @@ USERDEPDIRS := ifeq ($(CONFIG_BUILD_PROTECTED),y) USERDEPDIRS += $(APPDIR) -else -ifneq ($(CONFIG_BUILD_KERNEL),y) +else ifneq ($(CONFIG_BUILD_KERNEL),y) KERNDEPDIRS += $(APPDIR) else CLEANDIRS += $(APPDIR) endif -endif KERNDEPDIRS += sched drivers boards $(ARCH_SRC) KERNDEPDIRS += fs binfmt diff --git a/tools/Makefile.unix b/tools/Makefile.unix index a668447d9b..e332a4c653 100644 --- a/tools/Makefile.unix +++ b/tools/Makefile.unix @@ -170,9 +170,7 @@ LINKLIBS = $(patsubst staging/%,%,$(NUTTXLIBS)) MKEXPORT= tools/mkexport.sh MKEXPORT_ARGS = -w$(WINTOOL) -t "$(TOPDIR)" -ifeq ($(CONFIG_BUILD_PROTECTED),y) -MKEXPORT_ARGS += -u -else ifeq ($(CONFIG_BUILD_KERNEL),y) +ifneq ($(CONFIG_BUILD_FLAT),y) MKEXPORT_ARGS += -u endif diff --git a/tools/Makefile.win b/tools/Makefile.win index 1b987339b4..5950f69690 100644 --- a/tools/Makefile.win +++ b/tools/Makefile.win @@ -152,9 +152,7 @@ LINKLIBS = $(patsubst staging\\%,%,$(NUTTXLIBS)) MKEXPORT = tools\mkexport.bat MKEXPORT_ARGS = -w$(WINTOOL) -t "$(TOPDIR)" -ifeq ($(CONFIG_BUILD_PROTECTED),y) -MKEXPORT_ARGS += -u -else ifeq ($(CONFIG_BUILD_KERNEL),y) +ifneq ($(CONFIG_BUILD_FLAT),y) MKEXPORT_ARGS += -u endif