Fallout: AtomicPtr needs phantom data to indicate that it contains an unsafe pointer.
This commit is contained in:
parent
2bcf3a4cd1
commit
1735e41d1c
1 changed files with 4 additions and 1 deletions
|
@ -76,6 +76,7 @@ use marker::Sync;
|
||||||
|
|
||||||
use intrinsics;
|
use intrinsics;
|
||||||
use cell::UnsafeCell;
|
use cell::UnsafeCell;
|
||||||
|
use marker::PhantomData;
|
||||||
|
|
||||||
/// A boolean type which can be safely shared between threads.
|
/// A boolean type which can be safely shared between threads.
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
@ -105,6 +106,7 @@ unsafe impl Sync for AtomicUsize {}
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub struct AtomicPtr<T> {
|
pub struct AtomicPtr<T> {
|
||||||
p: UnsafeCell<usize>,
|
p: UnsafeCell<usize>,
|
||||||
|
_marker: PhantomData<*mut T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<T> Sync for AtomicPtr<T> {}
|
unsafe impl<T> Sync for AtomicPtr<T> {}
|
||||||
|
@ -791,7 +793,8 @@ impl<T> AtomicPtr<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn new(p: *mut T) -> AtomicPtr<T> {
|
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.
|
/// Loads a value from the pointer.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue