@@ -991,16 +991,8 @@ impl<T> AtomicPtr<T> {
991
991
#[ inline]
992
992
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
993
993
pub fn load ( & self , order : Ordering ) -> * mut T {
994
- #[ cfg( not( bootstrap) ) ]
995
994
// SAFETY: data races are prevented by atomic intrinsics.
996
- unsafe {
997
- atomic_load ( self . p . get ( ) , order)
998
- }
999
- #[ cfg( bootstrap) ]
1000
- // SAFETY: data races are prevented by atomic intrinsics.
1001
- unsafe {
1002
- atomic_load ( self . p . get ( ) as * mut usize , order) as * mut T
1003
- }
995
+ unsafe { atomic_load ( self . p . get ( ) , order) }
1004
996
}
1005
997
1006
998
/// Stores a value into the pointer.
@@ -1027,16 +1019,10 @@ impl<T> AtomicPtr<T> {
1027
1019
#[ inline]
1028
1020
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1029
1021
pub fn store ( & self , ptr : * mut T , order : Ordering ) {
1030
- #[ cfg( not( bootstrap) ) ]
1031
1022
// SAFETY: data races are prevented by atomic intrinsics.
1032
1023
unsafe {
1033
1024
atomic_store ( self . p . get ( ) , ptr, order) ;
1034
1025
}
1035
- #[ cfg( bootstrap) ]
1036
- // SAFETY: data races are prevented by atomic intrinsics.
1037
- unsafe {
1038
- atomic_store ( self . p . get ( ) as * mut usize , ptr as usize , order) ;
1039
- }
1040
1026
}
1041
1027
1042
1028
/// Stores a value into the pointer, returning the previous value.
@@ -1065,16 +1051,8 @@ impl<T> AtomicPtr<T> {
1065
1051
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1066
1052
#[ cfg( target_has_atomic = "ptr" ) ]
1067
1053
pub fn swap ( & self , ptr : * mut T , order : Ordering ) -> * mut T {
1068
- #[ cfg( bootstrap) ]
1069
- // SAFETY: data races are prevented by atomic intrinsics.
1070
- unsafe {
1071
- atomic_swap ( self . p . get ( ) as * mut usize , ptr as usize , order) as * mut T
1072
- }
1073
- #[ cfg( not( bootstrap) ) ]
1074
1054
// SAFETY: data races are prevented by atomic intrinsics.
1075
- unsafe {
1076
- atomic_swap ( self . p . get ( ) , ptr, order)
1077
- }
1055
+ unsafe { atomic_swap ( self . p . get ( ) , ptr, order) }
1078
1056
}
1079
1057
1080
1058
/// Stores a value into the pointer if the current value is the same as the `current` value.
@@ -1174,26 +1152,8 @@ impl<T> AtomicPtr<T> {
1174
1152
success : Ordering ,
1175
1153
failure : Ordering ,
1176
1154
) -> Result < * mut T , * mut T > {
1177
- #[ cfg( bootstrap) ]
1178
1155
// SAFETY: data races are prevented by atomic intrinsics.
1179
- unsafe {
1180
- let res = atomic_compare_exchange (
1181
- self . p . get ( ) as * mut usize ,
1182
- current as usize ,
1183
- new as usize ,
1184
- success,
1185
- failure,
1186
- ) ;
1187
- match res {
1188
- Ok ( x) => Ok ( x as * mut T ) ,
1189
- Err ( x) => Err ( x as * mut T ) ,
1190
- }
1191
- }
1192
- #[ cfg( not( bootstrap) ) ]
1193
- // SAFETY: data races are prevented by atomic intrinsics.
1194
- unsafe {
1195
- atomic_compare_exchange ( self . p . get ( ) , current, new, success, failure)
1196
- }
1156
+ unsafe { atomic_compare_exchange ( self . p . get ( ) , current, new, success, failure) }
1197
1157
}
1198
1158
1199
1159
/// Stores a value into the pointer if the current value is the same as the `current` value.
@@ -1241,29 +1201,11 @@ impl<T> AtomicPtr<T> {
1241
1201
success : Ordering ,
1242
1202
failure : Ordering ,
1243
1203
) -> Result < * mut T , * mut T > {
1244
- #[ cfg( bootstrap) ]
1245
- // SAFETY: data races are prevented by atomic intrinsics.
1246
- unsafe {
1247
- let res = atomic_compare_exchange_weak (
1248
- self . p . get ( ) as * mut usize ,
1249
- current as usize ,
1250
- new as usize ,
1251
- success,
1252
- failure,
1253
- ) ;
1254
- match res {
1255
- Ok ( x) => Ok ( x as * mut T ) ,
1256
- Err ( x) => Err ( x as * mut T ) ,
1257
- }
1258
- }
1259
- #[ cfg( not( bootstrap) ) ]
1260
1204
// SAFETY: This intrinsic is unsafe because it operates on a raw pointer
1261
1205
// but we know for sure that the pointer is valid (we just got it from
1262
1206
// an `UnsafeCell` that we have by reference) and the atomic operation
1263
1207
// itself allows us to safely mutate the `UnsafeCell` contents.
1264
- unsafe {
1265
- atomic_compare_exchange_weak ( self . p . get ( ) , current, new, success, failure)
1266
- }
1208
+ unsafe { atomic_compare_exchange_weak ( self . p . get ( ) , current, new, success, failure) }
1267
1209
}
1268
1210
1269
1211
/// Fetches the value, and applies a function to it that returns an optional
0 commit comments