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

Add note about in-memory representation of atomic types #253

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/sync/atomic/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use super::Atomic;
use std::sync::atomic::Ordering;

/// Mock implementation of `std::sync::atomic::AtomicBool`.
///
/// NOTE: Unlike `std::sync::atomic::AtomicBool`, this type has a different
/// in-memory representation than `bool`.
#[derive(Debug)]
pub struct AtomicBool(Atomic<bool>);

Expand Down
8 changes: 7 additions & 1 deletion src/sync/atomic/int.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ macro_rules! doc_comment {
};
}

#[rustfmt::skip] // rustfmt cannot properly format multi-line concat!.
macro_rules! atomic_int {
($name: ident, $atomic_type: ty) => {
doc_comment! {
concat!(" Mock implementation of `std::sync::atomic::", stringify!($name), "`."),
concat!(
" Mock implementation of `std::sync::atomic::", stringify!($name), "`.\n\n\
NOTE: Unlike `std::sync::atomic::", stringify!($name), "`, \
this type has a different in-memory representation than `",
stringify!($atomic_type), "`.",
),
#[derive(Debug)]
pub struct $name(Atomic<$atomic_type>);
}
Expand Down
3 changes: 3 additions & 0 deletions src/sync/atomic/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ use super::Atomic;
use std::sync::atomic::Ordering;

/// Mock implementation of `std::sync::atomic::AtomicPtr`.
///
/// NOTE: Unlike `std::sync::atomic::AtomicPtr`, this type has a different
/// in-memory representation than `*mut T`.
#[derive(Debug)]
pub struct AtomicPtr<T>(Atomic<*mut T>);

Expand Down