diff --git a/libavutil/aarch64/cpu.c b/libavutil/aarch64/cpu.c index cfa9306663..084c81e999 100644 --- a/libavutil/aarch64/cpu.c +++ b/libavutil/aarch64/cpu.c @@ -31,8 +31,8 @@ static int detect_flags(void) { int flags = 0; - unsigned long hwcap = getauxval(AT_HWCAP); - unsigned long hwcap2 = getauxval(AT_HWCAP2); + unsigned long hwcap = ff_getauxval(AT_HWCAP); + unsigned long hwcap2 = ff_getauxval(AT_HWCAP2); if (hwcap & HWCAP_AARCH64_ASIMDDP) flags |= AV_CPU_FLAG_DOTPROD; diff --git a/libavutil/arm/cpu.c b/libavutil/arm/cpu.c index c84a655c37..b84882005a 100644 --- a/libavutil/arm/cpu.c +++ b/libavutil/arm/cpu.c @@ -55,7 +55,7 @@ static int get_auxval(uint32_t *hwcap) { #if HAVE_GETAUXVAL - unsigned long ret = getauxval(AT_HWCAP); + unsigned long ret = ff_getauxval(AT_HWCAP); if (ret == 0) return -1; *hwcap = ret; diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 41cee7fa77..61c1cf3faf 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -49,6 +49,10 @@ #include #endif +#if HAVE_GETAUXVAL +#include +#endif + static atomic_int cpu_flags = -1; static atomic_int cpu_count = -1; @@ -283,3 +287,13 @@ size_t av_cpu_max_align(void) return 8; } + +unsigned long ff_getauxval(unsigned long type) +{ +#if HAVE_GETAUXVAL + return getauxval(type); +#else + errno = ENOSYS; + return 0; +#endif +} diff --git a/libavutil/cpu_internal.h b/libavutil/cpu_internal.h index 634f28bac4..585a115c49 100644 --- a/libavutil/cpu_internal.h +++ b/libavutil/cpu_internal.h @@ -59,4 +59,6 @@ size_t ff_get_cpu_max_align_ppc(void); size_t ff_get_cpu_max_align_x86(void); size_t ff_get_cpu_max_align_loongarch(void); +unsigned long ff_getauxval(unsigned long type); + #endif /* AVUTIL_CPU_INTERNAL_H */ diff --git a/libavutil/loongarch/cpu.c b/libavutil/loongarch/cpu.c index cad8504fde..d8c67ad7c8 100644 --- a/libavutil/loongarch/cpu.c +++ b/libavutil/loongarch/cpu.c @@ -28,7 +28,7 @@ static int cpu_flags_getauxval(void) { int flags = 0; - int flag = (int)getauxval(AT_HWCAP); + int flag = (int)ff_getauxval(AT_HWCAP); if (flag & LA_HWCAP_LSX) flags |= AV_CPU_FLAG_LSX; diff --git a/libavutil/mips/cpu.c b/libavutil/mips/cpu.c index 59619d54de..2009c70f71 100644 --- a/libavutil/mips/cpu.c +++ b/libavutil/mips/cpu.c @@ -34,7 +34,7 @@ static int cpucfg_available(void) { - return getauxval(AT_HWCAP) & HWCAP_LOONGSON_CPUCFG; + return ff_getauxval(AT_HWCAP) & HWCAP_LOONGSON_CPUCFG; } /* Most toolchains have no CPUCFG support yet */ diff --git a/libavutil/riscv/cpu.c b/libavutil/riscv/cpu.c index 52ca2ce814..4ec6d6c826 100644 --- a/libavutil/riscv/cpu.c +++ b/libavutil/riscv/cpu.c @@ -86,7 +86,7 @@ int ff_get_cpu_flags_riscv(void) } #elif HAVE_GETAUXVAL { - const unsigned long hwcap = getauxval(AT_HWCAP); + const unsigned long hwcap = ff_getauxval(AT_HWCAP); if (hwcap & HWCAP_RV('I')) ret |= AV_CPU_FLAG_RVI;