diff --git a/mm/iob/CMakeLists.txt b/mm/iob/CMakeLists.txt index 87e05fc829..dbe9234dbd 100644 --- a/mm/iob/CMakeLists.txt +++ b/mm/iob/CMakeLists.txt @@ -20,38 +20,34 @@ if(CONFIG_MM_IOB) - set(SRCS) - - list( - APPEND - SRCS - iob_add_queue.c - iob_alloc.c - iob_alloc_qentry.c - iob_clone.c - iob_concat.c - iob_copyin.c - iob_copyout.c - iob_contig.c - iob_free.c - iob_free_chain.c - iob_free_qentry.c - iob_free_queue.c - iob_initialize.c - iob_pack.c - iob_peek_queue.c - iob_remove_queue.c - iob_statistics.c - iob_trimhead.c - iob_trimhead_queue.c - iob_trimtail.c - iob_navail.c - iob_free_queue_qentry.c - iob_tailroom.c - iob_get_queue_size.c - iob_reserve.c - iob_update_pktlen.c - iob_count.c) + set(SRCS + iob_add_queue.c + iob_alloc.c + iob_alloc_qentry.c + iob_clone.c + iob_concat.c + iob_copyin.c + iob_copyout.c + iob_contig.c + iob_free.c + iob_free_chain.c + iob_free_qentry.c + iob_free_queue.c + iob_initialize.c + iob_pack.c + iob_peek_queue.c + iob_remove_queue.c + iob_statistics.c + iob_trimhead.c + iob_trimhead_queue.c + iob_trimtail.c + iob_navail.c + iob_free_queue_qentry.c + iob_tailroom.c + iob_get_queue_size.c + iob_reserve.c + iob_update_pktlen.c + iob_count.c) if(CONFIG_IOB_NOTIFIER) list(APPEND SRCS iob_notifier.c) @@ -61,6 +57,9 @@ if(CONFIG_MM_IOB) list(APPEND SRCS iob_dump.c) endif() + if(CONFIG_IOB_SECTION) + target_compile_options(mm PRIVATE -DIOB_SECTION=CONFIG_IOB_SECTION) + endif() target_sources(mm PRIVATE ${SRCS}) endif() diff --git a/mm/kmm_heap/CMakeLists.txt b/mm/kmm_heap/CMakeLists.txt index a571c806bc..075476d4e0 100644 --- a/mm/kmm_heap/CMakeLists.txt +++ b/mm/kmm_heap/CMakeLists.txt @@ -22,24 +22,20 @@ if(CONFIG_MM_KERNEL_HEAP) - set(SRCS) - - list( - APPEND - SRCS - kmm_initialize.c - kmm_addregion.c - kmm_malloc_size.c - kmm_brkaddr.c - kmm_calloc.c - kmm_extend.c - kmm_free.c - kmm_mallinfo.c - kmm_malloc.c - kmm_memalign.c - kmm_realloc.c - kmm_zalloc.c - kmm_heapmember.c) + set(SRCS + kmm_initialize.c + kmm_addregion.c + kmm_malloc_size.c + kmm_brkaddr.c + kmm_calloc.c + kmm_extend.c + kmm_free.c + kmm_mallinfo.c + kmm_malloc.c + kmm_memalign.c + kmm_realloc.c + kmm_zalloc.c + kmm_heapmember.c) if(CONFIG_DEBUG_MM) list(APPEND SRCS kmm_checkcorruption.c) diff --git a/mm/map/CMakeLists.txt b/mm/map/CMakeLists.txt index 80bf022b8d..5c5ba7726c 100644 --- a/mm/map/CMakeLists.txt +++ b/mm/map/CMakeLists.txt @@ -17,8 +17,7 @@ # the License. # # ############################################################################## -set(SRCS) -list(APPEND SRCS mm_map.c) +set(SRCS mm_map.c) if(CONFIG_ARCH_VMA_MAPPING) list(APPEND SRCS vm_region.c) diff --git a/mm/mempool/CMakeLists.txt b/mm/mempool/CMakeLists.txt index 49d108b5c2..8c2dcb53dc 100644 --- a/mm/mempool/CMakeLists.txt +++ b/mm/mempool/CMakeLists.txt @@ -17,8 +17,7 @@ # the License. # # ############################################################################## -set(SRCS) -list(APPEND SRCS mempool.c mempool_multiple.c) +set(SRCS mempool.c mempool_multiple.c) if(CONFIG_FS_PROCFS) if(NOT CONFIG_FS_PROCFS_EXCLUDE_MEMPOOL) diff --git a/mm/mm_gran/CMakeLists.txt b/mm/mm_gran/CMakeLists.txt index 6f6cfcad7b..50e8dbbd8c 100644 --- a/mm/mm_gran/CMakeLists.txt +++ b/mm/mm_gran/CMakeLists.txt @@ -21,19 +21,16 @@ # An optional granule allocator if(CONFIG_GRAN) - set(SRCS) - list( - APPEND - SRCS - mm_graninit.c - mm_granrelease.c - mm_granreserve.c - mm_granalloc.c - mm_granmark.c - mm_granfree.c - mm_graninfo.c - mm_grancritical.c) + set(SRCS + mm_graninit.c + mm_granrelease.c + mm_granreserve.c + mm_granalloc.c + mm_granmark.c + mm_granfree.c + mm_graninfo.c + mm_grancritical.c) # A page allocator based on the granule allocator diff --git a/mm/mm_heap/CMakeLists.txt b/mm/mm_heap/CMakeLists.txt index 6402c590b2..ddb935866a 100644 --- a/mm/mm_heap/CMakeLists.txt +++ b/mm/mm_heap/CMakeLists.txt @@ -22,29 +22,25 @@ if(CONFIG_MM_DEFAULT_MANAGER) - set(SRCS) - - list( - APPEND - SRCS - mm_initialize.c - mm_lock.c - mm_addfreechunk.c - mm_size2ndx.c - mm_malloc_size.c - mm_shrinkchunk.c - mm_brkaddr.c - mm_calloc.c - mm_extend.c - mm_free.c - mm_mallinfo.c - mm_malloc.c - mm_foreach.c - mm_memalign.c - mm_realloc.c - mm_zalloc.c - mm_heapmember.c - mm_memdump.c) + set(SRCS + mm_initialize.c + mm_lock.c + mm_addfreechunk.c + mm_size2ndx.c + mm_malloc_size.c + mm_shrinkchunk.c + mm_brkaddr.c + mm_calloc.c + mm_extend.c + mm_free.c + mm_mallinfo.c + mm_malloc.c + mm_foreach.c + mm_memalign.c + mm_realloc.c + mm_zalloc.c + mm_heapmember.c + mm_memdump.c) if(CONFIG_DEBUG_MM) list(APPEND SRCS mm_checkcorruption.c) diff --git a/mm/shm/CMakeLists.txt b/mm/shm/CMakeLists.txt index 98ee100283..fd8d24d1ec 100644 --- a/mm/shm/CMakeLists.txt +++ b/mm/shm/CMakeLists.txt @@ -21,5 +21,5 @@ # Shared memory allocator if(CONFIG_MM_SHM) - target_sources(mm PRIVATE shm_initialize.c shmat.c shmctl.c shmdt.c shmget.c) + target_sources(mm PRIVATE shmat.c shmctl.c shmdt.c shmget.c) endif() diff --git a/mm/tlsf/CMakeLists.txt b/mm/tlsf/CMakeLists.txt new file mode 100644 index 0000000000..3b3e3bb200 --- /dev/null +++ b/mm/tlsf/CMakeLists.txt @@ -0,0 +1,75 @@ +# ############################################################################## +# mm/tlsf/CMakeLists.txt +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +if(CONFIG_MM_TLSF_MANAGER) + + # ############################################################################ + # Config and Fetch tlsf + # ########################################################################TLSF + + set(TLSF_DIR ${CMAKE_CURRENT_LIST_DIR}/tlsf) + + if(NOT EXISTS ${TLSF_DIR}) + FetchContent_Declare( + tlsf_fetch + GIT_REPOSITORY https://github.com/mattconte/tlsf.git + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/tlsf BINARY_DIR + ${CMAKE_BINARY_DIR}/mm/tlsf/tlsf + PATCH_COMMAND + patch -p1 -d ${CMAKE_CURRENT_LIST_DIR} < + ${CMAKE_CURRENT_LIST_DIR}/0001-Add-TLSF_API-and-tlsf_printf.patch && + patch -p1 -d ${CMAKE_CURRENT_LIST_DIR} < + ${CMAKE_CURRENT_LIST_DIR}/0002-Define-_DEBUG-to-0-if-not-done-yet.patch + && patch -p1 -d ${CMAKE_CURRENT_LIST_DIR} < + ${CMAKE_CURRENT_LIST_DIR}/0003-Support-customize-FL_INDEX_MAX-to-reduce-the-memory-.patch + && patch -p1 -d ${CMAKE_CURRENT_LIST_DIR} < + ${CMAKE_CURRENT_LIST_DIR}/0004-Add-tlsf_extend_pool-function.patch && + patch -p1 -d ${CMAKE_CURRENT_LIST_DIR} < + ${CMAKE_CURRENT_LIST_DIR}/0005-Fix-warnining-on-implicit-pointer-conversion.patch + DOWNLOAD_NO_PROGRESS true + TIMEOUT 30) + + FetchContent_GetProperties(tlsf_fetch) + + if(NOT tlsf_fetch_POPULATED) + FetchContent_Populate(tlsf_fetch) + endif() + endif() + + # ############################################################################ + # Flags + # ############################################################################ + + set(CFLAGS -Dtlsf_printf=if\(0\)printf) + + # ############################################################################ + # Sources + # ############################################################################ + + set(CSRCS mm_tlsf.c ${TLSF_DIR}/tlsf.c) + + # ############################################################################ + # Library Configuration + # ############################################################################ + + target_sources(mm PRIVATE ${CSRCS}) + target_compile_options(mm PRIVATE ${CFLAGS}) + +endif() diff --git a/mm/ubsan/CMakeLists.txt b/mm/ubsan/CMakeLists.txt new file mode 100644 index 0000000000..f7fbd8304d --- /dev/null +++ b/mm/ubsan/CMakeLists.txt @@ -0,0 +1,25 @@ +# ############################################################################## +# mm/ubsan/CMakeLists.txt +# +# Licensed to the Apache Software Foundation (ASF) under one or more contributor +# license agreements. See the NOTICE file distributed with this work for +# additional information regarding copyright ownership. The ASF licenses this +# file to you under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +# +# ############################################################################## + +if(CONFIG_MM_UBSAN) + + target_sources(mm PRIVATE ubsan.c) + +endif() diff --git a/mm/umm_heap/CMakeLists.txt b/mm/umm_heap/CMakeLists.txt index 0df7edd7d2..78f906e780 100644 --- a/mm/umm_heap/CMakeLists.txt +++ b/mm/umm_heap/CMakeLists.txt @@ -20,24 +20,22 @@ # User heap allocator -set(SRCS) - -list( - APPEND - SRCS - umm_initialize.c - umm_addregion.c - umm_brkaddr.c - umm_calloc.c - umm_extend.c - umm_free.c - umm_mallinfo.c - umm_malloc.c - umm_memalign.c - umm_realloc.c - umm_zalloc.c - umm_heapmember.c - umm_globals.c) +set(SRCS + umm_initialize.c + umm_addregion.c + umm_brkaddr.c + umm_calloc.c + umm_extend.c + umm_free.c + umm_mallinfo.c + umm_malloc.c + umm_memalign.c + umm_realloc.c + umm_zalloc.c + umm_heapmember.c + umm_globals.c + umm_memdump.c + umm_malloc_size.c) if(CONFIG_BUILD_KERNEL) list(APPEND SRCS umm_sbrk.c)