netbsd32_time.c revision 1.39 1 1.39 njoly /* $NetBSD: netbsd32_time.c,v 1.39 2010/03/29 15:34:07 njoly Exp $ */
2 1.1 mrg
3 1.1 mrg /*
4 1.1 mrg * Copyright (c) 1998, 2001 Matthew R. Green
5 1.1 mrg * All rights reserved.
6 1.1 mrg *
7 1.1 mrg * Redistribution and use in source and binary forms, with or without
8 1.1 mrg * modification, are permitted provided that the following conditions
9 1.1 mrg * are met:
10 1.1 mrg * 1. Redistributions of source code must retain the above copyright
11 1.1 mrg * notice, this list of conditions and the following disclaimer.
12 1.1 mrg * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 mrg * notice, this list of conditions and the following disclaimer in the
14 1.1 mrg * documentation and/or other materials provided with the distribution.
15 1.1 mrg *
16 1.1 mrg * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 mrg * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 mrg * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 mrg * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 mrg * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 1.1 mrg * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 1.1 mrg * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 1.1 mrg * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 1.1 mrg * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 mrg * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 mrg * SUCH DAMAGE.
27 1.1 mrg */
28 1.3 lukem
29 1.3 lukem #include <sys/cdefs.h>
30 1.39 njoly __KERNEL_RCSID(0, "$NetBSD: netbsd32_time.c,v 1.39 2010/03/29 15:34:07 njoly Exp $");
31 1.1 mrg
32 1.2 mrg #if defined(_KERNEL_OPT)
33 1.1 mrg #include "opt_ntp.h"
34 1.21 drochner #include "opt_compat_netbsd.h"
35 1.1 mrg #endif
36 1.1 mrg
37 1.1 mrg #include <sys/param.h>
38 1.1 mrg #include <sys/systm.h>
39 1.1 mrg #include <sys/mount.h>
40 1.1 mrg #include <sys/time.h>
41 1.1 mrg #include <sys/timex.h>
42 1.13 cube #include <sys/timevar.h>
43 1.22 kardel #include <sys/timetc.h>
44 1.1 mrg #include <sys/proc.h>
45 1.5 thorpej #include <sys/pool.h>
46 1.1 mrg #include <sys/resourcevar.h>
47 1.12 christos #include <sys/dirent.h>
48 1.20 elad #include <sys/kauth.h>
49 1.1 mrg
50 1.1 mrg #include <compat/netbsd32/netbsd32.h>
51 1.1 mrg #include <compat/netbsd32/netbsd32_syscallargs.h>
52 1.1 mrg #include <compat/netbsd32/netbsd32_conv.h>
53 1.1 mrg
54 1.1 mrg #ifdef NTP
55 1.19 he
56 1.1 mrg int
57 1.35 christos netbsd32___ntp_gettime50(struct lwp *l,
58 1.35 christos const struct netbsd32___ntp_gettime50_args *uap, register_t *retval)
59 1.1 mrg {
60 1.30 dsl /* {
61 1.1 mrg syscallarg(netbsd32_ntptimevalp_t) ntvp;
62 1.30 dsl } */
63 1.1 mrg struct netbsd32_ntptimeval ntv32;
64 1.1 mrg struct ntptimeval ntv;
65 1.1 mrg int error = 0;
66 1.1 mrg
67 1.27 dsl if (SCARG_P32(uap, ntvp)) {
68 1.21 drochner ntp_gettime(&ntv);
69 1.1 mrg
70 1.21 drochner ntv32.time.tv_sec = ntv.time.tv_sec;
71 1.21 drochner ntv32.time.tv_nsec = ntv.time.tv_nsec;
72 1.1 mrg ntv32.maxerror = (netbsd32_long)ntv.maxerror;
73 1.1 mrg ntv32.esterror = (netbsd32_long)ntv.esterror;
74 1.21 drochner ntv32.tai = (netbsd32_long)ntv.tai;
75 1.21 drochner ntv32.time_state = ntv.time_state;
76 1.27 dsl error = copyout(&ntv32, SCARG_P32(uap, ntvp), sizeof(ntv32));
77 1.1 mrg }
78 1.1 mrg if (!error) {
79 1.21 drochner *retval = ntp_timestatus();
80 1.21 drochner }
81 1.1 mrg
82 1.21 drochner return (error);
83 1.21 drochner }
84 1.1 mrg
85 1.35 christos #ifdef COMPAT_50
86 1.35 christos int
87 1.35 christos compat_50_netbsd32_ntp_gettime(struct lwp *l,
88 1.35 christos const struct compat_50_netbsd32_ntp_gettime_args *uap, register_t *retval)
89 1.35 christos {
90 1.35 christos /* {
91 1.35 christos syscallarg(netbsd32_ntptimeval50p_t) ntvp;
92 1.35 christos } */
93 1.35 christos struct netbsd32_ntptimeval50 ntv32;
94 1.35 christos struct ntptimeval ntv;
95 1.35 christos int error = 0;
96 1.35 christos
97 1.35 christos if (SCARG_P32(uap, ntvp)) {
98 1.35 christos ntp_gettime(&ntv);
99 1.35 christos
100 1.35 christos ntv32.time.tv_sec = (int32_t)ntv.time.tv_sec;
101 1.35 christos ntv32.time.tv_nsec = ntv.time.tv_nsec;
102 1.35 christos ntv32.maxerror = (netbsd32_long)ntv.maxerror;
103 1.35 christos ntv32.esterror = (netbsd32_long)ntv.esterror;
104 1.35 christos ntv32.tai = (netbsd32_long)ntv.tai;
105 1.35 christos ntv32.time_state = ntv.time_state;
106 1.35 christos error = copyout(&ntv32, SCARG_P32(uap, ntvp), sizeof(ntv32));
107 1.35 christos }
108 1.35 christos if (!error) {
109 1.35 christos *retval = ntp_timestatus();
110 1.35 christos }
111 1.35 christos
112 1.35 christos return (error);
113 1.35 christos }
114 1.35 christos #endif
115 1.35 christos
116 1.21 drochner #ifdef COMPAT_30
117 1.21 drochner int
118 1.30 dsl compat_30_netbsd32_ntp_gettime(struct lwp *l, const struct compat_30_netbsd32_ntp_gettime_args *uap, register_t *retval)
119 1.21 drochner {
120 1.30 dsl /* {
121 1.21 drochner syscallarg(netbsd32_ntptimevalp_t) ntvp;
122 1.30 dsl } */
123 1.21 drochner struct netbsd32_ntptimeval30 ntv32;
124 1.21 drochner struct ntptimeval ntv;
125 1.21 drochner int error = 0;
126 1.1 mrg
127 1.27 dsl if (SCARG_P32(uap, ntvp)) {
128 1.21 drochner ntp_gettime(&ntv);
129 1.1 mrg
130 1.21 drochner ntv32.time.tv_sec = ntv.time.tv_sec;
131 1.21 drochner ntv32.time.tv_usec = ntv.time.tv_nsec / 1000;
132 1.21 drochner ntv32.maxerror = (netbsd32_long)ntv.maxerror;
133 1.21 drochner ntv32.esterror = (netbsd32_long)ntv.esterror;
134 1.27 dsl error = copyout(&ntv32, SCARG_P32(uap, ntvp), sizeof(ntv32));
135 1.21 drochner }
136 1.21 drochner if (!error) {
137 1.21 drochner *retval = ntp_timestatus();
138 1.1 mrg }
139 1.21 drochner
140 1.1 mrg return (error);
141 1.1 mrg }
142 1.21 drochner #endif
143 1.1 mrg
144 1.1 mrg int
145 1.30 dsl netbsd32_ntp_adjtime(struct lwp *l, const struct netbsd32_ntp_adjtime_args *uap, register_t *retval)
146 1.1 mrg {
147 1.30 dsl /* {
148 1.1 mrg syscallarg(netbsd32_timexp_t) tp;
149 1.30 dsl } */
150 1.1 mrg struct netbsd32_timex ntv32;
151 1.1 mrg struct timex ntv;
152 1.1 mrg int error = 0;
153 1.1 mrg int modes;
154 1.1 mrg
155 1.27 dsl if ((error = copyin(SCARG_P32(uap, tp), &ntv32, sizeof(ntv32))))
156 1.1 mrg return (error);
157 1.22 kardel
158 1.1 mrg netbsd32_to_timex(&ntv32, &ntv);
159 1.1 mrg
160 1.1 mrg /*
161 1.1 mrg * Update selected clock variables - only the superuser can
162 1.1 mrg * change anything. Note that there is no error checking here on
163 1.1 mrg * the assumption the superuser should know what it is doing.
164 1.1 mrg */
165 1.1 mrg modes = ntv.modes;
166 1.24 elad if (modes != 0 && (error = kauth_authorize_system(l->l_cred,
167 1.24 elad KAUTH_SYSTEM_TIME, KAUTH_REQ_SYSTEM_TIME_NTPADJTIME, NULL, NULL,
168 1.24 elad NULL)))
169 1.1 mrg return (error);
170 1.1 mrg
171 1.22 kardel ntp_adjtime1(&ntv);
172 1.1 mrg
173 1.1 mrg netbsd32_from_timex(&ntv, &ntv32);
174 1.27 dsl error = copyout(&ntv32, SCARG_P32(uap, tp), sizeof(ntv32));
175 1.1 mrg if (!error) {
176 1.22 kardel *retval = ntp_timestatus();
177 1.1 mrg }
178 1.1 mrg return error;
179 1.1 mrg }
180 1.21 drochner #endif /* NTP */
181 1.1 mrg
182 1.1 mrg int
183 1.35 christos netbsd32___setitimer50(struct lwp *l, const struct netbsd32___setitimer50_args *uap, register_t *retval)
184 1.1 mrg {
185 1.30 dsl /* {
186 1.1 mrg syscallarg(int) which;
187 1.1 mrg syscallarg(const netbsd32_itimervalp_t) itv;
188 1.1 mrg syscallarg(netbsd32_itimervalp_t) oitv;
189 1.30 dsl } */
190 1.5 thorpej struct proc *p = l->l_proc;
191 1.10 cube struct netbsd32_itimerval s32it, *itv32;
192 1.1 mrg int which = SCARG(uap, which);
193 1.35 christos struct netbsd32___getitimer50_args getargs;
194 1.1 mrg struct itimerval aitv;
195 1.10 cube int error;
196 1.1 mrg
197 1.1 mrg if ((u_int)which > ITIMER_PROF)
198 1.1 mrg return (EINVAL);
199 1.27 dsl itv32 = SCARG_P32(uap, itv);
200 1.10 cube if (itv32) {
201 1.10 cube if ((error = copyin(itv32, &s32it, sizeof(s32it))))
202 1.10 cube return (error);
203 1.10 cube netbsd32_to_itimerval(&s32it, &aitv);
204 1.10 cube }
205 1.26 dsl if (SCARG_P32(uap, oitv) != 0) {
206 1.1 mrg SCARG(&getargs, which) = which;
207 1.1 mrg SCARG(&getargs, itv) = SCARG(uap, oitv);
208 1.35 christos if ((error = netbsd32___getitimer50(l, &getargs, retval)) != 0)
209 1.1 mrg return (error);
210 1.1 mrg }
211 1.10 cube if (itv32 == 0)
212 1.10 cube return 0;
213 1.5 thorpej
214 1.10 cube return dosetitimer(p, which, &aitv);
215 1.1 mrg }
216 1.1 mrg
217 1.1 mrg int
218 1.35 christos netbsd32___getitimer50(struct lwp *l, const struct netbsd32___getitimer50_args *uap, register_t *retval)
219 1.1 mrg {
220 1.30 dsl /* {
221 1.1 mrg syscallarg(int) which;
222 1.1 mrg syscallarg(netbsd32_itimervalp_t) itv;
223 1.30 dsl } */
224 1.5 thorpej struct proc *p = l->l_proc;
225 1.1 mrg struct netbsd32_itimerval s32it;
226 1.1 mrg struct itimerval aitv;
227 1.10 cube int error;
228 1.1 mrg
229 1.10 cube error = dogetitimer(p, SCARG(uap, which), &aitv);
230 1.10 cube if (error)
231 1.10 cube return error;
232 1.5 thorpej
233 1.1 mrg netbsd32_from_itimerval(&aitv, &s32it);
234 1.27 dsl return copyout(&s32it, SCARG_P32(uap, itv), sizeof(s32it));
235 1.1 mrg }
236 1.1 mrg
237 1.1 mrg int
238 1.35 christos netbsd32___gettimeofday50(struct lwp *l, const struct netbsd32___gettimeofday50_args *uap, register_t *retval)
239 1.1 mrg {
240 1.30 dsl /* {
241 1.1 mrg syscallarg(netbsd32_timevalp_t) tp;
242 1.1 mrg syscallarg(netbsd32_timezonep_t) tzp;
243 1.30 dsl } */
244 1.1 mrg struct timeval atv;
245 1.1 mrg struct netbsd32_timeval tv32;
246 1.1 mrg int error = 0;
247 1.1 mrg struct netbsd32_timezone tzfake;
248 1.1 mrg
249 1.26 dsl if (SCARG_P32(uap, tp)) {
250 1.1 mrg microtime(&atv);
251 1.1 mrg netbsd32_from_timeval(&atv, &tv32);
252 1.27 dsl error = copyout(&tv32, SCARG_P32(uap, tp), sizeof(tv32));
253 1.1 mrg if (error)
254 1.1 mrg return (error);
255 1.1 mrg }
256 1.26 dsl if (SCARG_P32(uap, tzp)) {
257 1.1 mrg /*
258 1.1 mrg * NetBSD has no kernel notion of time zone, so we just
259 1.1 mrg * fake up a timezone struct and return it if demanded.
260 1.1 mrg */
261 1.1 mrg tzfake.tz_minuteswest = 0;
262 1.1 mrg tzfake.tz_dsttime = 0;
263 1.27 dsl error = copyout(&tzfake, SCARG_P32(uap, tzp), sizeof(tzfake));
264 1.1 mrg }
265 1.1 mrg return (error);
266 1.1 mrg }
267 1.1 mrg
268 1.1 mrg int
269 1.35 christos netbsd32___settimeofday50(struct lwp *l, const struct netbsd32___settimeofday50_args *uap, register_t *retval)
270 1.1 mrg {
271 1.30 dsl /* {
272 1.1 mrg syscallarg(const netbsd32_timevalp_t) tv;
273 1.1 mrg syscallarg(const netbsd32_timezonep_t) tzp;
274 1.30 dsl } */
275 1.1 mrg struct netbsd32_timeval atv32;
276 1.1 mrg struct timeval atv;
277 1.16 christos struct timespec ats;
278 1.1 mrg int error;
279 1.5 thorpej struct proc *p = l->l_proc;
280 1.1 mrg
281 1.16 christos /* Verify all parameters before changing time. */
282 1.16 christos
283 1.1 mrg /*
284 1.1 mrg * NetBSD has no kernel notion of time zone, and only an
285 1.1 mrg * obsolete program would try to set it, so we log a warning.
286 1.1 mrg */
287 1.26 dsl if (SCARG_P32(uap, tzp))
288 1.1 mrg printf("pid %d attempted to set the "
289 1.8 perry "(obsolete) kernel time zone\n", p->p_pid);
290 1.16 christos
291 1.26 dsl if (SCARG_P32(uap, tv) == 0)
292 1.16 christos return 0;
293 1.16 christos
294 1.27 dsl if ((error = copyin(SCARG_P32(uap, tv), &atv32, sizeof(atv32))) != 0)
295 1.16 christos return error;
296 1.16 christos
297 1.16 christos netbsd32_to_timeval(&atv32, &atv);
298 1.16 christos TIMEVAL_TO_TIMESPEC(&atv, &ats);
299 1.16 christos return settime(p, &ats);
300 1.1 mrg }
301 1.1 mrg
302 1.1 mrg int
303 1.35 christos netbsd32___adjtime50(struct lwp *l, const struct netbsd32___adjtime50_args *uap, register_t *retval)
304 1.1 mrg {
305 1.30 dsl /* {
306 1.1 mrg syscallarg(const netbsd32_timevalp_t) delta;
307 1.1 mrg syscallarg(netbsd32_timevalp_t) olddelta;
308 1.30 dsl } */
309 1.1 mrg struct netbsd32_timeval atv;
310 1.22 kardel int error;
311 1.1 mrg
312 1.32 joerg extern int time_adjusted; /* in kern_ntptime.c */
313 1.32 joerg extern int64_t time_adjtime; /* in kern_ntptime.c */
314 1.32 joerg
315 1.24 elad if ((error = kauth_authorize_system(l->l_cred,
316 1.24 elad KAUTH_SYSTEM_TIME, KAUTH_REQ_SYSTEM_TIME_ADJTIME, NULL, NULL,
317 1.24 elad NULL)) != 0)
318 1.1 mrg return (error);
319 1.23 ad
320 1.32 joerg if (SCARG_P32(uap, olddelta)) {
321 1.32 joerg atv.tv_sec = time_adjtime / 1000000;
322 1.32 joerg atv.tv_usec = time_adjtime % 1000000;
323 1.32 joerg if (atv.tv_usec < 0) {
324 1.32 joerg atv.tv_usec += 1000000;
325 1.32 joerg atv.tv_sec--;
326 1.22 kardel }
327 1.32 joerg (void) copyout(&atv,
328 1.32 joerg SCARG_P32(uap, olddelta),
329 1.32 joerg sizeof(atv));
330 1.32 joerg if (error)
331 1.32 joerg return (error);
332 1.32 joerg }
333 1.22 kardel
334 1.32 joerg if (SCARG_P32(uap, delta)) {
335 1.27 dsl error = copyin(SCARG_P32(uap, delta), &atv,
336 1.22 kardel sizeof(struct timeval));
337 1.22 kardel if (error)
338 1.22 kardel return (error);
339 1.1 mrg
340 1.32 joerg time_adjtime = (int64_t)atv.tv_sec * 1000000 + atv.tv_usec;
341 1.32 joerg
342 1.32 joerg if (time_adjtime)
343 1.32 joerg /* We need to save the system time during shutdown */
344 1.32 joerg time_adjusted |= 1;
345 1.1 mrg }
346 1.32 joerg
347 1.1 mrg return (0);
348 1.1 mrg }
349 1.1 mrg
350 1.1 mrg int
351 1.35 christos netbsd32___clock_gettime50(struct lwp *l, const struct netbsd32___clock_gettime50_args *uap, register_t *retval)
352 1.1 mrg {
353 1.30 dsl /* {
354 1.1 mrg syscallarg(netbsd32_clockid_t) clock_id;
355 1.1 mrg syscallarg(netbsd32_timespecp_t) tp;
356 1.30 dsl } */
357 1.1 mrg clockid_t clock_id;
358 1.1 mrg struct timespec ats;
359 1.1 mrg struct netbsd32_timespec ts32;
360 1.1 mrg
361 1.1 mrg clock_id = SCARG(uap, clock_id);
362 1.1 mrg if (clock_id != CLOCK_REALTIME)
363 1.1 mrg return (EINVAL);
364 1.1 mrg
365 1.14 simonb nanotime(&ats);
366 1.1 mrg netbsd32_from_timespec(&ats, &ts32);
367 1.1 mrg
368 1.27 dsl return copyout(&ts32, SCARG_P32(uap, tp), sizeof(ts32));
369 1.1 mrg }
370 1.1 mrg
371 1.1 mrg int
372 1.35 christos netbsd32___clock_settime50(struct lwp *l, const struct netbsd32___clock_settime50_args *uap, register_t *retval)
373 1.1 mrg {
374 1.30 dsl /* {
375 1.1 mrg syscallarg(netbsd32_clockid_t) clock_id;
376 1.1 mrg syscallarg(const netbsd32_timespecp_t) tp;
377 1.30 dsl } */
378 1.1 mrg struct netbsd32_timespec ts32;
379 1.1 mrg struct timespec ats;
380 1.1 mrg int error;
381 1.1 mrg
382 1.27 dsl if ((error = copyin(SCARG_P32(uap, tp), &ts32, sizeof(ts32))) != 0)
383 1.1 mrg return (error);
384 1.1 mrg
385 1.1 mrg netbsd32_to_timespec(&ts32, &ats);
386 1.39 njoly return clock_settime1(l->l_proc, SCARG(uap, clock_id), &ats, true);
387 1.1 mrg }
388 1.1 mrg
389 1.1 mrg int
390 1.35 christos netbsd32___clock_getres50(struct lwp *l, const struct netbsd32___clock_getres50_args *uap, register_t *retval)
391 1.1 mrg {
392 1.30 dsl /* {
393 1.1 mrg syscallarg(netbsd32_clockid_t) clock_id;
394 1.1 mrg syscallarg(netbsd32_timespecp_t) tp;
395 1.30 dsl } */
396 1.1 mrg struct netbsd32_timespec ts32;
397 1.1 mrg clockid_t clock_id;
398 1.1 mrg struct timespec ts;
399 1.1 mrg int error = 0;
400 1.1 mrg
401 1.1 mrg clock_id = SCARG(uap, clock_id);
402 1.1 mrg if (clock_id != CLOCK_REALTIME)
403 1.1 mrg return (EINVAL);
404 1.1 mrg
405 1.26 dsl if (SCARG_P32(uap, tp)) {
406 1.1 mrg ts.tv_sec = 0;
407 1.1 mrg ts.tv_nsec = 1000000000 / hz;
408 1.1 mrg
409 1.1 mrg netbsd32_from_timespec(&ts, &ts32);
410 1.38 njoly error = copyout(&ts32, SCARG_P32(uap, tp), sizeof(ts32));
411 1.1 mrg }
412 1.1 mrg
413 1.1 mrg return error;
414 1.1 mrg }
415 1.1 mrg
416 1.1 mrg int
417 1.35 christos netbsd32___nanosleep50(struct lwp *l, const struct netbsd32___nanosleep50_args *uap, register_t *retval)
418 1.1 mrg {
419 1.30 dsl /* {
420 1.1 mrg syscallarg(const netbsd32_timespecp_t) rqtp;
421 1.1 mrg syscallarg(netbsd32_timespecp_t) rmtp;
422 1.30 dsl } */
423 1.1 mrg struct netbsd32_timespec ts32;
424 1.37 njoly struct timespec rqt, rmt;
425 1.37 njoly int error, error1;
426 1.1 mrg
427 1.27 dsl error = copyin(SCARG_P32(uap, rqtp), &ts32, sizeof(ts32));
428 1.1 mrg if (error)
429 1.1 mrg return (error);
430 1.1 mrg netbsd32_to_timespec(&ts32, &rqt);
431 1.1 mrg
432 1.37 njoly error = nanosleep1(l, &rqt, SCARG_P32(uap, rmtp) ? &rmt : NULL);
433 1.37 njoly if (SCARG_P32(uap, rmtp) == NULL || (error != 0 && error != EINTR))
434 1.37 njoly return error;
435 1.1 mrg
436 1.37 njoly netbsd32_from_timespec(&rmt, &ts32);
437 1.37 njoly error1 = copyout(&ts32, SCARG_P32(uap,rmtp), sizeof(ts32));
438 1.37 njoly return error1 ? error1 : error;
439 1.1 mrg }
440 1.11 cube
441 1.11 cube static int
442 1.11 cube netbsd32_timer_create_fetch(const void *src, void *dst, size_t size)
443 1.11 cube {
444 1.11 cube struct sigevent *evp = dst;
445 1.11 cube struct netbsd32_sigevent ev32;
446 1.11 cube int error;
447 1.11 cube
448 1.11 cube error = copyin(src, &ev32, sizeof(ev32));
449 1.11 cube if (error)
450 1.11 cube return error;
451 1.11 cube
452 1.11 cube netbsd32_to_sigevent(&ev32, evp);
453 1.11 cube return 0;
454 1.11 cube }
455 1.11 cube
456 1.11 cube int
457 1.30 dsl netbsd32_timer_create(struct lwp *l, const struct netbsd32_timer_create_args *uap, register_t *retval)
458 1.11 cube {
459 1.30 dsl /* {
460 1.11 cube syscallarg(netbsd32_clockid_t) clock_id;
461 1.11 cube syscallarg(netbsd32_sigeventp_t) evp;
462 1.11 cube syscallarg(netbsd32_timerp_t) timerid;
463 1.30 dsl } */
464 1.11 cube
465 1.27 dsl return timer_create1(SCARG_P32(uap, timerid),
466 1.27 dsl SCARG(uap, clock_id), SCARG_P32(uap, evp),
467 1.23 ad netbsd32_timer_create_fetch, l);
468 1.11 cube }
469 1.11 cube
470 1.11 cube int
471 1.30 dsl netbsd32_timer_delete(struct lwp *l, const struct netbsd32_timer_delete_args *uap, register_t *retval)
472 1.11 cube {
473 1.30 dsl /* {
474 1.11 cube syscallarg(netbsd32_timer_t) timerid;
475 1.30 dsl } */
476 1.11 cube struct sys_timer_delete_args ua;
477 1.11 cube
478 1.11 cube NETBSD32TO64_UAP(timerid);
479 1.11 cube return sys_timer_delete(l, (void *)&ua, retval);
480 1.11 cube }
481 1.11 cube
482 1.11 cube int
483 1.35 christos netbsd32___timer_settime50(struct lwp *l, const struct netbsd32___timer_settime50_args *uap, register_t *retval)
484 1.11 cube {
485 1.30 dsl /* {
486 1.11 cube syscallarg(netbsd32_timer_t) timerid;
487 1.11 cube syscallarg(int) flags;
488 1.11 cube syscallarg(const netbsd32_itimerspecp_t) value;
489 1.11 cube syscallarg(netbsd32_itimerspecp_t) ovalue;
490 1.30 dsl } */
491 1.11 cube int error;
492 1.11 cube struct itimerspec value, ovalue, *ovp = NULL;
493 1.11 cube struct netbsd32_itimerspec its32;
494 1.11 cube
495 1.27 dsl if ((error = copyin(SCARG_P32(uap, value), &its32, sizeof(its32))) != 0)
496 1.11 cube return (error);
497 1.11 cube netbsd32_to_timespec(&its32.it_interval, &value.it_interval);
498 1.11 cube netbsd32_to_timespec(&its32.it_value, &value.it_value);
499 1.11 cube
500 1.26 dsl if (SCARG_P32(uap, ovalue))
501 1.11 cube ovp = &ovalue;
502 1.11 cube
503 1.11 cube if ((error = dotimer_settime(SCARG(uap, timerid), &value, ovp,
504 1.11 cube SCARG(uap, flags), l->l_proc)) != 0)
505 1.11 cube return error;
506 1.11 cube
507 1.11 cube if (ovp) {
508 1.11 cube netbsd32_from_timespec(&ovp->it_interval, &its32.it_interval);
509 1.11 cube netbsd32_from_timespec(&ovp->it_value, &its32.it_value);
510 1.27 dsl return copyout(&its32, SCARG_P32(uap, ovalue), sizeof(its32));
511 1.11 cube }
512 1.11 cube return 0;
513 1.11 cube }
514 1.11 cube
515 1.11 cube int
516 1.35 christos netbsd32___timer_gettime50(struct lwp *l, const struct netbsd32___timer_gettime50_args *uap, register_t *retval)
517 1.11 cube {
518 1.30 dsl /* {
519 1.11 cube syscallarg(netbsd32_timer_t) timerid;
520 1.11 cube syscallarg(netbsd32_itimerspecp_t) value;
521 1.30 dsl } */
522 1.11 cube int error;
523 1.11 cube struct itimerspec its;
524 1.11 cube struct netbsd32_itimerspec its32;
525 1.11 cube
526 1.11 cube if ((error = dotimer_gettime(SCARG(uap, timerid), l->l_proc,
527 1.11 cube &its)) != 0)
528 1.11 cube return error;
529 1.11 cube
530 1.11 cube netbsd32_from_timespec(&its.it_interval, &its32.it_interval);
531 1.11 cube netbsd32_from_timespec(&its.it_value, &its32.it_value);
532 1.11 cube
533 1.27 dsl return copyout(&its32, SCARG_P32(uap, value), sizeof(its32));
534 1.11 cube }
535 1.11 cube
536 1.11 cube int
537 1.30 dsl netbsd32_timer_getoverrun(struct lwp *l, const struct netbsd32_timer_getoverrun_args *uap, register_t *retval)
538 1.11 cube {
539 1.30 dsl /* {
540 1.11 cube syscallarg(netbsd32_timer_t) timerid;
541 1.30 dsl } */
542 1.11 cube struct sys_timer_getoverrun_args ua;
543 1.11 cube
544 1.11 cube NETBSD32TO64_UAP(timerid);
545 1.11 cube return sys_timer_getoverrun(l, (void *)&ua, retval);
546 1.11 cube }
547