1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
14 */
15
16 /*
17 * condvar(9f)
18 */
19
20 /* This is the API we're emulating */
21 #include <sys/condvar.h>
22
23 #include <sys/errno.h>
24 #include <sys/debug.h>
25 #include <sys/thread.h>
26
27 /* avoiding synch.h */
28 int _lwp_cond_wait(lwp_cond_t *, lwp_mutex_t *);
29 int _lwp_cond_timedwait(lwp_cond_t *, lwp_mutex_t *, timespec_t *);
30 int _lwp_cond_reltimedwait(lwp_cond_t *, lwp_mutex_t *, timespec_t *);
31 int _lwp_cond_signal(lwp_cond_t *);
32 int _lwp_cond_broadcast(lwp_cond_t *);
33
101 }
102
103 clock_t
104 cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime)
105 {
106 clock_t delta;
107
108 delta = abstime - ddi_get_lbolt();
109 return (cv__twait(cv, mp, delta, 0));
110 }
111
112 clock_t
113 cv_timedwait_sig(kcondvar_t *cv, kmutex_t *mp, clock_t abstime)
114 {
115 clock_t delta;
116
117 delta = abstime - ddi_get_lbolt();
118 return (cv__twait(cv, mp, delta, 1));
119 }
120
121 clock_t
122 cv_reltimedwait(kcondvar_t *cv, kmutex_t *mp, clock_t delta, time_res_t res)
123 {
124 _NOTE(ARGUNUSED(res))
125
126 return (cv__twait(cv, mp, delta, 0));
127 }
128
129 clock_t
130 cv_reltimedwait_sig(kcondvar_t *cv, kmutex_t *mp, clock_t delta,
131 time_res_t res)
132 {
133 _NOTE(ARGUNUSED(res))
134
135 return (cv__twait(cv, mp, delta, 1));
136 }
137
138 /*
139 * Factored out implementation of all the cv_*timedwait* functions.
140 * Note that the delta passed in is relative to the (simulated)
|
1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
14 * Copyright 2017 RackTop Systems.
15 */
16
17 /*
18 * condvar(9f)
19 */
20
21 /* This is the API we're emulating */
22 #include <sys/condvar.h>
23
24 #include <sys/errno.h>
25 #include <sys/debug.h>
26 #include <sys/thread.h>
27
28 /* avoiding synch.h */
29 int _lwp_cond_wait(lwp_cond_t *, lwp_mutex_t *);
30 int _lwp_cond_timedwait(lwp_cond_t *, lwp_mutex_t *, timespec_t *);
31 int _lwp_cond_reltimedwait(lwp_cond_t *, lwp_mutex_t *, timespec_t *);
32 int _lwp_cond_signal(lwp_cond_t *);
33 int _lwp_cond_broadcast(lwp_cond_t *);
34
102 }
103
104 clock_t
105 cv_timedwait(kcondvar_t *cv, kmutex_t *mp, clock_t abstime)
106 {
107 clock_t delta;
108
109 delta = abstime - ddi_get_lbolt();
110 return (cv__twait(cv, mp, delta, 0));
111 }
112
113 clock_t
114 cv_timedwait_sig(kcondvar_t *cv, kmutex_t *mp, clock_t abstime)
115 {
116 clock_t delta;
117
118 delta = abstime - ddi_get_lbolt();
119 return (cv__twait(cv, mp, delta, 1));
120 }
121
122 /*ARGSUSED*/
123 clock_t
124 cv_timedwait_hires(kcondvar_t *cv, kmutex_t *mp, hrtime_t tim, hrtime_t res,
125 int flag)
126 {
127 clock_t delta;
128
129 delta = tim;
130 if (flag & CALLOUT_FLAG_ABSOLUTE)
131 delta -= gethrtime();
132 return (cv__twait(cv, mp, delta, 0));
133 }
134
135 clock_t
136 cv_reltimedwait(kcondvar_t *cv, kmutex_t *mp, clock_t delta, time_res_t res)
137 {
138 _NOTE(ARGUNUSED(res))
139
140 return (cv__twait(cv, mp, delta, 0));
141 }
142
143 clock_t
144 cv_reltimedwait_sig(kcondvar_t *cv, kmutex_t *mp, clock_t delta,
145 time_res_t res)
146 {
147 _NOTE(ARGUNUSED(res))
148
149 return (cv__twait(cv, mp, delta, 1));
150 }
151
152 /*
153 * Factored out implementation of all the cv_*timedwait* functions.
154 * Note that the delta passed in is relative to the (simulated)
|