12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include <stdlib.h>
- #include <sched.h>
- #include "common-cpu.h"
- #include "common-logging.h"
- char *parse_cpulist(char *cpulist, long *from, long *to)
- {
- if (!cpulist || *cpulist == '\0')
- return NULL;
- char *endp;
- *from = strtol(cpulist, &endp, 10);
- if (endp == cpulist)
- return NULL;
- if (*endp == '\0' || *endp == ',') {
- *to = *from;
- if (*endp == '\0')
- return endp;
- return endp + 1;
- }
- if (*endp != '-')
- return NULL;
- cpulist = endp + 1;
- *to = strtol(cpulist, &endp, 10);
- if (endp == cpulist)
- return NULL;
- if (*to < *from)
- return NULL;
- if (*endp == '\0')
- return endp;
- return endp + 1;
- }
|