[libcxx-commits] [libcxx] [libc++] Avoid including <string> in <mutex> (PR #116254)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu Nov 14 08:30:45 PST 2024


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/116254

None

>From 42985bafb4539d08d47548fbf6337167bf10c21a Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 14 Nov 2024 17:30:23 +0100
Subject: [PATCH] [libc++] Avoid including <string> in <mutex>

---
 .../__condition_variable/condition_variable.h |  2 +-
 libcxx/include/__mutex/unique_lock.h          |  2 +-
 libcxx/include/__system_error/system_error.h  |  1 -
 .../__system_error/throw_system_error.h       | 25 +++++++++++++++++++
 4 files changed, 27 insertions(+), 3 deletions(-)
 create mode 100644 libcxx/include/__system_error/throw_system_error.h

diff --git a/libcxx/include/__condition_variable/condition_variable.h b/libcxx/include/__condition_variable/condition_variable.h
index 499e6f0f295dd3..4521fe274614ef 100644
--- a/libcxx/include/__condition_variable/condition_variable.h
+++ b/libcxx/include/__condition_variable/condition_variable.h
@@ -16,7 +16,7 @@
 #include <__config>
 #include <__mutex/mutex.h>
 #include <__mutex/unique_lock.h>
-#include <__system_error/system_error.h>
+#include <__system_error/throw_system_error.h>
 #include <__thread/support.h>
 #include <__type_traits/enable_if.h>
 #include <__type_traits/is_floating_point.h>
diff --git a/libcxx/include/__mutex/unique_lock.h b/libcxx/include/__mutex/unique_lock.h
index c404921070f913..3642ab93cb1f7c 100644
--- a/libcxx/include/__mutex/unique_lock.h
+++ b/libcxx/include/__mutex/unique_lock.h
@@ -14,7 +14,7 @@
 #include <__config>
 #include <__memory/addressof.h>
 #include <__mutex/tag_types.h>
-#include <__system_error/system_error.h>
+#include <__system_error/throw_system_error.h>
 #include <__utility/swap.h>
 #include <cerrno>
 
diff --git a/libcxx/include/__system_error/system_error.h b/libcxx/include/__system_error/system_error.h
index 2763aaba88f5fa..918effb6917cb4 100644
--- a/libcxx/include/__system_error/system_error.h
+++ b/libcxx/include/__system_error/system_error.h
@@ -39,7 +39,6 @@ class _LIBCPP_EXPORTED_FROM_ABI system_error : public runtime_error {
   _LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; }
 };
 
-[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg);
 [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI inline void __throw_system_error(error_code __ec, const char* __what_arg) {
 #if _LIBCPP_HAS_EXCEPTIONS
   throw system_error(__ec, __what_arg);
diff --git a/libcxx/include/__system_error/throw_system_error.h b/libcxx/include/__system_error/throw_system_error.h
new file mode 100644
index 00000000000000..e4605b6f014dc5
--- /dev/null
+++ b/libcxx/include/__system_error/throw_system_error.h
@@ -0,0 +1,25 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H
+#define _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#  pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg);
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H



More information about the libcxx-commits mailing list