changeset 1076:ff838098079a

* src/hal_if.c (delay_us): The first test against CYGNUM_KERNEL_COUNTERS_RTC_PERIOD is now against the period divided by two. By the time we get to this test we know that usecs can never be > usec_per_period/2 so we can double the range of period values that we can handle without overflow and use the more efficient approximation. The second test is not changed since we cannot make the same assumptions about the elapsed count.
author nickg
date Wed, 25 Jun 2003 17:40:41 +0000
parents 4d2ad80d01ca
children e4850e482c80
files packages/hal/common/current/ChangeLog packages/hal/common/current/src/hal_if.c
diffstat 2 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/packages/hal/common/current/ChangeLog
+++ b/packages/hal/common/current/ChangeLog
@@ -1,3 +1,13 @@
+2003-06-25  Nick Garnett  <nickg@balti.calivar.com>
+
+	* src/hal_if.c (delay_us): The first test against
+	CYGNUM_KERNEL_COUNTERS_RTC_PERIOD is now against the period
+	divided by two. By the time we get to this test we know that usecs
+	can never be > usec_per_period/2 so we can double the range of
+	period values that we can handle without overflow and use the more
+	efficient approximation. The second test is not changed since we
+	cannot make the same assumptions about the elapsed count.
+
 2003-06-24  Jonathan Larmour  <jifl@eCosCentric.com>
 
 	* src/generic-stub.c (crc32): Fix crctable option name typo.
--- a/packages/hal/common/current/src/hal_if.c
+++ b/packages/hal/common/current/src/hal_if.c
@@ -187,7 +187,7 @@ delay_us(cyg_int32 usecs)
             
             if( usecs > usec_per_period/2 )
                 slice = CYGNUM_KERNEL_COUNTERS_RTC_PERIOD/2;
-            else if( CYGNUM_KERNEL_COUNTERS_RTC_PERIOD >= 0x7FFFFFFF/usec_per_period )
+            else if( CYGNUM_KERNEL_COUNTERS_RTC_PERIOD/2 >= 0x7FFFFFFF/usec_per_period )
                 slice = usecs * ticks_per_usec;
             else
             {