2 * Copyright (C) 2005 Philippe Gerum <rpm@xenomai.org>.
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.
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.
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.
19 #ifndef _XENO_POSIX_TIME_H
20 #define _XENO_POSIX_TIME_H
22 #if defined(__KERNEL__) || defined(__XENO_SIM__)
24 #include <nucleus/xenomai.h>
27 #include <linux/time.h>
28 #define DELAYTIMER_MAX UINT_MAX
29 #endif /* __KERNEL__ */
32 #include <posix_overrides.h>
33 #endif /* __XENO_SIM__ */
36 #define TIMER_ABSTIME 1
39 #else /* !(__KERNEL__ || __XENO_SIM__) */
41 #pragma GCC system_header
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>
48 #endif /* !(__KERNEL__ || __XENO_SIM__) */
50 #ifndef CLOCK_MONOTONIC
51 /* Some archs do not implement this, but Xenomai always does. */
52 #define CLOCK_MONOTONIC 1
53 #endif /* CLOCK_MONOTONIC */
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.
60 #define CLOCK_HOST_REALTIME 42
62 #if defined(__KERNEL__) || defined(__XENO_SIM__)
72 int clock_getres(clockid_t clock_id
,
73 struct timespec
*res
);
75 int clock_gettime(clockid_t clock_id
,
78 int clock_settime(clockid_t clock_id
,
79 const struct timespec
*tp
);
81 int clock_nanosleep(clockid_t clock_id
,
83 const struct timespec
*rqtp
,
84 struct timespec
*rmtp
);
86 int nanosleep(const struct timespec
*rqtp
,
87 struct timespec
*rmtp
);
89 int timer_create(clockid_t clockid
,
90 const struct sigevent
*__restrict__ evp
,
91 timer_t
*__restrict__ timerid
);
93 int timer_delete(timer_t timerid
);
95 int timer_settime(timer_t timerid
,
97 const struct itimerspec
*__restrict__ value
,
98 struct itimerspec
*__restrict__ ovalue
);
100 int timer_gettime(timer_t timerid
, struct itimerspec
*value
);
102 int timer_getoverrun(timer_t timerid
);
108 #else /* !(__KERNEL__ || __XENO_SIM__) */
114 int __real_clock_getres(clockid_t clock_id
,
115 struct timespec
*tp
);
117 int __real_clock_gettime(clockid_t clock_id
,
118 struct timespec
*tp
);
120 int __real_clock_settime(clockid_t clock_id
,
121 const struct timespec
*tp
);
123 int __real_clock_nanosleep(clockid_t clock_id
,
125 const struct timespec
*rqtp
,
126 struct timespec
*rmtp
);
128 int __real_nanosleep(const struct timespec
*rqtp
,
129 struct timespec
*rmtp
);
131 int __real_timer_create (clockid_t clockid
,
132 struct sigevent
*evp
,
135 int __real_timer_delete (timer_t timerid
);
137 int __real_timer_settime(timer_t timerid
,
139 const struct itimerspec
*value
,
140 struct itimerspec
*ovalue
);
142 int __real_timer_gettime(timer_t timerid
,
143 struct itimerspec
*value
);
145 int __real_timer_getoverrun(timer_t timerid
);
151 #endif /* !(__KERNEL__ || __XENO_SIM__) */
153 #endif /* _XENO_POSIX_TIME_H */