diff options
author | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
---|---|---|
committer | stevel@tonic-gate <none@none> | 2005-06-14 00:00:00 -0700 |
commit | 7c478bd95313f5f23a4c958a745db2134aa03244 (patch) | |
tree | c871e58545497667cbb4b0a4f2daf204743e1fe7 /usr/src/lib/libproc/common/pr_pbind.c | |
download | illumos-joyent-7c478bd95313f5f23a4c958a745db2134aa03244.tar.gz |
OpenSolaris Launch
Diffstat (limited to 'usr/src/lib/libproc/common/pr_pbind.c')
-rw-r--r-- | usr/src/lib/libproc/common/pr_pbind.c | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/usr/src/lib/libproc/common/pr_pbind.c b/usr/src/lib/libproc/common/pr_pbind.c new file mode 100644 index 0000000000..1a9f6de689 --- /dev/null +++ b/usr/src/lib/libproc/common/pr_pbind.c @@ -0,0 +1,155 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License, Version 1.0 only + * (the "License"). You may not use this file except in compliance + * with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/types.h> +#include <sys/procset.h> +#include <sys/processor.h> +#include <sys/pset.h> +#include <stdlib.h> +#include <unistd.h> +#include <errno.h> +#include "libproc.h" + +int +pr_processor_bind(struct ps_prochandle *Pr, idtype_t idtype, id_t id, + int processorid, int *obind) +{ + sysret_t rval; /* return value */ + argdes_t argd[4]; /* arg descriptors */ + argdes_t *adp = &argd[0]; /* first argument */ + int error; + + if (Pr == NULL) /* no subject process */ + return (processor_bind(idtype, id, processorid, obind)); + + adp->arg_value = idtype; /* idtype */ + adp->arg_object = NULL; + adp->arg_type = AT_BYVAL; + adp->arg_inout = AI_INPUT; + adp->arg_size = 0; + adp++; + + adp->arg_value = id; /* id */ + adp->arg_object = NULL; + adp->arg_type = AT_BYVAL; + adp->arg_inout = AI_INPUT; + adp->arg_size = 0; + adp++; + + adp->arg_value = processorid; /* processorid */ + adp->arg_object = NULL; + adp->arg_type = AT_BYVAL; + adp->arg_inout = AI_INPUT; + adp->arg_size = 0; + adp++; + + if (obind == NULL) { + adp->arg_value = 0; /* obind */ + adp->arg_object = NULL; + adp->arg_type = AT_BYVAL; + adp->arg_inout = AI_INPUT; + adp->arg_size = 0; + } else { + adp->arg_value = 0; + adp->arg_object = obind; + adp->arg_type = AT_BYREF; + adp->arg_inout = AI_INOUT; + adp->arg_size = sizeof (int); + } + + error = Psyscall(Pr, &rval, SYS_processor_bind, 4, &argd[0]); + + if (error) { + errno = (error < 0)? ENOSYS : error; + return (-1); + } + return (rval.sys_rval1); +} + +int +pr_pset_bind(struct ps_prochandle *Pr, int pset, idtype_t idtype, id_t id, + int *opset) +{ + sysret_t rval; /* return value */ + argdes_t argd[5]; /* arg descriptors */ + argdes_t *adp = &argd[0]; /* first argument */ + int error; + + if (Pr == NULL) /* no subject process */ + return (pset_bind(pset, idtype, id, opset)); + + adp->arg_value = PSET_BIND; /* PSET_BIND */ + adp->arg_object = NULL; + adp->arg_type = AT_BYVAL; + adp->arg_inout = AI_INPUT; + adp->arg_size = 0; + adp++; + + adp->arg_value = pset; /* pset */ + adp->arg_object = NULL; + adp->arg_type = AT_BYVAL; + adp->arg_inout = AI_INPUT; + adp->arg_size = 0; + adp++; + + adp->arg_value = idtype; /* idtype */ + adp->arg_object = NULL; + adp->arg_type = AT_BYVAL; + adp->arg_inout = AI_INPUT; + adp->arg_size = 0; + adp++; + + adp->arg_value = id; /* id */ + adp->arg_object = NULL; + adp->arg_type = AT_BYVAL; + adp->arg_inout = AI_INPUT; + adp->arg_size = 0; + adp++; + + if (opset == NULL) { + adp->arg_value = 0; /* opset */ + adp->arg_object = NULL; + adp->arg_type = AT_BYVAL; + adp->arg_inout = AI_INPUT; + adp->arg_size = 0; + } else { + adp->arg_value = 0; + adp->arg_object = opset; + adp->arg_type = AT_BYREF; + adp->arg_inout = AI_INOUT; + adp->arg_size = sizeof (int); + } + + error = Psyscall(Pr, &rval, SYS_pset, 5, &argd[0]); + + if (error) { + errno = (error < 0)? ENOSYS : error; + return (-1); + } + return (rval.sys_rval1); +} |