[FFmpeg-devel] [PATCH] avutil: use getauxval on linux/android for CPU capabilities
Aman Karmani
ffmpeg at tmm1.net
Fri Feb 4 22:16:21 EET 2022
From: Aman Karmani <aman at tmm1.net>
fixes #6578
Signed-off-by: Aman Karmani <aman at tmm1.net>
---
libavutil/arm/cpu.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/libavutil/arm/cpu.c b/libavutil/arm/cpu.c
index 81e85e2525..983e5a4d83 100644
--- a/libavutil/arm/cpu.c
+++ b/libavutil/arm/cpu.c
@@ -36,6 +36,7 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
+#include <sys/auxv.h>
#include "libavutil/avstring.h"
#define AT_HWCAP 16
@@ -48,6 +49,15 @@
#define HWCAP_VFPv3 (1 << 13)
#define HWCAP_TLS (1 << 15)
+static int get_auxval(uint32_t *hwcap)
+{
+ unsigned long ret = getauxval(AT_HWCAP);
+ if (ret == 0)
+ return -1;
+ *hwcap = ret;
+ return 0;
+}
+
static int get_hwcap(uint32_t *hwcap)
{
struct { uint32_t a_type; uint32_t a_val; } auxv;
@@ -106,9 +116,10 @@ int ff_get_cpu_flags_arm(void)
int flags = CORE_CPU_FLAGS;
uint32_t hwcap;
- if (get_hwcap(&hwcap) < 0)
- if (get_cpuinfo(&hwcap) < 0)
- return flags;
+ if (get_auxval(&hwcap) < 0)
+ if (get_hwcap(&hwcap) < 0)
+ if (get_cpuinfo(&hwcap) < 0)
+ return flags;
#define check_cap(cap, flag) do { \
if (hwcap & HWCAP_ ## cap) \
--
2.33.0
More information about the ffmpeg-devel
mailing list