views:

27

answers:

1

Hi,

This is regarding the void spin_lock_irqsave(spinlock_t *lock, unsigned long flags); function call. It is mentioned that previous interrupt state is stored in flags and we can restore them by passing this to spin_unlock_irqrestore function.

But I did not get how flags which is passed by values captures the previous interrupt state when spin_lock_irqsave is called.

+4  A: 

spin_lock_irqsave is a macro, not a function. So it can assign to flags even though it's apparently passed by value.

See:

http://lxr.linux.no/#linux+v2.6.35.4/include/linux/spinlock.h#L312
http://lxr.linux.no/#linux+v2.6.35.4/include/linux/spinlock.h#L187

Zack