+unsigned qtest_get_arch_bits(void)
+{
+ static const char *const arch64[] = {
+ "aarch64", "hppa", "x86_64", "loongarch64", "mips64",
+ "mips64el", "ppc64", "riscv64", "s390x", "sparc64",
+ };
+ const char *arch = qtest_get_arch();
+
+ if (!strcmp(arch, "avr")) {
Just a matter of taste, but I prefer g_str_equal(), that's easier to read.
+ return 8;
+ }
+
+ for (unsigned i = 0; i < ARRAY_SIZE(arch64); i++) {
+ if (!strcmp(arch, arch64[i])) {
+ return 64;
+ }
+ }
+
+ return 32;
+}
Since this function might get called multiple times, would it make sense
to cache the value? I.e.:
static const unsigned bits;
if (!bits) {
... do all the magic to find out the right bits ...
}
return bits;
?