But I don't understand this logic: When does
!defined(CONFIG_BUILD_KERNEL) && defined(__KERNEL__) happen?

In the build, we build both user space code and internal OS code.  __KERNEL__, if defined means that we are currently building the internal OS code.  That allows the same files to be build differently depending on if it is inside our outside the OS.

defined(__KERNEL__) means we are build OS internal code

CONFIG_BUILD_KERNEL means that we performing a KERNEL build.  In the KERNEL build, the OS has its own private heap.

!defined(CONFIG_BUILD_KERNEL) means that we are doing a FLAT or a PROTECTED build.

In the FLAT build there is only one heap.  In the PROTECTED build there is a kernel heap and a user heap.  In KERNEL build there is a kernel heap, and a separate heap for every process that is populated via sbrk().



Reply via email to