1 /* $NetBSD: osf1_time.c,v 1.15 2007/12/08 18:36:22 dsl Exp $ */
4 * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 * This product includes software developed by Christopher G. Demetriou
17 * for the NetBSD Project.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/cdefs.h>
34 __KERNEL_RCSID(0, "$NetBSD: osf1_time.c,v 1.15 2007/12/08 18:36:22 dsl Exp $");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/namei.h>
41 #include <sys/mount.h>
42 #include <sys/syscallargs.h>
44 #include <compat/osf1/osf1.h>
45 #include <compat/osf1/osf1_syscallargs.h>
46 #include <compat/osf1/osf1_cvt.h>
49 osf1_sys_gettimeofday(struct lwp
*l
, const struct osf1_sys_gettimeofday_args
*uap
, register_t
*retval
)
51 struct osf1_timeval otv
;
52 struct osf1_timezone otz
;
57 memset(&otv
, 0, sizeof otv
);
58 otv
.tv_sec
= tv
.tv_sec
;
59 otv
.tv_usec
= tv
.tv_usec
;
60 error
= copyout(&otv
, SCARG(uap
, tp
), sizeof otv
);
62 if (error
== 0 && SCARG(uap
, tzp
) != NULL
) {
63 memset(&otz
, 0, sizeof otz
);
64 error
= copyout(&otz
, SCARG(uap
, tzp
), sizeof otz
);
70 osf1_sys_setitimer(struct lwp
*l
, const struct osf1_sys_setitimer_args
*uap
, register_t
*retval
)
72 struct osf1_itimerval o_itv
, o_oitv
;
73 struct itimerval b_itv
, b_oitv
;
77 switch (SCARG(uap
, which
)) {
78 case OSF1_ITIMER_REAL
:
82 case OSF1_ITIMER_VIRTUAL
:
83 which
= ITIMER_VIRTUAL
;
86 case OSF1_ITIMER_PROF
:
94 /* get the OSF/1 itimerval argument */
95 error
= copyin(SCARG(uap
, itv
), &o_itv
, sizeof o_itv
);
99 /* fill in and the NetBSD timeval */
100 memset(&b_itv
, 0, sizeof b_itv
);
101 b_itv
.it_interval
.tv_sec
= o_itv
.it_interval
.tv_sec
;
102 b_itv
.it_interval
.tv_usec
= o_itv
.it_interval
.tv_usec
;
103 b_itv
.it_value
.tv_sec
= o_itv
.it_value
.tv_sec
;
104 b_itv
.it_value
.tv_usec
= o_itv
.it_value
.tv_usec
;
106 if (SCARG(uap
, oitv
) != NULL
) {
107 dogetitimer(l
->l_proc
, which
, &b_oitv
);
112 error
= dosetitimer(l
->l_proc
, which
, &b_itv
);
114 if (error
== 0 || SCARG(uap
, oitv
) == NULL
)
117 /* fill in and copy out the old timeval */
118 memset(&o_oitv
, 0, sizeof o_oitv
);
119 o_oitv
.it_interval
.tv_sec
= b_oitv
.it_interval
.tv_sec
;
120 o_oitv
.it_interval
.tv_usec
= b_oitv
.it_interval
.tv_usec
;
121 o_oitv
.it_value
.tv_sec
= b_oitv
.it_value
.tv_sec
;
122 o_oitv
.it_value
.tv_usec
= b_oitv
.it_value
.tv_usec
;
124 return copyout(&o_oitv
, SCARG(uap
, oitv
), sizeof o_oitv
);
128 osf1_sys_getitimer(struct lwp
*l
, const struct osf1_sys_getitimer_args
*uap
, register_t
*retval
)
130 struct osf1_itimerval o_oitv
;
131 struct itimerval b_oitv
;
135 switch (SCARG(uap
, which
)) {
136 case OSF1_ITIMER_REAL
:
139 case OSF1_ITIMER_VIRTUAL
:
140 which
= ITIMER_VIRTUAL
;
142 case OSF1_ITIMER_PROF
:
149 error
= dogetitimer(l
->l_proc
, which
, &b_oitv
);
150 if (error
!= 0 || SCARG(uap
, itv
) == NULL
)
153 /* fill in and copy out the osf1 timeval */
154 memset(&o_oitv
, 0, sizeof o_oitv
);
155 o_oitv
.it_interval
.tv_sec
= b_oitv
.it_interval
.tv_sec
;
156 o_oitv
.it_interval
.tv_usec
= b_oitv
.it_interval
.tv_usec
;
157 o_oitv
.it_value
.tv_sec
= b_oitv
.it_value
.tv_sec
;
158 o_oitv
.it_value
.tv_usec
= b_oitv
.it_value
.tv_usec
;
159 return copyout(&o_oitv
, SCARG(uap
, itv
), sizeof o_oitv
);
163 osf1_sys_settimeofday(struct lwp
*l
, const struct osf1_sys_settimeofday_args
*uap
, register_t
*retval
)
165 struct osf1_timeval otv
;
166 struct timeval tv
, *tvp
;
169 if (SCARG(uap
, tv
) == NULL
)
172 /* get the OSF/1 timeval argument */
173 error
= copyin(SCARG(uap
, tv
), &otv
, sizeof otv
);
177 tv
.tv_sec
= otv
.tv_sec
;
178 tv
.tv_usec
= otv
.tv_usec
;
182 /* NetBSD ignores the timezone field */
184 return settimeofday1(tvp
, false, (const void *)SCARG(uap
, tzp
), l
, true);