I'm not a programmer. I'm a hardware designer that hacks at programming. So my questions are often naive and without enough detail. So bare with me, please
I would like to look at the code that defines cli(); and soi(); in the attached example for the this code is in the Inferred Library IRremote.
Like gfvalvo said, it's in avr/interrupt.h (for all AVRs, anyway.)
If you use interrupts() and noInterrupts(), your code should be more portable to other architectures, and produce the same code...
/** \name Global manipulation of the interrupt flag
The global interrupt flag is maintained in the I bit of the status
register (SREG).
Handling interrupts frequently requires attention regarding atomic
access to objects that could be altered by code running within an
interrupt context, see <util/atomic.h>.
Frequently, interrupts are being disabled for periods of time in
order to perform certain operations without being disturbed; see
\ref optim_code_reorder for things to be taken into account with
respect to compiler optimizations.
*/
#if defined(__DOXYGEN__)
/** \def sei()
\ingroup avr_interrupts
Enables interrupts by setting the global interrupt mask. This function
actually compiles into a single line of assembly, so there is no function
call overhead. However, the macro also implies a <i>memory barrier</i>
which can cause additional loss of optimization.
In order to implement atomic access to multi-byte objects,
consider using the macros from <util/atomic.h>, rather than
implementing them manually with cli() and sei().
*/
#define sei()
#else /* !DOXYGEN */
# define sei() __asm__ __volatile__ ("sei" ::: "memory")
#endif /* DOXYGEN */
#if defined(__DOXYGEN__)
/** \def cli()
\ingroup avr_interrupts
Disables all interrupts by clearing the global interrupt mask. This function
actually compiles into a single line of assembly, so there is no function
call overhead. However, the macro also implies a <i>memory barrier</i>
which can cause additional loss of optimization.
In order to implement atomic access to multi-byte objects,
consider using the macros from <util/atomic.h>, rather than
implementing them manually with cli() and sei().
*/
#define cli()
#else /* !DOXYGEN */
# define cli() __asm__ __volatile__ ("cli" ::: "memory")
#endif /* DOXYGEN */