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
|
|
| 230 | 230 | [pulseaudio_cv_support_arm_atomic_ops=no]) |
| 231 | 231 | ]) |
| 232 | 232 | 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.]) |
| 234 | 234 | need_libatomic_ops=no |
| 235 | 235 | ]) |
| 236 | 236 | fi |
| … |
… |
|
| 249 | 249 | esac |
| 250 | 250 | fi |
| 251 | 251 | |
| | 252 | # If we're on ARM, check for the ARMV6 instructions we need */ |
| | 253 | case $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 | ;; |
| | 281 | esac |
| | 282 | |
| 252 | 283 | CC_CHECK_TLS |
| 253 | 284 | |
| 254 | 285 | AC_CACHE_CHECK([whether $CC knows _Bool], |
diff --git a/src/pulsecore/svolume_arm.c b/src/pulsecore/svolume_arm.c
index fdd8f09..3973e51 100644
|
a
|
b
|
|
| 35 | 35 | #include "sample-util.h" |
| 36 | 36 | #include "endianmacros.h" |
| 37 | 37 | |
| 38 | | #if defined (__arm__) |
| | 38 | #if defined (__arm__) && defined (HAVE_ARMV6) |
| 39 | 39 | |
| 40 | 40 | #define MOD_INC() \ |
| 41 | 41 | " subs r0, r6, %2 \n\t" \ |
| … |
… |
|
| 182 | 182 | } |
| 183 | 183 | #endif |
| 184 | 184 | |
| 185 | | #endif /* defined (__arm__) */ |
| | 185 | #endif /* defined (__arm__) && defined (HAVE_ARMV6) */ |
| 186 | 186 | |
| 187 | 187 | |
| 188 | 188 | void pa_volume_func_init_arm (pa_cpu_arm_flag_t flags) { |
| 189 | | #if defined (__arm__) |
| | 189 | #if defined (__arm__) && defined (HAVE_ARMV6) |
| 190 | 190 | pa_log_info("Initialising ARM optimized functions."); |
| 191 | 191 | |
| 192 | 192 | #ifdef RUN_TEST |
| … |
… |
|
| 194 | 194 | #endif |
| 195 | 195 | |
| 196 | 196 | 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) */ |
| 198 | 198 | } |