clock.c 825 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. *
  5. * This product is part of the Amsterdam Compiler Kit.
  6. *
  7. * Permission to use, sell, duplicate or disclose this software must be
  8. * obtained in writing. Requests for such permissions may be sent to
  9. *
  10. * Dr. Andrew S. Tanenbaum
  11. * Wiskundig Seminarium
  12. * Vrije Universiteit
  13. * Postbox 7161
  14. * 1007 MC Amsterdam
  15. * The Netherlands
  16. *
  17. */
  18. /* Author: J.W. Stevenson */
  19. /* function clock:integer; extern; */
  20. extern int _times();
  21. struct tbuf {
  22. long utime;
  23. long stime;
  24. long cutime;
  25. long cstime;
  26. };
  27. #ifndef EM_WSIZE
  28. #define EM_WSIZE _EM_WSIZE
  29. #endif
  30. int clock() {
  31. struct tbuf t;
  32. _times(&t);
  33. return( (int)(t.utime + t.stime) &
  34. #if EM_WSIZE <= 2
  35. 077777
  36. #else
  37. 0x7fffffffL
  38. #endif
  39. );
  40. }