RTEMS
|
Timespec Helpers. More...
Files | |
file | timespec.h |
Contains Helpers for Manipulating Timespecs. | |
Macros | |
#define | _Timespec_Set(_time, _seconds, _nanoseconds) |
Set timespec to seconds nanosecond. More... | |
#define | _Timespec_Set_to_zero(_time) |
Sets the Timespec to Zero. More... | |
#define | _Timespec_Get_seconds(_time) ((_time)->tv_sec) |
Get seconds portion of timespec. More... | |
#define | _Timespec_Get_nanoseconds(_time) ((_time)->tv_nsec) |
Get nanoseconds portion of timespec. More... | |
#define | _Timespec_Greater_than(_lhs, _rhs) _Timespec_Less_than( _rhs, _lhs ) |
The Timespec "greater than" operator. More... | |
#define | _Timespec_Equal_to(lhs, rhs) |
The Timespec "equal to" operator. More... | |
Functions | |
uint64_t | _Timespec_Get_as_nanoseconds (const struct timespec *time) |
Gets the timestamp as nanoseconds. More... | |
bool | _Timespec_Is_valid (const struct timespec *time) |
Checks if timespec is valid. More... | |
bool | _Timespec_Less_than (const struct timespec *lhs, const struct timespec *rhs) |
Checks if the left hand side timespec is less than the right one. More... | |
uint32_t | _Timespec_Add_to (struct timespec *time, const struct timespec *add) |
Adds two timespecs. More... | |
uint32_t | _Timespec_To_ticks (const struct timespec *time) |
Converts timespec to number of ticks. More... | |
void | _Timespec_From_ticks (uint32_t ticks, struct timespec *time) |
Converts ticks to timespec. More... | |
void | _Timespec_Subtract (const struct timespec *start, const struct timespec *end, struct timespec *result) |
Subtracts two timespec. More... | |
void | _Timespec_Divide_by_integer (const struct timespec *time, uint32_t iterations, struct timespec *result) |
Divides timespec by an integer. More... | |
void | _Timespec_Divide (const struct timespec *lhs, const struct timespec *rhs, uint32_t *ival_percentage, uint32_t *fval_percentage) |
Divides a timespec by another timespec. More... | |
Timespec Helpers.
This handler encapsulates functionality related to manipulating POSIX struct timespecs.
#define _Timespec_Equal_to | ( | lhs, | |
rhs | |||
) |
The Timespec "equal to" operator.
This method is the is equal to than operator for timespecs.
[in] | lhs | is the left hand side timespec |
[in] | rhs | is the right hand side timespec |
This | method returns true if lhs is equal to rhs and false otherwise. |
Definition at line 164 of file timespec.h.
#define _Timespec_Get_nanoseconds | ( | _time | ) | ((_time)->tv_nsec) |
Get nanoseconds portion of timespec.
This method returns the nanoseconds portion of the specified timespec
[in] | _time | points to the timespec |
The | nanoseconds portion of _time. |
Definition at line 93 of file timespec.h.
#define _Timespec_Get_seconds | ( | _time | ) | ((_time)->tv_sec) |
Get seconds portion of timespec.
This method returns the seconds portion of the specified timespec
[in] | _time | points to the timespec |
The | seconds portion of _time. |
Definition at line 81 of file timespec.h.
#define _Timespec_Greater_than | ( | _lhs, | |
_rhs | |||
) | _Timespec_Less_than( _rhs, _lhs ) |
The Timespec "greater than" operator.
This method is the greater than operator for timespecs.
[in] | _lhs | is the left hand side timespec |
[in] | _rhs | is the right hand side timespec |
This | method returns true if lhs is greater than the rhs and false otherwise. |
Definition at line 150 of file timespec.h.
#define _Timespec_Set | ( | _time, | |
_seconds, | |||
_nanoseconds | |||
) |
Set timespec to seconds nanosecond.
This method sets the timespec to the specified seconds and nanoseconds value.
[in] | _time | points to the timespec instance to validate. |
[in] | _seconds | is the seconds portion of the timespec |
[in] | _nanoseconds | is the nanoseconds portion of the timespec |
Definition at line 52 of file timespec.h.
#define _Timespec_Set_to_zero | ( | _time | ) |
Sets the Timespec to Zero.
This method sets the timespec to zero. value.
[in] | _time | points to the timespec instance to zero. |
Definition at line 66 of file timespec.h.
uint32_t _Timespec_Add_to | ( | struct timespec * | time, |
const struct timespec * | add | ||
) |
Adds two timespecs.
This routine adds two timespecs. The second argument is added to the first.
time | The base time to be added to. |
add | The timespec to add to the first argument. |
void _Timespec_Divide | ( | const struct timespec * | lhs, |
const struct timespec * | rhs, | ||
uint32_t * | ival_percentage, | ||
uint32_t * | fval_percentage | ||
) |
Divides a timespec by another timespec.
This routine divides a timespec by another timespec. The intended use is for calculating percentages to three decimal points.
lhs | The left hand timespec. | |
rhs | The right hand timespec. | |
[out] | ival_percentage | The integer portion of the average. |
[out] | fval_percentage | The thousandths of percentage. |
void _Timespec_Divide_by_integer | ( | const struct timespec * | time, |
uint32_t | iterations, | ||
struct timespec * | result | ||
) |
Divides timespec by an integer.
This routine divides a timespec by an integer value. The expected use is to assist in benchmark calculations where you typically divide a duration by a number of iterations.
time | The total. | |
iterations | The number of iterations. | |
[out] | result | The average time. |
void _Timespec_From_ticks | ( | uint32_t | ticks, |
struct timespec * | time | ||
) |
Converts ticks to timespec.
This routine converts the ticks value to the corresponding timespec format time.
ticks | The number of ticks to convert. | |
[out] | time | The timespec format time result. |
uint64_t _Timespec_Get_as_nanoseconds | ( | const struct timespec * | time | ) |
Gets the timestamp as nanoseconds.
This method returns the timestamp as nanoseconds.
time | points to the timestamp. |
bool _Timespec_Is_valid | ( | const struct timespec * | time | ) |
Checks if timespec is valid.
This method determines the validity of a timespec.
time | is the timespec instance to validate. |
true | The timespec is valid. |
false | The timespec is invalid. |
bool _Timespec_Less_than | ( | const struct timespec * | lhs, |
const struct timespec * | rhs | ||
) |
Checks if the left hand side timespec is less than the right one.
This method is the less than operator for timespecs.
lhs | is the left hand side timespec. |
rhs | is the right hand side timespec. |
true | lhs is less than rhs. |
false | lhs is greater than rhs. |
void _Timespec_Subtract | ( | const struct timespec * | start, |
const struct timespec * | end, | ||
struct timespec * | result | ||
) |
Subtracts two timespec.
This routine subtracts two timespecs. result is set to end - start.
start | The starting time | |
end | The ending time | |
[out] | result | The difference between starting and ending time. |
uint32_t _Timespec_To_ticks | ( | const struct timespec * | time | ) |
Converts timespec to number of ticks.
This routine convert the time timespec to the corresponding number of clock ticks.
time | The time to be converted. |