FreeRTOS: POSIX
Return to main page ↑
time.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 
33 #ifndef _FREERTOS_POSIX_TIME_H_
34 #define _FREERTOS_POSIX_TIME_H_
35 
36 /* FreeRTOS+POSIX includes. */
38 #include "FreeRTOS_POSIX/signal.h"
39 
44 #define MICROSECONDS_PER_SECOND ( 1000000LL )
45 #define NANOSECONDS_PER_SECOND ( 1000000000LL )
46 #define NANOSECONDS_PER_TICK ( NANOSECONDS_PER_SECOND / configTICK_RATE_HZ )
53 #define CLOCK_REALTIME 0
54 #define CLOCK_MONOTONIC 1
61 #define CLOCKS_PER_SEC ( ( clock_t ) configTICK_RATE_HZ )
62 
70 #define TIMER_ABSTIME 0x01
71 
73 #if !defined( posixconfigENABLE_TM ) || ( posixconfigENABLE_TM == 1 )
74 
79  struct tm
80  {
81  int tm_sec;
82  int tm_min;
83  int tm_hour;
84  int tm_mday;
85  int tm_mon;
86  int tm_year;
87  int tm_wday;
88  int tm_yday;
89  int tm_isdst;
90  };
91 #endif /* if !defined( posixconfigENABLE_TM ) || ( posixconfigENABLE_TM == 1 ) */
92 
93 #if !defined( posixconfigENABLE_TIMESPEC ) || ( posixconfigENABLE_TIMESPEC == 1 )
94 
99  struct timespec
100  {
102  long tv_nsec;
103  };
104 #endif
105 
106 #if !defined( posixconfigENABLE_ITIMERSPEC ) || ( posixconfigENABLE_ITIMERSPEC == 1 )
107 
112  struct itimerspec
113  {
114  struct timespec it_interval;
115  struct timespec it_value;
116  };
117 #endif
118 
129 clock_t clock( void );
130 
141 int clock_getcpuclockid( pid_t pid,
142  clockid_t * clock_id );
143 
154 int clock_getres( clockid_t clock_id,
155  struct timespec * res );
156 
167 int clock_gettime( clockid_t clock_id,
168  struct timespec * tp );
169 
182 int clock_nanosleep( clockid_t clock_id,
183  int flags,
184  const struct timespec * rqtp,
185  struct timespec * rmtp );
186 
196 int clock_settime( clockid_t clock_id,
197  const struct timespec * tp );
198 
210 int nanosleep( const struct timespec * rqtp,
211  struct timespec * rmtp );
212 
230 int timer_create( clockid_t clockid,
231  struct sigevent * evp,
232  timer_t * timerid );
233 
241 int timer_delete( timer_t timerid );
242 
250 int timer_getoverrun( timer_t timerid );
251 
259 int timer_gettime( timer_t timerid,
260  struct itimerspec * value );
261 
275 int timer_settime( timer_t timerid,
276  int flags,
277  const struct itimerspec * value,
278  struct itimerspec * ovalue );
279 
280 #endif /* ifndef _FREERTOS_POSIX_TIME_H_ */
int tm_min
Definition: time.h:82
int pid_t
Used for process IDs and process group IDs.
Definition: types.h:79
Data types.
int timer_delete(timer_t timerid)
Delete a per-process timer.
Definition: FreeRTOS_POSIX_timer.c:153
int clock_gettime(clockid_t clock_id, struct timespec *tp)
Returns the current value for the specified clock, clock_id.
Definition: FreeRTOS_POSIX_clock.c:90
int tm_mday
Definition: time.h:84
int64_t time_t
Used for time in seconds.
Definition: types.h:175
int tm_year
Definition: time.h:86
int timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue)
Set the time until the next expiration of the timer.
Definition: FreeRTOS_POSIX_timer.c:190
void * timer_t
Used for timer ID returned by timer_create().
Definition: types.h:185
int timer_gettime(timer_t timerid, struct itimerspec *value)
Get the amount of time until the timer expires.
Definition: FreeRTOS_POSIX_timer.c:295
time_t tv_sec
Definition: time.h:101
int clock_getres(clockid_t clock_id, struct timespec *res)
Returns the resolution of a clock.
Definition: FreeRTOS_POSIX_clock.c:72
int clock_getcpuclockid(pid_t pid, clockid_t *clock_id)
Access a process CPU-time clock.
Definition: FreeRTOS_POSIX_clock.c:59
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
High resolution sleep.
Definition: FreeRTOS_POSIX_clock.c:212
int tm_mon
Definition: time.h:85
Signal event structure.
Definition: signal.h:62
int clock_settime(clockid_t clock_id, const struct timespec *tp)
Sets the time for the specified clock.
Definition: FreeRTOS_POSIX_clock.c:196
long tv_nsec
Definition: time.h:102
Signals.
uint32_t clock_t
Used for system times in clock ticks or CLOCKS_PER_SEC.
Definition: types.h:49
int timer_getoverrun(timer_t timerid)
Get the timer overrun count.
Definition: FreeRTOS_POSIX_timer.c:180
timer
Definition: time.h:112
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
High resolution sleep with specifiable clock.
Definition: FreeRTOS_POSIX_clock.c:122
clock_t clock(void)
Report CPU time used.
Definition: FreeRTOS_POSIX_clock.c:50
int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
Create a per-process timer.
Definition: FreeRTOS_POSIX_timer.c:101
represents calendar time
Definition: time.h:79
int tm_wday
Definition: time.h:87
int tm_yday
Definition: time.h:88
int clockid_t
Used for clock ID type in the clock and timer functions.
Definition: types.h:59
represents an elapsed time
Definition: time.h:99
int tm_sec
Definition: time.h:81
int tm_hour
Definition: time.h:83
int tm_isdst
Definition: time.h:89