Christian Weisgerber:

> I have attached a patch by Jeremie Courreges-Anglas which adds
> proper autoconf checks to detect <sys/auxv.h> and getauxval().  This
> could be extended to cover elf_aux_info().

And here's the version that covers both getauxval() and elf_aux_info().
Attached.

-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de
--- configure.ac.orig   2019-08-04 08:26:40 UTC
+++ configure.ac
@@ -69,7 +69,7 @@ AC_C_INLINE
 AC_C_VARARRAYS
 AC_C_TYPEOF
 
-AC_CHECK_HEADERS([stdint.h inttypes.h byteswap.h sys/param.h sys/ioctl.h 
termios.h x86intrin.h cpuid.h])
+AC_CHECK_HEADERS([stdint.h inttypes.h byteswap.h sys/param.h sys/ioctl.h 
termios.h x86intrin.h cpuid.h sys/auxv.h])
 
 XIPH_C_BSWAP32
 XIPH_C_BSWAP16
@@ -104,6 +104,8 @@ AC_CHECK_TYPES(socklen_t, [], [])
 dnl check for getopt in standard library
 dnl AC_CHECK_FUNCS(getopt_long , , [LIBOBJS="$LIBOBJS getopt.o getopt1.o"] )
 AC_CHECK_FUNCS(getopt_long, [], [])
+
+AC_CHECK_FUNCS([getauxval elf_aux_info])
 
 AC_CHECK_SIZEOF(void*,1)
 
--- src/libFLAC/cpu.c.orig      2018-08-20 08:17:21 UTC
+++ src/libFLAC/cpu.c
@@ -53,7 +53,7 @@
 #define dfprintf(file, format, ...)
 #endif
 
-#if defined FLAC__CPU_PPC
+#if defined(HAVE_SYS_AUXV_H)
 #include <sys/auxv.h>
 #endif
 
@@ -236,7 +236,10 @@ x86_cpu_info (FLAC__CPUInfo *info)
 static void
 ppc_cpu_info (FLAC__CPUInfo *info)
 {
-#if defined FLAC__CPU_PPC
+       info->ppc.arch_2_07 = false;
+       info->ppc.arch_3_00 = false;
+
+#if defined(FLAC__CPU_PPC)
 #ifndef PPC_FEATURE2_ARCH_3_00
 #define PPC_FEATURE2_ARCH_3_00         0x00800000
 #endif
@@ -245,14 +248,21 @@ ppc_cpu_info (FLAC__CPUInfo *info)
 #define PPC_FEATURE2_ARCH_2_07         0x80000000
 #endif
 
+#if defined(HAVE_GETAUXVAL)
        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;
        }
-#else
-       info->ppc.arch_2_07 = false;
-       info->ppc.arch_3_00 = false;
+#elif defined(HAVE_ELF_AUX_INFO)
+       long hwcaps;
+       elf_aux_info(AT_HWCAP2, &hwcaps, sizeof(hwcaps));
+       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;
+       }
+#endif
 #endif
 }
 
_______________________________________________
flac-dev mailing list
flac-dev@xiph.org
http://lists.xiph.org/mailman/listinfo/flac-dev

Reply via email to