Skip to content

Commit b8a66e8

Browse files
committed
Format thread.rs.
1 parent d0437b3 commit b8a66e8

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ use crate::ffi::CStr;
22
use crate::io;
33
use crate::mem;
44
use crate::ptr;
5+
use crate::sync::{
6+
atomic::{AtomicU8, Ordering::SeqCst},
7+
Arc,
8+
};
59
use crate::sys::mutex::Mutex;
610
use crate::time::Duration;
7-
use crate::sync::{Arc, atomic::{AtomicU8, Ordering::SeqCst}};
811

912
use crate::sys::ffi::*;
1013
use crate::sys::thread_local;
@@ -27,8 +30,11 @@ unsafe impl Sync for Thread {}
2730

2831
impl Thread {
2932
// unsafe: see thread::Builder::spawn_unchecked for safety requirements
30-
pub unsafe fn new(name: Option<&CStr>, stack: usize, p: Box<dyn FnOnce()>)
31-
-> io::Result<Thread> {
33+
pub unsafe fn new(
34+
name: Option<&CStr>,
35+
stack: usize,
36+
p: Box<dyn FnOnce()>,
37+
) -> io::Result<Thread> {
3238
let join_mutex = Arc::new(Mutex::new());
3339
let state = Arc::new(AtomicU8::new(PENDING));
3440

@@ -55,17 +61,22 @@ impl Thread {
5561
}
5662

5763
if res == errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY {
58-
return Err(io::Error::new(io::ErrorKind::Other, "could not allocate required memory for thread"));
64+
return Err(io::Error::new(
65+
io::ErrorKind::Other,
66+
"could not allocate required memory for thread",
67+
));
5968
} else {
6069
return Err(io::ErrorKind::WouldBlock.into());
6170
}
6271
}
6372

6473
return Ok(thread);
6574

66-
extern fn thread_start(arg: *mut libc::c_void) -> *mut libc::c_void {
75+
extern "C" fn thread_start(arg: *mut libc::c_void) -> *mut libc::c_void {
6776
unsafe {
68-
let arg = Box::<(Arc<Mutex>, Arc<AtomicU8>, Box<Box<dyn FnOnce()>>)>::from_raw(arg as *mut _);
77+
let arg = Box::<(Arc<Mutex>, Arc<AtomicU8>, Box<Box<dyn FnOnce()>>)>::from_raw(
78+
arg as *mut _,
79+
);
6980
let (join_mutex, state, main) = *arg;
7081

7182
join_mutex.lock();
@@ -125,7 +136,9 @@ impl Thread {
125136
}
126137
}
127138

128-
pub fn id(&self) -> TaskHandle_t { self.id }
139+
pub fn id(&self) -> TaskHandle_t {
140+
self.id
141+
}
129142

130143
pub fn into_id(self) -> TaskHandle_t {
131144
let id = self.id;
@@ -149,6 +162,10 @@ impl Drop for Thread {
149162
pub mod guard {
150163
use crate::ops::Range;
151164
pub type Guard = Range<usize>;
152-
pub unsafe fn current() -> Option<Guard> { None }
153-
pub unsafe fn init() -> Option<Guard> { None }
165+
pub unsafe fn current() -> Option<Guard> {
166+
None
167+
}
168+
pub unsafe fn init() -> Option<Guard> {
169+
None
170+
}
154171
}

0 commit comments

Comments
 (0)