rustc_metadata: use configurable AtomicBool for privateness flag

This switches to using a `Cell` for single-threaded rustc.
This commit is contained in:
Michael Howell 2023-05-08 15:12:45 -07:00
parent b537c1f175
commit a12f50ddc4
2 changed files with 16 additions and 2 deletions

View File

@ -143,6 +143,20 @@ cfg_if! {
self.0.set(val);
result
}
pub fn fetch_update(
&self,
_order_set: Ordering,
_order_get: Ordering,
mut f: impl FnMut(bool) -> Option<bool>,
) -> Result<bool, bool> {
let prev = self.0.get();
if let Some(next) = f(prev) {
self.0.set(next);
Ok(prev)
} else {
Err(prev)
}
}
}
impl<T: Copy + PartialEq> Atomic<T> {

View File

@ -9,7 +9,7 @@ use rustc_data_structures::captures::Captures;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::owned_slice::OwnedSlice;
use rustc_data_structures::svh::Svh;
use rustc_data_structures::sync::{AppendOnlyVec, Lock, Lrc, OnceCell};
use rustc_data_structures::sync::{AppendOnlyVec, AtomicBool, Lock, Lrc, OnceCell};
use rustc_data_structures::unhash::UnhashMap;
use rustc_expand::base::{SyntaxExtension, SyntaxExtensionKind};
use rustc_expand::proc_macro::{AttrProcMacro, BangProcMacro, DeriveProcMacro};
@ -40,7 +40,7 @@ use proc_macro::bridge::client::ProcMacro;
use std::iter::TrustedLen;
use std::num::NonZeroUsize;
use std::path::Path;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::atomic::Ordering;
use std::{io, iter, mem};
pub(super) use cstore_impl::provide;