Skip to content

Commit dedc515

Browse files
authored
[libc++] Avoid including <string> in <mutex> (#116254)
1 parent adb80d8 commit dedc515

File tree

15 files changed

+39
-96
lines changed

15 files changed

+39
-96
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ set(files
718718
__system_error/error_code.h
719719
__system_error/error_condition.h
720720
__system_error/system_error.h
721+
__system_error/throw_system_error.h
721722
__thread/formatter.h
722723
__thread/id.h
723724
__thread/jthread.h

libcxx/include/__condition_variable/condition_variable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <__config>
1717
#include <__mutex/mutex.h>
1818
#include <__mutex/unique_lock.h>
19-
#include <__system_error/system_error.h>
19+
#include <__system_error/throw_system_error.h>
2020
#include <__thread/support.h>
2121
#include <__type_traits/enable_if.h>
2222
#include <__type_traits/is_floating_point.h>

libcxx/include/__mutex/unique_lock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <__config>
1515
#include <__memory/addressof.h>
1616
#include <__mutex/tag_types.h>
17-
#include <__system_error/system_error.h>
17+
#include <__system_error/throw_system_error.h>
1818
#include <__utility/swap.h>
1919
#include <cerrno>
2020

libcxx/include/__system_error/system_error.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class _LIBCPP_EXPORTED_FROM_ABI system_error : public runtime_error {
3939
_LIBCPP_HIDE_FROM_ABI const error_code& code() const _NOEXCEPT { return __ec_; }
4040
};
4141

42-
[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg);
4342
[[__noreturn__]] _LIBCPP_HIDE_FROM_ABI inline void __throw_system_error(error_code __ec, const char* __what_arg) {
4443
#if _LIBCPP_HAS_EXCEPTIONS
4544
throw system_error(__ec, __what_arg);
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H
11+
#define _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H
12+
13+
#include <__config>
14+
15+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16+
# pragma GCC system_header
17+
#endif
18+
19+
_LIBCPP_BEGIN_NAMESPACE_STD
20+
21+
[[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg);
22+
23+
_LIBCPP_END_NAMESPACE_STD
24+
25+
#endif // _LIBCPP___SYSTEM_ERROR_THROW_SYSTEM_ERROR_H

libcxx/include/__thread/thread.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818
#include <__functional/unary_function.h>
1919
#include <__memory/unique_ptr.h>
2020
#include <__mutex/mutex.h>
21-
#include <__system_error/system_error.h>
21+
#include <__system_error/throw_system_error.h>
2222
#include <__thread/id.h>
2323
#include <__thread/support.h>
2424
#include <__type_traits/decay.h>
25+
#include <__type_traits/enable_if.h>
26+
#include <__type_traits/is_same.h>
27+
#include <__type_traits/remove_cvref.h>
2528
#include <__utility/forward.h>
2629
#include <tuple>
2730

libcxx/include/module.modulemap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,6 +1924,7 @@ module std [system] {
19241924
}
19251925
module error_condition { header "__system_error/error_condition.h" }
19261926
module system_error { header "__system_error/system_error.h" }
1927+
module throw_system_error { header "__system_error/throw_system_error.h" }
19271928

19281929
header "system_error"
19291930
export *

libcxx/include/print

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace std {
3636
#include <__assert>
3737
#include <__concepts/same_as.h>
3838
#include <__config>
39-
#include <__system_error/system_error.h>
39+
#include <__system_error/throw_system_error.h>
4040
#include <__utility/forward.h>
4141
#include <cerrno>
4242
#include <cstdio>

libcxx/include/shared_mutex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ template <class Mutex>
134134
# include <__mutex/mutex.h>
135135
# include <__mutex/tag_types.h>
136136
# include <__mutex/unique_lock.h>
137-
# include <__system_error/system_error.h>
137+
# include <__system_error/throw_system_error.h>
138138
# include <__utility/swap.h>
139139
# include <cerrno>
140140
# include <version>

libcxx/src/chrono.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# define _LARGE_TIME_API
1313
#endif
1414

15-
#include <__system_error/system_error.h>
15+
#include <__system_error/throw_system_error.h>
1616
#include <cerrno> // errno
1717
#include <chrono>
1818

0 commit comments

Comments
 (0)