automagp68:
It has to be down in one clock cycle to prevent possible interrupts from interfering during the set.
Impossible. All references are read-modify-write.
Just protect the calls to attachInterrupt and detachInterrupt. Or modify the core. You have the source code for both.