// SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2023 Ventana Micro Systems Inc. * * Test the RISCV_HWPROBE_WHICH_CPUS flag of hwprobe. Also provides a command * line interface to get the cpu list for arbitrary hwprobe pairs.
*/ #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sched.h> #include <unistd.h> #include <assert.h>
#include"hwprobe.h" #include"../../kselftest.h"
staticvoid help(void)
{
printf("\n" "which-cpus: [-h] [ [ ...]]\n\n" " Without parameters, tests the RISCV_HWPROBE_WHICH_CPUS flag of hwprobe.\n" " With parameters, where each parameter is a hwprobe pair written as\n" " , outputs the cpulist for cpus which all match the given set\n" " of pairs. 'key' and 'value' should be in numeric form, e.g. 4=0x3b\n");
}
staticvoid print_cpulist(cpu_set_t *cpus)
{ int start = 0, end = 0;
if (!CPU_COUNT(cpus)) {
printf("cpus: None\n"); return;
}
printf("cpus:"); for (int i = 0, c = 0; i < CPU_COUNT(cpus); i++, c++) { if (start != end && !CPU_ISSET(c, cpus))
printf("-%d", end);
while (!CPU_ISSET(c, cpus))
++c;
if (i != 0 && c == end + 1) {
end = c; continue;
}
printf("%c%d", i == 0 ? ' ' : ',', c);
start = end = c;
} if (start != end)
printf("-%d", end);
printf("\n");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.