Skip to content

[libc] Move freelist + block to __support #96231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions libc/src/__support/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,47 @@
add_subdirectory(CPP)
add_subdirectory(macros)

add_header_library(
block
HDRS
block.h
DEPENDS
libc.src.__support.CPP.algorithm
libc.src.__support.CPP.limits
libc.src.__support.CPP.new
libc.src.__support.CPP.optional
libc.src.__support.CPP.span
libc.src.__support.CPP.type_traits
)

add_header_library(
freelist
HDRS
freelist.h
DEPENDS
libc.src.__support.fixedvector
libc.src.__support.CPP.array
libc.src.__support.CPP.cstddef
libc.src.__support.CPP.new
libc.src.__support.CPP.span
)

add_header_library(
freelist_heap
HDRS
freelist_heap.h
DEPENDS
.block
.freelist
libc.src.__support.CPP.cstddef
libc.src.__support.CPP.array
libc.src.__support.CPP.optional
libc.src.__support.CPP.span
libc.src.__support.libc_assert
libc.src.string.memory_utils.inline_memcpy
libc.src.string.memory_utils.inline_memset
)

add_header_library(
blockstore
HDRS
Expand Down
6 changes: 3 additions & 3 deletions libc/src/stdlib/block.h → libc/src/__support/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_STDLIB_BLOCK_H
#define LLVM_LIBC_SRC_STDLIB_BLOCK_H
#ifndef LLVM_LIBC_SRC___SUPPORT_BLOCK_H
#define LLVM_LIBC_SRC___SUPPORT_BLOCK_H

#include "src/__support/CPP/algorithm.h"
#include "src/__support/CPP/cstddef.h"
Expand Down Expand Up @@ -481,4 +481,4 @@ internal::BlockStatus Block<OffsetType, kAlign>::check_status() const {

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_STDLIB_BLOCK_H
#endif // LLVM_LIBC_SRC___SUPPORT_BLOCK_H
6 changes: 3 additions & 3 deletions libc/src/stdlib/freelist.h → libc/src/__support/freelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_STDLIB_FREELIST_H
#define LLVM_LIBC_SRC_STDLIB_FREELIST_H
#ifndef LLVM_LIBC_SRC___SUPPORT_FREELIST_H
#define LLVM_LIBC_SRC___SUPPORT_FREELIST_H

#include "src/__support/CPP/array.h"
#include "src/__support/CPP/cstddef.h"
Expand Down Expand Up @@ -187,4 +187,4 @@ FreeList<NUM_BUCKETS>::find_chunk_ptr_for_size(size_t size,

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_STDLIB_FREELIST_H
#endif // LLVM_LIBC_SRC___SUPPORT_FREELIST_H
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_STDLIB_FREELIST_HEAP_H
#define LLVM_LIBC_SRC_STDLIB_FREELIST_HEAP_H
#ifndef LLVM_LIBC_SRC___SUPPORT_FREELIST_HEAP_H
#define LLVM_LIBC_SRC___SUPPORT_FREELIST_HEAP_H

#include <stddef.h>

Expand Down Expand Up @@ -220,4 +220,4 @@ extern FreeListHeap<> *freelist_heap;

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_STDLIB_FREELIST_HEAP_H
#endif // LLVM_LIBC_SRC___SUPPORT_FREELIST_HEAP_H
40 changes: 1 addition & 39 deletions libc/src/stdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -380,44 +380,6 @@ elseif(LIBC_TARGET_OS_IS_GPU)
aligned_alloc
)
else()
add_header_library(
block
HDRS
block.h
DEPENDS
libc.src.__support.CPP.algorithm
libc.src.__support.CPP.limits
libc.src.__support.CPP.new
libc.src.__support.CPP.optional
libc.src.__support.CPP.span
libc.src.__support.CPP.type_traits
)
add_header_library(
freelist
HDRS
freelist.h
DEPENDS
libc.src.__support.fixedvector
libc.src.__support.CPP.array
libc.src.__support.CPP.cstddef
libc.src.__support.CPP.new
libc.src.__support.CPP.span
)
add_header_library(
freelist_heap
HDRS
freelist_heap.h
DEPENDS
.block
.freelist
libc.src.__support.CPP.cstddef
libc.src.__support.CPP.array
libc.src.__support.CPP.optional
libc.src.__support.CPP.span
libc.src.__support.libc_assert
libc.src.string.memory_utils.inline_memcpy
libc.src.string.memory_utils.inline_memset
)
# Only add malloc in full build mode. Use the system malloc in overlay mode.
if(LLVM_LIBC_FULL_BUILD)
add_entrypoint_object(
Expand All @@ -427,7 +389,7 @@ else()
HDRS
malloc.h
DEPENDS
.freelist_heap
libc.src.__support.freelist_heap
)
else()
add_entrypoint_external(
Expand Down
2 changes: 1 addition & 1 deletion libc/src/stdlib/freelist_malloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//

#include "freelist_heap.h"
#include "src/__support/freelist_heap.h"
#include "src/stdlib/calloc.h"
#include "src/stdlib/free.h"
#include "src/stdlib/malloc.h"
Expand Down
42 changes: 42 additions & 0 deletions libc/test/src/__support/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,47 @@
add_custom_target(libc-support-tests)

add_libc_test(
block_test
SUITE
libc-support-tests
SRCS
block_test.cpp
DEPENDS
libc.src.__support.CPP.array
libc.src.__support.CPP.span
libc.src.__support.block
libc.src.string.memcpy
)

add_libc_test(
freelist_test
SUITE
libc-support-tests
SRCS
freelist_test.cpp
DEPENDS
libc.src.__support.CPP.array
libc.src.__support.CPP.span
libc.src.__support.freelist
)

if(LLVM_LIBC_FULL_BUILD)
add_libc_test(
freelist_heap_test
SUITE
libc-support-tests
SRCS
freelist_heap_test.cpp
freelist_malloc_test.cpp
DEPENDS
libc.src.__support.CPP.span
libc.src.__support.freelist_heap
libc.src.stdlib.malloc
libc.src.string.memcmp
libc.src.string.memcpy
)
endif()

add_libc_test(
blockstore_test
SUITE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
//===----------------------------------------------------------------------===//
#include <stddef.h>

#include "src/stdlib/block.h"

#include "src/__support/CPP/array.h"
#include "src/__support/CPP/span.h"
#include "src/__support/block.h"
#include "src/string/memcpy.h"
#include "test/UnitTest/Test.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//

#include "src/__support/CPP/span.h"
#include "src/stdlib/freelist_heap.h"
#include "src/__support/freelist_heap.h"
#include "src/string/memcmp.h"
#include "src/string/memcpy.h"
#include "test/UnitTest/Test.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
//
//===----------------------------------------------------------------------===//

#include "src/__support/freelist_heap.h"
#include "src/stdlib/calloc.h"
#include "src/stdlib/free.h"
#include "src/stdlib/freelist_heap.h"
#include "src/stdlib/malloc.h"
#include "test/UnitTest/Test.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#include "src/__support/CPP/array.h"
#include "src/__support/CPP/span.h"
#include "src/stdlib/freelist.h"
#include "src/__support/freelist.h"
#include "test/UnitTest/Test.h"

using LIBC_NAMESPACE::FreeList;
Expand Down
42 changes: 0 additions & 42 deletions libc/test/src/stdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,48 +54,6 @@ add_libc_test(
libc.src.stdlib.atoll
)

add_libc_test(
block_test
SUITE
libc-stdlib-tests
SRCS
block_test.cpp
DEPENDS
libc.src.stdlib.block
libc.src.__support.CPP.array
libc.src.__support.CPP.span
libc.src.string.memcpy
)

add_libc_test(
freelist_test
SUITE
libc-stdlib-tests
SRCS
freelist_test.cpp
DEPENDS
libc.src.stdlib.freelist
libc.src.__support.CPP.array
libc.src.__support.CPP.span
)

if(LLVM_LIBC_FULL_BUILD)
add_libc_test(
freelist_heap_test
SUITE
libc-stdlib-tests
SRCS
freelist_heap_test.cpp
freelist_malloc_test.cpp
DEPENDS
libc.src.__support.CPP.span
libc.src.stdlib.freelist_heap
libc.src.stdlib.malloc
libc.src.string.memcmp
libc.src.string.memcpy
)
endif()

add_fp_unittest(
strtod_test
SUITE
Expand Down
Loading