FreeRTOS: POSIX
Return to main page ↑
utils.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS POSIX V1.2.0
3  * Copyright (C) 2020 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 
106 int UTILS_TimespecAdd( const struct timespec * const x,
107  const struct timespec * const y,
108  struct timespec * const pxResult );
109 
119 int UTILS_TimespecAddNanoseconds( const struct timespec * const x,
120  int64_t llNanoseconds,
121  struct timespec * const pxResult );
122 
133 int UTILS_TimespecSubtract( const struct timespec * const x,
134  const struct timespec * const y,
135  struct timespec * const pxResult );
136 
145 int UTILS_TimespecCompare( const struct timespec * const x,
146  const struct timespec * const y );
147 
157 bool UTILS_ValidateTimespec( const struct timespec * const pxTimespec );
158 
159 #endif /* ifndef _FREERTOS_POSIX_UTILS_ */
int UTILS_TimespecCompare(const struct timespec *const x, const struct timespec *const y)
Compare x == y.
Definition: FreeRTOS_POSIX_utils.c:330
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
Time types.
void UTILS_NanosecondsToTimespec(int64_t llSource, struct timespec *const pxDestination)
Converts an integer value to a timespec.
Definition: FreeRTOS_POSIX_utils.c:163
bool UTILS_ValidateTimespec(const struct timespec *const pxTimespec)
Checks that a timespec conforms to POSIX.
Definition: FreeRTOS_POSIX_utils.c:378
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:275
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
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:234
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
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
represents an elapsed time
Definition: time.h:99