xref: /onnv-gate/usr/src/lib/libproc/common/pr_pbind.c (revision 10089:3b42b78e6a26)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*10089SSurya.Prakki@Sun.COM  * Common Development and Distribution License (the "License").
6*10089SSurya.Prakki@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*10089SSurya.Prakki@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #include <sys/types.h>
270Sstevel@tonic-gate #include <sys/procset.h>
280Sstevel@tonic-gate #include <sys/processor.h>
290Sstevel@tonic-gate #include <sys/pset.h>
300Sstevel@tonic-gate #include <stdlib.h>
310Sstevel@tonic-gate #include <unistd.h>
320Sstevel@tonic-gate #include <errno.h>
330Sstevel@tonic-gate #include "libproc.h"
340Sstevel@tonic-gate 
350Sstevel@tonic-gate int
pr_processor_bind(struct ps_prochandle * Pr,idtype_t idtype,id_t id,int processorid,int * obind)360Sstevel@tonic-gate pr_processor_bind(struct ps_prochandle *Pr, idtype_t idtype, id_t id,
370Sstevel@tonic-gate     int processorid, int *obind)
380Sstevel@tonic-gate {
390Sstevel@tonic-gate 	sysret_t rval;			/* return value */
400Sstevel@tonic-gate 	argdes_t argd[4];		/* arg descriptors */
410Sstevel@tonic-gate 	argdes_t *adp = &argd[0];	/* first argument */
420Sstevel@tonic-gate 	int error;
430Sstevel@tonic-gate 
440Sstevel@tonic-gate 	if (Pr == NULL)		/* no subject process */
450Sstevel@tonic-gate 		return (processor_bind(idtype, id, processorid, obind));
460Sstevel@tonic-gate 
470Sstevel@tonic-gate 	adp->arg_value = idtype;	/* idtype */
480Sstevel@tonic-gate 	adp->arg_object = NULL;
490Sstevel@tonic-gate 	adp->arg_type = AT_BYVAL;
500Sstevel@tonic-gate 	adp->arg_inout = AI_INPUT;
510Sstevel@tonic-gate 	adp->arg_size = 0;
520Sstevel@tonic-gate 	adp++;
530Sstevel@tonic-gate 
540Sstevel@tonic-gate 	adp->arg_value = id;		/* id */
550Sstevel@tonic-gate 	adp->arg_object = NULL;
560Sstevel@tonic-gate 	adp->arg_type = AT_BYVAL;
570Sstevel@tonic-gate 	adp->arg_inout = AI_INPUT;
580Sstevel@tonic-gate 	adp->arg_size = 0;
590Sstevel@tonic-gate 	adp++;
600Sstevel@tonic-gate 
610Sstevel@tonic-gate 	adp->arg_value = processorid;	/* processorid */
620Sstevel@tonic-gate 	adp->arg_object = NULL;
630Sstevel@tonic-gate 	adp->arg_type = AT_BYVAL;
640Sstevel@tonic-gate 	adp->arg_inout = AI_INPUT;
650Sstevel@tonic-gate 	adp->arg_size = 0;
660Sstevel@tonic-gate 	adp++;
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 	if (obind == NULL) {
690Sstevel@tonic-gate 		adp->arg_value = 0;	/* obind */
700Sstevel@tonic-gate 		adp->arg_object = NULL;
710Sstevel@tonic-gate 		adp->arg_type = AT_BYVAL;
720Sstevel@tonic-gate 		adp->arg_inout = AI_INPUT;
730Sstevel@tonic-gate 		adp->arg_size = 0;
740Sstevel@tonic-gate 	} else {
750Sstevel@tonic-gate 		adp->arg_value = 0;
760Sstevel@tonic-gate 		adp->arg_object = obind;
770Sstevel@tonic-gate 		adp->arg_type = AT_BYREF;
780Sstevel@tonic-gate 		adp->arg_inout = AI_INOUT;
790Sstevel@tonic-gate 		adp->arg_size = sizeof (int);
800Sstevel@tonic-gate 	}
810Sstevel@tonic-gate 
820Sstevel@tonic-gate 	error = Psyscall(Pr, &rval, SYS_processor_bind, 4, &argd[0]);
830Sstevel@tonic-gate 
840Sstevel@tonic-gate 	if (error) {
850Sstevel@tonic-gate 		errno = (error < 0)? ENOSYS : error;
860Sstevel@tonic-gate 		return (-1);
870Sstevel@tonic-gate 	}
880Sstevel@tonic-gate 	return (rval.sys_rval1);
890Sstevel@tonic-gate }
90