File tree Expand file tree Collapse file tree 2 files changed +60
-1
lines changed
library/std/src/sys/pal/uefi Expand file tree Collapse file tree 2 files changed +60
-1
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ pub mod pipe;
3131#[ path = "../unsupported/process.rs" ]
3232pub mod process;
3333pub mod stdio;
34- #[ path = "../unsupported/thread.rs" ]
3534pub mod thread;
3635#[ path = "../unsupported/thread_local_key.rs" ]
3736pub mod thread_local_key;
Original file line number Diff line number Diff line change 1+ use super :: unsupported;
2+ use crate :: ffi:: CStr ;
3+ use crate :: io;
4+ use crate :: num:: NonZeroUsize ;
5+ use crate :: ptr:: NonNull ;
6+ use crate :: time:: Duration ;
7+
8+ pub struct Thread ( !) ;
9+
10+ pub const DEFAULT_MIN_STACK_SIZE : usize = 4096 ;
11+
12+ impl Thread {
13+ // unsafe: see thread::Builder::spawn_unchecked for safety requirements
14+ pub unsafe fn new ( _stack : usize , _p : Box < dyn FnOnce ( ) > ) -> io:: Result < Thread > {
15+ unsupported ( )
16+ }
17+
18+ pub fn yield_now ( ) {
19+ // do nothing
20+ }
21+
22+ pub fn set_name ( _name : & CStr ) {
23+ // nope
24+ }
25+
26+ pub fn sleep ( dur : Duration ) {
27+ let boot_services: NonNull < r_efi:: efi:: BootServices > =
28+ crate :: os:: uefi:: env:: boot_services ( ) . expect ( "can't sleep" ) . cast ( ) ;
29+ let mut dur_ms = dur. as_micros ( ) ;
30+ // ceil up to the nearest millisecond
31+ if dur. subsec_nanos ( ) % 1000 > 0 {
32+ dur_ms += 1 ;
33+ }
34+
35+ while dur_ms > 0 {
36+ let ms = crate :: cmp:: min ( dur_ms, usize:: MAX as u128 ) ;
37+ let _ = unsafe { ( ( * boot_services. as_ptr ( ) ) . stall ) ( ms as usize ) } ;
38+ dur_ms -= ms;
39+ }
40+ }
41+
42+ pub fn join ( self ) {
43+ self . 0
44+ }
45+ }
46+
47+ pub fn available_parallelism ( ) -> io:: Result < NonZeroUsize > {
48+ // UEFI is single threaded
49+ Ok ( NonZeroUsize :: new ( 1 ) . unwrap ( ) )
50+ }
51+
52+ pub mod guard {
53+ pub type Guard = !;
54+ pub unsafe fn current ( ) -> Option < Guard > {
55+ None
56+ }
57+ pub unsafe fn init ( ) -> Option < Guard > {
58+ None
59+ }
60+ }
You can’t perform that action at this time.
0 commit comments