Replacement for AVR libc ATOMIC_BLOCK macros, now for DUE and other platforms.

WizenedEE:
You are correct that break is still a valid statement, and that this would be an ever greater problem:

Yep, that's a real problem, and potentially an easy trap for the unwary to fall into. Initially, I thought it was an unlikely bug to cause real problems, but now I think this is a shortcoming with potential to cause some real grief. I don't think it unreasonable or unlikely that someone would want to protect only a section of code within a "for" or "while" loop. If that section contains a break or continue, things certainly won't work as expected anymore if using ATOMIC_BLOCK macros.

In which case, I think Pyro's alternative is looking better all the time... I'll have to get around to having a play.