Lely core libraries 2.3.4
time.h
Go to the documentation of this file.
1
22#ifndef LELY_LIBC_TIME_H_
23#define LELY_LIBC_TIME_H_
24
25#include <lely/libc/sys/types.h>
26
27#include <time.h>
28
29#ifndef LELY_HAVE_ITIMERSPEC
30#if defined(_POSIX_C_SOURCE) || defined(_POSIX_TIMERS) \
31 || defined(_TIMESPEC_DEFINED)
32#define LELY_HAVE_ITIMERSPEC 1
33#endif
34#endif
35
36#ifndef LELY_HAVE_TIMESPEC
37#if __STDC_VERSION__ >= 201112L || _MSC_VER >= 1900 \
38 || _POSIX_C_SOURCE >= 199309L || defined(__CYGWIN__) \
39 || defined(_TIMESPEC_DEFINED) || defined(__timespec_defined)
40#define LELY_HAVE_TIMESPEC 1
41#endif
42#endif
43
44#ifndef LELY_HAVE_TIMESPEC_GET
45#if (__STDC_VERSION__ >= 201112L || __USE_ISOC11 || _MSC_VER >= 1900) \
46 && defined(TIME_UTC)
47#define LELY_HAVE_TIMESPEC_GET 1
48#endif
49#endif
50
51#if !defined(_POSIX_C_SOURCE) && !defined(_POSIX_TIMERS) \
52 && !defined(__MINGW32__)
53
54#ifndef CLOCK_REALTIME
56#define CLOCK_REALTIME 0
57#endif
58
64#define CLOCK_MONOTONIC 1
65
70#define CLOCK_PROCESS_CPUTIME_ID 2
71
76#define CLOCK_THREAD_CPUTIME_ID 3
77
78#ifndef TIMER_ABSTIME
80#define TIMER_ABSTIME 1
81#endif
82
83#endif // !_POSIX_C_SOURCE && !_POSIX_TIMERS && !__MINGW32__
84
85#if !LELY_HAVE_TIMESPEC
86
88struct timespec {
90 time_t tv_sec;
92 long tv_nsec;
93};
94
95#endif // !LELY_HAVE_TIMESPEC
96
97#if !LELY_HAVE_ITIMERSPEC
98
106
107#endif // !LELY_HAVE_ITIMERSPEC
108
109#ifdef __cplusplus
110extern "C" {
111#endif
112
113#if !defined(_POSIX_TIMERS) && !defined(__MINGW32__)
114
130int clock_getres(clockid_t clock_id, struct timespec *res);
131
146int clock_gettime(clockid_t clock_id, struct timespec *tp);
147
178int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
179 struct timespec *rmtp);
180
193int clock_settime(clockid_t clock_id, const struct timespec *tp);
194
199int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
200
201#endif // !_POSIX_TIMERS && !__MINGW32__
202
203#if !LELY_HAVE_TIMESPEC_GET
204
205#ifndef TIME_UTC
207#define TIME_UTC 1
208#endif
209
222int timespec_get(struct timespec *ts, int base);
223
224#endif // !LELY_HAVE_TIMESPEC_GET
225
226#ifdef __cplusplus
227}
228#endif
229
230#endif // !LELY_LIBC_TIME_H_
int timespec_get(struct timespec *ts, int base)
Sets the interval at ts to hold the current calendar time based on the specified time base.
Definition time.c:32
A struct specifying an interval and initial value for a timer.
Definition time.h:100
struct timespec it_interval
The timer period.
Definition time.h:102
struct timespec it_value
The timer expiration.
Definition time.h:104
A time type with nanosecond resolution.
Definition time.h:88
long tv_nsec
Nanoseconds [0, 999999999].
Definition time.h:92
time_t tv_sec
Whole seconds (>= 0).
Definition time.h:90
This header file is part of the C11 and POSIX compatibility library; it includes <sys/types....
int clockid_t
Used for clock ID type in the clock and timer functions.
Definition types.h:40
This header file is part of the utilities library; it contains the time function declarations.