Tenok
A Linux-like Real-Time Operating System for Robotics and Internet of Things
Data Structures | Macros | Functions
time.h File Reference
#include <signal.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
Include dependency graph for time.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  timespec
 
struct  itimerspec
 
struct  tm
 

Macros

#define CLOCK_REALTIME   0
 
#define CLOCK_MONOTONIC   1
 
#define TIMER_ABSTIME   1
 

Functions

int clock_getres (clockid_t clockid, struct timespec *res)
 Get the resolution (precision) of the specified clock ID. More...
 
int clock_gettime (clockid_t clockid, struct timespec *tp)
 Retrieve the time of the specified clock ID. More...
 
int clock_settime (clockid_t clockid, const struct timespec *tp)
 Set the time of the specified clock ID. More...
 
int timer_create (clockid_t clockid, struct sigevent *sevp, timer_t *timerid)
 Create a new per-thread interval timer. More...
 
int timer_delete (timer_t timerid)
 Delete the timer specified with the timer ID. More...
 
int timer_settime (timer_t timerid, int flags, const struct itimerspec *new_value, struct itimerspec *old_value)
 Arm or disarm the timer specified by the timer ID. More...
 
int timer_gettime (timer_t timerid, struct itimerspec *curr_value)
 Return the timer interval and the time until next expiration. More...
 
time_t time (time_t *tloc)
 Return the time as the number of seconds since 1970-01-01 00:00:00 +0000 (UTC) More...
 
int nanosleep (const struct timespec *req, struct timespec *rem)
 Suspend execution for a specified time. More...
 
int clock_nanosleep (clockid_t clockid, int flags, const struct timespec *req, struct timespec *rem)
 High-resolution sleep with clock selection. More...
 
struct tmlocaltime (const time_t *timep)
 
struct tmlocaltime_r (const time_t *timep, struct tm *result)
 
struct tmgmtime (const time_t *timep)
 
struct tmgmtime_r (const time_t *timep, struct tm *result)
 
time_t mktime (struct tm *tm)
 
size_t strftime (char *s, size_t max, const char *format, const struct tm *tm)
 
char * strptime (const char *s, const char *format, struct tm *tm)
 
char * ctime (const time_t *timep)
 
char * ctime_r (const time_t *timep, char *buf)
 

Function Documentation

◆ clock_getres()

int clock_getres ( clockid_t  clockid,
struct timespec res 
)

Get the resolution (precision) of the specified clock ID.

Parameters
clk_idThe clock ID to provide.
resThe time object for returning the clock resolution.
Return values
int0 on success and nonzero error number on error.

◆ clock_gettime()

int clock_gettime ( clockid_t  clockid,
struct timespec tp 
)

Retrieve the time of the specified clock ID.

Parameters
clk_idThe clock ID to provide.
tpThe time object for returning the time.
Return values
int0 on success and nonzero error number on error.

◆ clock_nanosleep()

int clock_nanosleep ( clockid_t  clockid,
int  flags,
const struct timespec req,
struct timespec rem 
)

High-resolution sleep with clock selection.

Parameters
clockidThe clock ID to use.
flagsTIMER_ABSTIME for absolute time, otherwise relative.
reqRequested sleep time.
remRemaining time if interrupted (optional).
Return values
int0 on success and nonzero error number on error.

◆ clock_settime()

int clock_settime ( clockid_t  clockid,
const struct timespec tp 
)

Set the time of the specified clock ID.

Parameters
clk_idThe clock ID to provide.
tpThe time object for setting the clock.
Return values
int0 on success and nonzero error number on error.

◆ nanosleep()

int nanosleep ( const struct timespec req,
struct timespec rem 
)

Suspend execution for a specified time.

Parameters
reqRequested sleep time.
remRemaining time if interrupted (optional).
Return values
int0 on success and nonzero error number on error.

◆ time()

time_t time ( time_t *  tloc)

Return the time as the number of seconds since 1970-01-01 00:00:00 +0000 (UTC)

Parameters
tlocSame as return value if tloc is not NULL.
Return values
time_tThe time in seconds.

◆ timer_create()

int timer_create ( clockid_t  clockid,
struct sigevent sevp,
timer_t *  timerid 
)

Create a new per-thread interval timer.

Parameters
clk_idThe clock ID to provide.
sevpFor signaling an event when the timer expired.
timeridFor returning the ID of the newly created timer.
Return values
int0 on success and nonzero error number on error.

◆ timer_delete()

int timer_delete ( timer_t  timerid)

Delete the timer specified with the timer ID.

Parameters
timeridThe timer ID to provide.
Return values
int0 on success and nonzero error number on error.

◆ timer_gettime()

int timer_gettime ( timer_t  timerid,
struct itimerspec curr_value 
)

Return the timer interval and the time until next expiration.

Parameters
timeridThe timer ID to provide.
curr_valueThe timer object for returning the timer time.
Return values
int0 on success and nonzero error number on error.

◆ timer_settime()

int timer_settime ( timer_t  timerid,
int  flags,
const struct itimerspec new_value,
struct itimerspec old_value 
)

Arm or disarm the timer specified by the timer ID.

Parameters
timeridThe timer ID to provide.
flagsNot used.
new_valuePointer the the new timer setting.
old_valuePointer to the memory space for storing the old timer setting.
Return values
int0 on success and nonzero error number on error.