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