]>
git.proxmox.com Git - mirror_lxcfs.git/blob - cpuset.c
7 * Helper functions for cpuset_in-set
9 static char *cpuset_nexttok(const char *c
)
11 char *r
= strchr(c
+1, ',');
17 static int cpuset_getrange(const char *c
, int *a
, int *b
)
21 ret
= sscanf(c
, "%d-%d", a
, b
);
26 * cpusets are in format "1,2-3,4"
27 * iow, comma-delimited ranges
29 bool cpu_in_cpuset(int cpu
, const char *cpuset
)
33 for (c
= cpuset
; c
; c
= cpuset_nexttok(c
)) {
36 ret
= cpuset_getrange(c
, &a
, &b
);
37 if (ret
== 1 && cpu
== a
) // "1" or "1,6"
39 else if (ret
== 2 && cpu
>= a
&& cpu
<= b
) // range match