summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGHC GitLab CI <ghc-ci@gitlab-haskell.org>2020-09-18 13:19:08 +0000
committerBen Gamari <ben@smart-cactus.org>2020-10-24 21:01:34 -0400
commitcef667b081c71008e0633d276349dd863cb46d7f (patch)
tree381977ba6f34818004d3155bb776df81d7617ef5
parent8f802f386ad5774a863f756f2d8d397903074700 (diff)
downloadhaskell-wip/tsan/misc.tar.gz
rts: Use proper relaxe operations in getCurrentThreadCPUTimewip/tsan/misc
Here we are doing lazy initialization; it's okay if we do the check more than once, hence relaxed operation is fine.
-rw-r--r--rts/posix/GetTime.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/rts/posix/GetTime.c b/rts/posix/GetTime.c
index 0128e3bc8b..7d53f95401 100644
--- a/rts/posix/GetTime.c
+++ b/rts/posix/GetTime.c
@@ -85,7 +85,9 @@ Time getCurrentThreadCPUTime(void)
defined(CLOCK_PROCESS_CPUTIME_ID) && \
defined(HAVE_SYSCONF)
static bool have_checked_usability = false;
- if (!have_checked_usability) {
+ // The RELAXED operation is fine here as it's okay if we do the check below
+ // more than once.
+ if (!RELAXED_LOAD(&have_checked_usability)) {
// The Linux clock_getres(2) manpage claims that some early versions of
// Linux will return values which are uninterpretable in the presence
// of migration across CPUs. They claim that clock_getcpuclockid(0)
@@ -95,7 +97,7 @@ Time getCurrentThreadCPUTime(void)
sysErrorBelch("getCurrentThreadCPUTime: no supported");
stg_exit(EXIT_FAILURE);
}
- have_checked_usability = true;
+ RELAXED_STORE(&have_checked_usability, true);
}
return getClockTime(CLOCK_THREAD_CPUTIME_ID);
#else