blob: 37dabeca44f1f561567b045f179404d8baad51ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/* timer.h - Timer interface.
Copyright (C) 2009 Free Software Foundation, Inc.
Written by Neal H. Walfield <neal@gnu.org>.
This file is part of the GNU Hurd.
The GNU Hurd is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
The GNU Hurd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see
<http://www.gnu.org/licenses/>. */
#ifndef _VIENGOOS_TIMER_H
#define _VIENGOOS_TIMER_H 1
#include <stdint.h>
#include <stdbool.h>
#include <hurd/stddef.h>
#include <viengoos/bits/sys.h>
extern volatile struct vg_time time_data;
struct timer
{
struct timer *next;
struct timer *prev;
void (*callback) (struct timer *timer);
uint64_t expire;
};
/* Register a timer. TIMER->EXPIRE and TIMER->CALLBACK must be
correctly initialized prior to calling this function. */
extern void timer_register (struct timer *timer);
/* Cancel a previously registered and as of yet unfired timer. */
extern void timer_cancel (struct timer *timer);
static inline void
timer_check (void)
{
extern bool timer_bottom_half_pending;
extern struct timer *timers;
if (timers && unlikely (timers->expire <= time_data.ns_since_boot)
&& ! timer_bottom_half_pending)
{
extern void timer_check_hard (void);
timer_check_hard ();
}
}
extern void timer_bootstrap (void);
#endif
|