]> git.sur5r.net Git - freertos/blob - FreeRTOS-Labs/Demo/FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator/lib/include/FreeRTOS_POSIX/time.h
Add the Labs projects provided in the V10.2.1_191129 zip file.
[freertos] / FreeRTOS-Labs / Demo / FreeRTOS_Plus_POSIX_with_actor_Windows_Simulator / lib / include / FreeRTOS_POSIX / time.h
1 /*\r
2  * Amazon FreeRTOS POSIX V1.1.0\r
3  * Copyright (C) 2019 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://aws.amazon.com/freertos\r
23  * http://www.FreeRTOS.org\r
24  */\r
25 \r
26 /**\r
27  * @file time.h\r
28  * @brief Time types.\r
29  *\r
30  * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html\r
31  */\r
32 \r
33 #ifndef _FREERTOS_POSIX_TIME_H_\r
34 #define _FREERTOS_POSIX_TIME_H_\r
35 \r
36 /* FreeRTOS+POSIX includes. */\r
37 #include "FreeRTOS_POSIX/sys/types.h"\r
38 #include "FreeRTOS_POSIX/signal.h"\r
39 \r
40 /**\r
41  * @name Unit conversion constants.\r
42  */\r
43 /**@{ */\r
44 #define MICROSECONDS_PER_SECOND    ( 1000000LL )                                   /**< Microseconds per second. */\r
45 #define NANOSECONDS_PER_SECOND     ( 1000000000LL )                                /**< Nanoseconds per second. */\r
46 #define NANOSECONDS_PER_TICK       ( NANOSECONDS_PER_SECOND / configTICK_RATE_HZ ) /**< Nanoseconds per FreeRTOS tick. */\r
47 /**@} */\r
48 \r
49 /**\r
50  * @name Clock identifiers.\r
51  */\r
52 /**@{ */\r
53 #define CLOCK_REALTIME     0     /**< The identifier of the system-wide clock measuring real time. */\r
54 #define CLOCK_MONOTONIC    1     /**< The identifier for the system-wide monotonic clock.*/\r
55 /**@} */\r
56 \r
57 /**\r
58  * @name A number used to convert the value returned by the clock() function into seconds.\r
59  */\r
60 /**@{ */\r
61 #define CLOCKS_PER_SEC    ( ( clock_t ) configTICK_RATE_HZ )\r
62 /**@} */\r
63 \r
64 /**\r
65  * @name Flag indicating time is absolute.\r
66  *\r
67  * For functions taking timer objects, this refers to the clock associated with the timer.\r
68  */\r
69 /**@{ */\r
70 #define TIMER_ABSTIME    0x01\r
71 /**@} */\r
72 \r
73 #if !defined( posixconfigENABLE_TIMESPEC ) || ( posixconfigENABLE_TIMESPEC == 1 )\r
74 \r
75 /**\r
76  * @brief represents an elapsed time\r
77  */\r
78     struct timespec\r
79     {\r
80         time_t tv_sec; /**< Seconds. */\r
81         long tv_nsec;  /**< Nanoseconds. */\r
82     };\r
83 #endif\r
84 \r
85 #if !defined( posixconfigENABLE_ITIMERSPEC ) || ( posixconfigENABLE_ITIMERSPEC == 1 )\r
86 \r
87 /**\r
88  * @brief timer\r
89  */\r
90     struct itimerspec\r
91     {\r
92         struct timespec it_interval; /**< Timer period. */\r
93         struct timespec it_value;    /**< Timer expiration. */\r
94     };\r
95 #endif\r
96 \r
97 /**\r
98  * @brief Report CPU time used.\r
99  *\r
100  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock.html\r
101  *\r
102  * @return  The number of FreeRTOS ticks since the scheduler\r
103  * was started minus the ticks spent in the idle task.\r
104  *\r
105  * @note This function does NOT report the number of ticks spent by the calling thread.\r
106  */\r
107 clock_t clock( void );\r
108 \r
109 /**\r
110  * @brief Access a process CPU-time clock.\r
111  *\r
112  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getcpuclockid.html\r
113  *\r
114  * @retval EPERM\r
115  *\r
116  * @note This function is currently unsupported.\r
117  *\r
118  */\r
119 int clock_getcpuclockid( pid_t pid,\r
120                          clockid_t * clock_id );\r
121 \r
122 /**\r
123  * @brief Returns the resolution of a clock.\r
124  *\r
125  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html\r
126  *\r
127  * @note clock_id is ignored\r
128  * @note This function stores the resolution of the FreeRTOS tick count in the object res points to.\r
129  *\r
130  * @retval 0 - Upon successful execution\r
131  */\r
132 int clock_getres( clockid_t clock_id,\r
133                   struct timespec * res );\r
134 \r
135 /**\r
136  * @brief Returns the current value for the specified clock, clock_id.\r
137  *\r
138  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html\r
139  *\r
140  * @note clock_id is ignored\r
141  * @note  this function does not check for overflows of time_t.\r
142  *\r
143  * @retval 0 - Upon successful completion.\r
144  */\r
145 int clock_gettime( clockid_t clock_id,\r
146                    struct timespec * tp );\r
147 \r
148 /**\r
149  * @brief High resolution sleep with specifiable clock.\r
150  *\r
151  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_nanosleep.html\r
152  *\r
153  * @note clock_id is ignored, as this function uses the FreeRTOS tick count as its clock.\r
154  * @note flags is ignored, if INCLUDE_vTaskDelayUntil is 0. i.e. the FreeRTOS function vTaskDelayUntil isn't available.\r
155  * @note rmtp is also ignored, as signals are not implemented.\r
156  *\r
157  * @retval 0 - Upon successful completion.\r
158  * @retval EINVAL - The rqtp argument specified a nanosecond value less than zero or greater than or equal to 1000 million.\r
159  */\r
160 int clock_nanosleep( clockid_t clock_id,\r
161                      int flags,\r
162                      const struct timespec * rqtp,\r
163                      struct timespec * rmtp );\r
164 \r
165 /**\r
166  * @brief Sets the time for the specified clock.\r
167  *\r
168  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_settime.html\r
169  *\r
170  * @retval -1 with errno set to EPERM.\r
171  *\r
172  * @note This function is currently unsupported, as FreeRTOS does not provide a function to modify the tick count.\r
173  */\r
174 int clock_settime( clockid_t clock_id,\r
175                    const struct timespec * tp );\r
176 \r
177 /**\r
178  * @brief High resolution sleep.\r
179  *\r
180  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html\r
181  *\r
182  * @note rmtp is ignored, as signals are not implemented.\r
183  *\r
184  * @retval 0 - Upon successful completion.\r
185  * @retval -1 - The rqtp argument is invalid OR the rqtp argument specified a nanosecond value less than zero or greater than or equal to 1000 million.\r
186  *\r
187  */\r
188 int nanosleep( const struct timespec * rqtp,\r
189                struct timespec * rmtp );\r
190 \r
191 /**\r
192  * @brief Create a per-process timer.\r
193  *\r
194  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_create.html\r
195  *\r
196  * @note clock_id is ignored, as this function used the FreeRTOS tick count as its clock.\r
197  * @note evp.sigev_notify must be set to SIGEV_THREAD, since signals are currently not supported.\r
198  *\r
199  * @retval 0 - Upon successful completion, with location referenced by timerid updated.\r
200  * @retval -1 - If an error occurs. errno is also set.\r
201  *\r
202  * @sideeffect Possible errno values\r
203  * <br>\r
204  * ENOTSUP - If evp is NULL OR evp->sigen_notify == SIGEV_SIGNAL.\r
205  * <br>\r
206  * EAGAIN - The system lacks sufficient signal queuing resources to honor the request.\r
207  */\r
208 int timer_create( clockid_t clockid,\r
209                   struct sigevent * evp,\r
210                   timer_t * timerid );\r
211 \r
212 /**\r
213  * @brief Delete a per-process timer.\r
214  *\r
215  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_delete.html\r
216  *\r
217  * @retval 0 - Upon successful completion.\r
218  */\r
219 int timer_delete( timer_t timerid );\r
220 \r
221 /**\r
222  * @brief Get the timer overrun count.\r
223  *\r
224  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_getoverrun.html\r
225  *\r
226  * @retval 0 - Always return 0, since signals are not supported.\r
227  */\r
228 int timer_getoverrun( timer_t timerid );\r
229 \r
230 /**\r
231  * @brief Get the amount of time until the timer expires.\r
232  *\r
233  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_gettime.html\r
234  *\r
235  * @retval 0 - Upon successful completion.\r
236  */\r
237 int timer_gettime( timer_t timerid,\r
238                    struct itimerspec * value );\r
239 \r
240 /**\r
241  * @brief Set the time until the next expiration of the timer.\r
242  *\r
243  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_settime.html\r
244  *\r
245  * @retval 0 - Upon successful completion.\r
246  * @retval -1 - An error occurred, errno is also set.\r
247  *\r
248  * @sideeffect Possible errno values\r
249  * <br>\r
250  * EINVAL - A value structure specified a nanosecond value less than zero or greater than or equal to 1000 million,\r
251  * AND the it_value member of that structure did not specify zero seconds and nanoseconds.\r
252  */\r
253 int timer_settime( timer_t timerid,\r
254                    int flags,\r
255                    const struct itimerspec * value,\r
256                    struct itimerspec * ovalue );\r
257 \r
258 #endif /* ifndef _FREERTOS_POSIX_TIME_H_ */\r