Synchronize with sys/i386/isa/clock.c revision 1.75.
This commit is contained in:
parent
e10cf2fa74
commit
d3e1120fab
@ -456,7 +456,7 @@ getit(void)
|
|||||||
void
|
void
|
||||||
DELAY(int n)
|
DELAY(int n)
|
||||||
{
|
{
|
||||||
int delta, prev_tick, tick, ticks_left, sec, usec;
|
int delta, prev_tick, tick, ticks_left;
|
||||||
|
|
||||||
#ifdef DELAYDEBUG
|
#ifdef DELAYDEBUG
|
||||||
int getit_calls = 1;
|
int getit_calls = 1;
|
||||||
@ -487,19 +487,30 @@ DELAY(int n)
|
|||||||
* multiplications and divisions to scale the count take a while).
|
* multiplications and divisions to scale the count take a while).
|
||||||
*/
|
*/
|
||||||
prev_tick = getit();
|
prev_tick = getit();
|
||||||
n -= 20;
|
n -= 0; /* XXX actually guess no initial overhead */
|
||||||
/*
|
/*
|
||||||
* Calculate (n * (timer_freq / 1e6)) without using floating point
|
* Calculate (n * (timer_freq / 1e6)) without using floating point
|
||||||
* and without any avoidable overflows.
|
* and without any avoidable overflows.
|
||||||
*/
|
*/
|
||||||
sec = n / 1000000;
|
if (n <= 0)
|
||||||
usec = n - sec * 1000000;
|
ticks_left = 0;
|
||||||
ticks_left = sec * timer_freq
|
else if (n < 256)
|
||||||
+ usec * (timer_freq / 1000000)
|
/*
|
||||||
+ usec * ((timer_freq % 1000000) / 1000) / 1000
|
* Use fixed point to avoid a slow division by 1000000.
|
||||||
+ usec * (timer_freq % 1000) / 1000000;
|
* 39099 = 1193182 * 2^15 / 10^6 rounded to nearest.
|
||||||
if (n < 0)
|
* 2^15 is the first power of 2 that gives exact results
|
||||||
ticks_left = 0; /* XXX timer_freq is unsigned */
|
* for n between 0 and 256.
|
||||||
|
*/
|
||||||
|
ticks_left = ((u_int)n * 39099 + (1 << 15) - 1) >> 15;
|
||||||
|
else
|
||||||
|
/*
|
||||||
|
* Don't bother using fixed point, although gcc-2.7.2
|
||||||
|
* generates particularly poor code for the long long
|
||||||
|
* division, since even the slow way will complete long
|
||||||
|
* before the delay is up (unless we're interrupted).
|
||||||
|
*/
|
||||||
|
ticks_left = ((u_int)n * (long long)timer_freq + 999999)
|
||||||
|
/ 1000000;
|
||||||
|
|
||||||
while (ticks_left > 0) {
|
while (ticks_left > 0) {
|
||||||
tick = getit();
|
tick = getit();
|
||||||
|
@ -456,7 +456,7 @@ getit(void)
|
|||||||
void
|
void
|
||||||
DELAY(int n)
|
DELAY(int n)
|
||||||
{
|
{
|
||||||
int delta, prev_tick, tick, ticks_left, sec, usec;
|
int delta, prev_tick, tick, ticks_left;
|
||||||
|
|
||||||
#ifdef DELAYDEBUG
|
#ifdef DELAYDEBUG
|
||||||
int getit_calls = 1;
|
int getit_calls = 1;
|
||||||
@ -487,19 +487,30 @@ DELAY(int n)
|
|||||||
* multiplications and divisions to scale the count take a while).
|
* multiplications and divisions to scale the count take a while).
|
||||||
*/
|
*/
|
||||||
prev_tick = getit();
|
prev_tick = getit();
|
||||||
n -= 20;
|
n -= 0; /* XXX actually guess no initial overhead */
|
||||||
/*
|
/*
|
||||||
* Calculate (n * (timer_freq / 1e6)) without using floating point
|
* Calculate (n * (timer_freq / 1e6)) without using floating point
|
||||||
* and without any avoidable overflows.
|
* and without any avoidable overflows.
|
||||||
*/
|
*/
|
||||||
sec = n / 1000000;
|
if (n <= 0)
|
||||||
usec = n - sec * 1000000;
|
ticks_left = 0;
|
||||||
ticks_left = sec * timer_freq
|
else if (n < 256)
|
||||||
+ usec * (timer_freq / 1000000)
|
/*
|
||||||
+ usec * ((timer_freq % 1000000) / 1000) / 1000
|
* Use fixed point to avoid a slow division by 1000000.
|
||||||
+ usec * (timer_freq % 1000) / 1000000;
|
* 39099 = 1193182 * 2^15 / 10^6 rounded to nearest.
|
||||||
if (n < 0)
|
* 2^15 is the first power of 2 that gives exact results
|
||||||
ticks_left = 0; /* XXX timer_freq is unsigned */
|
* for n between 0 and 256.
|
||||||
|
*/
|
||||||
|
ticks_left = ((u_int)n * 39099 + (1 << 15) - 1) >> 15;
|
||||||
|
else
|
||||||
|
/*
|
||||||
|
* Don't bother using fixed point, although gcc-2.7.2
|
||||||
|
* generates particularly poor code for the long long
|
||||||
|
* division, since even the slow way will complete long
|
||||||
|
* before the delay is up (unless we're interrupted).
|
||||||
|
*/
|
||||||
|
ticks_left = ((u_int)n * (long long)timer_freq + 999999)
|
||||||
|
/ 1000000;
|
||||||
|
|
||||||
while (ticks_left > 0) {
|
while (ticks_left > 0) {
|
||||||
tick = getit();
|
tick = getit();
|
||||||
|
@ -456,7 +456,7 @@ getit(void)
|
|||||||
void
|
void
|
||||||
DELAY(int n)
|
DELAY(int n)
|
||||||
{
|
{
|
||||||
int delta, prev_tick, tick, ticks_left, sec, usec;
|
int delta, prev_tick, tick, ticks_left;
|
||||||
|
|
||||||
#ifdef DELAYDEBUG
|
#ifdef DELAYDEBUG
|
||||||
int getit_calls = 1;
|
int getit_calls = 1;
|
||||||
@ -487,19 +487,30 @@ DELAY(int n)
|
|||||||
* multiplications and divisions to scale the count take a while).
|
* multiplications and divisions to scale the count take a while).
|
||||||
*/
|
*/
|
||||||
prev_tick = getit();
|
prev_tick = getit();
|
||||||
n -= 20;
|
n -= 0; /* XXX actually guess no initial overhead */
|
||||||
/*
|
/*
|
||||||
* Calculate (n * (timer_freq / 1e6)) without using floating point
|
* Calculate (n * (timer_freq / 1e6)) without using floating point
|
||||||
* and without any avoidable overflows.
|
* and without any avoidable overflows.
|
||||||
*/
|
*/
|
||||||
sec = n / 1000000;
|
if (n <= 0)
|
||||||
usec = n - sec * 1000000;
|
ticks_left = 0;
|
||||||
ticks_left = sec * timer_freq
|
else if (n < 256)
|
||||||
+ usec * (timer_freq / 1000000)
|
/*
|
||||||
+ usec * ((timer_freq % 1000000) / 1000) / 1000
|
* Use fixed point to avoid a slow division by 1000000.
|
||||||
+ usec * (timer_freq % 1000) / 1000000;
|
* 39099 = 1193182 * 2^15 / 10^6 rounded to nearest.
|
||||||
if (n < 0)
|
* 2^15 is the first power of 2 that gives exact results
|
||||||
ticks_left = 0; /* XXX timer_freq is unsigned */
|
* for n between 0 and 256.
|
||||||
|
*/
|
||||||
|
ticks_left = ((u_int)n * 39099 + (1 << 15) - 1) >> 15;
|
||||||
|
else
|
||||||
|
/*
|
||||||
|
* Don't bother using fixed point, although gcc-2.7.2
|
||||||
|
* generates particularly poor code for the long long
|
||||||
|
* division, since even the slow way will complete long
|
||||||
|
* before the delay is up (unless we're interrupted).
|
||||||
|
*/
|
||||||
|
ticks_left = ((u_int)n * (long long)timer_freq + 999999)
|
||||||
|
/ 1000000;
|
||||||
|
|
||||||
while (ticks_left > 0) {
|
while (ticks_left > 0) {
|
||||||
tick = getit();
|
tick = getit();
|
||||||
|
Loading…
Reference in New Issue
Block a user