Skip to content

Commit 2b4ae6f

Browse files
committed
---
yaml --- r: 69431 b: refs/heads/auto c: 5c7e016 h: refs/heads/master i: 69429: 4a819d4 69427: 8619fce 69423: 07e7a55 v: v3
1 parent b5e279a commit 2b4ae6f

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 4a1a0fbed5a57958eb7b658bbe3e5257872ae99f
17+
refs/heads/auto: 5c7e016700cd002647508ec4be764606c0086ce8
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/libstd/unstable/atomics.rs

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ pub enum Ordering {
7575
SeqCst
7676
}
7777

78+
pub static INIT_ATOMIC_FLAG : AtomicFlag = AtomicFlag { v: 0 };
79+
pub static INIT_ATOMIC_BOOL : AtomicBool = AtomicBool { v: 0 };
80+
pub static INIT_ATOMIC_INT : AtomicInt = AtomicInt { v: 0 };
81+
pub static INIT_ATOMIC_UINT : AtomicUint = AtomicUint { v: 0 };
7882

7983
impl AtomicFlag {
8084

@@ -589,11 +593,13 @@ pub unsafe fn atomic_umin<T>(dst: &mut T, val: T, order: Ordering) -> T {
589593
*/
590594
#[inline] #[cfg(not(stage0))]
591595
pub fn fence(order: Ordering) {
592-
match order {
593-
Acquire => intrinsics::atomic_fence_acq(),
594-
Release => intrinsics::atomic_fence_rel(),
595-
AcqRel => intrinsics::atomic_fence_rel(),
596-
_ => intrinsics::atomic_fence(),
596+
unsafe {
597+
match order {
598+
Acquire => intrinsics::atomic_fence_acq(),
599+
Release => intrinsics::atomic_fence_rel(),
600+
AcqRel => intrinsics::atomic_fence_rel(),
601+
_ => intrinsics::atomic_fence(),
602+
}
597603
}
598604
}
599605

@@ -657,4 +663,19 @@ mod test {
657663
assert_eq!(a.fetch_and(false, SeqCst),true);
658664
assert_eq!(a.load(SeqCst),false);
659665
}
666+
667+
static mut S_FLAG : AtomicFlag = INIT_ATOMIC_FLAG;
668+
static mut S_BOOL : AtomicBool = INIT_ATOMIC_BOOL;
669+
static mut S_INT : AtomicInt = INIT_ATOMIC_INT;
670+
static mut S_UINT : AtomicUint = INIT_ATOMIC_UINT;
671+
672+
#[test]
673+
fn static_init() {
674+
unsafe {
675+
assert!(!S_FLAG.test_and_set(SeqCst));
676+
assert!(!S_BOOL.load(SeqCst));
677+
assert!(S_INT.load(SeqCst) == 0);
678+
assert!(S_UINT.load(SeqCst) == 0);
679+
}
680+
}
660681
}

0 commit comments

Comments
 (0)