Utility functions for time operations


Data Structures

struct  trtime
 Time structure. More...

Typedefs

typedef trtime trtime_t

Functions

LT_INLINE uint32_t trtime_to_secs (const trtime_t *const lt)
LT_INLINE void secs_to_trtime (uint32_t seconds, trtime_t *lt)
LT_INLINE void time_sub (const trtime_t *x, const trtime_t *y, trtime_t *res)
LT_INLINE void time_add (const trtime_t *x, const trtime_t *y, trtime_t *res)
LT_INLINE int time_compare (const trtime_t *t1, const trtime_t *t2)
LT_INLINE int time_lessthan (const trtime_t *t1, const trtime_t *t2)


Typedef Documentation

typedef struct trtime trtime_t

Time structure.

Different hardware architectures may represent time in formats that are most efficient and suitable for that hardware. We impose no requirements except for two functions that can convert this hardware dependent time structure into units of seconds and vice-versa The trtime_t structure consists of two elements:

  1. A subsecond unit (could be milli-seconds, nano-seconds,etc.)
  2. A supersecond unit ( could be a unit of 1 second, 10 secs, 1 minute etc.
This choice of time is kept deliberately vague, since the application is an embedded system, where these functions have to be fast, take advantage of the hardware, and cannot waste cycles converting time units from the hardware representation to a standard form.


Function Documentation

LT_INLINE uint32_t trtime_to_secs ( const trtime_t *const   lt  ) 

Convert time represented in trtime to seconds.

Parameters:
[in] lt Pointer to trtime structure.
Returns:
Equivalent time in seconds

LT_INLINE void secs_to_trtime ( uint32_t  seconds,
trtime_t lt 
)

Convert time represented in seconds to trtime.

Parameters:
seconds Time in seconds to be converted.
[out] lt Pointer to trtime structure.

LT_INLINE void time_sub ( const trtime_t x,
const trtime_t y,
trtime_t res 
)

Time subtraction.

Note: Time1 >= Time2, check using time_compare if needed.

Parameters:
x Time1
y Time2
[out] res Time1 - Time 2

LT_INLINE void time_add ( const trtime_t x,
const trtime_t y,
trtime_t res 
)

Time addition.

Parameters:
x Time1
y Time2
[out] res Time1 + Time 2

LT_INLINE int time_compare ( const trtime_t t1,
const trtime_t t2 
)

Time comparison.

Parameters:
t1 Time1
t2 Time2
Returns:
(-1,0,1) depending on whether t1 < t2, t1==t2, t1 > t2

LT_INLINE int time_lessthan ( const trtime_t t1,
const trtime_t t2 
)

Time less than.

Parameters:
t1 Time1
t2 Time2
Returns:
(1,0) depending on whether t1 < t2. This can easily be implemented using time_compare but is provided as an optimization.


TiROS User Manual: Last Updated on Fri Jul 20 10:52:24 2007