summaryrefslogtreecommitdiffstats
path: root/include/alarm.h
blob: c68e7f494b9c082d628a1ad874589eaf2e53ac62 (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
#ifndef _TIMER_H_
#define _TIMER_H_

#include "linux_list.h"

struct alarm_list {
	struct list_head	head;
	struct timeval		tv;
	void			*data;
	void			(*function)(struct alarm_list *a, void *data);
};

static inline void
set_alarm_expiration(struct alarm_list *t, long tv_sec, long tv_usec)
{
	t->tv.tv_sec = tv_sec;
	t->tv.tv_usec = tv_usec;
}

void set_alarm_function(struct alarm_list *t,
			void (*fcn)(struct alarm_list *a, void *data));

void set_alarm_data(struct alarm_list *t, void *data);

void init_alarm(struct alarm_list *t);

void add_alarm(struct alarm_list *alarm);

void del_alarm(struct alarm_list *alarm);

void mod_alarm(struct alarm_list *alarm, unsigned long sc, unsigned long usc);

int get_next_alarm(struct timeval *tv, struct timeval *next_alarm);

int do_alarm_run(struct timeval *next_alarm);

#endif