Skip to content

Commit f77ade0

Browse files
authored
[libc] Move freelist + block to __support (#96231)
1 parent 6e38df3 commit f77ade0

File tree

12 files changed

+98
-96
lines changed

12 files changed

+98
-96
lines changed

libc/src/__support/CMakeLists.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,47 @@
11
add_subdirectory(CPP)
22
add_subdirectory(macros)
33

4+
add_header_library(
5+
block
6+
HDRS
7+
block.h
8+
DEPENDS
9+
libc.src.__support.CPP.algorithm
10+
libc.src.__support.CPP.limits
11+
libc.src.__support.CPP.new
12+
libc.src.__support.CPP.optional
13+
libc.src.__support.CPP.span
14+
libc.src.__support.CPP.type_traits
15+
)
16+
17+
add_header_library(
18+
freelist
19+
HDRS
20+
freelist.h
21+
DEPENDS
22+
libc.src.__support.fixedvector
23+
libc.src.__support.CPP.array
24+
libc.src.__support.CPP.cstddef
25+
libc.src.__support.CPP.new
26+
libc.src.__support.CPP.span
27+
)
28+
29+
add_header_library(
30+
freelist_heap
31+
HDRS
32+
freelist_heap.h
33+
DEPENDS
34+
.block
35+
.freelist
36+
libc.src.__support.CPP.cstddef
37+
libc.src.__support.CPP.array
38+
libc.src.__support.CPP.optional
39+
libc.src.__support.CPP.span
40+
libc.src.__support.libc_assert
41+
libc.src.string.memory_utils.inline_memcpy
42+
libc.src.string.memory_utils.inline_memset
43+
)
44+
445
add_header_library(
546
blockstore
647
HDRS

libc/src/stdlib/block.h renamed to libc/src/__support/block.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_LIBC_SRC_STDLIB_BLOCK_H
10-
#define LLVM_LIBC_SRC_STDLIB_BLOCK_H
9+
#ifndef LLVM_LIBC_SRC___SUPPORT_BLOCK_H
10+
#define LLVM_LIBC_SRC___SUPPORT_BLOCK_H
1111

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

482482
} // namespace LIBC_NAMESPACE
483483

484-
#endif // LLVM_LIBC_SRC_STDLIB_BLOCK_H
484+
#endif // LLVM_LIBC_SRC___SUPPORT_BLOCK_H

libc/src/stdlib/freelist.h renamed to libc/src/__support/freelist.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_LIBC_SRC_STDLIB_FREELIST_H
10-
#define LLVM_LIBC_SRC_STDLIB_FREELIST_H
9+
#ifndef LLVM_LIBC_SRC___SUPPORT_FREELIST_H
10+
#define LLVM_LIBC_SRC___SUPPORT_FREELIST_H
1111

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

188188
} // namespace LIBC_NAMESPACE
189189

190-
#endif // LLVM_LIBC_SRC_STDLIB_FREELIST_H
190+
#endif // LLVM_LIBC_SRC___SUPPORT_FREELIST_H

libc/src/stdlib/freelist_heap.h renamed to libc/src/__support/freelist_heap.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef LLVM_LIBC_SRC_STDLIB_FREELIST_HEAP_H
10-
#define LLVM_LIBC_SRC_STDLIB_FREELIST_HEAP_H
9+
#ifndef LLVM_LIBC_SRC___SUPPORT_FREELIST_HEAP_H
10+
#define LLVM_LIBC_SRC___SUPPORT_FREELIST_HEAP_H
1111

1212
#include <stddef.h>
1313

@@ -220,4 +220,4 @@ extern FreeListHeap<> *freelist_heap;
220220

221221
} // namespace LIBC_NAMESPACE
222222

223-
#endif // LLVM_LIBC_SRC_STDLIB_FREELIST_HEAP_H
223+
#endif // LLVM_LIBC_SRC___SUPPORT_FREELIST_HEAP_H

libc/src/stdlib/CMakeLists.txt

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -380,44 +380,6 @@ elseif(LIBC_TARGET_OS_IS_GPU)
380380
aligned_alloc
381381
)
382382
else()
383-
add_header_library(
384-
block
385-
HDRS
386-
block.h
387-
DEPENDS
388-
libc.src.__support.CPP.algorithm
389-
libc.src.__support.CPP.limits
390-
libc.src.__support.CPP.new
391-
libc.src.__support.CPP.optional
392-
libc.src.__support.CPP.span
393-
libc.src.__support.CPP.type_traits
394-
)
395-
add_header_library(
396-
freelist
397-
HDRS
398-
freelist.h
399-
DEPENDS
400-
libc.src.__support.fixedvector
401-
libc.src.__support.CPP.array
402-
libc.src.__support.CPP.cstddef
403-
libc.src.__support.CPP.new
404-
libc.src.__support.CPP.span
405-
)
406-
add_header_library(
407-
freelist_heap
408-
HDRS
409-
freelist_heap.h
410-
DEPENDS
411-
.block
412-
.freelist
413-
libc.src.__support.CPP.cstddef
414-
libc.src.__support.CPP.array
415-
libc.src.__support.CPP.optional
416-
libc.src.__support.CPP.span
417-
libc.src.__support.libc_assert
418-
libc.src.string.memory_utils.inline_memcpy
419-
libc.src.string.memory_utils.inline_memset
420-
)
421383
# Only add malloc in full build mode. Use the system malloc in overlay mode.
422384
if(LLVM_LIBC_FULL_BUILD)
423385
add_entrypoint_object(
@@ -427,7 +389,7 @@ else()
427389
HDRS
428390
malloc.h
429391
DEPENDS
430-
.freelist_heap
392+
libc.src.__support.freelist_heap
431393
)
432394
else()
433395
add_entrypoint_external(

libc/src/stdlib/freelist_malloc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "freelist_heap.h"
9+
#include "src/__support/freelist_heap.h"
1010
#include "src/stdlib/calloc.h"
1111
#include "src/stdlib/free.h"
1212
#include "src/stdlib/malloc.h"

libc/test/src/__support/CMakeLists.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
add_custom_target(libc-support-tests)
22

3+
add_libc_test(
4+
block_test
5+
SUITE
6+
libc-support-tests
7+
SRCS
8+
block_test.cpp
9+
DEPENDS
10+
libc.src.__support.CPP.array
11+
libc.src.__support.CPP.span
12+
libc.src.__support.block
13+
libc.src.string.memcpy
14+
)
15+
16+
add_libc_test(
17+
freelist_test
18+
SUITE
19+
libc-support-tests
20+
SRCS
21+
freelist_test.cpp
22+
DEPENDS
23+
libc.src.__support.CPP.array
24+
libc.src.__support.CPP.span
25+
libc.src.__support.freelist
26+
)
27+
28+
if(LLVM_LIBC_FULL_BUILD)
29+
add_libc_test(
30+
freelist_heap_test
31+
SUITE
32+
libc-support-tests
33+
SRCS
34+
freelist_heap_test.cpp
35+
freelist_malloc_test.cpp
36+
DEPENDS
37+
libc.src.__support.CPP.span
38+
libc.src.__support.freelist_heap
39+
libc.src.stdlib.malloc
40+
libc.src.string.memcmp
41+
libc.src.string.memcpy
42+
)
43+
endif()
44+
345
add_libc_test(
446
blockstore_test
547
SUITE

libc/test/src/stdlib/block_test.cpp renamed to libc/test/src/__support/block_test.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@
77
//===----------------------------------------------------------------------===//
88
#include <stddef.h>
99

10-
#include "src/stdlib/block.h"
11-
1210
#include "src/__support/CPP/array.h"
1311
#include "src/__support/CPP/span.h"
12+
#include "src/__support/block.h"
1413
#include "src/string/memcpy.h"
1514
#include "test/UnitTest/Test.h"
1615

libc/test/src/stdlib/freelist_heap_test.cpp renamed to libc/test/src/__support/freelist_heap_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "src/__support/CPP/span.h"
10-
#include "src/stdlib/freelist_heap.h"
10+
#include "src/__support/freelist_heap.h"
1111
#include "src/string/memcmp.h"
1212
#include "src/string/memcpy.h"
1313
#include "test/UnitTest/Test.h"

libc/test/src/stdlib/freelist_malloc_test.cpp renamed to libc/test/src/__support/freelist_malloc_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "src/__support/freelist_heap.h"
910
#include "src/stdlib/calloc.h"
1011
#include "src/stdlib/free.h"
11-
#include "src/stdlib/freelist_heap.h"
1212
#include "src/stdlib/malloc.h"
1313
#include "test/UnitTest/Test.h"
1414

libc/test/src/stdlib/freelist_test.cpp renamed to libc/test/src/__support/freelist_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "src/__support/CPP/array.h"
1212
#include "src/__support/CPP/span.h"
13-
#include "src/stdlib/freelist.h"
13+
#include "src/__support/freelist.h"
1414
#include "test/UnitTest/Test.h"
1515

1616
using LIBC_NAMESPACE::FreeList;

libc/test/src/stdlib/CMakeLists.txt

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -54,48 +54,6 @@ add_libc_test(
5454
libc.src.stdlib.atoll
5555
)
5656

57-
add_libc_test(
58-
block_test
59-
SUITE
60-
libc-stdlib-tests
61-
SRCS
62-
block_test.cpp
63-
DEPENDS
64-
libc.src.stdlib.block
65-
libc.src.__support.CPP.array
66-
libc.src.__support.CPP.span
67-
libc.src.string.memcpy
68-
)
69-
70-
add_libc_test(
71-
freelist_test
72-
SUITE
73-
libc-stdlib-tests
74-
SRCS
75-
freelist_test.cpp
76-
DEPENDS
77-
libc.src.stdlib.freelist
78-
libc.src.__support.CPP.array
79-
libc.src.__support.CPP.span
80-
)
81-
82-
if(LLVM_LIBC_FULL_BUILD)
83-
add_libc_test(
84-
freelist_heap_test
85-
SUITE
86-
libc-stdlib-tests
87-
SRCS
88-
freelist_heap_test.cpp
89-
freelist_malloc_test.cpp
90-
DEPENDS
91-
libc.src.__support.CPP.span
92-
libc.src.stdlib.freelist_heap
93-
libc.src.stdlib.malloc
94-
libc.src.string.memcmp
95-
libc.src.string.memcpy
96-
)
97-
endif()
98-
9957
add_fp_unittest(
10058
strtod_test
10159
SUITE

0 commit comments

Comments
 (0)