[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



This is exactly what you want:

(DEFMACRO BIND-INTERRUPT-STATE (NEW-VALUE CODE)
  `(UNWIND-PROTECT () (NOINTERRUPT ,NEW-VALUE) . ,CODE))

It is sort of a kludge, but given the fact that UNWIND-PROTECT does the binding for you,
it'll work.  Of course, if CODE does a *THROW (or similar) this will lose, so perhaps
you want to hair it up by doing:

(DEFMACRO BIND-INTERRUPT-STATE (NEW-VALUE CODE)
  `(LET ((OLD-STATE (NOINTERRUPT T)))
	(NOINTERRUPT OLD-STATE)				;Just to read the current state
	(CATCHALL '(LAMBDA (TAG VALUE) (NOINTERRUPT OLD-STATE) (*THROW TAG VALUE))
		  (UNWIND-PROTECT () (NOINTERRUPT ,NEW-VALUE) . ,CODE))))

If NEW-VALUE is T, then I believe that this code is foolproof as once the NOINTERRUPT in the
UNWIND-PROTECT gets done, the old value is garunteed to get restored.  If it is NIL, then
you could lose in certain circumstances.  [I'm not really sure if it's 100% secure,
but it is damn close].

I personnally believe that the right thing to do is to make NOINTERRUPT a special
avriable like *RSET so that it can be bound by the standard mechainisms!

--howard