summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_cpuset.c
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2011-05-31 14:18:10 +0000
committerattilio <attilio@FreeBSD.org>2011-05-31 14:18:10 +0000
commitb1bf71d3c513adb3ecd4c1c7f5448ff4e16ace0d (patch)
treec759a44cfd864954c1c16cc322d118053a9ac6e9 /sys/kern/kern_cpuset.c
parent8dd6262cd373f038ccdf8cfe1bb317679fd36c2b (diff)
parentf863f8506b376153bd82f6f80933a3faac1bd48c (diff)
downloadFreeBSD-src-b1bf71d3c513adb3ecd4c1c7f5448ff4e16ace0d.zip
FreeBSD-src-b1bf71d3c513adb3ecd4c1c7f5448ff4e16ace0d.tar.gz
MFC
Diffstat (limited to 'sys/kern/kern_cpuset.c')
-rw-r--r--sys/kern/kern_cpuset.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/sys/kern/kern_cpuset.c b/sys/kern/kern_cpuset.c
index 3b2c653..5ca3be2 100644
--- a/sys/kern/kern_cpuset.c
+++ b/sys/kern/kern_cpuset.c
@@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
#include <sys/cpuset.h>
#include <sys/sx.h>
#include <sys/queue.h>
+#include <sys/libkern.h>
#include <sys/limits.h>
#include <sys/bus.h>
#include <sys/interrupt.h>
@@ -660,6 +661,41 @@ cpusetobj_strprint(char *buf, const cpuset_t *set)
}
/*
+ * Build a valid cpuset_t object from a string representation.
+ * It expects an incoming buffer at least sized as CPUSETBUFSIZ.
+ */
+int
+cpusetobj_strscan(cpuset_t *set, const char *buf)
+{
+ u_int nwords;
+ int i;
+
+ if (strlen(buf) > CPUSETBUFSIZ - 1)
+ return (-1);
+
+ /* Allow to pass a shorter version of the mask when necessary. */
+ nwords = 1;
+ for (i = 0; buf[i] != '\0'; i++)
+ if (buf[i] == ',')
+ nwords++;
+ if (nwords > _NCPUWORDS)
+ return (-1);
+
+ CPU_ZERO(set);
+ for (i = nwords - 1; i > 0; i--) {
+ if (!sscanf(buf, "%lx, ", &set->__bits[i]))
+ return (-1);
+ buf = strstr(buf, " ");
+ if (buf == NULL)
+ return (-1);
+ buf++;
+ }
+ if (!sscanf(buf, "%lx", &set->__bits[0]))
+ return (-1);
+ return (0);
+}
+
+/*
* Apply an anonymous mask to a single thread.
*/
int
OpenPOWER on IntegriCloud