Return to BSD News archive
Path: sserve!manuel.anu.edu.au!munnari.oz.au!sgiblab!darwin.sura.net!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!chalmers.se!cs.chalmers.se!augustss
From: augustss@cs.chalmers.se (Lennart Augustsson)
Newsgroups: comp.unix.bsd
Subject: [386BSD] DELAY in isa.c
Message-ID: <1992Oct29.220653.4520@cs.chalmers.se>
Date: 29 Oct 92 22:06:53 GMT
Sender: news@cs.chalmers.se (News administrator)
Organization: Dept. of CS, Chalmers, Sweden
Lines: 41
Is the definition of DELAY in i386/isa/isa.c really correct?
It reads
DELAY(n) {
int tick = getit(0,0) & 1;
while (n--) {
/* wait approximately 1 micro second */
while (tick == getit(0,0) & 1) ;
^^^^^^^^^^^^^^
tick = getit(0,0) & 1;
}
}
Shouldn't that be
while (tick == (getit(0,0) & 1)) ;
In C == binds tighter than &. So doing the & with 1 is a noop,
and I suspect this is not what was intended. (Looping while the LSB
of the timer remain intact seems much more sensible.)
BTW, I would have written the whole thing as
DELAY(n) {
int tick;
while (n--) {
tick = getit(0,0) & 1;
/* wait approximately 1 micro second */
while (tick == (getit(0,0) & 1))
;
}
}
--
-- Lennart Augustsson
[This signature is intentionally left blank.]