Xenomai API  2.6.5
time.h
1 /*
2  * Copyright (C) 2005 Philippe Gerum <[email protected]>.
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18 
19 #ifndef _XENO_POSIX_TIME_H
20 #define _XENO_POSIX_TIME_H
21 
22 #if defined(__KERNEL__) || defined(__XENO_SIM__)
23 
24 #include <nucleus/xenomai.h>
25 
26 #ifdef __KERNEL__
27 #include <linux/time.h>
28 #define DELAYTIMER_MAX UINT_MAX
29 #endif /* __KERNEL__ */
30 
31 #ifdef __XENO_SIM__
32 #include <posix_overrides.h>
33 #endif /* __XENO_SIM__ */
34 
35 #ifndef TIMER_ABSTIME
36 #define TIMER_ABSTIME 1
37 #endif
38 
39 #else /* !(__KERNEL__ || __XENO_SIM__) */
40 
41 #pragma GCC system_header
42 
43 #include_next <time.h>
44 /* In case time.h is included for a side effect of an __need* macro, include it
45  a second time to get all definitions. */
46 #include_next <time.h>
47 
48 #endif /* !(__KERNEL__ || __XENO_SIM__) */
49 
50 #ifndef CLOCK_MONOTONIC
51 /* Some archs do not implement this, but Xenomai always does. */
52 #define CLOCK_MONOTONIC 1
53 #endif /* CLOCK_MONOTONIC */
54 
55 /*
56  * This number is supposed to not collide with any of the POSIX and
57  * Linux kernel definitions so that no ambiguities arise when porting
58  * applications in both directions.
59  */
60 #define CLOCK_HOST_REALTIME 42
61 
62 #if defined(__KERNEL__) || defined(__XENO_SIM__)
63 
64 struct sigevent;
65 
66 struct timespec;
67 
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
71 
72 int clock_getres(clockid_t clock_id,
73  struct timespec *res);
74 
75 int clock_gettime(clockid_t clock_id,
76  struct timespec *tp);
77 
78 int clock_settime(clockid_t clock_id,
79  const struct timespec *tp);
80 
81 int clock_nanosleep(clockid_t clock_id,
82  int flags,
83  const struct timespec *rqtp,
84  struct timespec *rmtp);
85 
86 int nanosleep(const struct timespec *rqtp,
87  struct timespec *rmtp);
88 
89 int timer_create(clockid_t clockid,
90  const struct sigevent *__restrict__ evp,
91  timer_t *__restrict__ timerid);
92 
93 int timer_delete(timer_t timerid);
94 
95 int timer_settime(timer_t timerid,
96  int flags,
97  const struct itimerspec *__restrict__ value,
98  struct itimerspec *__restrict__ ovalue);
99 
100 int timer_gettime(timer_t timerid, struct itimerspec *value);
101 
102 int timer_getoverrun(timer_t timerid);
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
108 #else /* !(__KERNEL__ || __XENO_SIM__) */
109 
110 #ifdef __cplusplus
111 extern "C" {
112 #endif
113 
114 int __real_clock_getres(clockid_t clock_id,
115  struct timespec *tp);
116 
117 int __real_clock_gettime(clockid_t clock_id,
118  struct timespec *tp);
119 
120 int __real_clock_settime(clockid_t clock_id,
121  const struct timespec *tp);
122 
123 int __real_clock_nanosleep(clockid_t clock_id,
124  int flags,
125  const struct timespec *rqtp,
126  struct timespec *rmtp);
127 
128 int __real_nanosleep(const struct timespec *rqtp,
129  struct timespec *rmtp);
130 
131 int __real_timer_create (clockid_t clockid,
132  struct sigevent *evp,
133  timer_t *timerid);
134 
135 int __real_timer_delete (timer_t timerid);
136 
137 int __real_timer_settime(timer_t timerid,
138  int flags,
139  const struct itimerspec *value,
140  struct itimerspec *ovalue);
141 
142 int __real_timer_gettime(timer_t timerid,
143  struct itimerspec *value);
144 
145 int __real_timer_getoverrun(timer_t timerid);
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif /* !(__KERNEL__ || __XENO_SIM__) */
152 
153 #endif /* _XENO_POSIX_TIME_H */
int clock_gettime(clockid_t clock_id, struct timespec *tp)
Read the specified clock.
Definition: clock.c:176
int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, struct timespec *rmtp)
Sleep some amount of time.
Definition: clock.c:290
int timer_getoverrun(timer_t timerid)
Get expiration overruns count since the most recent timer expiration signal delivery.
Definition: timer.c:517
int timer_create(clockid_t clockid, const struct sigevent *__restrict__ evp, timer_t *__restrict__ timerid)
Create a timer object.
Definition: timer.c:133
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp)
Sleep some amount of time.
Definition: clock.c:374
int timer_gettime(timer_t timerid, struct itimerspec *value)
Get timer next expiration date and reload value.
Definition: timer.c:457
int clock_getres(clockid_t clock_id, struct timespec *res)
Get the resolution of the specified clock.
Definition: clock.c:80
int clock_settime(clockid_t clock_id, const struct timespec *tp)
Set the specified clock.
Definition: clock.c:226
int timer_delete(timer_t timerid)
Delete a timer object.
Definition: timer.c:264
int timer_settime(timer_t timerid, int flags, const struct itimerspec *__restrict__ value, struct itimerspec *__restrict__ ovalue)
Start or stop a timer.
Definition: timer.c:335