Amazon FreeRTOS: POSIX
Return to main page ↑
time.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 
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_TIMESPEC ) || ( posixconfigENABLE_TIMESPEC == 1 )
74 
79  struct timespec
80  {
82  long tv_nsec;
83  };
84 #endif
85 
86 #if !defined( posixconfigENABLE_ITIMERSPEC ) || ( posixconfigENABLE_ITIMERSPEC == 1 )
87 
92  struct itimerspec
93  {
95  struct timespec it_value;
96  };
97 #endif
98 
109 clock_t clock( void );
110 
121 int clock_getcpuclockid( pid_t pid,
122  clockid_t * clock_id );
123 
134 int clock_getres( clockid_t clock_id,
135  struct timespec * res );
136 
147 int clock_gettime( clockid_t clock_id,
148  struct timespec * tp );
149 
162 int clock_nanosleep( clockid_t clock_id,
163  int flags,
164  const struct timespec * rqtp,
165  struct timespec * rmtp );
166 
176 int clock_settime( clockid_t clock_id,
177  const struct timespec * tp );
178 
190 int nanosleep( const struct timespec * rqtp,
191  struct timespec * rmtp );
192 
210 int timer_create( clockid_t clockid,
211  struct sigevent * evp,
212  timer_t * timerid );
213 
221 int timer_delete( timer_t timerid );
222 
230 int timer_getoverrun( timer_t timerid );
231 
239 int timer_gettime( timer_t timerid,
240  struct itimerspec * value );
241 
255 int timer_settime( timer_t timerid,
256  int flags,
257  const struct itimerspec * value,
258  struct itimerspec * ovalue );
259 
260 #endif /* ifndef _FREERTOS_POSIX_TIME_H_ */
itimerspec::it_interval
struct timespec it_interval
Definition: time.h:94
clock_t
uint32_t clock_t
Used for system times in clock ticks or CLOCKS_PER_SEC.
Definition: types.h:49
types.h
Data types.
clock_settime
int clock_settime(clockid_t clock_id, const struct timespec *tp)
Sets the time for the specified clock.
Definition: FreeRTOS_POSIX_clock.c:196
clockid_t
int clockid_t
Used for clock ID type in the clock and timer functions.
Definition: types.h:59
clock_gettime
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
timespec::tv_nsec
long tv_nsec
Definition: time.h:82
clock
clock_t clock(void)
Report CPU time used.
Definition: FreeRTOS_POSIX_clock.c:50
timer_getoverrun
int timer_getoverrun(timer_t timerid)
Get the timer overrun count.
Definition: FreeRTOS_POSIX_timer.c:180
sigevent
Signal event structure.
Definition: signal.h:62
timer_delete
int timer_delete(timer_t timerid)
Delete a per-process timer.
Definition: FreeRTOS_POSIX_timer.c:153
timespec::tv_sec
time_t tv_sec
Definition: time.h:81
timer_gettime
int timer_gettime(timer_t timerid, struct itimerspec *value)
Get the amount of time until the timer expires.
Definition: FreeRTOS_POSIX_timer.c:295
itimerspec
timer
Definition: time.h:92
clock_nanosleep
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_getres
int clock_getres(clockid_t clock_id, struct timespec *res)
Returns the resolution of a clock.
Definition: FreeRTOS_POSIX_clock.c:72
signal.h
Signals.
pid_t
int pid_t
Used for process IDs and process group IDs.
Definition: types.h:79
clock_getcpuclockid
int clock_getcpuclockid(pid_t pid, clockid_t *clock_id)
Access a process CPU-time clock.
Definition: FreeRTOS_POSIX_clock.c:59
itimerspec::it_value
struct timespec it_value
Definition: time.h:95
time_t
int64_t time_t
Used for time in seconds.
Definition: types.h:175
timer_t
void * timer_t
Used for timer ID returned by timer_create().
Definition: types.h:185
nanosleep
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
High resolution sleep.
Definition: FreeRTOS_POSIX_clock.c:212
timespec
represents an elapsed time
Definition: time.h:79
timer_create
int timer_create(clockid_t clockid, struct sigevent *evp, timer_t *timerid)
Create a per-process timer.
Definition: FreeRTOS_POSIX_timer.c:101
timer_settime
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