Amazon FreeRTOS: POSIX
Return to main page ↑
utils.h
Go to the documentation of this file.
1 /*
2  * Amazon FreeRTOS POSIX V1.1.0
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://aws.amazon.com/freertos
23  * http://www.FreeRTOS.org
24  */
25 
31 #ifndef _FREERTOS_POSIX_UTILS_
32 #define _FREERTOS_POSIX_UTILS_
33 
34 /* C standard library includes. */
35 #include <stdbool.h>
36 #include <stdint.h>
37 
38 /* FreeRTOS+POSIX includes. */
39 #include "FreeRTOS_POSIX/time.h"
40 
50 size_t UTILS_strnlen( const char * const pcString,
51  size_t xMaxLength );
52 
66 int UTILS_AbsoluteTimespecToDeltaTicks( const struct timespec * const pxAbsoluteTime,
67  const struct timespec * const pxCurrentTime,
68  TickType_t * const pxResult );
69 
79 int UTILS_TimespecToTicks( const struct timespec * const pxTimespec,
80  TickType_t * const pxResult );
81 
90 void UTILS_NanosecondsToTimespec( int64_t llSource,
91  struct timespec * const pxDestination );
92 
102 int UTILS_TimespecAdd( const struct timespec * const x,
103  const struct timespec * const y,
104  struct timespec * const pxResult );
105 
115 int UTILS_TimespecAddNanoseconds( const struct timespec * const x,
116  int64_t llNanoseconds,
117  struct timespec * const pxResult );
118 
129 int UTILS_TimespecSubtract( const struct timespec * const x,
130  const struct timespec * const y,
131  struct timespec * const pxResult );
132 
141 int UTILS_TimespecCompare( const struct timespec * const x,
142  const struct timespec * const y );
143 
153 bool UTILS_ValidateTimespec( const struct timespec * const pxTimespec );
154 
155 #endif /* ifndef _FREERTOS_POSIX_UTILS_ */
UTILS_ValidateTimespec
bool UTILS_ValidateTimespec(const struct timespec *const pxTimespec)
Checks that a timespec conforms to POSIX.
Definition: FreeRTOS_POSIX_utils.c:371
UTILS_TimespecCompare
int UTILS_TimespecCompare(const struct timespec *const x, const struct timespec *const y)
Compare x == y.
Definition: FreeRTOS_POSIX_utils.c:323
UTILS_TimespecSubtract
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.
Definition: FreeRTOS_POSIX_utils.c:268
UTILS_TimespecAddNanoseconds
int UTILS_TimespecAddNanoseconds(const struct timespec *const x, int64_t llNanoseconds, struct timespec *const pxResult)
Calculates pxResult = x + ( struct timespec ) nanosec.
Definition: FreeRTOS_POSIX_utils.c:227
time.h
Time types.
UTILS_TimespecAdd
int UTILS_TimespecAdd(const struct timespec *const x, const struct timespec *const y, struct timespec *const pxResult)
Calculates pxResult = x + y.
Definition: FreeRTOS_POSIX_utils.c:185
UTILS_strnlen
size_t UTILS_strnlen(const char *const pcString, size_t xMaxLength)
Calculates the length of pcString, up to xMaxLength.
Definition: FreeRTOS_POSIX_utils.c:42
UTILS_NanosecondsToTimespec
void UTILS_NanosecondsToTimespec(int64_t llSource, struct timespec *const pxDestination)
Converts an integer value to a timespec.
Definition: FreeRTOS_POSIX_utils.c:163
UTILS_TimespecToTicks
int UTILS_TimespecToTicks(const struct timespec *const pxTimespec, TickType_t *const pxResult)
Converts a struct timespec to FreeRTOS ticks.
Definition: FreeRTOS_POSIX_utils.c:103
UTILS_AbsoluteTimespecToDeltaTicks
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.
Definition: FreeRTOS_POSIX_utils.c:62
timespec
represents an elapsed time
Definition: time.h:79