1 use core::arch::asm; 2 3 #[inline] local_irq_save() -> usize4pub fn local_irq_save() -> usize { 5 let x: usize; 6 // x86_64::registers::rflags:: 7 unsafe { 8 asm!("pushfq; pop {}; cli", out(reg) x, options(nomem, preserves_flags)); 9 } 10 x 11 } 12 13 #[inline] 14 // 恢复先前保存的rflags的值x local_irq_restore(x: usize)15pub fn local_irq_restore(x: usize) { 16 unsafe { 17 asm!("push {}; popfq", in(reg) x, options(nomem, preserves_flags)); 18 } 19 } 20