[libcxx-commits] [PATCH] D153136: [libc++] Move non operator new definitions outside of new.cpp
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jun 16 06:42:05 PDT 2023
ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
This makes it such that new.cpp contains only the definitions of
operator new and operator delete, like its libc++abi counterpart.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153136
Files:
libcxx/src/CMakeLists.txt
libcxx/src/new.cpp
libcxx/src/new_helpers.cpp
Index: libcxx/src/new_helpers.cpp
===================================================================
--- /dev/null
+++ 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
+ _VSTD::abort();
+# endif
+}
+
+#endif // !LIBSTDCXX
+
+} // namespace std
Index: libcxx/src/new.cpp
===================================================================
--- libcxx/src/new.cpp
+++ 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)
Index: libcxx/src/CMakeLists.txt
===================================================================
--- libcxx/src/CMakeLists.txt
+++ libcxx/src/CMakeLists.txt
@@ -36,6 +36,7 @@
mutex_destructor.cpp
new.cpp
new_handler.cpp
+ new_helpers.cpp
optional.cpp
random_shuffle.cpp
ryu/d2fixed.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153136.532127.patch
Type: text/x-patch
Size: 1839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230616/8e13e1d1/attachment.bin>
More information about the libcxx-commits
mailing list