hrtimer.h revision 1.5
1/*	$NetBSD: hrtimer.h,v 1.5 2021/12/19 11:36:57 riastradh Exp $	*/
2
3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Taylor R. Campbell.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef _LINUX_HRTIMER_H_
33#define _LINUX_HRTIMER_H_
34
35#include <sys/types.h>
36
37#include <sys/callout.h>
38
39#include <linux/ktime.h>
40#include <linux/timer.h>
41
42struct hrtimer {
43	enum hrtimer_restart (*function)(struct hrtimer *);
44
45	struct hrtimer_private	*hrt_private;
46};
47
48enum hrtimer_mode {
49	HRTIMER_MODE_ABS,
50	HRTIMER_MODE_REL,
51	HRTIMER_MODE_REL_PINNED,
52};
53
54enum hrtimer_restart {
55	HRTIMER_NORESTART,
56	HRTIMER_RESTART,
57};
58
59#define	hrtimer_active		linux_hrtimer_active
60#define	hrtimer_add_expires_ns	linux_hrtimer_add_expires_ns
61#define	hrtimer_cancel		linux_hrtimer_cancel
62#define	hrtimer_forward		linux_hrtimer_forward
63#define	hrtimer_forward_now	linux_hrtimer_forward_now
64#define	hrtimer_init		linux_hrtimer_init
65#define	hrtimer_set_expires	linux_hrtimer_set_expiresp
66#define	hrtimer_start		linux_hrtimer_start
67#define	hrtimer_start_range_ns	linux_hrtimer_start_range_ns
68
69void hrtimer_init(struct hrtimer *, clockid_t, enum hrtimer_mode);
70void hrtimer_set_expires(struct hrtimer *, ktime_t);
71void hrtimer_add_expires_ns(struct hrtimer *, uint64_t);
72void hrtimer_start(struct hrtimer *, ktime_t, enum hrtimer_mode);
73void hrtimer_start_range_ns(struct hrtimer *, ktime_t, uint64_t,
74    enum hrtimer_mode);
75int hrtimer_cancel(struct hrtimer *);
76bool hrtimer_active(struct hrtimer *);
77uint64_t hrtimer_forward(struct hrtimer *, ktime_t, ktime_t);
78uint64_t hrtimer_forward_now(struct hrtimer *, ktime_t);
79
80#endif  /* _LINUX_HRTIMER_H_ */
81