]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Fix bootstrap for --disable-threads build [PR107221]
authorJonathan Wakely <jwakely@redhat.com>
Tue, 11 Oct 2022 19:19:08 +0000 (20:19 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 11 Oct 2022 19:36:09 +0000 (20:36 +0100)
The __scoped_lock type should be used unqualified so that we always
refer to pool::__scoped_lock, which might be the dummy fallback
implementation.

The __mutex and __scoped_lock types in <ext/concurrence.h> already work
fine without __GTHREADS being defined, but that header isn't included at
all unless _GLIBCXX_HOSTED != 0. The fallback implementation should be
used for ! _GLIBCXX_HOSTED instead of for !defined __GTHREADS.

libstdc++-v3/ChangeLog:

PR bootstrap/107221
* libsupc++/eh_alloc.cc (pool): Change preprocessor condition
for using __mutex from __GTHREADS to _GLIBCXX_HOSTED.
(pool::allocate): Remove namespace qualification to use
pool::__scoped_lock instead of __gnu_cxx::__scoped_lock.

libstdc++-v3/libsupc++/eh_alloc.cc

index 50dc37c0d9c16e3d1a79fcc49a7e42ef72058bfd..81b8a1548c6fd580ca22adf33bc66fb597db5b86 100644 (file)
@@ -145,7 +145,7 @@ namespace
        char data[] __attribute__((aligned));
       };
 
-#ifdef __GTHREADS
+#if _GLIBCXX_HOSTED
       // A single mutex controlling emergency allocations.
       __gnu_cxx::__mutex emergency_mutex;
       using __scoped_lock = __gnu_cxx::__scoped_lock;
@@ -236,7 +236,7 @@ namespace
 
   void *pool::allocate (std::size_t size) noexcept
     {
-      __gnu_cxx::__scoped_lock sentry(emergency_mutex);
+      __scoped_lock sentry(emergency_mutex);
       // We need an additional size_t member plus the padding to
       // ensure proper alignment of data.
       size += offsetof (allocated_entry, data);