on2_timer.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef _ON2_TIMER_H_
  2. #define _ON2_TIMER_H_
  3. /************************************************************************/
  4. /* on2Timer: cross-platform timer, works on win32 and linux so far */
  5. /* started: August 14, 2001 */
  6. /* codemonkey: TJF */
  7. /************************************************************************/
  8. #include <stdio.h>
  9. #if defined(__cplusplus)
  10. extern "C" {
  11. #endif
  12. typedef struct on2Timer_ {
  13. unsigned long baseMilli;
  14. unsigned long elapsedMilli;
  15. } on2Timer;
  16. /****************************************************************/
  17. /* void on2Timer_Init ( on2Timer* pTimer ) */
  18. /* initialize an allocated timer's members to 0 */
  19. /****************************************************************/
  20. void on2Timer_Init ( on2Timer* pTimer );
  21. /****************************************************************/
  22. /* unsigned long on2Timer_Start ( on2Timer* pTimer ) */
  23. /* start a timer: sets baseTime to currentTime in milliseconds */
  24. /****************************************************************/
  25. unsigned long on2Timer_Start ( on2Timer* pTimer );
  26. /****************************************************************/
  27. /* unsigned long on2Timer_Stop ( on2Timer* pTimer ) */
  28. /* stop a timer: sets elapsed time and accounts for rollover */
  29. /****************************************************************/
  30. unsigned long on2Timer_Stop ( on2Timer* pTimer );
  31. /********************************************************************************/
  32. /* unsigned long on2Timer_GetCurrentElapsedMilli ( on2Timer* pTimer ) */
  33. /* get current elapsed time: returns elapsed time and accounts for rollover */
  34. /********************************************************************************/
  35. unsigned long on2Timer_GetCurrentElapsedMilli ( on2Timer* pTimer );
  36. /********************************************************************************/
  37. /* unsigned long on2Timer_GetMilliBeforeRollover ( unsigned long baseMilli ) */
  38. /* returns milliseconds elapsed since rollover occurred */
  39. /********************************************************************************/
  40. unsigned long on2Timer_GetMilliBeforeRollover ( unsigned long baseMilli );
  41. /****************************************************************/
  42. /* unsigned long on2Timer_GetCurrentTimeSeconds ( void ) */
  43. /* returns seconds since midnight */
  44. /****************************************************************/
  45. unsigned long on2Timer_GetCurrentTimeSeconds ( void );
  46. /****************************************************************/
  47. /* unsigned long on2Timer_GetCurrentTimeMilli ( void ) */
  48. /* returns milliseconds since midnight */
  49. /****************************************************************/
  50. unsigned long on2Timer_GetCurrentTimeMilli ( void );
  51. /****************************************************************/
  52. /* void on2Timer_DeInit ( on2Timer* pTimer ); */
  53. /* on2_free's a pointer to a on2Timer struct, for the lazy ;-) */
  54. /****************************************************************/
  55. void on2Timer_DeInit ( on2Timer* pTimer );
  56. /****************************************************************/
  57. /* void on2Timer_Sleep ( int msec ); */
  58. /* Sleeps for the passed in number of milliseconds */
  59. /****************************************************************/
  60. int on2Timer_Sleep( int msec );
  61. #if defined(__cplusplus)
  62. }
  63. #endif
  64. #endif /* #ifndef _ON2_TIMER_H_ */