Lely core libraries 1.9.2
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#undef 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
43#ifndef LELY_HAVE_TIMESPEC_GET
44#if (__STDC_VERSION__ >= 201112L || __USE_ISOC11 || _MSC_VER >= 1900) \
45 && defined(TIME_UTC)
46#define LELY_HAVE_TIMESPEC_GET 1
47#endif
48#endif
49
50#if !defined(_POSIX_C_SOURCE) && !defined(_POSIX_TIMERS) \
51 && !defined(__MINGW32__)
52
54#define CLOCK_REALTIME 0
55
61#define CLOCK_MONOTONIC 1
62
67#define CLOCK_PROCESS_CPUTIME_ID 2
68
73#define CLOCK_THREAD_CPUTIME_ID 3
74
76#define TIMER_ABSTIME 1
77
78#endif // !_POSIX_C_SOURCE && !_POSIX_TIMERS && !__MINGW32__
79
80#if !LELY_HAVE_TIMESPEC
81
83struct timespec {
85 time_t tv_sec;
87 long tv_nsec;
88};
89
90#endif // !LELY_HAVE_TIMESPEC
91
92#if !LELY_HAVE_ITIMERSPEC
93
95struct itimerspec {
100};
101
102#endif // !LELY_HAVE_ITIMERSPEC
103
104#ifdef __cplusplus
105extern "C" {
106#endif
107
108#if !defined(_POSIX_TIMERS) && !defined(__MINGW32__)
109
125int clock_getres(clockid_t clock_id, struct timespec *res);
126
141int clock_gettime(clockid_t clock_id, struct timespec *tp);
142
173int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp,
174 struct timespec *rmtp);
175
188int clock_settime(clockid_t clock_id, const struct timespec *tp);
189
194int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
195
196#endif // !_POSIX_TIMERS && !__MINGW32__
197
198#if !LELY_HAVE_TIMESPEC_GET
199
200#ifndef TIME_UTC
202#define TIME_UTC 1
203#endif
204
217int timespec_get(struct timespec *ts, int base);
218
219#endif // !LELY_HAVE_TIMESPEC_GET
220
221#ifdef __cplusplus
222}
223#endif
224
225#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:95
struct timespec it_interval
The timer period.
Definition: time.h:97
struct timespec it_value
The timer expiration.
Definition: time.h:99
A time type with nanosecond resolution.
Definition: time.h:83
long tv_nsec
Nanoseconds [0, 999999999].
Definition: time.h:87
time_t tv_sec
Whole seconds (>= 0).
Definition: time.h:85
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.