Refine __KERNEL__ and CONFIG_BUILD_xxx usage in the code base

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2020-04-30 03:21:23 +08:00
committed by Alan Carvalho de Assis
parent fe5cb9529d
commit eca7059785
83 changed files with 158 additions and 339 deletions
+1 -1
View File
@@ -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
-4
View File
@@ -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
+4 -18
View File
@@ -48,7 +48,7 @@
/* How can we access the errno variable? */
#if !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL)
#ifdef CONFIG_BUILD_FLAT
/* Flat build */
# if defined(CONFIG_LIB_SYSCALL) && !defined(__KERNEL__)
@@ -66,31 +66,17 @@
# define __DIRECT_ERRNO_ACCESS 1
# endif
#elif defined(CONFIG_BUILD_PROTECTED)
#else
# if defined(__KERNEL__)
/* Kernel portion of protected build. Kernel code has direct access */
/* Kernel portion of protected/kernel build. Kernel code has direct access */
# define __DIRECT_ERRNO_ACCESS 1
# else
/* User portion of protected build. Application code has only indirect
/* User portion of protected/kernel build. Application code has only indirect
* access
*/
# undef __DIRECT_ERRNO_ACCESS
# endif
#elif defined(CONFIG_BUILD_KERNEL) && !defined(__KERNEL__)
# if defined(__KERNEL__)
/* Kernel build. Kernel code has direct access */
# define __DIRECT_ERRNO_ACCESS 1
# else
/* User libraries for the kernel. Only indirect access from user
* libraries
*/
# undef __DIRECT_ERRNO_ACCESS
# endif
#endif
+5 -7
View File
@@ -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;
+4 -9
View File
@@ -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,
+2 -24
View File
@@ -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 */
+4 -13
View File
@@ -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 **************************************/
+1 -2
View File
@@ -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 */
+2 -2
View File
@@ -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
+12 -21
View File
@@ -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 ***************************/
+2 -2
View File
@@ -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