* [FFmpeg-devel] [PATCH v2] avutil: use getauxval for CPU capabilities on linux/android ARM
@ 2022-02-05 6:10 Aman Karmani
0 siblings, 0 replies; only message in thread
From: Aman Karmani @ 2022-02-05 6:10 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: martin, Aman Karmani
From: Aman Karmani <aman@tmm1.net>
getauxval is faster, and works when procfs is not mounted
note that support on Android was added in 4.4 (API 20)
fixes #6578
Signed-off-by: Aman Karmani <aman@tmm1.net>
---
configure | 1 +
libavutil/arm/cpu.c | 24 +++++++++++++++++++++---
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 5b19a35f59..d21cfb4cbd 100755
--- a/configure
+++ b/configure
@@ -6265,6 +6265,7 @@ check_func_headers lzo/lzo1x.h lzo1x_999_compress
check_func_headers mach/mach_time.h mach_absolute_time
check_func_headers stdlib.h getenv
check_func_headers sys/stat.h lstat
+check_func_headers sys/auxv.h getauxval
check_func_headers windows.h GetModuleHandle
check_func_headers windows.h GetProcessAffinityMask
diff --git a/libavutil/arm/cpu.c b/libavutil/arm/cpu.c
index 81e85e2525..c84a655c37 100644
--- a/libavutil/arm/cpu.c
+++ b/libavutil/arm/cpu.c
@@ -38,6 +38,10 @@
#include <string.h>
#include "libavutil/avstring.h"
+#if HAVE_GETAUXVAL
+#include <sys/auxv.h>
+#endif
+
#define AT_HWCAP 16
/* Relevant HWCAP values from kernel headers */
@@ -48,6 +52,19 @@
#define HWCAP_VFPv3 (1 << 13)
#define HWCAP_TLS (1 << 15)
+static int get_auxval(uint32_t *hwcap)
+{
+#if HAVE_GETAUXVAL
+ unsigned long ret = getauxval(AT_HWCAP);
+ if (ret == 0)
+ return -1;
+ *hwcap = ret;
+ return 0;
+#else
+ return -1;
+#endif
+}
+
static int get_hwcap(uint32_t *hwcap)
{
struct { uint32_t a_type; uint32_t a_val; } auxv;
@@ -106,9 +123,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
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-02-05 6:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-05 6:10 [FFmpeg-devel] [PATCH v2] avutil: use getauxval for CPU capabilities on linux/android ARM Aman Karmani
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git