Question

What I want to do (high-level): use qsort_r on Android.

There is no default implementation. So I've grabbed one from BSD. Unfortunately it needs fls functions which is also unavailable on Android. So I've grabbed Apple Open Source Libc library and copied ARM implementation into an inline assembly. Now I'm getting this:

Assembler messages:
Error: selected processor does not support Thumb mode `clz r3,r0'
Error: cannot honor width suffix -- `rsb r0,r3,#32'

AFAIR ARM-6 doesn't support it in Thumb mode. So how can I force non-Thumb mode for this one file, or is pure C implementation available for fls?

(and God, why do I have to play such low-level just to have qsort_r...)

Was it helpful?

Solution

In your Android.mk file, here is how to set things up to compile thumb, arm and neon versions of your code. The assembly language source files need to have the "S" capitalized in the makefile, but the actual name doesn't need to be capitalized. The suffixes ".arm" and ".arm.neon" are only in the makefile and not part of the name (e.g. the files below are named main.c, main_asm.s, test.c and test_asm.s).

LOCAL_ARM_MODE := arm  # remove this if you want thumb mode
LOCAL_ARM_NEON := true # remove this if you want armv5 mode

# this flag will allow neon intrinsics in your C files
LOCAL_CFLAGS := -mfpu=neon -march=armv7

LOCAL_SRC_FILES := \
          main.c.arm \
          test.c.arm.neon \
          main_asm.S.arm \
          test_asm.S.arm.neon \
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top