On 2012-12-05 02:29:02 +0000, Måns Rullgård wrote:
> This allows compiling optimised functions for features not enabled
> in the core build and selecting these at runtime if the system has
> the necessary support.
> 
> Signed-off-by: Mans Rullgard <[email protected]>
> ---
> This version does not rely on headers missing on Android, but rather
> includes a copy of the (trivial) definitions.  The kernel interface is
> stable, so this does not pose a compatibility problem.
> 
> Also changed is the returned flags if /proc/self/auxv could not be opened.
> Instead of returning zero as in previous versions of the patch, the flags
> corresponding to the base build options are used.  Features signalled in
> auxv are merely added to this set with nothing being removed.  This way
> the base feature set is always fully utilised, even if runtime detection
> somehow fails.
> ---
>  configure           |  4 ++-
>  libavutil/arm/cpu.c | 83 
> +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 86 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index bf6aceb..63a5d6f 100755
> --- a/configure
> +++ b/configure
> @@ -3175,7 +3175,9 @@ EOF
>      enabled vfp     && check_insn vfp     'fadds s0, s0, s0'
>      enabled vfpv3   && check_insn vfpv3   'vmov.f32 s0, #1.0'
>  
> -    map 'enabled_any ${v}_external ${v}_inline || disable $v' 
> $ARCH_EXT_LIST_ARM
> +    [ $target_os = linux ] ||
> +        map 'enabled_any ${v}_external ${v}_inline || disable $v' \
> +            $ARCH_EXT_LIST_ARM

What is the intentention for the plain HAVE_CPU_EXT? Trying not to use
it to the point of removing it?

>      check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
>      check_inline_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)'
> diff --git a/libavutil/arm/cpu.c b/libavutil/arm/cpu.c
> index 7058aeb..041afc9 100644
> --- a/libavutil/arm/cpu.c
> +++ b/libavutil/arm/cpu.c
> @@ -19,6 +19,87 @@
>  #include "libavutil/cpu.h"
>  #include "config.h"
>  
> +#define CORE_FLAG(f) \
> +    (AV_CPU_FLAG_ ## f * (HAVE_ ## f ## _EXTERNAL || HAVE_ ## f ## _INLINE))

This is a duplication of the configure code, ok if we want to stop using
the plain HAVE_CPU_EXT. Although I'm not sure how that matches the base
build description from above. did you mean

    (AV_CPU_FLAG_ ## f * (HAVE_ ## f || HAVE_ ## f ## _INLINE)) ?

> +#define CORE_CPU_FLAGS                          \
> +    (CORE_FLAG(ARMV5TE) |                       \
> +     CORE_FLAG(ARMV6)   |                       \
> +     CORE_FLAG(ARMV6T2) |                       \
> +     CORE_FLAG(VFP)     |                       \
> +     CORE_FLAG(VFPV3)   |                       \
> +     CORE_FLAG(NEON))
> +
> +#if defined __linux__ || defined __ANDROID__
> +
> +#include <stdint.h>
> +#include <stdio.h>
> +
> +#define AT_HWCAP        16
> +
> +/* Relevant HWCAP values from kernel headers */
> +#define HWCAP_VFP       (1 << 6)
> +#define HWCAP_EDSP      (1 << 7)
> +#define HWCAP_THUMBEE   (1 << 11)
> +#define HWCAP_NEON      (1 << 12)
> +#define HWCAP_VFPv3     (1 << 13)
> +#define HWCAP_TLS       (1 << 15)
> +
> +static int get_hwcap(uint32_t *hwcap)
> +{
> +    struct { uint32_t a_type; uint32_t a_val; } auxv;
> +    FILE *f = fopen("/proc/self/auxv", "r");
> +    int err = -1;
> +
> +    if (!f)
> +        return -1;
> +
> +    while (fread(&auxv, sizeof(auxv), 1, f) > 0) {
> +        if (auxv.a_type == AT_HWCAP) {
> +            *hwcap = auxv.a_val;
> +            err = 0;
> +            break;
> +        }
> +    }
> +
> +    fclose(f);
> +    return err;
> +}

ok, simple enough and the kernel guarantees stability

> +
> +int ff_get_cpu_flags_arm(void)
> +{
> +    int flags = CORE_CPU_FLAGS;

this is not going to work with only bitwise or and as noted above

Janne
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to