|
341 | 341 | #![warn(missing_docs)] |
342 | 342 | #![deny(missing_debug_implementations, unconditional_recursion)] |
343 | 343 | #![cfg_attr(all(not(feature = "std"), not(test)), no_std)] |
344 | | -// When compiled for the rustc compiler itself we want to make sure that this is |
345 | | -// an unstable crate |
346 | | -#![cfg_attr(rustbuild, feature(staged_api, rustc_private))] |
347 | | -#![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))] |
348 | 344 |
|
349 | 345 | #[cfg(any( |
350 | 346 | all(feature = "max_level_off", feature = "max_level_error"), |
@@ -1405,24 +1401,21 @@ fn set_logger_inner<F>(make_logger: F) -> Result<(), SetLoggerError> |
1405 | 1401 | where |
1406 | 1402 | F: FnOnce() -> &'static dyn Log, |
1407 | 1403 | { |
1408 | | - let old_state = match STATE.compare_exchange( |
| 1404 | + match STATE.compare_exchange( |
1409 | 1405 | UNINITIALIZED, |
1410 | 1406 | INITIALIZING, |
1411 | | - Ordering::SeqCst, |
1412 | | - Ordering::SeqCst, |
| 1407 | + Ordering::Acquire, |
| 1408 | + Ordering::Relaxed, |
1413 | 1409 | ) { |
1414 | | - Ok(s) | Err(s) => s, |
1415 | | - }; |
1416 | | - match old_state { |
1417 | | - UNINITIALIZED => { |
| 1410 | + Ok(UNINITIALIZED) => { |
1418 | 1411 | unsafe { |
1419 | 1412 | LOGGER = make_logger(); |
1420 | 1413 | } |
1421 | | - STATE.store(INITIALIZED, Ordering::SeqCst); |
| 1414 | + STATE.store(INITIALIZED, Ordering::Release); |
1422 | 1415 | Ok(()) |
1423 | 1416 | } |
1424 | | - INITIALIZING => { |
1425 | | - while STATE.load(Ordering::SeqCst) == INITIALIZING { |
| 1417 | + Err(INITIALIZING) => { |
| 1418 | + while STATE.load(Ordering::Relaxed) == INITIALIZING { |
1426 | 1419 | std::hint::spin_loop(); |
1427 | 1420 | } |
1428 | 1421 | Err(SetLoggerError(())) |
@@ -1451,10 +1444,10 @@ where |
1451 | 1444 | /// |
1452 | 1445 | /// [`set_logger`]: fn.set_logger.html |
1453 | 1446 | pub unsafe fn set_logger_racy(logger: &'static dyn Log) -> Result<(), SetLoggerError> { |
1454 | | - match STATE.load(Ordering::SeqCst) { |
| 1447 | + match STATE.load(Ordering::Acquire) { |
1455 | 1448 | UNINITIALIZED => { |
1456 | 1449 | LOGGER = logger; |
1457 | | - STATE.store(INITIALIZED, Ordering::SeqCst); |
| 1450 | + STATE.store(INITIALIZED, Ordering::Release); |
1458 | 1451 | Ok(()) |
1459 | 1452 | } |
1460 | 1453 | INITIALIZING => { |
|
0 commit comments