posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
time.h File Reference

<time.h>: POSIX time types, clocks, and timers More...

#include <stddef.h>
#include <zephyr/sys/clock.h>
#include <zephyr/toolchain.h>
Include dependency graph for posix_time.h:

Go to the source code of this file.

Data Structures

struct  timespec
 Time value with nanosecond resolution. More...
 
struct  itimerspec
 Interval timer specification used with timer_settime() and timer_gettime(). More...
 

Macros

#define _CLOCKID_T_DECLARED
 
#define __clockid_t_defined
 
#define _TIMER_T_DECLARED
 
#define __timer_t_defined
 
#define _LOCALE_T_DECLARED
 
#define __locale_t_defined
 
#define _PID_T_DECLARED
 
#define __pid_t_defined
 
#define _TIMESPEC_DECLARED
 
#define __timespec_defined
 
#define _ITIMERSPEC_DECLARED
 
#define __itimerspec_defined
 
#define CLOCK_REALTIME   ((clockid_t)SYS_CLOCK_REALTIME)
 Clock measuring real (wall-clock) time.
 
#define CLOCKS_PER_SEC   1000000
 Number of clock ticks per second as seen by clock().
 
#define CLOCK_PROCESS_CPUTIME_ID   ((clockid_t)2)
 CPU-time clock for the calling process.
 
#define CLOCK_THREAD_CPUTIME_ID   ((clockid_t)3)
 CPU-time clock for the calling thread.
 
#define CLOCK_MONOTONIC   ((clockid_t)SYS_CLOCK_MONOTONIC)
 Monotonically increasing clock that cannot be set.
 
#define TIMER_ABSTIME   SYS_TIMER_ABSTIME
 Flag for clock_nanosleep() and timer_settime(): interpret time as absolute.
 

Typedefs

typedef unsigned long clockid_t
 Identifies a clock (e.g.
 
typedef unsigned long timer_t
 Opaque handle for a POSIX interval timer created with timer_create().
 
typedef void * locale_t
 Opaque locale object.
 
typedef int pid_t
 Process ID type.
 

Functions

char * asctime_r (const struct tm *ZRESTRICT tm, char *ZRESTRICT buf)
 Convert broken-down time to a string (thread-safe version of asctime()).
 
int clock_getcpuclockid (pid_t pid, clockid_t *clock_id)
 Get the CPU-time clock ID for a process.
 
int clock_getres (clockid_t clock_id, struct timespec *ts)
 Get the resolution of a clock.
 
int clock_gettime (clockid_t clock_id, struct timespec *ts)
 Get the current time of a clock.
 
int clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
 High-resolution sleep against a specified clock.
 
int clock_settime (clockid_t clock_id, const struct timespec *ts)
 Set the time of a clock.
 
char * ctime_r (const time_t *clock, char *buf)
 Convert a time_t to a string (thread-safe version of ctime()).
 
struct tm * getdate (const char *string)
 Convert a date-time string to broken-down time (XSI extension).
 
struct tm * gmtime_r (const time_t *ZRESTRICT timer, struct tm *ZRESTRICT result)
 Convert a time_t to UTC broken-down time (thread-safe version of gmtime()).
 
struct tm * localtime_r (const time_t *ZRESTRICT timer, struct tm *ZRESTRICT result)
 Convert a time_t to local broken-down time (thread-safe version of localtime()).
 
int nanosleep (const struct timespec *rqtp, struct timespec *rmtp)
 Sleep for a specified number of nanoseconds (high-resolution sleep).
 
size_t strftime_l (char *ZRESTRICT s, size_t maxsize, const char *ZRESTRICT format, const struct tm *ZRESTRICT timeptr, locale_t locale)
 Format broken-down time into a string using the specified locale.
 
char * strptime (const char *ZRESTRICT s, const char *ZRESTRICT format, struct tm *ZRESTRICT tm)
 Parse a date/time string according to a format (XSI extension).
 
int timer_create (clockid_t clockId, struct sigevent *ZRESTRICT evp, timer_t *ZRESTRICT timerid)
 Create a per-process timer.
 
int timer_delete (timer_t timerid)
 Delete a per-process timer.
 
int timer_getoverrun (timer_t timerid)
 Get the number of timer overruns since the last timer expiration notification.
 
int timer_gettime (timer_t timerid, struct itimerspec *its)
 Get the time remaining until the next timer expiration.
 
int timer_settime (timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue)
 Arm or disarm a per-process timer.
 

Variables

int daylight
 Non-zero if Daylight Saving Time is in effect.
 
long timezone
 Offset in seconds from UTC for the current timezone.
 
char * tzname []
 Timezone abbreviations; tzname[0] = std, tzname[1] = dst.
 

Detailed Description

<time.h>: POSIX time types, clocks, and timers

Provides the clock identifiers, POSIX timer API, thread-safe time conversion helpers, and locale-aware time formatting that extend the C standard <time.h> interface.

See also
POSIX.1-2017 <time.h>

Definition in file time.h.

Macro Definition Documentation

◆ __clockid_t_defined

#define __clockid_t_defined

Definition at line 42 of file time.h.

◆ __itimerspec_defined

#define __itimerspec_defined

Definition at line 100 of file time.h.

◆ __locale_t_defined

#define __locale_t_defined

Definition at line 62 of file time.h.

◆ __pid_t_defined

#define __pid_t_defined

Definition at line 69 of file time.h.

◆ __timer_t_defined

#define __timer_t_defined

Definition at line 49 of file time.h.

◆ __timespec_defined

#define __timespec_defined

Definition at line 89 of file time.h.

◆ _CLOCKID_T_DECLARED

#define _CLOCKID_T_DECLARED

Definition at line 41 of file time.h.

◆ _ITIMERSPEC_DECLARED

#define _ITIMERSPEC_DECLARED

Definition at line 99 of file time.h.

◆ _LOCALE_T_DECLARED

#define _LOCALE_T_DECLARED

Definition at line 61 of file time.h.

◆ _PID_T_DECLARED

#define _PID_T_DECLARED

Definition at line 68 of file time.h.

◆ _TIMER_T_DECLARED

#define _TIMER_T_DECLARED

Definition at line 48 of file time.h.

◆ _TIMESPEC_DECLARED

#define _TIMESPEC_DECLARED

Definition at line 88 of file time.h.

Typedef Documentation

◆ clockid_t

typedef unsigned long clockid_t

Identifies a clock (e.g.

CLOCK_REALTIME, CLOCK_MONOTONIC).

Definition at line 40 of file time.h.

◆ locale_t

typedef void* locale_t

Opaque locale object.

Definition at line 59 of file time.h.

◆ pid_t

typedef int pid_t

Process ID type.

Definition at line 67 of file time.h.

◆ timer_t

typedef unsigned long timer_t

Opaque handle for a POSIX interval timer created with timer_create().

Definition at line 47 of file time.h.