@ -46,6 +46,17 @@
# include "libavutil/cpu.h"
# include "libavutil/cpu.h"
# include "libavutil/cpu_internal.h"
# include "libavutil/cpu_internal.h"
# ifndef AT_HWCAP
# define AT_HWCAP 16
# endif
# ifndef AT_HWCAP2
# define AT_HWCAP2 26
# endif
# define HWCAP_PPC_VSX (1 << 7)
# define HWCAP_PPC_ALTIVEC (1 << 28)
# define HWCAP2_PPC_ARCH_2_07 (1 << 31)
/**
/**
* This function MAY rely on signal ( ) or fork ( ) in order to make sure AltiVec
* This function MAY rely on signal ( ) or fork ( ) in order to make sure AltiVec
* is present .
* is present .
@ -65,20 +76,14 @@ int ff_get_cpu_flags_ppc(void)
int flags = 0 ;
int flags = 0 ;
unsigned long hwcap = ff_getauxval ( AT_HWCAP ) ;
unsigned long hwcap = ff_getauxval ( AT_HWCAP ) ;
# ifdef PPC_FEATURE2_ARCH_2_07
unsigned long hwcap2 = ff_getauxval ( AT_HWCAP2 ) ;
unsigned long hwcap2 = ff_getauxval ( AT_HWCAP2 ) ;
# endif
if ( hwcap & PPC_FEATURE_HAS _ALTIVEC)
if ( hwcap & HWCAP_PPC _ALTIVEC)
flags | = AV_CPU_FLAG_ALTIVEC ;
flags | = AV_CPU_FLAG_ALTIVEC ;
# ifdef PPC_FEATURE_HAS_VSX
if ( hwcap & HWCAP_PPC_VSX )
if ( hwcap & PPC_FEATURE_HAS_VSX )
flags | = AV_CPU_FLAG_VSX ;
flags | = AV_CPU_FLAG_VSX ;
# endif
if ( hwcap2 & HWCAP2_PPC_ARCH_2_07 )
# ifdef PPC_FEATURE2_ARCH_2_07
if ( hwcap2 & PPC_FEATURE2_ARCH_2_07 )
flags | = AV_CPU_FLAG_POWER8 ;
flags | = AV_CPU_FLAG_POWER8 ;
# endif
return flags ;
return flags ;
# elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
# elif defined(__APPLE__) || defined(__NetBSD__) || defined(__OpenBSD__)
@ -112,23 +117,17 @@ int ff_get_cpu_flags_ppc(void)
if ( buf [ i ] = = AT_NULL )
if ( buf [ i ] = = AT_NULL )
goto out ;
goto out ;
if ( buf [ i ] = = AT_HWCAP ) {
if ( buf [ i ] = = AT_HWCAP ) {
if ( buf [ i + 1 ] & PPC_FEATURE_HAS _ALTIVEC)
if ( buf [ i + 1 ] & HWCAP_PPC _ALTIVEC)
ret = AV_CPU_FLAG_ALTIVEC ;
ret = AV_CPU_FLAG_ALTIVEC ;
# ifdef PPC_FEATURE_HAS_VSX
if ( buf [ i + 1 ] & HWCAP_PPC_VSX )
if ( buf [ i + 1 ] & PPC_FEATURE_HAS_VSX )
ret | = AV_CPU_FLAG_VSX ;
ret | = AV_CPU_FLAG_VSX ;
# endif
if ( ret & AV_CPU_FLAG_VSX )
if ( ret & AV_CPU_FLAG_VSX )
av_assert0 ( ret & AV_CPU_FLAG_ALTIVEC ) ;
av_assert0 ( ret & AV_CPU_FLAG_ALTIVEC ) ;
}
}
# ifdef AT_HWCAP2 /* not introduced until glibc 2.18 */
else if ( buf [ i ] = = AT_HWCAP2 ) {
else if ( buf [ i ] = = AT_HWCAP2 ) {
# ifdef PPC_FEATURE2_ARCH_2_07
if ( buf [ i + 1 ] & HWCAP2_PPC_ARCH_2_07 )
if ( buf [ i + 1 ] & PPC_FEATURE2_ARCH_2_07 )
ret | = AV_CPU_FLAG_POWER8 ;
ret | = AV_CPU_FLAG_POWER8 ;
# endif
}
}
# endif /* AT_HWCAP2 */
}
}
}
}