Affan said:
I am not able to figure out exactly what this macro is doing. Can one of the
gurus around here decipher this?
#define sei() __asm__ __volatile__ ("sei" :
PS: It is from the avr-libc interrupt.h and it should set a partilcular
interrrupt.
For the most part, off topic, but I think we can scrounge at least some
topicality. The C standard states:
7.1.3 Reserved identifiers
[...]
All identifiers that begin with an underscore and either
an uppercase letter or another underscore are always
reserved for any use.
So __asm__ and __volatile__ are implementation-defined identifiers, or
in other words, specific to your compiler.
[OT]
If you're using gcc, __asm__ is a construct for using assembly code
from within C code. The presence of __volatile__ tells the compiler
not to reorder or optimize away the instruction. "sei" is an assembly
instruction that enables interrupt processing on the processor. The
double colons delimit input and output operands, of which there are
none here. As always, see your compiler documentation for definitive
information.
When you're mucking around with enabling and disabling interrupts,
there's usually hard and strict requirements about exactly what is
executed with interrupts enabled/disabled. The last thing you want
there is the compiler rearranging or eliminating instructions like this
behind your back, hence the usage of __volatile__ in this case.
Mark F. Haigh
(e-mail address removed)