1 use crate::include::bindings::bindings::process_control_block;
2 
3 use core::{arch::asm, sync::atomic::compiler_fence};
4 
5 /// @brief 获取指向当前进程的pcb的可变引用
6 #[inline]
current_pcb() -> &'static mut process_control_block7 pub fn current_pcb() -> &'static mut process_control_block {
8     let ret: Option<&mut process_control_block>;
9     unsafe {
10         let mut tmp: u64 = !(32767u64);
11         compiler_fence(core::sync::atomic::Ordering::SeqCst);
12         asm!("and {0}, rsp", inout(reg)(tmp),);
13         compiler_fence(core::sync::atomic::Ordering::SeqCst);
14         ret = (tmp as *mut process_control_block).as_mut();
15     }
16 
17     ret.unwrap()
18 }
19