From: Michael de Lang <kingoipo@gmail.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] tsan: fix test for machines without pthread_cond_clockwait
Date: Tue, 25 Oct 2022 19:39:33 +0200 [thread overview]
Message-ID: <CAJbH2PyhVRnAgtEPnHc+3-XpdXVVbmV70V2rNmxFh5YRDmb1tw@mail.gmail.com> (raw)
Hey,
As per J. Wakeley's comments on
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100655
make the call to pthread_cond_clockwait conditional. This allows
compilation on machines
with older glibc versions.
Cheers,
Michael
2022-10-25 Michael de Lang <kingoipo@gmail.com>
* Fix testcase for pthread_cond_clockwait on machines with old glibc
--- a/gcc/testsuite/g++.dg/tsan/pthread_cond_clockwait.C
+++ b/gcc/testsuite/g++.dg/tsan/pthread_cond_clockwait.C
@@ -4,6 +4,10 @@
#include <pthread.h>
+// Include this to get the libstdc++ _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT
+// macro that indicates pthread_cond_clockwait is available.
+#include <type_traits>
+
pthread_cond_t cv;
pthread_mutex_t mtx;
@@ -23,7 +27,9 @@ int main() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
ts.tv_sec += 10;
+#ifdef _GLIBCXX_USE_PTHREAD_COND_CLOCKWAIT
pthread_cond_clockwait(&cv, &mtx, CLOCK_MONOTONIC, &ts);
+#endif
pthread_mutex_unlock(&mtx);
pthread_join(tid, NULL);
reply other threads:[~2022-10-25 17:39 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJbH2PyhVRnAgtEPnHc+3-XpdXVVbmV70V2rNmxFh5YRDmb1tw@mail.gmail.com \
--to=kingoipo@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).