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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_TIMER_H
#define _SYS_TIMER_H
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/types.h>
#include <sys/proc.h>
#include <sys/thread.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _KERNEL
#define _TIMER_MAX 32
/*
* Bit values for the it_lock field.
*/
#define ITLK_LOCKED 0x01
#define ITLK_WANTED 0x02
#define ITLK_REMOVE 0x04
/*
* Bit values for the it_flags field.
*/
#define IT_SIGNAL 0x01
#define IT_PORT 0x02 /* use event port notification */
struct clock_backend;
typedef struct itimer {
itimerspec_t it_itime;
hrtime_t it_hrtime;
ushort_t it_flags;
ushort_t it_lock;
void *it_arg;
sigqueue_t *it_sigq;
klwp_t *it_lwp;
struct proc *it_proc;
kcondvar_t it_cv;
int it_blockers;
int it_pending;
int it_overrun;
struct clock_backend *it_backend;
kmutex_t it_mutex;
void *it_portev; /* port_kevent_t pointer */
void *it_portsrc; /* port_source_t pointer */
int it_portfd; /* port file descriptor */
} itimer_t;
typedef struct clock_backend {
struct sigevent clk_default;
int (*clk_clock_settime)(timespec_t *);
int (*clk_clock_gettime)(timespec_t *);
int (*clk_clock_getres)(timespec_t *);
int (*clk_timer_create)(itimer_t *, struct sigevent *);
int (*clk_timer_settime)(itimer_t *, int, const struct itimerspec *);
int (*clk_timer_gettime)(itimer_t *, struct itimerspec *);
int (*clk_timer_delete)(itimer_t *);
void (*clk_timer_lwpbind)(itimer_t *);
} clock_backend_t;
extern void clock_add_backend(clockid_t clock, clock_backend_t *backend);
extern void timer_fire(itimer_t *);
extern void timer_lwpbind();
extern void timer_func(sigqueue_t *);
extern void timer_exit(void);
extern void timer_lwpexit(void);
extern clock_t hzto(struct timeval *);
extern clock_t timespectohz(timespec_t *, timespec_t);
extern clock_t timespectohz_adj(timespec_t *, timespec_t);
extern int itimerspecfix(timespec_t *);
extern void timespecadd(timespec_t *, timespec_t *);
extern void timespecsub(timespec_t *, timespec_t *);
extern void timespecfix(timespec_t *);
extern int xgetitimer(uint_t, struct itimerval *, int);
extern int xsetitimer(uint_t, struct itimerval *, int);
#define timerspecisset(tvp) ((tvp)->tv_sec || (tvp)->tv_nsec)
#define timerspeccmp(tvp, uvp) (((tvp)->tv_sec - (uvp)->tv_sec) ? \
((tvp)->tv_sec - (uvp)->tv_sec):((tvp)->tv_nsec - (uvp)->tv_nsec))
#define timerspecclear(tvp) ((tvp)->tv_sec = (tvp)->tv_nsec = 0)
struct oldsigevent {
/* structure definition prior to notification attributes member */
int _notify;
union {
int _signo;
void (*_notify_function)(union sigval);
} _un;
union sigval _value;
};
#if defined(_SYSCALL32)
struct oldsigevent32 {
int32_t _notify;
union {
int32_t _signo;
caddr32_t _notify_function;
} _un;
union sigval32 _value;
};
#endif /* _SYSCALL32 */
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_TIMER_H */
|