FreeRTOS:
POSIX
|
Return to main page ↑ |
Utility functions used by FreeRTOS+POSIX. More...
Go to the source code of this file.
Functions | |
size_t | UTILS_strnlen (const char *const pcString, size_t xMaxLength) |
Calculates the length of pcString, up to xMaxLength. More... | |
int | UTILS_AbsoluteTimespecToDeltaTicks (const struct timespec *const pxAbsoluteTime, const struct timespec *const pxCurrentTime, TickType_t *const pxResult) |
Calculates the number of ticks between now and a given timespec. More... | |
int | UTILS_TimespecToTicks (const struct timespec *const pxTimespec, TickType_t *const pxResult) |
Converts a struct timespec to FreeRTOS ticks. More... | |
void | UTILS_NanosecondsToTimespec (int64_t llSource, struct timespec *const pxDestination) |
Converts an integer value to a timespec. More... | |
int | UTILS_TimespecAdd (const struct timespec *const x, const struct timespec *const y, struct timespec *const pxResult) |
Calculates pxResult = x + y. More... | |
int | UTILS_TimespecAddNanoseconds (const struct timespec *const x, int64_t llNanoseconds, struct timespec *const pxResult) |
Calculates pxResult = x + ( struct timespec ) nanosec. More... | |
int | UTILS_TimespecSubtract (const struct timespec *const x, const struct timespec *const y, struct timespec *const pxResult) |
Calculates pxResult = x - y. If the result is negative contents of pResult are undefined. More... | |
int | UTILS_TimespecCompare (const struct timespec *const x, const struct timespec *const y) |
Compare x == y. More... | |
bool | UTILS_ValidateTimespec (const struct timespec *const pxTimespec) |
Checks that a timespec conforms to POSIX. More... | |
Utility functions used by FreeRTOS+POSIX.
size_t UTILS_strnlen | ( | const char *const | pcString, |
size_t | xMaxLength | ||
) |
Calculates the length of pcString, up to xMaxLength.
[in] | pcString | The string to find the length of. |
[in] | xMaxLength | The limit when searching for the end of pcString. |
int UTILS_AbsoluteTimespecToDeltaTicks | ( | const struct timespec *const | pxAbsoluteTime, |
const struct timespec *const | pxCurrentTime, | ||
TickType_t *const | pxResult | ||
) |
Calculates the number of ticks between now and a given timespec.
[in] | pxAbsoluteTime | A time in the future, specified as seconds and nanoseconds since CLOCK_REALTIME's 0. |
[in] | pxCurrentTime | current time, specified as seconds and nanoseconds. |
[out] | pxResult | Where the result of the conversion is stored. The result is rounded up for fractional ticks. |
int UTILS_TimespecToTicks | ( | const struct timespec *const | pxTimespec, |
TickType_t *const | pxResult | ||
) |
Converts a struct timespec to FreeRTOS ticks.
[in] | pxTimespec | The timespec to convert. |
[out] | Where | the result of the conversion is stored. The result is rounded up for fractional ticks. |
void UTILS_NanosecondsToTimespec | ( | int64_t | llSource, |
struct timespec *const | pxDestination | ||
) |
Converts an integer value to a timespec.
[in] | llSource | The value to convert. |
[out] | pxDestination | Where to store the converted value. |
int UTILS_TimespecAdd | ( | const struct timespec *const | x, |
const struct timespec *const | y, | ||
struct timespec *const | pxResult | ||
) |
Calculates pxResult = x + y.
This function supports both signed and unsigned type definitions of the timespec.tv_sec member.
[in] | x | The first argument for addition. |
[in] | y | The second argument for addition. |
[out] | pxResult | Where the result of the calculation is stored. |
int UTILS_TimespecAddNanoseconds | ( | const struct timespec *const | x, |
int64_t | llNanoseconds, | ||
struct timespec *const | pxResult | ||
) |
Calculates pxResult = x + ( struct timespec ) nanosec.
[in] | x | The first argument for addition. |
[in] | llNanoseconds | The second argument for addition. |
[out] | pxResult | Where the result of the calculation is stored. |
int UTILS_TimespecSubtract | ( | const struct timespec *const | x, |
const struct timespec *const | y, | ||
struct timespec *const | pxResult | ||
) |
Calculates pxResult = x - y. If the result is negative contents of pResult are undefined.
[in] | x | The first argument for subtraction. |
[in] | y | The second argument for subtraction. |
[out] | pxResult | Where the result of the calculation is stored. |
Compare x == y.
[in] | x | The first argument for comparison. |
[in] | y | The second argument for comparison. |
bool UTILS_ValidateTimespec | ( | const struct timespec *const | pxTimespec | ) |
Checks that a timespec conforms to POSIX.
A valid timespec must have 0 <= tv_nsec < 1000000000.
[in] | pxTimespec | The timespec to validate. |