4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1997-2000 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/isa_defs.h>
36 * getitimer() system call -- executed by victim process.
39 pr_getitimer(struct ps_prochandle
*Pr
, int which
, struct itimerval
*itv
)
41 sysret_t rval
; /* return value from getitimer() */
42 argdes_t argd
[2]; /* arg descriptors for getitimer() */
46 int victim32
= (Pstatus(Pr
)->pr_dmodel
== PR_MODEL_ILP32
);
47 struct itimerval32 itimerval32
;
50 if (Pr
== NULL
) /* no victim process */
51 return (getitimer(which
, itv
));
53 adp
= &argd
[0]; /* which argument */
54 adp
->arg_value
= which
;
55 adp
->arg_type
= AT_BYVAL
;
56 adp
->arg_inout
= AI_INPUT
;
57 adp
->arg_object
= NULL
;
60 adp
++; /* itv argument */
62 adp
->arg_type
= AT_BYREF
;
63 adp
->arg_inout
= AI_OUTPUT
;
66 adp
->arg_object
= &itimerval32
;
67 adp
->arg_size
= sizeof (itimerval32
);
69 adp
->arg_object
= itv
;
70 adp
->arg_size
= sizeof (*itv
);
73 adp
->arg_object
= itv
;
74 adp
->arg_size
= sizeof (*itv
);
77 error
= Psyscall(Pr
, &rval
, SYS_getitimer
, 2, &argd
[0]);
80 errno
= (error
> 0)? error
: ENOSYS
;
85 ITIMERVAL32_TO_ITIMERVAL(itv
, &itimerval32
);
88 return (rval
.sys_rval1
);
92 * setitimer() system call -- executed by victim process.
95 pr_setitimer(struct ps_prochandle
*Pr
,
96 int which
, const struct itimerval
*itv
, struct itimerval
*oitv
)
98 sysret_t rval
; /* return value from setitimer() */
99 argdes_t argd
[3]; /* arg descriptors for setitimer() */
103 int victim32
= (Pstatus(Pr
)->pr_dmodel
== PR_MODEL_ILP32
);
104 struct itimerval32 itimerval32
;
105 struct itimerval32 oitimerval32
;
108 if (Pr
== NULL
) /* no victim process */
109 return (setitimer(which
, (struct itimerval
*)itv
, oitv
));
111 adp
= &argd
[0]; /* which argument */
112 adp
->arg_value
= which
;
113 adp
->arg_type
= AT_BYVAL
;
114 adp
->arg_inout
= AI_INPUT
;
115 adp
->arg_object
= NULL
;
118 adp
++; /* itv argument */
120 adp
->arg_type
= AT_BYREF
;
121 adp
->arg_inout
= AI_INPUT
;
124 ITIMERVAL_TO_ITIMERVAL32(&itimerval32
, itv
);
125 adp
->arg_object
= (void *)&itimerval32
;
126 adp
->arg_size
= sizeof (itimerval32
);
128 adp
->arg_object
= (void *)itv
;
129 adp
->arg_size
= sizeof (*itv
);
132 adp
->arg_object
= (void *)itv
;
133 adp
->arg_size
= sizeof (*itv
);
136 adp
++; /* oitv argument */
139 adp
->arg_type
= AT_BYVAL
;
140 adp
->arg_inout
= AI_INPUT
;
141 adp
->arg_object
= NULL
;
144 adp
->arg_type
= AT_BYREF
;
145 adp
->arg_inout
= AI_OUTPUT
;
148 adp
->arg_object
= (void *)&oitimerval32
;
149 adp
->arg_size
= sizeof (oitimerval32
);
151 adp
->arg_object
= oitv
;
152 adp
->arg_size
= sizeof (*oitv
);
155 adp
->arg_object
= oitv
;
156 adp
->arg_size
= sizeof (*oitv
);
160 error
= Psyscall(Pr
, &rval
, SYS_setitimer
, 3, &argd
[0]);
163 errno
= (error
> 0)? error
: ENOSYS
;
167 if (victim32
&& oitv
!= NULL
) {
168 ITIMERVAL32_TO_ITIMERVAL(oitv
, &oitimerval32
);
171 return (rval
.sys_rval1
);