Ticket #790: 0001-volume-Add-explicit-checks-for-ARMv6-instructions.2.patch

File 0001-volume-Add-explicit-checks-for-ARMv6-instructions.2.patch, 3.3 KB (added by Ford_Prefect, 18 months ago)
  • configure.ac

    From e5b136fc0fde751df3a94cd64855a74732dd4cc7 Mon Sep 17 00:00:00 2001
    From: Arun Raghavan <arun.raghavan@collabora.co.uk>
    Date: Fri, 26 Nov 2010 11:55:57 +0530
    Subject: [PATCH] volume: Add explicit checks for ARMv6 instructions
    
    This ensures that the build does not fail if the ssat and pkhbt
    instructions are not available (armv5te and below).
    
    Fixes: http://www.pulseaudio.org/ticket/790
    ---
     configure.ac                |   33 ++++++++++++++++++++++++++++++++-
     src/pulsecore/svolume_arm.c |    8 ++++----
     2 files changed, 36 insertions(+), 5 deletions(-)
    
    diff --git a/configure.ac b/configure.ac
    index 7ab42dc..3df8c6b 100644
    a b  
    230230                    [pulseaudio_cv_support_arm_atomic_ops=no]) 
    231231                 ]) 
    232232               AS_IF([test "$pulseaudio_cv_support_arm_atomic_ops" = "yes"], [ 
    233                    AC_DEFINE([ATOMIC_ARM_INLINE_ASM], 1, [Have ARMv6 instructions.]) 
     233                   AC_DEFINE([ATOMIC_ARM_INLINE_ASM], 1, [Have ARM atomic instructions.]) 
    234234                   need_libatomic_ops=no 
    235235                 ]) 
    236236           fi 
     
    249249    esac 
    250250fi 
    251251 
     252# If we're on ARM, check for the ARMV6 instructions we need */ 
     253case $host in 
     254  arm*) 
     255    AC_CACHE_CHECK([support for required armv6 instructions], 
     256      pulseaudio_cv_support_armv6, 
     257      [AC_COMPILE_IFELSE( 
     258         AC_LANG_PROGRAM([], 
     259           [[volatile int a = -60000, b = 0xaaaabbbb, c = 0xccccdddd; 
     260             asm volatile ("ldr r0, %2 \n" 
     261                           "ldr r2, %3 \n" 
     262                           "ldr r3, %4 \n" 
     263                           "ssat r1, #8, r0 \n" 
     264                           "str r1, %0 \n" 
     265                           "pkhbt r1, r3, r2, LSL #8 \n" 
     266                           "str r1, %1 \n" 
     267                           : "=m" (a), "=m" (b) 
     268                           : "m" (a), "m" (b), "m" (c) 
     269                           : "r0", "r1", "r2", "r3", "cc"); 
     270             return (a == -128 && b == 0xaabbdddd) ? 0 : -1; 
     271           ]]), 
     272         [pulseaudio_cv_support_armv6=yes], 
     273         [pulseaudio_cv_support_armv6=no]) 
     274      ]) 
     275    AS_IF([test "$pulseaudio_cv_support_armv6" = "yes"], [ 
     276        AC_DEFINE([HAVE_ARMV6], 1, [Have ARMv6 instructions.]) 
     277      ]) 
     278  ;; 
     279  *) 
     280  ;; 
     281esac 
     282 
    252283CC_CHECK_TLS 
    253284 
    254285AC_CACHE_CHECK([whether $CC knows _Bool], 
  • src/pulsecore/svolume_arm.c

    diff --git a/src/pulsecore/svolume_arm.c b/src/pulsecore/svolume_arm.c
    index fdd8f09..3973e51 100644
    a b  
    3535#include "sample-util.h" 
    3636#include "endianmacros.h" 
    3737 
    38 #if defined (__arm__) 
     38#if defined (__arm__) && defined (HAVE_ARMV6) 
    3939 
    4040#define MOD_INC() \ 
    4141    " subs  r0, r6, %2              \n\t" \ 
     
    182182} 
    183183#endif 
    184184 
    185 #endif /* defined (__arm__) */ 
     185#endif /* defined (__arm__) && defined (HAVE_ARMV6) */ 
    186186 
    187187 
    188188void pa_volume_func_init_arm (pa_cpu_arm_flag_t flags) { 
    189 #if defined (__arm__) 
     189#if defined (__arm__) && defined (HAVE_ARMV6) 
    190190    pa_log_info("Initialising ARM optimized functions."); 
    191191 
    192192#ifdef RUN_TEST 
     
    194194#endif 
    195195 
    196196    pa_set_volume_func (PA_SAMPLE_S16NE,     (pa_do_volume_func_t) pa_volume_s16ne_arm); 
    197 #endif /* defined (__arm__) */ 
     197#endif /* defined (__arm__) && defined (HAVE_ARMV6) */ 
    198198}