[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- To: KMP at MIT-MC, (BUG LISP) at MIT-MC
- From: HIC at MIT-MC (Howard I. Cannon)
- Date: Sun, 14 Jan 79 09:33:00 GMT
- Original-date: 14 JAN 1979 0433-EST
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