Xenomai  3.1
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_timer {
29  struct xntimer timerbase;
30  timer_t id;
31  int overruns;
32  clockid_t clockid;
33  pid_t target;
34  struct cobalt_sigpending sigp;
35  struct cobalt_extref extref;
36 };
37 
38 int cobalt_timer_deliver(struct cobalt_thread *waiter,
39  timer_t timerid);
40 
41 void cobalt_timer_reclaim(struct cobalt_process *p);
42 
43 static inline timer_t cobalt_timer_id(const struct cobalt_timer *timer)
44 {
45  return timer->id;
46 }
47 
48 struct cobalt_timer *
49 cobalt_timer_by_id(struct cobalt_process *p, timer_t timer_id);
50 
51 void cobalt_timer_handler(struct xntimer *xntimer);
52 
53 void __cobalt_timer_getval(struct xntimer *__restrict__ timer,
54  struct itimerspec *__restrict__ value);
55 
56 int __cobalt_timer_setval(struct xntimer *__restrict__ timer, int clock_flag,
57  const struct itimerspec *__restrict__ value);
58 
59 int __cobalt_timer_create(clockid_t clock,
60  const struct sigevent *sev,
61  timer_t __user *u_tm);
62 
63 int __cobalt_timer_settime(timer_t timerid, int flags,
64  const struct itimerspec *__restrict__ value,
65  struct itimerspec *__restrict__ ovalue);
66 
67 int __cobalt_timer_gettime(timer_t timerid, struct itimerspec *value);
68 
69 COBALT_SYSCALL_DECL(timer_create,
70  (clockid_t clock,
71  const struct sigevent __user *u_sev,
72  timer_t __user *u_tm));
73 
74 COBALT_SYSCALL_DECL(timer_delete, (timer_t tm));
75 
76 COBALT_SYSCALL_DECL(timer_settime,
77  (timer_t tm, int flags,
78  const struct itimerspec __user *u_newval,
79  struct itimerspec __user *u_oldval));
80 
81 COBALT_SYSCALL_DECL(timer_gettime,
82  (timer_t tm, struct itimerspec __user *u_val));
83 
84 COBALT_SYSCALL_DECL(timer_getoverrun, (timer_t tm));
85 
86 #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:75
int timer_gettime(timer_t timerid, struct itimerspec *value)
Get timer next expiration date and reload value.
Definition: timer.c:212
int timer_delete(timer_t timerid)
Delete a timer object.
Definition: timer.c:107
int timer_getoverrun(timer_t timerid)
Get expiration overruns count since the most recent timer expiration signal delivery.
Definition: timer.c:247
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:168