4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
30 #pragma ident "%Z%%M% %I% %E% SMI"
33 #include <sys/types.h>
34 #include <sys/procset.h>
35 #include <sys/priocntl.h>
40 * The declarations of __priocntlset() and __priocntl() were in prior releases
41 * in <sys/priocntl.h>. They are used to define PC_VERSION at compile time,
42 * based on the contents of the header file. This behavior is now changed.
43 * Old binaries call __priocntl() and __priocntlset() instead of priocntl()
44 * and priocntlset(). New binaries call priocntl() and priocntlset().
48 * defined in priocntlset.s
50 extern long __priocntlset(int, procset_t
*, int, caddr_t
, ...);
52 static int pc_vaargs2parms(va_list valist
, pc_vaparms_t
*vp
);
55 __priocntl(int pc_version
, idtype_t idtype
, id_t id
, int cmd
, caddr_t arg
)
59 setprocset(&procset
, POP_AND
, idtype
, id
, P_ALL
, 0);
61 return (__priocntlset(pc_version
, &procset
, cmd
, arg
, 0));
67 priocntl(idtype_t idtype
, id_t id
, int cmd
, ...)
71 pc_vaparms_t varparms
;
75 setprocset(&procset
, POP_AND
, idtype
, id
, P_ALL
, 0);
77 va_start(valist
, cmd
);
78 arg
= va_arg(valist
, caddr_t
);
80 if (cmd
!= PC_GETXPARMS
&& cmd
!= PC_SETXPARMS
) {
82 return (__priocntlset(PC_VERSION
, &procset
, cmd
, arg
, 0));
85 error
= pc_vaargs2parms(valist
, &varparms
);
93 return (__priocntlset(PC_VERSION
, &procset
, cmd
, arg
, &varparms
));
99 priocntlset(procset_t
*procsetp
, int cmd
, ...)
102 pc_vaparms_t varparms
;
106 va_start(valist
, cmd
);
107 arg
= va_arg(valist
, caddr_t
);
109 if (cmd
!= PC_GETXPARMS
&& cmd
!= PC_SETXPARMS
) {
111 return (__priocntlset(PC_VERSION
, procsetp
, cmd
, arg
, 0));
114 error
= pc_vaargs2parms(valist
, &varparms
);
122 return (__priocntlset(PC_VERSION
, procsetp
, cmd
, arg
, &varparms
));
127 pc_vaargs2parms(va_list valist
, pc_vaparms_t
*vp
)
129 pc_vaparm_t
*vpp
= &vp
->pc_parms
[0];
132 for (vp
->pc_vaparmscnt
= 0;
133 (key
= va_arg(valist
, int)) != PC_KY_NULL
; vpp
++) {
134 if (++vp
->pc_vaparmscnt
> PC_VAPARMCNT
)
138 vpp
->pc_parm
= va_arg(valist
, uintptr_t);