mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-28 03:34:06 +00:00
Merge pull request #224 from jbeich/powerpc
Switch AltiVec on Linux to getauxval()
This commit is contained in:
commit
7a8641b002
|
@ -374,40 +374,23 @@ static INLINE int get_cpuid(unsigned level, unsigned sublevel, cpuid_t *cpu_info
|
||||||
#endif // COMPILE_INTEL
|
#endif // COMPILE_INTEL
|
||||||
|
|
||||||
#if COMPILE_POWERPC
|
#if COMPILE_POWERPC
|
||||||
# if defined(__linux__)
|
# if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD__ >= 12)
|
||||||
#include <fcntl.h>
|
#ifdef __linux__
|
||||||
#include <unistd.h>
|
|
||||||
#include <linux/auxvec.h>
|
|
||||||
#include <asm/cputable.h>
|
#include <asm/cputable.h>
|
||||||
|
#else
|
||||||
|
#include <machine/cpu.h>
|
||||||
|
#endif
|
||||||
|
#include <sys/auxv.h>
|
||||||
|
|
||||||
//Source: http://freevec.org/function/altivec_runtime_detection_linux
|
|
||||||
static int altivec_available(void)
|
static int altivec_available(void)
|
||||||
{
|
{
|
||||||
int result = 0;
|
unsigned long hwcap = 0;
|
||||||
unsigned long buf[64];
|
#ifdef __linux__
|
||||||
ssize_t count;
|
hwcap = getauxval(AT_HWCAP);
|
||||||
int fd, i;
|
#else
|
||||||
|
elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
|
||||||
fd = open("/proc/self/auxv", O_RDONLY);
|
#endif
|
||||||
if (fd < 0) {
|
return !!(hwcap & PPC_FEATURE_HAS_ALTIVEC);
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// loop on reading
|
|
||||||
do {
|
|
||||||
count = read(fd, buf, sizeof(buf));
|
|
||||||
if (count < 0)
|
|
||||||
break;
|
|
||||||
for (i=0; i < (count / sizeof(unsigned long)); i += 2) {
|
|
||||||
if (buf[i] == AT_HWCAP) {
|
|
||||||
result = !!(buf[i+1] & PPC_FEATURE_HAS_ALTIVEC);
|
|
||||||
goto out_close;
|
|
||||||
} else if (buf[i] == AT_NULL)
|
|
||||||
goto out_close;
|
|
||||||
}
|
|
||||||
} while (count == sizeof(buf));
|
|
||||||
out_close:
|
|
||||||
close(fd);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
# elif defined(__FreeBSD__)
|
# elif defined(__FreeBSD__)
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
Loading…
Reference in a new issue