diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-10-07 10:22:24 +0100 |
---|---|---|
committer | Jonathan Wakely <redi@gcc.gnu.org> | 2024-10-09 13:41:06 +0100 |
commit | 9a5ac633f0f49c819f2745584475051c9eb8f6e0 (patch) | |
tree | 92fc36f7ea4d5f249f252a486675bcb4a82868b7 | |
parent | e998014d1b14592c43b0f655793011c6395ff02a (diff) | |
download | gcc-9a5ac633f0f49c819f2745584475051c9eb8f6e0.zip gcc-9a5ac633f0f49c819f2745584475051c9eb8f6e0.tar.gz gcc-9a5ac633f0f49c819f2745584475051c9eb8f6e0.tar.bz2 |
libstdc++: Ignore _GLIBCXX_USE_POSIX_SEMAPHORE if not supported [PR116992]
If _GLIBCXX_HAVE_POSIX_SEMAPHRE is undefined then users get an error
when defining _GLIBCXX_USE_POSIX_SEMAPHORE. We can just ignore it
instead (and warn them it's being ignored).
This fixes a testsuite failure on hppa64-hp-hpux11.11 (and probably some
other targets):
FAIL: 30_threads/semaphore/platform_try_acquire_for.cc -std=gnu++20 (test for excess errors)
Excess errors:
semaphore:49: error: '__semaphore_impl' has not been declared
libstdc++-v3/ChangeLog:
PR libstdc++/116992
* include/bits/semaphore_base.h (_GLIBCXX_USE_POSIX_SEMAPHORE):
Undefine and issue a warning if POSIX sem_t is not supported.
* testsuite/30_threads/semaphore/platform_try_acquire_for.cc:
Prune new warning.
-rw-r--r-- | libstdc++-v3/include/bits/semaphore_base.h | 3 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/30_threads/semaphore/platform_try_acquire_for.cc | 2 |
2 files changed, 5 insertions, 0 deletions
diff --git a/libstdc++-v3/include/bits/semaphore_base.h b/libstdc++-v3/include/bits/semaphore_base.h index 9d73b37..dd16d2c 100644 --- a/libstdc++-v3/include/bits/semaphore_base.h +++ b/libstdc++-v3/include/bits/semaphore_base.h @@ -45,6 +45,9 @@ # include <cerrno> // errno, EINTR, EAGAIN etc. # include <limits.h> // SEM_VALUE_MAX # include <semaphore.h> // sem_t, sem_init, sem_wait, sem_post etc. +#elif defined(_GLIBCXX_USE_POSIX_SEMAPHORE) +# warning "POSIX semaphore not available, ignoring _GLIBCXX_USE_POSIX_SEMAPHORE" +# undef _GLIBCXX_USE_POSIX_SEMAPHORE #endif namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/testsuite/30_threads/semaphore/platform_try_acquire_for.cc b/libstdc++-v3/testsuite/30_threads/semaphore/platform_try_acquire_for.cc index bf6cd14..6d90564 100644 --- a/libstdc++-v3/testsuite/30_threads/semaphore/platform_try_acquire_for.cc +++ b/libstdc++-v3/testsuite/30_threads/semaphore/platform_try_acquire_for.cc @@ -5,3 +5,5 @@ // { dg-add-options libatomic } #include "try_acquire_for.cc" + +// { dg-prune-output "ignoring _GLIBCXX_USE_POSIX_SEMAPHORE" } |