home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / UTGETCLK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  1.4 KB  |  54 lines

  1. /**
  2. *
  3. * Name        UTGETCLK -- Read BIOS clock tick count.
  4. *
  5. * Synopsis    rollover = utgetclk(pcount);
  6. *
  7. *        int rollover      1 if midnight rollover occurred
  8. *                    on the most recent clock tick;
  9. *                  0 if not.
  10. *        long *pcount      The count of timer ticks since
  11. *                  midnight.
  12. *
  13. * Description    This function returns the BIOS's four-byte count of
  14. *        clock ticks since midnight.  On standard IBM PCs, timer
  15. *        ticks occur 1193180/65536 (about 18.2) times per second.
  16. *
  17. *        If the value of the function is 1, then the midnight
  18. *        rollover has occurred but has not yet been cleared.
  19. *        This function does NOT clear the rollover flag, thus
  20. *        allowing another program (presumably DOS) to respond to
  21. *        the rollover and to clear it.
  22. *
  23. * Returns    rollover      1 if midnight rollover occurred
  24. *                    on the most recent clock tick;
  25. *                  0 if not.
  26. *
  27. * Version    6.00 (C)Copyright Blaise Computing Inc.  1986,1987,1989
  28. *
  29. **/
  30.  
  31.  
  32. #include <butil.h>
  33.  
  34.  
  35. int utgetclk(pcount)
  36. long *pcount;
  37. {
  38.     int  were_on;        /* Stores previous interrupt state.     */
  39.     unsigned char rollover; /* Copy of BIOS's rollover flag.        */
  40.  
  41.     were_on = utintoff();   /* Turn interrupts off.            */
  42.  
  43.     utpeekn ((char far *) UTCLOCKADDR,
  44.          (void *) pcount,
  45.          sizeof (*pcount));
  46.  
  47.     rollover = utpeekb (UTROLLADDR);
  48.  
  49.     if (were_on)
  50.     utinton();        /* Turn interrupts back on.         */
  51.  
  52.     return (rollover != 0);
  53. }
  54.