kernel: remove oldsigevent compatibility code
[unleashed.git] / include / sys / timer.h
bloba6fb37b3f6b9b85afb4788fc73d41bc1d100617e
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 * Copyright (c) 2015, Joyent, Inc. All rights reserved.
31 #ifndef _SYS_TIMER_H
32 #define _SYS_TIMER_H
34 #include <sys/types.h>
35 #include <sys/proc.h>
36 #include <sys/thread.h>
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
42 #ifdef _KERNEL
44 #define _TIMER_MAX 32
45 extern int timer_max; /* patchable via /etc/system */
48 * Bit values for the it_lock field.
50 #define ITLK_LOCKED 0x01
51 #define ITLK_WANTED 0x02
52 #define ITLK_REMOVE 0x04
55 * Bit values for the it_flags field.
57 #define IT_SIGNAL 0x01
58 #define IT_PORT 0x02 /* use event port notification */
60 struct clock_backend;
62 struct itimer;
63 typedef struct itimer itimer_t;
65 struct itimer {
66 itimerspec_t it_itime;
67 hrtime_t it_hrtime;
68 ushort_t it_flags;
69 ushort_t it_lock;
70 void *it_arg; /* clock backend-specific data */
71 struct proc *it_proc;
72 union {
73 struct {
74 sigqueue_t *__it_sigq;
75 klwp_t *__it_lwp;
76 } __proc;
77 void *__it_frontend;
78 } __data; /* timer frontend-specific data */
79 kcondvar_t it_cv;
80 int it_blockers;
81 int it_pending;
82 int it_overrun;
83 struct clock_backend *it_backend;
84 void (*it_fire)(itimer_t *);
85 kmutex_t it_mutex;
86 void *it_portev; /* port_kevent_t pointer */
87 void *it_portsrc; /* port_source_t pointer */
88 int it_portfd; /* port file descriptor */
91 #define it_sigq __data.__proc.__it_sigq
92 #define it_lwp __data.__proc.__it_lwp
93 #define it_frontend __data.__it_frontend
95 typedef struct clock_backend {
96 struct sigevent clk_default;
97 int (*clk_clock_settime)(timespec_t *);
98 int (*clk_clock_gettime)(timespec_t *);
99 int (*clk_clock_getres)(timespec_t *);
100 int (*clk_timer_create)(itimer_t *, void (*)(itimer_t *));
101 int (*clk_timer_settime)(itimer_t *, int, const struct itimerspec *);
102 int (*clk_timer_gettime)(itimer_t *, struct itimerspec *);
103 int (*clk_timer_delete)(itimer_t *);
104 void (*clk_timer_lwpbind)(itimer_t *);
105 } clock_backend_t;
107 extern void clock_add_backend(clockid_t clock, clock_backend_t *backend);
108 extern clock_backend_t *clock_get_backend(clockid_t clock);
110 extern void timer_lwpbind();
112 extern void timer_func(sigqueue_t *);
113 extern void timer_exit(void);
114 extern void timer_lwpexit(void);
115 extern clock_t hzto(struct timeval *);
116 extern clock_t timespectohz(timespec_t *, timespec_t);
117 extern int64_t timespectohz64(timespec_t *);
118 extern int itimerspecfix(timespec_t *);
119 extern void timespecadd(timespec_t *, timespec_t *);
120 extern void timespecsub(timespec_t *, timespec_t *);
121 extern void timespecfix(timespec_t *);
122 extern int xgetitimer(uint_t, struct itimerval *, int);
123 extern int xsetitimer(uint_t, struct itimerval *, int);
124 extern void delete_itimer_realprof(void);
126 #define timerspecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec)
127 #define timerspeccmp(tvp, uvp) (((tvp)->tv_sec - (uvp)->tv_sec) ? \
128 ((tvp)->tv_sec - (uvp)->tv_sec):((tvp)->tv_nsec - (uvp)->tv_nsec))
129 #define timerspecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0)
131 #endif /* _KERNEL */
133 #ifdef __cplusplus
135 #endif
137 #endif /* _SYS_TIMER_H */