Fix build on FreeBSD PowerPC
authorpkubaj <pkubaj@users.noreply.github.com>
Thu, 15 Aug 2019 10:27:19 +0000 (10:27 +0000)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Sun, 18 Aug 2019 00:44:15 +0000 (10:44 +1000)
Used the elf_aux_info function on FreeBSD and clarify that users of other
systems need to implement reading from AT_HWCAP2.

src/libFLAC/cpu.c

index 64da9cb..c90b899 100644 (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;