Embedded Multicore Building Blocks V1.0.0
Duration and Time

Relative time durations and absolute time points. More...

Duration

typedef opaque_type embb_duration_t
 Opaque type representing a relative time duration. More...
 
const embb_duration_tembb_duration_max ()
 Returns duration with maximum ticks representable by implementation. More...
 
const embb_duration_tembb_duration_min ()
 Returns duration with minimum ticks representable by implementation. More...
 
const embb_duration_tembb_duration_zero ()
 Returns duration of length zero. More...
 
int embb_duration_set_nanoseconds (embb_duration_t *duration, unsigned long long nanoseconds)
 Set duration from nanosecond ticks. More...
 
int embb_duration_set_microseconds (embb_duration_t *duration, unsigned long long microseconds)
 Sets duration from microsecond ticks. More...
 
int embb_duration_set_milliseconds (embb_duration_t *duration, unsigned long long milliseconds)
 Sets duration from millisecond ticks. More...
 
int embb_duration_set_seconds (embb_duration_t *duration, unsigned long long seconds)
 Sets duration from second ticks. More...
 
int embb_duration_add (embb_duration_t *lhs, const embb_duration_t *rhs)
 Adds two durations. More...
 
int embb_duration_as_nanoseconds (const embb_duration_t *duration, unsigned long long *nanoseconds)
 Converts duration to nanosecond ticks. More...
 
int embb_duration_as_microseconds (const embb_duration_t *duration, unsigned long long *microseconds)
 Converts duration to microsecond ticks. More...
 
int embb_duration_as_milliseconds (const embb_duration_t *duration, unsigned long long *milliseconds)
 Converts duration to millisecond ticks. More...
 
int embb_duration_as_seconds (const embb_duration_t *duration, unsigned long long *seconds)
 Converts duration to second ticks. More...
 
int embb_duration_compare (const embb_duration_t *lhs, const embb_duration_t *rhs)
 Compares two durations. More...
 
#define EMBB_DURATION_INIT
 Macro for initializing a duration with zero length at definition. More...
 

Time

typedef opaque_type embb_time_t
 Opaque type representing an absolute time point. More...
 
void embb_time_now (embb_time_t *time)
 Sets time point to now. More...
 
int embb_time_in (embb_time_t *time, const embb_duration_t *duration)
 Sets time point to now plus the given duration. More...
 
int embb_time_compare (const embb_time_t *lhs, const embb_time_t *rhs)
 Compares two time points. More...
 

Detailed Description

Relative time durations and absolute time points.

Macro Definition Documentation

#define EMBB_DURATION_INIT

Macro for initializing a duration with zero length at definition.

Typedef Documentation

typedef opaque_type embb_duration_t

Opaque type representing a relative time duration.

typedef opaque_type embb_time_t

Opaque type representing an absolute time point.

Function Documentation

const embb_duration_t* embb_duration_max ( )

Returns duration with maximum ticks representable by implementation.

Returns
Pointer to duration with maximum value
Concurrency
Not thread-safe
See also
embb_duration_min()
const embb_duration_t* embb_duration_min ( )

Returns duration with minimum ticks representable by implementation.

Returns
Pointer to duration with minimum value
Concurrency
Not thread-safe
See also
embb_duration_max()
const embb_duration_t* embb_duration_zero ( )

Returns duration of length zero.

Returns
Pointer to duration of length zero
Concurrency
Not thread-safe
int embb_duration_set_nanoseconds ( embb_duration_t duration,
unsigned long long  nanoseconds 
)

Set duration from nanosecond ticks.

Returns
EMBB_SUCCESS
EMBB_UNDERFLOW if given nanosecond interval is too small to be represented by implementation
EMBB_OVERFLOW if given nanosecond interval is too large to be represented by implementation
Concurrency
Not thread-safe
Parameters
[out]durationPointer to duration
[in]nanosecondsNanosecond ticks
int embb_duration_set_microseconds ( embb_duration_t duration,
unsigned long long  microseconds 
)

Sets duration from microsecond ticks.

Returns
EMBB_SUCCESS
EMBB_UNDERFLOW if given microsecond interval is too small to be represented by implementation
EMBB_OVERFLOW if given microsecond interval is too large to be represented by implementation
Concurrency
Not thread-safe
Parameters
[out]durationPointer to duration
[in]microsecondsMicrosecond ticks
int embb_duration_set_milliseconds ( embb_duration_t duration,
unsigned long long  milliseconds 
)

Sets duration from millisecond ticks.

Returns
EMBB_SUCCESS
EMBB_UNDERFLOW if given millisecond interval is too small to be represented by implementation
EMBB_OVERFLOW if given millisecond interval is too large to be represented by implementation
Concurrency
Not thread-safe
Parameters
[out]durationPointer to duration
[in]millisecondsMillisecond ticks
int embb_duration_set_seconds ( embb_duration_t duration,
unsigned long long  seconds 
)

Sets duration from second ticks.

Returns
EMBB_SUCCESS
EMBB_UNDERFLOW if given second interval is too small to be represented by implementation
EMBB_OVERFLOW if given second interval is too large to be represented by implementation
Concurrency
Not thread-safe
Parameters
[out]durationPointer to duration
[in]secondsSecond ticks
int embb_duration_add ( embb_duration_t lhs,
const embb_duration_t rhs 
)

Adds two durations.

Computest the sum of rhs and lhs and stores the result in lhs.

Returns
EMBB_SUCCESS
EMBB_OVERFLOW if sum is greater than embb_duration_max()
Concurrency
Not thread-safe
Parameters
[in,out]lhsLeft-hand side operand, overwritten by result of addition
[in]rhsRight-hand side operand of addition
int embb_duration_as_nanoseconds ( const embb_duration_t duration,
unsigned long long *  nanoseconds 
)

Converts duration to nanosecond ticks.

Returns
EMBB_SUCCESS
EMBB_UNDERFLOW if duration contains fractions less than a nanosecond
EMBB_OVERFLOW if duration is not representable by tick type
Concurrency
Not thread-safe
Parameters
[in]durationPointer to duration
[out]nanosecondsPointer to nanosecond ticks of duration
int embb_duration_as_microseconds ( const embb_duration_t duration,
unsigned long long *  microseconds 
)

Converts duration to microsecond ticks.

Returns
EMBB_SUCCESS
EMBB_UNDERFLOW if duration contains fractions less than a microsecond
EMBB_OVERFLOW if duration is not representable by tick type
Concurrency
Not thread-safe
Parameters
[in]durationPointer to duration
[out]microsecondsPointer to microsecond ticks of duration
int embb_duration_as_milliseconds ( const embb_duration_t duration,
unsigned long long *  milliseconds 
)

Converts duration to millisecond ticks.

Returns
EMBB_SUCCESS
EMBB_UNDERFLOW if duration contains fractions less than a millisecond
EMBB_OVERFLOW if duration is not representable by tick type
Concurrency
Not thread-safe
Parameters
[in]durationPointer to duration
[out]millisecondsPointer to millisecond ticks of duration
int embb_duration_as_seconds ( const embb_duration_t duration,
unsigned long long *  seconds 
)

Converts duration to second ticks.

Returns
EMBB_SUCCESS
EMBB_UNDERFLOW if duration contains fractions less than a second
EMBB_OVERFLOW if duration is not representable by tick type
Concurrency
Not thread-safe
Parameters
[in]durationPointer to duration
[out]secondsPointer to second ticks of duration
int embb_duration_compare ( const embb_duration_t lhs,
const embb_duration_t rhs 
)

Compares two durations.

Precondition
lhs and rhs are not NULL and properly initialized.
Returns
-1 if lhs < rhs
0 if lhs == rhs
1 if lhs > rhs
Concurrency
Not thread-safe
Parameters
[in]lhsPointer to left-hand side operand
[in]rhsPointer to right-hand side operand
void embb_time_now ( embb_time_t time)

Sets time point to now.

Concurrency
Not thread-safe
See also
embb_time_in()
Parameters
[out]timePointer to time point
int embb_time_in ( embb_time_t time,
const embb_duration_t duration 
)

Sets time point to now plus the given duration.

Returns
EMBB_SUCCESS
EMBB_UNDERFLOW if duration is smaller than implementation allows
EMBB_OVERFLOW if time + duration is larger than implementation allows
Concurrency
Not thread-safe
See also
embb_time_now()
Parameters
[out]timePointer to time point
[in]durationPointer to duration
int embb_time_compare ( const embb_time_t lhs,
const embb_time_t rhs 
)

Compares two time points.

Precondition
lhs and rhs are not NULL and properly initialized.
Returns
-1 if lhs < rhs
0 if lhs == rhs
1 if lhs > rhs
Concurrency
Not thread-safe
Parameters
[in]lhsPointer to left-hand side operand
[in]rhsPointer to right-hand side operand