timer.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*====================================================================*
  2. *
  3. * timer.h - custom data type definitions and declarations;
  4. *
  5. * this file is a subset of the original that includes only those
  6. * definitions and declaration needed for toolkit programs;
  7. *
  8. * Motley Tools by Charles Maier;
  9. * Copyright 2001-2006 by Charles Maier Associates;
  10. * Licensed under the Internet Software Consortium License;
  11. *
  12. *--------------------------------------------------------------------*/
  13. #ifndef TIMER_HEADER
  14. #define TIMER_HEADER
  15. /*====================================================================*
  16. * system header files;
  17. *--------------------------------------------------------------------*/
  18. #include <stdint.h>
  19. /*====================================================================*
  20. * constants;
  21. *--------------------------------------------------------------------*/
  22. #ifdef WIN32
  23. #define SLEEP(n) Sleep(n)
  24. #else
  25. #define SLEEP(n) usleep((n)*1000)
  26. #endif
  27. /*====================================================================*
  28. * macros;
  29. *--------------------------------------------------------------------*/
  30. #define MILLISECONDS(start,timer) ((((timer).tv_sec - (start).tv_sec) * 1000) + ((timer).tv_usec - (start).tv_usec) / 1000)
  31. #define SECONDS(start,timer) (MILLISECONDS(start,timer) / 1000)
  32. /*====================================================================*
  33. * end definitions and declarations;
  34. *--------------------------------------------------------------------*/
  35. #endif