[libcxx-commits] [libcxx] 3956a34 - [libc++] Move non operator new definitions outside of new.cpp
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jun 19 06:47:05 PDT 2023
Author: Louis Dionne
Date: 2023-06-19T09:46:40-04:00
New Revision: 3956a34e4fc6994021e8f3cbcb81a02161ce15e0
URL: https://github.com/llvm/llvm-project/commit/3956a34e4fc6994021e8f3cbcb81a02161ce15e0
DIFF: https://github.com/llvm/llvm-project/commit/3956a34e4fc6994021e8f3cbcb81a02161ce15e0.diff
LOG: [libc++] Move non operator new definitions outside of new.cpp
This makes it such that new.cpp contains only the definitions of
operator new and operator delete, like its libc++abi counterpart.
Differential Revision: https://reviews.llvm.org/D153136
Added:
libcxx/src/new_helpers.cpp
Modified:
libcxx/src/CMakeLists.txt
libcxx/src/new.cpp
Removed:
################################################################################
diff --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index dede38652e2f9..5280436108e7f 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -36,6 +36,7 @@ set(LIBCXX_SOURCES
mutex_destructor.cpp
new.cpp
new_handler.cpp
+ new_helpers.cpp
optional.cpp
random_shuffle.cpp
ryu/d2fixed.cpp
diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp
index b8d24e73f0812..a9920ba09849b 100644
--- a/libcxx/src/new.cpp
+++ b/libcxx/src/new.cpp
@@ -10,29 +10,6 @@
#include <cstdlib>
#include <new>
-namespace std
-{
-
-#ifndef __GLIBCXX__
-const nothrow_t nothrow{};
-#endif
-
-#ifndef LIBSTDCXX
-
-void
-__throw_bad_alloc()
-{
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- throw bad_alloc();
-#else
- _VSTD::abort();
-#endif
-}
-
-#endif // !LIBSTDCXX
-
-} // std
-
#if !defined(__GLIBCXX__) && \
!defined(_LIBCPP_ABI_VCRUNTIME) && \
!defined(_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS)
diff --git a/libcxx/src/new_helpers.cpp b/libcxx/src/new_helpers.cpp
new file mode 100644
index 0000000000000..45a0a661db0e4
--- /dev/null
+++ b/libcxx/src/new_helpers.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstdlib>
+#include <new>
+
+namespace std { // purposefully not versioned
+
+#ifndef __GLIBCXX__
+const nothrow_t nothrow{};
+#endif
+
+#ifndef LIBSTDCXX
+
+void __throw_bad_alloc() {
+# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+ throw bad_alloc();
+# else
+ std::abort();
+# endif
+}
+
+#endif // !LIBSTDCXX
+
+} // namespace std
More information about the libcxx-commits
mailing list