mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-26 07:25:48 +00:00
Fallout: AtomicPtr needs phantom data to indicate that it contains an unsafe pointer.
This commit is contained in:
parent
2bcf3a4cd1
commit
1735e41d1c
@ -76,6 +76,7 @@ use marker::Sync;
|
||||
|
||||
use intrinsics;
|
||||
use cell::UnsafeCell;
|
||||
use marker::PhantomData;
|
||||
|
||||
/// A boolean type which can be safely shared between threads.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -105,6 +106,7 @@ unsafe impl Sync for AtomicUsize {}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct AtomicPtr<T> {
|
||||
p: UnsafeCell<usize>,
|
||||
_marker: PhantomData<*mut T>,
|
||||
}
|
||||
|
||||
unsafe impl<T> Sync for AtomicPtr<T> {}
|
||||
@ -791,7 +793,8 @@ impl<T> AtomicPtr<T> {
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn new(p: *mut T) -> AtomicPtr<T> {
|
||||
AtomicPtr { p: UnsafeCell::new(p as usize) }
|
||||
AtomicPtr { p: UnsafeCell::new(p as usize),
|
||||
_marker: PhantomData }
|
||||
}
|
||||
|
||||
/// Loads a value from the pointer.
|
||||
|
Loading…
Reference in New Issue
Block a user