|
|
|
@ -299,10 +299,28 @@ static std::vector<size_t> parse_hartids(const char *s) |
|
|
|
|
|
|
|
int n; |
|
|
|
while (stream >> n) { |
|
|
|
if (n < 0) { |
|
|
|
fprintf(stderr, "Negative hart ID %d is unsupported\n", n); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
|
|
|
|
hartids.push_back(n); |
|
|
|
if (stream.peek() == ',') stream.ignore(); |
|
|
|
} |
|
|
|
|
|
|
|
if (hartids.empty()) { |
|
|
|
fprintf(stderr, "No hart IDs specified\n"); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
|
|
|
|
std::sort(hartids.begin(), hartids.end()); |
|
|
|
|
|
|
|
const auto dup = std::adjacent_find(hartids.begin(), hartids.end()); |
|
|
|
if (dup != hartids.end()) { |
|
|
|
fprintf(stderr, "Duplicate hart ID %zu\n", *dup); |
|
|
|
exit(-1); |
|
|
|
} |
|
|
|
|
|
|
|
return hartids; |
|
|
|
} |
|
|
|
|
|
|
|
|