[libc-commits] [libc] [libc] Move freelist + block to __support (PR #96231)
via libc-commits
libc-commits at lists.llvm.org
Thu Jun 20 12:32:48 PDT 2024
https://github.com/PiJoules created https://github.com/llvm/llvm-project/pull/96231
None
>From d69e2461d921e562ea25cb241e81adad806031c7 Mon Sep 17 00:00:00 2001
From: Leonard Chan <leonardchan at google.com>
Date: Thu, 20 Jun 2024 12:27:06 -0700
Subject: [PATCH] [libc] Move freelist + block to __support
---
libc/src/__support/CMakeLists.txt | 41 ++++++++++++++++++
libc/src/{stdlib => __support}/block.h | 6 +--
libc/src/{stdlib => __support}/freelist.h | 0
.../src/{stdlib => __support}/freelist_heap.h | 6 +--
libc/src/stdlib/CMakeLists.txt | 40 +-----------------
libc/src/stdlib/freelist_malloc.cpp | 2 +-
libc/test/src/__support/CMakeLists.txt | 42 +++++++++++++++++++
.../src/{stdlib => __support}/block_test.cpp | 3 +-
.../freelist_heap_test.cpp | 2 +-
.../freelist_malloc_test.cpp | 2 +-
.../{stdlib => __support}/freelist_test.cpp | 2 +-
libc/test/src/stdlib/CMakeLists.txt | 42 -------------------
12 files changed, 95 insertions(+), 93 deletions(-)
rename libc/src/{stdlib => __support}/block.h (99%)
rename libc/src/{stdlib => __support}/freelist.h (100%)
rename libc/src/{stdlib => __support}/freelist_heap.h (97%)
rename libc/test/src/{stdlib => __support}/block_test.cpp (99%)
rename libc/test/src/{stdlib => __support}/freelist_heap_test.cpp (99%)
rename libc/test/src/{stdlib => __support}/freelist_malloc_test.cpp (98%)
rename libc/test/src/{stdlib => __support}/freelist_test.cpp (99%)
diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index 32d693ec6a268..d8a192f1ffa57 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -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
diff --git a/libc/src/stdlib/block.h b/libc/src/__support/block.h
similarity index 99%
rename from libc/src/stdlib/block.h
rename to libc/src/__support/block.h
index b0462a12afb39..580f20e1ec4a4 100644
--- a/libc/src/stdlib/block.h
+++ b/libc/src/__support/block.h
@@ -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"
@@ -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
diff --git a/libc/src/stdlib/freelist.h b/libc/src/__support/freelist.h
similarity index 100%
rename from libc/src/stdlib/freelist.h
rename to libc/src/__support/freelist.h
diff --git a/libc/src/stdlib/freelist_heap.h b/libc/src/__support/freelist_heap.h
similarity index 97%
rename from libc/src/stdlib/freelist_heap.h
rename to libc/src/__support/freelist_heap.h
index 6357c047021df..3569baf27bdaa 100644
--- a/libc/src/stdlib/freelist_heap.h
+++ b/libc/src/__support/freelist_heap.h
@@ -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>
@@ -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
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index fdbf7b75e72f4..3b1ca3ab2fe42 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -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(
@@ -427,7 +389,7 @@ else()
HDRS
malloc.h
DEPENDS
- .freelist_heap
+ libc.src.__support.freelist_heap
)
else()
add_entrypoint_external(
diff --git a/libc/src/stdlib/freelist_malloc.cpp b/libc/src/stdlib/freelist_malloc.cpp
index 185b36444e371..0be7f3467e32c 100644
--- a/libc/src/stdlib/freelist_malloc.cpp
+++ b/libc/src/stdlib/freelist_malloc.cpp
@@ -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"
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index d05377eca8a81..082a002959c95 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -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
diff --git a/libc/test/src/stdlib/block_test.cpp b/libc/test/src/__support/block_test.cpp
similarity index 99%
rename from libc/test/src/stdlib/block_test.cpp
rename to libc/test/src/__support/block_test.cpp
index 0544e699cc8b2..6614e4b583d3f 100644
--- a/libc/test/src/stdlib/block_test.cpp
+++ b/libc/test/src/__support/block_test.cpp
@@ -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"
diff --git a/libc/test/src/stdlib/freelist_heap_test.cpp b/libc/test/src/__support/freelist_heap_test.cpp
similarity index 99%
rename from libc/test/src/stdlib/freelist_heap_test.cpp
rename to libc/test/src/__support/freelist_heap_test.cpp
index e30c23e724a06..a35cb5589ed62 100644
--- a/libc/test/src/stdlib/freelist_heap_test.cpp
+++ b/libc/test/src/__support/freelist_heap_test.cpp
@@ -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"
diff --git a/libc/test/src/stdlib/freelist_malloc_test.cpp b/libc/test/src/__support/freelist_malloc_test.cpp
similarity index 98%
rename from libc/test/src/stdlib/freelist_malloc_test.cpp
rename to libc/test/src/__support/freelist_malloc_test.cpp
index b2527c5b571b1..989e9548fa26d 100644
--- a/libc/test/src/stdlib/freelist_malloc_test.cpp
+++ b/libc/test/src/__support/freelist_malloc_test.cpp
@@ -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"
diff --git a/libc/test/src/stdlib/freelist_test.cpp b/libc/test/src/__support/freelist_test.cpp
similarity index 99%
rename from libc/test/src/stdlib/freelist_test.cpp
rename to libc/test/src/__support/freelist_test.cpp
index e25c74b47b852..cae0ed470315c 100644
--- a/libc/test/src/stdlib/freelist_test.cpp
+++ b/libc/test/src/__support/freelist_test.cpp
@@ -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;
diff --git a/libc/test/src/stdlib/CMakeLists.txt b/libc/test/src/stdlib/CMakeLists.txt
index 0ded674ee0e12..38488778c657c 100644
--- a/libc/test/src/stdlib/CMakeLists.txt
+++ b/libc/test/src/stdlib/CMakeLists.txt
@@ -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
More information about the libc-commits
mailing list