Skip to content

Commit 263b2bc

Browse files
committed
Use AtomicU8 for Mutex.
1 parent 9f4b537 commit 263b2bc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/libstd/sys/unix/freertos/mutex.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
use crate::cell::UnsafeCell;
22
use crate::ptr;
3-
use crate::sync::atomic::{AtomicUsize, Ordering::SeqCst};
3+
use crate::sync::atomic::{AtomicU8, Ordering::SeqCst};
44

55
use crate::sys::ffi::*;
66

77
pub struct Mutex {
88
inner: UnsafeCell<SemaphoreHandle_t>,
9-
initialized: AtomicUsize,
9+
initialized: AtomicU8,
1010
}
1111

1212
unsafe impl Send for Mutex {}
1313
unsafe impl Sync for Mutex {}
1414

15-
const UNINITIALIZING: usize = 3;
16-
const UNINITIALIZED: usize = 2;
17-
const INITIALIZING: usize = 1;
18-
const INITIALIZED: usize = 0;
15+
const UNINITIALIZING: u8 = 3;
16+
const UNINITIALIZED: u8 = 2;
17+
const INITIALIZING: u8 = 1;
18+
const INITIALIZED: u8 = 0;
1919

2020
#[allow(dead_code)] // sys isn't exported yet
2121
impl Mutex {
2222
pub const fn new() -> Mutex {
23-
Mutex { inner: UnsafeCell::new(ptr::null_mut()), initialized: AtomicUsize::new(UNINITIALIZED) }
23+
Mutex { inner: UnsafeCell::new(ptr::null_mut()), initialized: AtomicU8::new(UNINITIALIZED) }
2424
}
2525

2626
#[inline]
@@ -89,7 +89,7 @@ impl Drop for Mutex {
8989

9090
pub struct ReentrantMutex {
9191
inner: UnsafeCell<SemaphoreHandle_t>,
92-
initialized: AtomicUsize,
92+
initialized: AtomicU8,
9393
}
9494

9595
unsafe impl Send for ReentrantMutex {}
@@ -99,7 +99,7 @@ impl ReentrantMutex {
9999
pub const unsafe fn uninitialized() -> ReentrantMutex {
100100
ReentrantMutex {
101101
inner: UnsafeCell::new(ptr::null_mut()),
102-
initialized: AtomicUsize::new(UNINITIALIZED),
102+
initialized: AtomicU8::new(UNINITIALIZED),
103103
}
104104
}
105105

0 commit comments

Comments
 (0)