Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use AtomicU8 instead of AtomicUsize in backtrace.rs #118798

Merged
merged 1 commit into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions library/std/src/backtrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ use crate::env;
use crate::ffi::c_void;
use crate::fmt;
use crate::panic::UnwindSafe;
use crate::sync::atomic::{AtomicUsize, Ordering::Relaxed};
use crate::sync::atomic::{AtomicU8, Ordering::Relaxed};
use crate::sync::LazyLock;
use crate::sys_common::backtrace::{lock, output_filename, set_image_base};
use crate::vec::Vec;
Expand Down Expand Up @@ -255,7 +255,7 @@ impl Backtrace {
// Cache the result of reading the environment variables to make
// backtrace captures speedy, because otherwise reading environment
// variables every time can be somewhat slow.
static ENABLED: AtomicUsize = AtomicUsize::new(0);
static ENABLED: AtomicU8 = AtomicU8::new(0);
match ENABLED.load(Relaxed) {
0 => {}
1 => return false,
Expand All @@ -268,7 +268,7 @@ impl Backtrace {
Err(_) => false,
},
};
ENABLED.store(enabled as usize + 1, Relaxed);
ENABLED.store(enabled as u8 + 1, Relaxed);
enabled
}

Expand Down