home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 9 / FreshFishVol9-CD2.bin / bbs / gnu / libnix-0.8-src.lha / libnix-0.8 / sources / nix / time / clock.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-12  |  567 b   |  30 lines

  1. #include <time.h>
  2. #include <dos/dos.h>
  3. #ifdef __GNUC__ /* This is very sad :-( */
  4. #undef BITSPERBYTE
  5. #undef MAXINT
  6. #undef MININT
  7. #endif
  8. #include <limits.h>
  9. #ifdef __GNUC__
  10. #include <inline/dos.h>
  11. #endif
  12. #include <stabs.h>
  13.  
  14. static struct DateStamp ds;
  15.  
  16. int __initclock(void)
  17. { DateStamp(&ds);
  18.   return 0;
  19. }
  20.  
  21. ADD2INIT(__initclock,-10);
  22.  
  23. clock_t clock(void)
  24. { struct DateStamp ds2;
  25.   DateStamp(&ds2);
  26.   return (((ds2.ds_Days-ds.ds_Days)*(24*60)+
  27.            ds2.ds_Minute-ds.ds_Minute)*(60*TICKS_PER_SECOND)+
  28.           ds2.ds_Tick-ds.ds_Tick)*CLK_TCK/TICKS_PER_SECOND;
  29. }
  30.