Skip to content

Commit

Permalink
[libc++] Avoid including <string> in <mutex>
Browse files Browse the repository at this point in the history
  • Loading branch information
philnik777 committed Nov 14, 2024
1 parent 9e1faa8 commit cd30f5c
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 8 deletions.
1 change: 1 addition & 0 deletions libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ set(files
__system_error/error_code.h
__system_error/error_condition.h
__system_error/system_error.h
__system_error/throw_system_error.h
__thread/formatter.h
__thread/id.h
__thread/jthread.h
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__condition_variable/condition_variable.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__mutex/unique_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down
1 change: 0 additions & 1 deletion libcxx/include/__system_error/system_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
25 changes: 25 additions & 0 deletions libcxx/include/__system_error/throw_system_error.h
Original file line number Diff line number Diff line change
@@ -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
5 changes: 4 additions & 1 deletion libcxx/include/__thread/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
#include <__functional/unary_function.h>
#include <__memory/unique_ptr.h>
#include <__mutex/mutex.h>
#include <__system_error/system_error.h>
#include <__system_error/throw_system_error.h>
#include <__thread/id.h>
#include <__thread/support.h>
#include <__type_traits/decay.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/is_same.h>
#include <__type_traits/remove_cvref.h>
#include <__utility/forward.h>
#include <tuple>

Expand Down
1 change: 1 addition & 0 deletions libcxx/include/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -1921,6 +1921,7 @@ module std [system] {
}
module error_condition { header "__system_error/error_condition.h" }
module system_error { header "__system_error/system_error.h" }
module throw_system_error { header "__system_error/throw_system_error.h" }

header "system_error"
export *
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/print
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace std {
#include <__assert>
#include <__concepts/same_as.h>
#include <__config>
#include <__system_error/system_error.h>
#include <__system_error/throw_system_error.h>
#include <__utility/forward.h>
#include <cerrno>
#include <cstdio>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/shared_mutex
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ template <class Mutex>
# include <__mutex/mutex.h>
# include <__mutex/tag_types.h>
# include <__mutex/unique_lock.h>
# include <__system_error/system_error.h>
# include <__system_error/throw_system_error.h>
# include <__utility/swap.h>
# include <cerrno>
# include <version>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/src/chrono.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# define _LARGE_TIME_API
#endif

#include <__system_error/system_error.h>
#include <__system_error/throw_system_error.h>
#include <cerrno> // errno
#include <chrono>

Expand Down
1 change: 1 addition & 0 deletions libcxx/src/filesystem/filesystem_clock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include <__config>
#include <__system_error/throw_system_error.h>
#include <chrono>
#include <filesystem>
#include <time.h>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/src/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# define _CRT_RAND_S
#endif // defined(_LIBCPP_USING_WIN32_RANDOM)

#include <__system_error/system_error.h>
#include <__system_error/throw_system_error.h>
#include <limits>
#include <random>

Expand Down
1 change: 1 addition & 0 deletions libcxx/src/system_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <__assert>
#include <__config>
#include <__system_error/throw_system_error.h>
#include <__verbose_abort>
#include <cerrno>
#include <cstdio>
Expand Down

0 comments on commit cd30f5c

Please sign in to comment.