Xenomai  3.0-rc3
timer.h
1 /*
2  * Copyright (C) 2005 Philippe Gerum <rpm@xenomai.org>.
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 #ifndef _COBALT_POSIX_TIMER_H
19 #define _COBALT_POSIX_TIMER_H
20 
21 #include <linux/types.h>
22 #include <linux/time.h>
23 #include <linux/list.h>
24 #include <cobalt/kernel/timer.h>
25 #include <xenomai/posix/signal.h>
26 #include <xenomai/posix/syscall.h>
27 
28 struct cobalt_thread;
29 struct cobalt_kqueues;
30 
31 struct cobalt_timer {
32  struct xntimer timerbase;
33  timer_t id;
34  int overruns;
35  clockid_t clockid;
36  pid_t target;
37  struct cobalt_sigpending sigp;
38  struct cobalt_extref extref;
39 };
40 
41 int cobalt_timer_deliver(timer_t timerid);
42 
43 void cobalt_timers_cleanup(struct cobalt_process *p);
44 
45 static inline timer_t cobalt_timer_id(const struct cobalt_timer *timer)
46 {
47  return timer->id;
48 }
49 
50 struct cobalt_timer *
51 cobalt_timer_by_id(struct cobalt_process *p, timer_t timer_id);
52 
53 void cobalt_timer_handler(struct xntimer *xntimer);
54 
55 void __cobalt_timer_getval(struct xntimer *__restrict__ timer,
56  struct itimerspec *__restrict__ value);
57 
58 int __cobalt_timer_setval(struct xntimer *__restrict__ timer, int clock_flag,
59  const struct itimerspec *__restrict__ value);
60 
61 int __cobalt_timer_create(clockid_t clock,
62  const struct sigevent *sev,
63  timer_t __user *u_tm);
64 
65 int __cobalt_timer_settime(timer_t timerid, int flags,
66  const struct itimerspec *__restrict__ value,
67  struct itimerspec *__restrict__ ovalue);
68 
69 int __cobalt_timer_gettime(timer_t timerid, struct itimerspec *value);
70 
71 COBALT_SYSCALL_DECL(timer_create,
72  (clockid_t clock,
73  const struct sigevent __user *u_sev,
74  timer_t __user *u_tm));
75 
76 COBALT_SYSCALL_DECL(timer_delete, (timer_t tm));
77 
78 COBALT_SYSCALL_DECL(timer_settime,
79  (timer_t tm, int flags,
80  const struct itimerspec __user *u_newval,
81  struct itimerspec __user *u_oldval));
82 
83 COBALT_SYSCALL_DECL(timer_gettime,
84  (timer_t tm, struct itimerspec __user *u_val));
85 
86 COBALT_SYSCALL_DECL(timer_getoverrun, (timer_t tm));
87 
88 #endif /* !_COBALT_POSIX_TIMER_H */
int timer_create(clockid_t clockid, const struct sigevent *__restrict__ evp, timer_t *__restrict__ timerid)
Create a timer.
Definition: timer.c:72
int timer_gettime(timer_t timerid, struct itimerspec *value)
Get timer next expiration date and reload value.
Definition: timer.c:202
int timer_delete(timer_t timerid)
Delete a timer object.
Definition: timer.c:102
int timer_getoverrun(timer_t timerid)
Get expiration overruns count since the most recent timer expiration signal delivery.
Definition: timer.c:235
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:161