Mark s_cancellation_signal a relaxed atomic

Thread sanitizer is salty about this even though it's
volatile sig_atomic_t. Make it atomic too.
This commit is contained in:
ridiculousfish 2020-09-04 16:10:22 -07:00
parent 3f3531c819
commit 457f95fe52
2 changed files with 3 additions and 2 deletions

View File

@ -93,9 +93,10 @@ class relaxed_atomic_t {
relaxed_atomic_t() = default;
relaxed_atomic_t(T value) : value_(value) {}
operator T() const { return value_.load(std::memory_order_relaxed); }
operator T() const volatile { return value_.load(std::memory_order_relaxed); }
void operator=(T v) { return value_.store(v, std::memory_order_relaxed); }
void operator=(T v) volatile { return value_.store(v, std::memory_order_relaxed); }
// Perform a CAS operation, returning whether it succeeded.
bool compare_exchange(T expected, T desired) {

View File

@ -201,7 +201,7 @@ static bool reraise_if_forked_child(int sig) {
/// The cancellation signal we have received.
/// Of course this is modified from a signal handler.
static volatile sig_atomic_t s_cancellation_signal = 0;
static volatile relaxed_atomic_t<sig_atomic_t> s_cancellation_signal{0};
void signal_clear_cancel() { s_cancellation_signal = 0; }