Amazon FreeRTOS: POSIX
Return to main page ↑
time.h File Reference

Time types. More...

Go to the source code of this file.

Data Structures

struct  timespec
 represents an elapsed time More...
 
struct  itimerspec
 timer More...
 

Macros

Unit conversion constants.
#define MICROSECONDS_PER_SECOND   ( 1000000LL )
 
#define NANOSECONDS_PER_SECOND   ( 1000000000LL )
 
#define NANOSECONDS_PER_TICK   ( NANOSECONDS_PER_SECOND / configTICK_RATE_HZ )
 
Clock identifiers.
#define CLOCK_REALTIME   0
 
#define CLOCK_MONOTONIC   1
 
A number used to convert the value returned by the clock() function into seconds.
#define CLOCKS_PER_SEC   ( ( clock_t ) configTICK_RATE_HZ )
 
Flag indicating time is absolute.

For functions taking timer objects, this refers to the clock associated with the timer.

#define TIMER_ABSTIME   0x01
 

Functions

clock_t clock (void)
 Report CPU time used. More...
 
int clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
 Access a process CPU-time clock. More...
 
int clock_getres (clockid_t clock_id, struct timespec *res)
 Returns the resolution of a clock. More...
 
int clock_gettime (clockid_t clock_id, struct timespec *tp)
 Returns the current value for the specified clock, clock_id. More...
 
int clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
 High resolution sleep with specifiable clock. More...
 
int clock_settime (clockid_t clock_id, const struct timespec *tp)
 Sets the time for the specified clock. More...
 
int nanosleep (const struct timespec *rqtp, struct timespec *rmtp)
 High resolution sleep. More...
 
int timer_create (clockid_t clockid, struct sigevent *evp, timer_t *timerid)
 Create a per-process timer. More...
 
int timer_delete (timer_t timerid)
 Delete a per-process timer. More...
 
int timer_getoverrun (timer_t timerid)
 Get the timer overrun count. More...
 
int timer_gettime (timer_t timerid, struct itimerspec *value)
 Get the amount of time until the timer expires. More...
 
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. More...
 

Detailed Description

Macro Definition Documentation

◆ MICROSECONDS_PER_SECOND

#define MICROSECONDS_PER_SECOND   ( 1000000LL )

Microseconds per second.

◆ NANOSECONDS_PER_SECOND

#define NANOSECONDS_PER_SECOND   ( 1000000000LL )

Nanoseconds per second.

◆ NANOSECONDS_PER_TICK

#define NANOSECONDS_PER_TICK   ( NANOSECONDS_PER_SECOND / configTICK_RATE_HZ )

Nanoseconds per FreeRTOS tick.

◆ CLOCK_REALTIME

#define CLOCK_REALTIME   0

The identifier of the system-wide clock measuring real time.

◆ CLOCK_MONOTONIC

#define CLOCK_MONOTONIC   1

The identifier for the system-wide monotonic clock.

Function Documentation

◆ clock()

clock_t clock ( void  )

Report CPU time used.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock.html

Returns
The number of FreeRTOS ticks since the scheduler was started minus the ticks spent in the idle task.
Note
This function does NOT report the number of ticks spent by the calling thread.

◆ clock_getcpuclockid()

int clock_getcpuclockid ( pid_t  pid,
clockid_t clock_id 
)

Access a process CPU-time clock.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getcpuclockid.html

Return values
EPERM
Note
This function is currently unsupported.

◆ clock_getres()

int clock_getres ( clockid_t  clock_id,
struct timespec res 
)

Returns the resolution of a clock.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html

Note
clock_id is ignored
This function stores the resolution of the FreeRTOS tick count in the object res points to.
Return values
0- Upon successful execution

◆ clock_gettime()

int clock_gettime ( clockid_t  clock_id,
struct timespec tp 
)

Returns the current value for the specified clock, clock_id.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html

Note
clock_id is ignored
this function does not check for overflows of time_t.
Return values
0- Upon successful completion.

◆ clock_nanosleep()

int clock_nanosleep ( clockid_t  clock_id,
int  flags,
const struct timespec rqtp,
struct timespec rmtp 
)

High resolution sleep with specifiable clock.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_nanosleep.html

Note
clock_id is ignored, as this function uses the FreeRTOS tick count as its clock.
flags is ignored, if INCLUDE_vTaskDelayUntil is 0. i.e. the FreeRTOS function vTaskDelayUntil isn't available.
rmtp is also ignored, as signals are not implemented.
Return values
0- Upon successful completion.
EINVAL- The rqtp argument specified a nanosecond value less than zero or greater than or equal to 1000 million.

◆ clock_settime()

int clock_settime ( clockid_t  clock_id,
const struct timespec tp 
)

Sets the time for the specified clock.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_settime.html

Return values
-1with errno set to EPERM.
Note
This function is currently unsupported, as FreeRTOS does not provide a function to modify the tick count.

◆ nanosleep()

int nanosleep ( const struct timespec rqtp,
struct timespec rmtp 
)

High resolution sleep.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html

Note
rmtp is ignored, as signals are not implemented.
Return values
0- Upon successful completion.
-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.

◆ timer_create()

int timer_create ( clockid_t  clockid,
struct sigevent evp,
timer_t timerid 
)

Create a per-process timer.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_create.html

Note
clock_id is ignored, as this function used the FreeRTOS tick count as its clock.
evp.sigev_notify must be set to SIGEV_THREAD, since signals are currently not supported.
Return values
0- Upon successful completion, with location referenced by timerid updated.
-1- If an error occurs. errno is also set.
Side Effects Possible errno values

ENOTSUP - If evp is NULL OR evp->sigen_notify == SIGEV_SIGNAL.
EAGAIN - The system lacks sufficient signal queuing resources to honor the request.

◆ timer_delete()

int timer_delete ( timer_t  timerid)

Delete a per-process timer.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_delete.html

Return values
0- Upon successful completion.

◆ timer_getoverrun()

int timer_getoverrun ( timer_t  timerid)

Get the timer overrun count.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_getoverrun.html

Return values
0- Always return 0, since signals are not supported.

◆ timer_gettime()

int timer_gettime ( timer_t  timerid,
struct itimerspec value 
)

Get the amount of time until the timer expires.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_gettime.html

Return values
0- Upon successful completion.

◆ 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.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_settime.html

Return values
0- Upon successful completion.
-1- An error occurred, errno is also set.
Side Effects Possible errno values

EINVAL - A value structure specified a nanosecond value less than zero or greater than or equal to 1000 million, AND the it_value member of that structure did not specify zero seconds and nanoseconds.