]> git.saurik.com Git - apple/xnu.git/blob - bsd/net/devtimer.h
xnu-792.25.20.tar.gz
[apple/xnu.git] / bsd / net / devtimer.h
1 /*
2 * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
11 *
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23 /*
24 * devtimer.h
25 * - timer source based on <kern/thread_call.h>
26 */
27
28
29 #ifndef _NET_DEVTIMER_H
30 #define _NET_DEVTIMER_H
31
32 #include <sys/types.h>
33 #include <sys/systm.h>
34
35 #define DEVTIMER_USECS_PER_SEC (1000 * 1000)
36
37 enum {
38 devtimer_process_func_event_lock,
39 devtimer_process_func_event_unlock,
40 };
41 typedef int devtimer_process_func_event;
42
43 typedef struct devtimer_s * devtimer_ref;
44 typedef void (*devtimer_process_func)(devtimer_ref timer,
45 devtimer_process_func_event event);
46 typedef void (*devtimer_timeout_func)(void * arg0, void * arg1, void * arg2);
47
48 int
49 devtimer_valid(devtimer_ref timer);
50
51 void
52 devtimer_retain(devtimer_ref timer);
53
54 void *
55 devtimer_arg0(devtimer_ref timer);
56
57 devtimer_ref
58 devtimer_create(devtimer_process_func process_func, void * arg0);
59
60 void
61 devtimer_invalidate(devtimer_ref timer);
62
63 void
64 devtimer_release(devtimer_ref timer);
65
66 void
67 devtimer_set_absolute(devtimer_ref t,
68 struct timeval abs_time,
69 devtimer_timeout_func func,
70 void * arg1, void * arg2);
71
72 void
73 devtimer_set_relative(devtimer_ref t,
74 struct timeval rel_time,
75 devtimer_timeout_func func,
76 void * arg1, void * arg2);
77 void
78 devtimer_cancel(devtimer_ref t);
79
80 int
81 devtimer_enabled(devtimer_ref t);
82
83 struct timeval
84 devtimer_current_time(void);
85
86 int32_t
87 devtimer_current_secs(void);
88
89 #endif _NET_DEVTIMER_H