aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/ppc
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-05-31 21:57:07 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-05-31 21:57:07 +0200
commitff1995437fa22f82bff68e3fca61dfed1efbdfbb (patch)
tree012551f439a343a4e93292274de48535fae86509 /libavutil/ppc
parent08f229d81e41f3aa5463f0c835bc03b0f8d64a71 (diff)
parentbaa94563fede8959a638b0fa132dd2124acd93e8 (diff)
downloadffmpeg-ff1995437fa22f82bff68e3fca61dfed1efbdfbb.tar.gz
Merge commit 'baa94563fede8959a638b0fa132dd2124acd93e8'
* commit 'baa94563fede8959a638b0fa132dd2124acd93e8': ppc: linux: Check altivec using the auxv Conflicts: libavutil/ppc/cpu.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/ppc')
-rw-r--r--libavutil/ppc/cpu.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c
index d51e3fa659..1c87fd90b0 100644
--- a/libavutil/ppc/cpu.c
+++ b/libavutil/ppc/cpu.c
@@ -18,6 +18,11 @@
#ifdef __APPLE__
#include <sys/sysctl.h>
+#elif defined(__linux__)
+#include <asm/cputable.h>
+#include <linux/auxvec.h>
+#include <fcntl.h>
+#include <unistd.h>
#elif defined(__OpenBSD__)
#include <sys/param.h>
#include <sys/sysctl.h>
@@ -62,6 +67,32 @@ int ff_get_cpu_flags_ppc(void)
if (err == 0)
return has_vu ? AV_CPU_FLAG_ALTIVEC : 0;
return 0;
+#elif defined(__linux__)
+ // The linux kernel could have the altivec support disabled
+ // even if the cpu has it.
+ int i, ret = 0;
+ int fd = open("/proc/self/auxv", O_RDONLY);
+ unsigned long buf[64] = { 0 };
+ ssize_t count;
+
+ if (fd < 0)
+ return 0;
+
+ while ((count = read(fd, buf, sizeof(buf))) > 0) {
+ for (i = 0; i < count / sizeof(*buf); i += 2) {
+ if (buf[i] == AT_NULL)
+ goto out;
+ if (buf[i] == AT_HWCAP) {
+ if (buf[i + 1] & PPC_FEATURE_HAS_ALTIVEC)
+ ret = AV_CPU_FLAG_ALTIVEC;
+ goto out;
+ }
+ }
+ }
+
+out:
+ close(fd);
+ return ret;
#elif CONFIG_RUNTIME_CPUDETECT && defined(__linux__) && !ARCH_PPC64
int proc_ver;
// Support of mfspr PVR emulation added in Linux 2.6.17.