[committed] libstdc++: Do not include <exception> in <mutex>

Message ID 20230531122303.4117519-1-jwakely@redhat.com
State Accepted
Headers
Series [committed] libstdc++: Do not include <exception> in <mutex> |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Jonathan Wakely May 31, 2023, 12:23 p.m. UTC
  Tested powerpc64le-linux. Pushed to trunk.

-- >8 --

We previously needed <exception> in <mutex> for the std::lock_error
exception class, but that was moved out of <mutex> in 2009 when it was
removed from the C++0x draft. We can stop including <exception> now.

Move the include for <bits/error_constants.h> to <bits/unique_lock.h>
where it's actually used, and only include <errno.h> in <mutex> (for
EAGAIN and EDEADLK).

Also add some headers to <mutex> that are needed but are not included
directly: <bits/functexcept.h>, <bits/invoke.h> and <bits/move.h>.

libstdc++-v3/ChangeLog:

	* include/bits/unique_lock.h: Include <bits/error_constants.h>
	here for std::errc constants.
	* include/std/mutex: Do not include <bits/error_constants.h> and
	<exception> here.
---
 libstdc++-v3/include/bits/unique_lock.h |  1 +
 libstdc++-v3/include/std/mutex          | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)
  

Patch

diff --git a/libstdc++-v3/include/bits/unique_lock.h b/libstdc++-v3/include/bits/unique_lock.h
index f14674ed471..c28e6456ad5 100644
--- a/libstdc++-v3/include/bits/unique_lock.h
+++ b/libstdc++-v3/include/bits/unique_lock.h
@@ -37,6 +37,7 @@ 
 #else
 
 #include <bits/chrono.h>
+#include <bits/error_constants.h> // for std::errc
 #include <bits/move.h> // for std::swap
 #include <bits/std_mutex.h> // for std::defer_lock_t
 
diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex
index 79420388abc..2b0059fcfe8 100644
--- a/libstdc++-v3/include/std/mutex
+++ b/libstdc++-v3/include/std/mutex
@@ -37,11 +37,13 @@ 
 # include <bits/c++0x_warning.h>
 #else
 
-#include <tuple>
-#include <exception>
-#include <type_traits>
-#include <bits/chrono.h>
-#include <bits/error_constants.h>
+#include <tuple>	      // std::tuple
+#include <type_traits>        // is_same_v
+#include <errno.h>	      // EAGAIN, EDEADLK
+#include <bits/chrono.h>      // duration, time_point, is_clock_v
+#include <bits/functexcept.h> // __throw_system_error
+#include <bits/invoke.h>      // __invoke
+#include <bits/move.h>	      // std::forward
 #include <bits/std_mutex.h>
 #include <bits/unique_lock.h>
 #if ! _GTHREAD_USE_MUTEX_TIMEDLOCK