* [PATCH] tsan: fix test for machines without pthread_cond_clockwait
@ 2022-10-25 17:39 Michael de Lang
0 siblings, 0 replies; only message in thread
From: Michael de Lang @ 2022-10-25 17:39 UTC (permalink / raw)
To: gcc-patches
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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-10-25 17:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 17:39 [PATCH] tsan: fix test for machines without pthread_cond_clockwait Michael de Lang
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).