www.delorie.com/djgpp/bugs/show.cgi   search  
Bug 000245

When Created: 08/03/1998 06:07:19
Against DJGPP version: 2.01
By whom: asa@lan.eed.miee.ru
Abstract: uclock() bug
uclock () sometimes return negative values. i've made patch for rtc8254, but
not fot rtc8253:

*** uclock.c	Thu Jan 25 21:39:06 1996
--- uclock.new	Mon Aug  3 14:13:12 1998
***************
*** 20,26 ****
  {
    static uclock_t base = 0;
    static unsigned long last_tics = 0;
!   unsigned char lsb, msb;
    unsigned long tics, otics;
    uclock_t rv;
  
--- 20,26 ----
  {
    static uclock_t base = 0;
    static unsigned long last_tics = 0;
!   unsigned char lsb, msb, status;
    unsigned long tics, otics;
    uclock_t rv;
  
***************
*** 41,51 ****
    /* Make sure the numbers we get are consistent */
    do {
      otics = _farpeekl(_dos_ds, 0x46c);
!     outportb(0x43, 0x00);
      lsb = inportb(0x40);
      msb = inportb(0x40);
      tics = _farpeekl(_dos_ds, 0x46c);
!   } while (otics != tics);
  
    /* calculate absolute time */
    msb ^= 0xff;
--- 41,52 ----
    /* Make sure the numbers we get are consistent */
    do {
      otics = _farpeekl(_dos_ds, 0x46c);
!     outportb(0x43, 0xd0);
!     status = inportb(0x40);
      lsb = inportb(0x40);
      msb = inportb(0x40);
      tics = _farpeekl(_dos_ds, 0x46c);
!   } while ((otics != tics) && (status & 0x40));
  
    /* calculate absolute time */
    msb ^= 0xff;

actually i don't know if there are any 386 or higher PCs that using rtc8253.
it works for me and all my boards and i happy :-)

Note added: 04/13/1999 12:00:55
By whom: eliz@is.elta.co.il
I cannot verify the problem, since there's no test program supplied
with the bug report.  A simple test program I wrote doesn't report
negative time intervals at all on Windows 95.

And since the solution requires a certain type of a timer chip, I'm 
putting this bug on hold until somebody provides a test program that
exhibits the problem.

Closed on 04/19/1999 06:00:40: The problem cannot be reproduced.
By whom: eliz@is.elta.co.il



  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2010   by DJ Delorie     Updated Jul 2010