#![feature(custom_attribute,plugin)]
#![plugin(tag_safe)]
#![allow(dead_code)]
struct Spinlock;
struct HeldSpinlock(&'static Spinlock);
struct IRQLock;
struct IrqSpinlock(Spinlock);
static S_NON_IRQ_SPINLOCK: Spinlock = Spinlock;
static S_IRQ_SPINLOCK: IrqSpinlock = IrqSpinlock(Spinlock);
#[deny(not_tagged_safe)] #[req_safe(irq)] fn irq_handler()
{
let _lock = acquire_non_irq_spinlock(&S_NON_IRQ_SPINLOCK);
}
#[is_safe(irq)]
fn acquire_irq_spinlock(l: &'static IrqSpinlock) -> (IRQLock,HeldSpinlock)
{
let irql = hold_irqs();
(irql, acquire_non_irq_spinlock(&l.0))
}
#[is_safe(irq)]
fn hold_irqs() -> IRQLock
{
IRQLock
}
#[not_safe(irq)]
fn acquire_non_irq_spinlock(l: &'static Spinlock) -> HeldSpinlock
{
HeldSpinlock(l)
}
fn main() {
irq_handler();
}