Fix build on FreeBSD PowerPC

Used the elf_aux_info function on FreeBSD and clarify that users of other
systems need to implement reading from AT_HWCAP2.
This commit is contained in:
pkubaj 2019-08-15 10:27:19 +00:00 committed by Erik de Castro Lopo
parent 88ddb5b59e
commit 5db5820932

View File

@ -245,11 +245,24 @@ ppc_cpu_info (FLAC__CPUInfo *info)
#define PPC_FEATURE2_ARCH_2_07 0x80000000
#endif
#ifdef __linux__
if (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_3_00) {
info->ppc.arch_3_00 = true;
} else if (getauxval(AT_HWCAP2) & PPC_FEATURE2_ARCH_2_07) {
info->ppc.arch_2_07 = true;
}
#elif defined(__FreeBSD__)
long hwcaps;
elf_aux_info(AT_HWCAP2, &hwcaps, sizeof(hwcaps));
#else
#error Unsupported platform! Please add support for reading ppc hwcaps.
#endif
if (hwcaps & PPC_FEATURE2_ARCH_3_00) {
info->ppc.arch_3_00 = true;
} else if (hwcaps & PPC_FEATURE2_ARCH_2_07) {
info->ppc.arch_2_07 = true;
}
#else
info->ppc.arch_2_07 = false;
info->ppc.arch_3_00 = false;