libcm is a C development framework with an emphasis on audio signal processing applications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmTime.h 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //| Copyright: (C) 2009-2020 Kevin Larke <contact AT larke DOT org>
  2. //| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
  3. //( { file_desc:"Time cand clock related functions." kw: [ time system ] }
  4. //
  5. //
  6. // This interface is used to read the systems high resolution timer and
  7. // calculate elapsed time.
  8. //)
  9. #ifndef cmTime_h
  10. #define cmTime_h
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. //(
  15. typedef struct timespec cmTimeSpec_t;
  16. // Get the time
  17. void cmTimeGet( cmTimeSpec_t* t );
  18. // Return the elapsed time (t1 - t0) in microseconds
  19. // t1 is assumed to be at a later time than t0.
  20. unsigned cmTimeElapsedMicros( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 );
  21. // Same as cmTimeElapsedMicros() but the times are not assumed to be ordered.
  22. // The function therefore begins by swapping t1 and t0 if t0 is after t1.
  23. unsigned cmTimeAbsElapsedMicros( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 );
  24. // Same as cmTimeElapsedMicros() but returns a negative value if t0 is after t1.
  25. int cmTimeDiffMicros( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 );
  26. // Returns true if t0 <= t1.
  27. bool cmTimeIsLTE( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 );
  28. // Return true if t0 >= t1.
  29. bool cmTimeIsGTE( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 );
  30. bool cmTimeIsEqual( const cmTimeSpec_t* t0, const cmTimeSpec_t* t1 );
  31. bool cmTimeIsZero( const cmTimeSpec_t* t0 );
  32. void cmTimeSetZero( cmTimeSpec_t* t0 );
  33. //)
  34. #ifdef __cplusplus
  35. }
  36. #endif
  37. #endif