You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2020/05/01 13:43:53 UTC

[incubator-nuttx] branch master updated (8b054db -> f8a809e)

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 8b054db  sim: Update hostfs after the recent struct stat timespec changes
     new fe5cb95  builtin: Remove HAVE_BUILTIN_CONTEXT macro
     new eca7059  Refine __KERNEL__ and CONFIG_BUILD_xxx usage in the code base
     new f8a809e  Fix nxstyle issue

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 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            |  6 ++--
 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         |  4 +--
 arch/misoc/src/lm32/lm32_releasestack.c        |  2 +-
 arch/misoc/src/minerva/minerva_createstack.c   |  8 +++---
 arch/misoc/src/minerva/minerva_releasestack.c  |  2 +-
 arch/or1k/src/common/up_createstack.c          | 36 +++++++++++------------
 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       |  6 ++--
 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 +--
 arch/risc-v/src/rv64gc/riscv_signal_dispatch.c |  5 ++--
 arch/x86/src/i486/up_createstack.c             |  6 ++--
 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 +-
 binfmt/binfmt.h                                |  4 +--
 binfmt/binfmt_initialize.c                     |  2 +-
 binfmt/builtin.c                               |  4 +--
 drivers/input/button_lower.c                   |  3 +-
 drivers/leds/userled_lower.c                   |  6 ++--
 fs/vfs/fs_fdopen.c                             |  7 ++---
 include/aio.h                                  |  5 +++-
 include/dsp.h                                  |  4 ---
 include/errno.h                                | 40 +++++++++-----------------
 include/nuttx/arch.h                           | 12 ++++----
 include/nuttx/clock.h                          | 15 ++++------
 include/nuttx/kmalloc.h                        | 26 ++---------------
 include/nuttx/lib/builtin.h                    | 12 +-------
 include/nuttx/mm/mm.h                          | 17 +++--------
 include/nuttx/sched.h                          |  5 ++--
 include/nuttx/userspace.h                      | 16 +++++++----
 include/nuttx/wqueue.h                         | 33 ++++++++-------------
 include/stdio.h                                |  8 ++++--
 libs/libc/builtin/lib_builtin_forindex.c       |  4 ---
 libs/libc/builtin/lib_builtin_getname.c        |  4 ---
 libs/libc/builtin/lib_builtin_isavail.c        |  4 ---
 libs/libc/dlfcn/lib_dlsymtab.c                 | 18 ++++++------
 libs/libc/libc.h                               | 15 +++++-----
 libs/libc/misc/lib_stream.c                    | 25 ++++++----------
 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                  | 17 +++--------
 libs/libc/unistd/lib_gethostname.c             |  3 +-
 libs/libc/unistd/lib_sethostname.c             |  9 +++---
 libs/libc/wqueue/Make.defs                     | 23 ++-------------
 libs/libnx/nxcontext.h                         | 26 ++++++++---------
 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                         | 10 ++-----
 mm/umm_heap/umm_malloc.c                       |  2 +-
 sched/group/Make.defs                          |  6 +---
 sched/group/group_create.c                     | 18 ++++++------
 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 +--
 92 files changed, 252 insertions(+), 442 deletions(-)


[incubator-nuttx] 02/03: Refine __KERNEL__ and CONFIG_BUILD_xxx usage in the code base

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit eca70597858bc619d3114901d16e4a30f1ebffbe
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Apr 30 03:21:23 2020 +0800

    Refine __KERNEL__ and CONFIG_BUILD_xxx usage in the code base
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 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 ++--
 arch/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                    | 25 +++++++------------
 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, 157 insertions(+), 338 deletions(-)

diff --git a/arch/arm/src/armv6-m/arm_signal_dispatch.c b/arch/arm/src/armv6-m/arm_signal_dispatch.c
index d728057..8f3d3f2 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 10be736..7737292 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 6b21c32..e50236a 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 6718795..f6a0d37 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 eef30d7..4d3b773 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 3ee27ec..ce3dffd 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 9607c91..080ed30 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 e7bc25a..76204a2 100644
--- a/arch/arm/src/common/arm_releasestack.c
+++ b/arch/arm/src/common/arm_releasestack.c
@@ -48,18 +48,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 ce2a137..1182b9f 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 2244e9b..bcfb348 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 5b8ae83..77181da 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 5f95458..d9aa7f7 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 e8830fa..6d00694 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 cd43235..1e1ba28 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 21a66b7..c3eca9e 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 a9aa314..7da441f 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 d9bebc5..434d217 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 782cc07..dbe6aec 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 27dd597..2812e72 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 bcb6d83..1775a60 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 15880ad..79404e8 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 9ef5598..9e622b1 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 d44b9f9..7833b6c 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 f4461a0..5ba0551 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 913002c..0d318f2 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 b8c09ca..da674e5 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 b27df8b..f66b174 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 219062d..dab8710 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 37b3252..f1783c1 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 1aa1298..3dadf00 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 8173457..eb667a6 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 43acbf36..11760a9 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 d13c0ec..10e2b08 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 23a2fbf..2a66060 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 9cb3dc8..b96633d 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 4b2c417..fb6ef6e 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 5de680c..d2b8026 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 3f62467..ba557e8 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 2342186..a94b0b1 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 a2ba6e1..bc40a13 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 b139d2e..10b25f7 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 ebbd3e5..b83264c 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 595f5fe..90de7d5 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,33 +66,19 @@
 #    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
 
 /* Convenience/compatibility definition.
diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h
index c57bc42..4551a10 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 6a6027f..d209130 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 6ea4d8e..a8a3b04 100644
--- a/include/nuttx/kmalloc.h
+++ b/include/nuttx/kmalloc.h
@@ -34,8 +34,6 @@
 #include <nuttx/mm/mm.h>
 #include <nuttx/userspace.h>
 
-#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 f448138..f42c48a 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 4c49248..60564c2 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 d5e9243..1a1e4fa 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 f4e7260..d353772 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 3cc81ae..f9be618 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 68ca345..a3d1343 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 e76da6c..a467d4d 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 <nuttx/kmalloc.h>
 
    /* Domain-specific allocations */
diff --git a/libs/libc/misc/lib_stream.c b/libs/libc/misc/lib_stream.c
index 6d05d1d..2aa48c9 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)
+#endif
             {
-              kmm_free(stream->fs_bufstart);
+              group_free(group, stream->fs_bufstart);
             }
-#endif
         }
     }
 #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 c14bab0..03c91b3 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 cd89b20..ef08b0a 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 f30f4a9..8b00033 100644
--- a/libs/libc/pthread/pthread_startup.c
+++ b/libs/libc/pthread/pthread_startup.c
@@ -44,8 +44,7 @@
 
 #include <nuttx/userspace.h>
 
-#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 ae21529..99f1b94 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 fc986c2..9ed6f44 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 f2cb1fc..00f9ae2 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 db96583..4b8a5b7 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 910c9cc..9d36dc4 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 <nuttx/kmalloc.h>
 
diff --git a/libs/libxx/libxx.hxx b/libs/libxx/libxx.hxx
index 758f4f5..ed2d739 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 <nuttx/kmalloc.h>
 #  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 bfac73f..7a1be11 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 e83bff8..71a5c5a 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 2052e98..8a423c6 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 963c309..ee10403 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 ea2f13e..261cd92 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 a803947..18c1ba6 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 6ab4c9d..821233f 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 5326485..1ee8494 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 0194000..ac08163 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 8612071..4ab09a0 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 50b883f..0115ef4 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 c74b099..75abadd 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 d748439..e2e2003 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 3c727bf..958eb9b 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 10db415..599c539 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 078871d..a764635 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 54b1bb9..ccb3315 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 70a07ab..f63fb03 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 a668447..e332a4c 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 1b98733..5950f69 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
 


[incubator-nuttx] 03/03: Fix nxstyle issue

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit f8a809eb5b830eab1ddf872436d8ff744b16f107
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri May 1 02:43:08 2020 +0800

    Fix nxstyle issue
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 arch/hc/src/common/up_createstack.c          |  4 ++--
 arch/misoc/src/lm32/lm32_createstack.c       |  2 +-
 arch/misoc/src/minerva/minerva_createstack.c |  6 +++---
 arch/or1k/src/common/up_createstack.c        | 26 ++++++++++++++------------
 arch/renesas/src/common/up_createstack.c     |  4 ++--
 arch/x86/src/i486/up_createstack.c           |  4 ++--
 drivers/input/button_lower.c                 |  3 ++-
 drivers/leds/userled_lower.c                 |  6 ++++--
 fs/vfs/fs_fdopen.c                           |  4 ++--
 include/aio.h                                |  3 +++
 include/errno.h                              | 24 +++++++++++++-----------
 include/nuttx/clock.h                        |  2 +-
 include/nuttx/lib/builtin.h                  |  2 +-
 include/nuttx/sched.h                        |  2 +-
 include/nuttx/userspace.h                    | 12 ++++++++----
 include/stdio.h                              |  4 +++-
 libs/libc/libc.h                             | 12 ++++++------
 libs/libc/stdio/lib_libdtoa.c                |  6 ++++--
 libs/libc/unistd/lib_sethostname.c           |  4 ++--
 libs/libnx/nxcontext.h                       | 23 +++++++++++------------
 mm/umm_heap/umm_heap.h                       |  8 ++------
 sched/group/group_create.c                   | 12 ++++++------
 22 files changed, 93 insertions(+), 80 deletions(-)

diff --git a/arch/hc/src/common/up_createstack.c b/arch/hc/src/common/up_createstack.c
index d9aa7f7..e0948f9 100644
--- a/arch/hc/src/common/up_createstack.c
+++ b/arch/hc/src/common/up_createstack.c
@@ -182,12 +182,12 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
 
       /* Save the adjusted stack values in the struct tcb_s */
 
-      tcb->adj_stack_ptr  = (uint32_t*)top_of_stack;
+      tcb->adj_stack_ptr  = (uint32_t *)top_of_stack;
       tcb->adj_stack_size = size_of_stack;
 
       board_autoled_on(LED_STACKCREATED);
       return OK;
     }
 
-   return ERROR;
+  return ERROR;
 }
diff --git a/arch/misoc/src/lm32/lm32_createstack.c b/arch/misoc/src/lm32/lm32_createstack.c
index 7da441f..12da119 100644
--- a/arch/misoc/src/lm32/lm32_createstack.c
+++ b/arch/misoc/src/lm32/lm32_createstack.c
@@ -210,5 +210,5 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
       return OK;
     }
 
-   return ERROR;
+  return ERROR;
 }
diff --git a/arch/misoc/src/minerva/minerva_createstack.c b/arch/misoc/src/minerva/minerva_createstack.c
index dbe6aec..c9d26ad 100644
--- a/arch/misoc/src/minerva/minerva_createstack.c
+++ b/arch/misoc/src/minerva/minerva_createstack.c
@@ -185,9 +185,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
       top_of_stack = (uint32_t) tcb->stack_alloc_ptr + stack_size - 4;
 
       /* The MINERVA stack must be aligned at word (4 byte) boundaries; for
-       * floating point use, the stack must be aligned to 8-byte addresses. If
-       * necessary top_of_stack must be rounded down to the next boundary to
-       * meet these alignment requirements.
+       * floating point use, the stack must be aligned to 8-byte addresses.
+       * If necessary top_of_stack must be rounded down to the next boundary
+       * to meet these alignment requirements.
        */
 
       top_of_stack = STACK_ALIGN_DOWN(top_of_stack);
diff --git a/arch/or1k/src/common/up_createstack.c b/arch/or1k/src/common/up_createstack.c
index 1775a60..78cfee2 100644
--- a/arch/or1k/src/common/up_createstack.c
+++ b/arch/or1k/src/common/up_createstack.c
@@ -118,19 +118,19 @@
 int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
 {
 #ifdef CONFIG_TLS
-   /* Add the size of the TLS information structure */
+  /* Add the size of the TLS information structure */
 
-   stack_size += sizeof(struct tls_info_s);
+  stack_size += sizeof(struct tls_info_s);
 
-   /* The allocated stack size must not exceed the maximum possible for the
-    * TLS feature.
-    */
+  /* The allocated stack size must not exceed the maximum possible for the
+   * TLS feature.
+   */
 
-   DEBUGASSERT(stack_size <= TLS_MAXSTACK);
-   if (stack_size >= TLS_MAXSTACK)
-     {
-       stack_size = TLS_MAXSTACK;
-     }
+  DEBUGASSERT(stack_size <= TLS_MAXSTACK);
+  if (stack_size >= TLS_MAXSTACK)
+    {
+      stack_size = TLS_MAXSTACK;
+    }
 #endif
 
   /* Is there already a stack allocated of a different size?  Because of
@@ -229,8 +229,10 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
        * water marks.
        */
 
-      stack_base = (uintptr_t)tcb->stack_alloc_ptr + sizeof(struct tls_info_s);
-      stack_size = tcb->adj_stack_size - sizeof(struct tls_info_s);
+      stack_base = (uintptr_t)tcb->stack_alloc_ptr +
+                   sizeof(struct tls_info_s);
+      stack_size = tcb->adj_stack_size -
+                   sizeof(struct tls_info_s);
       up_stack_color((FAR void *)stack_base, stack_size);
 
 #endif /* CONFIG_STACK_COLORATION */
diff --git a/arch/renesas/src/common/up_createstack.c b/arch/renesas/src/common/up_createstack.c
index 5ba0551..bb6b974 100644
--- a/arch/renesas/src/common/up_createstack.c
+++ b/arch/renesas/src/common/up_createstack.c
@@ -182,12 +182,12 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
 
       /* Save the adjusted stack values in the struct tcb_s */
 
-      tcb->adj_stack_ptr  = (uint32_t*)top_of_stack;
+      tcb->adj_stack_ptr  = (uint32_t *)top_of_stack;
       tcb->adj_stack_size = size_of_stack;
 
       board_autoled_on(LED_STACKCREATED);
       return OK;
     }
 
-   return ERROR;
+  return ERROR;
 }
diff --git a/arch/x86/src/i486/up_createstack.c b/arch/x86/src/i486/up_createstack.c
index eb667a6..20b6486 100644
--- a/arch/x86/src/i486/up_createstack.c
+++ b/arch/x86/src/i486/up_createstack.c
@@ -182,12 +182,12 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
 
       /* Save the adjusted stack values in the struct tcb_s */
 
-      tcb->adj_stack_ptr  = (uint32_t*)top_of_stack;
+      tcb->adj_stack_ptr  = (uint32_t *)top_of_stack;
       tcb->adj_stack_size = size_of_stack;
 
       board_autoled_on(LED_STACKCREATED);
       return OK;
     }
 
-   return ERROR;
+  return ERROR;
 }
diff --git a/drivers/input/button_lower.c b/drivers/input/button_lower.c
index 67dd991..bebf028 100644
--- a/drivers/input/button_lower.c
+++ b/drivers/input/button_lower.c
@@ -57,7 +57,8 @@
  * Private Function Prototypes
  ****************************************************************************/
 
-static btn_buttonset_t btn_supported(FAR const struct btn_lowerhalf_s *lower);
+static btn_buttonset_t
+btn_supported(FAR const struct btn_lowerhalf_s *lower);
 static btn_buttonset_t btn_buttons(FAR const struct btn_lowerhalf_s *lower);
 static void btn_enable(FAR const struct btn_lowerhalf_s *lower,
                        btn_buttonset_t press, btn_buttonset_t release,
diff --git a/drivers/leds/userled_lower.c b/drivers/leds/userled_lower.c
index 8f2fc9d..74643fa 100644
--- a/drivers/leds/userled_lower.c
+++ b/drivers/leds/userled_lower.c
@@ -55,7 +55,8 @@
  * Private Function Prototypes
  ****************************************************************************/
 
-static userled_set_t userled_supported(FAR const struct userled_lowerhalf_s *lower);
+static userled_set_t
+userled_supported(FAR const struct userled_lowerhalf_s *lower);
 static void userled_led(FAR const struct userled_lowerhalf_s *lower,
                         int led, bool ledon);
 static void userled_ledset(FAR const struct userled_lowerhalf_s *lower,
@@ -86,7 +87,8 @@ static const struct userled_lowerhalf_s g_userled_lower =
  *
  ****************************************************************************/
 
-static userled_set_t userled_supported(FAR const struct userled_lowerhalf_s *lower)
+static userled_set_t
+userled_supported(FAR const struct userled_lowerhalf_s *lower)
 {
   ledinfo("BOARD_NLEDS: %02x\n", BOARD_NLEDS);
   return (userled_set_t)((1 << BOARD_NLEDS) - 1);
diff --git a/fs/vfs/fs_fdopen.c b/fs/vfs/fs_fdopen.c
index bc40a13..0a347a6 100644
--- a/fs/vfs/fs_fdopen.c
+++ b/fs/vfs/fs_fdopen.c
@@ -239,8 +239,8 @@ FAR struct file_struct *fs_fdopen(int fd, int oflags, FAR struct tcb_s *tcb)
 
           /* Set up pointers */
 
-          stream->fs_bufend  = &stream->fs_bufstart[CONFIG_STDIO_BUFFER_SIZE];
-          stream->fs_bufpos  = stream->fs_bufstart;
+          stream->fs_bufend = &stream->fs_bufstart[CONFIG_STDIO_BUFFER_SIZE];
+          stream->fs_bufpos = stream->fs_bufstart;
           stream->fs_bufread = stream->fs_bufstart;
 
 #ifdef CONFIG_STDIO_LINEBUFFER
diff --git a/include/aio.h b/include/aio.h
index 10b25f7..28e1c71 100644
--- a/include/aio.h
+++ b/include/aio.h
@@ -51,7 +51,9 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
+
 /* Configuration ************************************************************/
+
 /* These interfaces are not available to kernel code */
 
 #if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
@@ -75,6 +77,7 @@
 #endif
 
 /* Standard Definitions *****************************************************/
+
 /* aio_cancel return values
  *
  * AIO_ALLDONE     - Indicates that none of the requested operations could
diff --git a/include/errno.h b/include/errno.h
index 90de7d5..35dca42 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -49,33 +49,35 @@
 /* How can we access the errno variable? */
 
 #ifdef CONFIG_BUILD_FLAT
-   /* Flat build */
+  /* Flat build */
 
 #  if defined(CONFIG_LIB_SYSCALL) && !defined(__KERNEL__)
-   /* We still might be using system calls in user code.  If so, then
-    * user code will have no direct access to the errno variable.
-    */
+  /* We still might be using system calls in user code.  If so, then
+   * user code will have no direct access to the errno variable.
+   */
 
 #    undef __DIRECT_ERRNO_ACCESS
 
 #   else
-   /* Flat build with no system calls OR internal kernel logic... There
-    * is direct access.
-    */
+  /* Flat build with no system calls OR internal kernel logic... There
+   * is direct access.
+   */
 
 #    define __DIRECT_ERRNO_ACCESS 1
 #  endif
 
 #else
 #  if defined(__KERNEL__)
-   /* Kernel portion of protected/kernel 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/kernel build.  Application code has only indirect
-    * access
-    */
+  /* User portion of protected/kernel build. Application code has only
+   * indirect access
+   */
 
 #    undef __DIRECT_ERRNO_ACCESS
 #  endif
diff --git a/include/nuttx/clock.h b/include/nuttx/clock.h
index d209130..a2a8900 100644
--- a/include/nuttx/clock.h
+++ b/include/nuttx/clock.h
@@ -436,7 +436,7 @@ int clock_systimespec(FAR struct timespec *ts);
  *   Return load measurement data for the select PID.
  *
  * Input Parameters:
- *   pid - The task ID of the thread of interest.  pid == 0 is the IDLE thread.
+ *   pid - The task ID of the thread of interest. pid == 0 is IDLE thread.
  *   cpuload - The location to return the CPU load
  *
  * Returned Value:
diff --git a/include/nuttx/lib/builtin.h b/include/nuttx/lib/builtin.h
index 6d36520..6093d25 100644
--- a/include/nuttx/lib/builtin.h
+++ b/include/nuttx/lib/builtin.h
@@ -102,7 +102,7 @@ EXTERN const int g_builtin_count;
 #endif
 
 /****************************************************************************
- * Public Functions
+ * Public Function Prototypes
  ****************************************************************************/
 
 /****************************************************************************
diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index 60564c2..d45f1f0 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -63,7 +63,7 @@
 #  define HAVE_GROUP_MEMBERS  1
 #endif
 
-/* In any event, we don't need group members if support for pthreads is disabled */
+/* We don't need group members if support for pthreads is disabled */
 
 #ifdef CONFIG_DISABLE_PTHREAD
 #  undef HAVE_GROUP_MEMBERS
diff --git a/include/nuttx/userspace.h b/include/nuttx/userspace.h
index 1a1e4fa..c849b8a 100644
--- a/include/nuttx/userspace.h
+++ b/include/nuttx/userspace.h
@@ -54,7 +54,9 @@
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
+
 /* Configuration ************************************************************/
+
 /* If CONFIG_BUILD_PROTECTED, then CONFIG_NUTTX_USERSPACE must be defined to
  * provide the address where the user-space header can be found in memory.
  */
@@ -73,6 +75,7 @@
 #endif
 
 /* Helper Macros ************************************************************/
+
 /* This macro is used to access the struct userpace_s header that can be
  * found at the beginning of the user-space blob.
  */
@@ -89,9 +92,9 @@
 
 struct mm_heaps_s; /* Forward reference */
 
- /* Every user-space blob starts with a header that provides information about
- * the blob.  The form of that header is provided by struct userspace_s.  An
- * instance of this structure is expected to reside at CONFIG_NUTTX_USERSPACE.
+/* Every user-space blob starts with a header that provides information about
+ * the blob.  The form of that header is provided by struct userspace_s. An
+ * instance of this is expected to reside at CONFIG_NUTTX_USERSPACE.
  */
 
 struct userspace_s
@@ -166,7 +169,8 @@ extern "C"
  ****************************************************************************/
 
 #ifndef __KERNEL__
-void task_startup(main_t entrypt, int argc, FAR char *argv[]) noreturn_function;
+void task_startup(main_t entrypt, int argc, FAR char *argv[])
+       noreturn_function;
 #endif
 
 /****************************************************************************
diff --git a/include/stdio.h b/include/stdio.h
index f9be618..71213fd 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -172,7 +172,9 @@ void   setbuf(FAR FILE *stream, FAR char *buf);
 int    setvbuf(FAR FILE *stream, FAR char *buffer, int mode, size_t size);
 int    ungetc(int c, FAR FILE *stream);
 
-/* Operations on the stdout stream, buffers, paths, and the whole printf-family */
+/* Operations on the stdout stream, buffers, paths,
+ * and the whole printf-family
+ */
 
 void   perror(FAR const char *s);
 int    printf(FAR const IPTR char *fmt, ...);
diff --git a/libs/libc/libc.h b/libs/libc/libc.h
index a467d4d..71a58a2 100644
--- a/libs/libc/libc.h
+++ b/libs/libc/libc.h
@@ -45,9 +45,11 @@
 #include <sys/types.h>
 #include <stdbool.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <limits.h>
 #include <semaphore.h>
 
+#include <nuttx/kmalloc.h>
 #include <nuttx/streams.h>
 
 /****************************************************************************
@@ -82,9 +84,8 @@
  */
 
 #if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
-#  include <nuttx/kmalloc.h>
 
-   /* Domain-specific allocations */
+  /* Domain-specific allocations */
 
 #  define lib_malloc(s)     kmm_malloc(s)
 #  define lib_zalloc(s)     kmm_zalloc(s)
@@ -92,7 +93,7 @@
 #  define lib_memalign(p,s) kmm_memalign(p,s)
 #  define lib_free(p)       kmm_free(p)
 
-   /* User-accessible allocations */
+  /* User-accessible allocations */
 
 #  define lib_umalloc(s)    kumm_malloc(s)
 #  define lib_uzalloc(s)    kumm_zalloc(s)
@@ -100,16 +101,15 @@
 #  define lib_ufree(p)      kumm_free(p)
 
 #else
-#  include <stdlib.h>
 
-   /* Domain-specific allocations */
+  /* Domain-specific allocations */
 
 #  define lib_malloc(s)     malloc(s)
 #  define lib_zalloc(s)     zalloc(s)
 #  define lib_realloc(p,s)  realloc(p,s)
 #  define lib_free(p)       free(p)
 
-   /* User-accessible allocations */
+  /* User-accessible allocations */
 
 #  define lib_umalloc(s)    malloc(s)
 #  define lib_uzalloc(s)    zalloc(s)
diff --git a/libs/libc/stdio/lib_libdtoa.c b/libs/libc/stdio/lib_libdtoa.c
index 99f1b94..6f02566 100644
--- a/libs/libc/stdio/lib_libdtoa.c
+++ b/libs/libc/stdio/lib_libdtoa.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * libs/libc/unistd/lib_libdtoa.c
+ * libs/libc/stdio/lib_libdtoa.c
  *
  * This file was ported to NuttX by Yolande Cates.
  *
@@ -271,7 +271,9 @@ static void lib_dtoa(FAR struct lib_outstream_s *obj, int fmt, int prec,
         {
           obj->put(obj, '.');
 
-          /* Always print at least one digit to the right of the decimal point. */
+          /* Always print at least one digit to the right of the decimal
+           * point.
+           */
 
           if (notrailing)
             {
diff --git a/libs/libc/unistd/lib_sethostname.c b/libs/libc/unistd/lib_sethostname.c
index 00f9ae2..922ff48 100644
--- a/libs/libc/unistd/lib_sethostname.c
+++ b/libs/libc/unistd/lib_sethostname.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * libs/libc/unistd/lib_gethostname.c
+ * libs/libc/unistd/lib_sethostname.c
  *
  *   Copyright (C) 2015 Stavros Polymenis. All rights reserved.
  *   Copyright (C) 2015, 2016 Gregory Nutt. All rights reserved.
@@ -110,7 +110,7 @@ int sethostname(FAR const char *name, size_t size)
   irqstate_t flags;
 
   /* Save the new host name, truncating to HOST_NAME_MAX if necessary.  This
-   * internal copy is always NUL terminated.  The hostname is global resource.
+   * internal copy is always NUL terminated. The hostname is global resource.
    * There is a microscopic possibility that it could be accessed while we
    * are setting it.
    */
diff --git a/libs/libnx/nxcontext.h b/libs/libnx/nxcontext.h
index 9d36dc4..dbdeb88 100644
--- a/libs/libnx/nxcontext.h
+++ b/libs/libnx/nxcontext.h
@@ -45,26 +45,26 @@
 #include <sys/types.h>
 #include <stdbool.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <limits.h>
 
+#include <nuttx/kmalloc.h>
 #include <nuttx/streams.h>
 
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
 
-/* The NuttX NX library an be build in two modes: (1) as a standard, C-library
- * that can be used by normal, user-space applications, or (2) as a special,
- * kernel-mode NX-library only used within the OS.  If NuttX is not being
- * built as separated kernel- and user-space modules, then only the first
- * mode is supported.
+/* The NuttX NX library can be build in two modes: (1) as a standard, C-
+ * library that can be used by normal, user-space applications, or (2) as
+ * a special, kernel-mode NX-library only used within the OS.  If NuttX is
+ * not being built as separated kernel- and user-space modules, then only
+ * the first mode is supported.
  */
 
 #if !defined(CONFIG_BUILD_FLAT) && defined(__KERNEL__)
 
-#  include <nuttx/kmalloc.h>
-
-   /* Domain-specific allocations */
+  /* Domain-specific allocations */
 
 #  define lib_malloc(s)     kmm_malloc(s)
 #  define lib_zalloc(s)     kmm_zalloc(s)
@@ -72,7 +72,7 @@
 #  define lib_memalign(p,s) kmm_memalign(p,s)
 #  define lib_free(p)       kmm_free(p)
 
-   /* User-accessible allocations */
+  /* User-accessible allocations */
 
 #  define lib_umalloc(s)    kumm_malloc(s)
 #  define lib_uzalloc(s)    kumm_zalloc(s)
@@ -80,16 +80,15 @@
 #  define lib_ufree(p)      kumm_free(p)
 
 #else
-#  include <stdlib.h>
 
-   /* Domain-specific allocations */
+  /* Domain-specific allocations */
 
 #  define lib_malloc(s)     malloc(s)
 #  define lib_zalloc(s)     zalloc(s)
 #  define lib_realloc(p,s)  realloc(p,s)
 #  define lib_free(p)       free(p)
 
-   /* User-accessible allocations */
+  /* User-accessible allocations */
 
 #  define lib_umalloc(s)    malloc(s)
 #  define lib_uzalloc(s)    zalloc(s)
diff --git a/mm/umm_heap/umm_heap.h b/mm/umm_heap/umm_heap.h
index ee10403..f631044 100644
--- a/mm/umm_heap/umm_heap.h
+++ b/mm/umm_heap/umm_heap.h
@@ -42,6 +42,8 @@
 
 #include <nuttx/config.h>
 
+#include <nuttx/addrenv.h>
+#include <nuttx/userspace.h>
 #include <nuttx/mm/mm.h>
 
 /****************************************************************************
@@ -56,7 +58,6 @@
  * ARCH_DATA_RESERVE_SIZE
  */
 
-#  include <nuttx/addrenv.h>
 #  define USR_HEAP (&ARCH_DATA_RESERVE->ar_usrheap)
 
 #elif defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)
@@ -65,7 +66,6 @@
  * structure from the userspace interface.
  */
 
-#  include <nuttx/userspace.h>
 #  define USR_HEAP (USERSPACE->us_heap)
 
 #else
@@ -74,8 +74,4 @@
 #  define USR_HEAP &g_mmheap
 #endif
 
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
 #endif /* __MM_UMM_HEAP_UMM_HEAP_H */
diff --git a/sched/group/group_create.c b/sched/group/group_create.c
index 821233f..fcc1068 100644
--- a/sched/group/group_create.c
+++ b/sched/group/group_create.c
@@ -117,7 +117,7 @@ static void group_assign_grpid(FAR struct task_group_s *group)
 
   for (; ; )
     {
-      /* Increment the ID counter.  This is global data so be extra paranoid. */
+      /* Increment the ID counter. It is global data so be extra paranoid. */
 
       flags = enter_critical_section();
       grpid = ++g_grpid_counter;
@@ -193,8 +193,8 @@ static inline void group_inherit_identity(FAR struct task_group_s *group)
  *   function is called as part of the task creation sequence.  The structure
  *   allocated and zeroed, but otherwise uninitialized.  The full creation
  *   of the group of a two step process:  (1) First, this function allocates
- *   group structure early in the task creation sequence in order to provide a
- *   group container, then (2) group_initialize() is called to set up the
+ *   group structure early in the task creation sequence in order to provide
+ *   a group container, then (2) group_initialize() is called to set up the
  *   group membership.
  *
  * Input Parameters:
@@ -226,8 +226,8 @@ int group_allocate(FAR struct task_tcb_s *tcb, uint8_t ttype)
     }
 
 #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.
+  /* If this group is being created for a privileged thread, then all
+   * elements of the group must be created for privileged access.
    */
 
   if ((ttype & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
@@ -337,7 +337,7 @@ int group_initialize(FAR struct task_tcb_s *tcb)
 #ifdef HAVE_GROUP_MEMBERS
   /* Allocate space to hold GROUP_INITIAL_MEMBERS members of the group */
 
-  group->tg_members = (FAR pid_t *)kmm_malloc(GROUP_INITIAL_MEMBERS * sizeof(pid_t));
+  group->tg_members = kmm_malloc(GROUP_INITIAL_MEMBERS * sizeof(pid_t));
   if (!group->tg_members)
     {
       kmm_free(group);


[incubator-nuttx] 01/03: builtin: Remove HAVE_BUILTIN_CONTEXT macro

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit fe5cb9529d7539270bc6664a72c60f77ac85547a
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Thu Apr 30 14:35:04 2020 +0800

    builtin: Remove HAVE_BUILTIN_CONTEXT macro
    
    it's enough to decide which code should be compiled with CONFIG_BUILTIN and CONFIG_FS_BINFS
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 binfmt/binfmt.h                          |  4 ++--
 binfmt/binfmt_initialize.c               |  2 +-
 binfmt/builtin.c                         |  4 ++--
 include/nuttx/lib/builtin.h              | 10 ----------
 libs/libc/builtin/lib_builtin_forindex.c |  4 ----
 libs/libc/builtin/lib_builtin_getname.c  |  4 ----
 libs/libc/builtin/lib_builtin_isavail.c  |  4 ----
 7 files changed, 5 insertions(+), 27 deletions(-)

diff --git a/binfmt/binfmt.h b/binfmt/binfmt.h
index d26bd31..371d6f3 100644
--- a/binfmt/binfmt.h
+++ b/binfmt/binfmt.h
@@ -147,7 +147,7 @@ void binfmt_freeargv(FAR struct binary_s *bin);
  *
  ****************************************************************************/
 
-#if defined(CONFIG_FS_BINFS) && defined(HAVE_BUILTIN_CONTEXT)
+#ifdef CONFIG_FS_BINFS
 int builtin_initialize(void);
 #endif
 
@@ -162,7 +162,7 @@ int builtin_initialize(void);
  *
  ****************************************************************************/
 
-#if defined(CONFIG_FS_BINFS) && defined(HAVE_BUILTIN_CONTEXT)
+#ifdef CONFIG_FS_BINFS
 void builtin_uninitialize(void);
 #endif
 
diff --git a/binfmt/binfmt_initialize.c b/binfmt/binfmt_initialize.c
index 14c9558..99d16bb 100644
--- a/binfmt/binfmt_initialize.c
+++ b/binfmt/binfmt_initialize.c
@@ -64,7 +64,7 @@ void binfmt_initialize(void)
 {
   int ret;
 
-#if defined(CONFIG_FS_BINFS) && defined(HAVE_BUILTIN_CONTEXT)
+#ifdef CONFIG_FS_BINFS
   ret = builtin_initialize();
   if (ret < 0)
     {
diff --git a/binfmt/builtin.c b/binfmt/builtin.c
index a3356d2..57b2431 100644
--- a/binfmt/builtin.c
+++ b/binfmt/builtin.c
@@ -53,7 +53,7 @@
 #include <nuttx/binfmt/binfmt.h>
 #include <nuttx/lib/builtin.h>
 
-#ifdef HAVE_BUILTIN_CONTEXT
+#ifdef CONFIG_FS_BINFS
 
 /****************************************************************************
  * Private Function Prototypes
@@ -191,4 +191,4 @@ void builtin_uninitialize(void)
   unregister_binfmt(&g_builtin_binfmt);
 }
 
-#endif /* HAVE_BUILTIN_CONTEXT */
+#endif /* CONFIG_FS_BINFS */
diff --git a/include/nuttx/lib/builtin.h b/include/nuttx/lib/builtin.h
index 8e853d5..6d36520 100644
--- a/include/nuttx/lib/builtin.h
+++ b/include/nuttx/lib/builtin.h
@@ -53,16 +53,6 @@
 #ifdef CONFIG_BUILTIN
 
 /****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/* This logic is not usable in the KERNEL build from within the kernel. */
-
-#if !defined(CONFIG_BUILD_KERNEL) || !defined(__KERNEL__)
-#  define HAVE_BUILTIN_CONTEXT
-#endif
-
-/****************************************************************************
  * Public Types
  ****************************************************************************/
 
diff --git a/libs/libc/builtin/lib_builtin_forindex.c b/libs/libc/builtin/lib_builtin_forindex.c
index e8f1471..4c4ec70 100644
--- a/libs/libc/builtin/lib_builtin_forindex.c
+++ b/libs/libc/builtin/lib_builtin_forindex.c
@@ -43,8 +43,6 @@
 
 #include <nuttx/lib/builtin.h>
 
-#ifdef HAVE_BUILTIN_CONTEXT
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -77,5 +75,3 @@ FAR const struct builtin_s *builtin_for_index(int index)
 
   return NULL;
 }
-
-#endif /* HAVE_BUILTIN_CONTEXT */
diff --git a/libs/libc/builtin/lib_builtin_getname.c b/libs/libc/builtin/lib_builtin_getname.c
index 5627856..fa7a7b2 100644
--- a/libs/libc/builtin/lib_builtin_getname.c
+++ b/libs/libc/builtin/lib_builtin_getname.c
@@ -48,8 +48,6 @@
 
 #include <nuttx/lib/builtin.h>
 
-#ifdef HAVE_BUILTIN_CONTEXT
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -83,5 +81,3 @@ FAR const char *builtin_getname(int index)
 
   return NULL;
 }
-
-#endif /* HAVE_BUILTIN_CONTEXT */
diff --git a/libs/libc/builtin/lib_builtin_isavail.c b/libs/libc/builtin/lib_builtin_isavail.c
index 3a99fe0..d5b8f56 100644
--- a/libs/libc/builtin/lib_builtin_isavail.c
+++ b/libs/libc/builtin/lib_builtin_isavail.c
@@ -52,8 +52,6 @@
 
 #include <nuttx/lib/builtin.h>
 
-#ifdef HAVE_BUILTIN_CONTEXT
-
 /****************************************************************************
  * Public Functions
  ****************************************************************************/
@@ -92,5 +90,3 @@ int builtin_isavail(FAR const char *appname)
 
   return -ENOENT;
 }
-
-#endif /* HAVE_BUILTIN_CONTEXT */