Compiling the Android source code for ARMv4T

 先收藏一篇 Compiling the Android source code for ARMv4T
  1. After a lot of stuffing around installing new hard drives so I had enough space to actually play with the source code, getting screwed by Time Machine when trying to convert my filesystem from case-insenstive to case-insensitive (I gave up and am now usuing a case-sensitive disk image on top of my case-insenstive file system.. sigh), I finally have the Android source code compiling, yay!.
  2. Compiling is fairly trivial, just make and away it goes. The fun thing is trying to work out exactly what the hell the build system is actually doing. I’ve got to admit though, it is a pretty clean build system, although it isn’t going to win any speed records. I’m going to go into more details on the build sstem when i have more time, and I’ve actually worked out what the hell is happening.
  3. Anyway, after a few false starts I now have the build system compiling for ARMv4T processors (such as the one inside the Neo1973), and hopefully at the same time I haven’t broken compilation from ARMv5TE.
  4. For those interested I have a patch available. Simply apply this to the checked out code, and the build using make TARGET_ARCH_VERSION=armv4t. Now, of course I haven’t actually tried to run this code yet, so it might not work, but it seems to compile fine, so that is a good start! Now once I work out how to make git play nice I'll actually put this into a branch and make it available, but the diff will have to suffice for now. Of course I’m not the only one looking at this, check out Christopher’s page for more information. (Where he actually starts solving some problems instead of just working around them ;)
  5. The rest of this post documents the patch. For those interested it should give you some idea of the build system and layout, and hopefully it is something that can be applied to mainline.
  6. The first changes made are to the linux-arm.mk file. A new make variable TARGET_ARCH_VERSION is added. For now this is defaulted to armv5te, but it can be overridden on the command line as shown above.
  7. project build/
  8. diff --git a/core/combo/linux-arm.mk b/core/combo/linux-arm.mk
  9. index adb82d3..a43368f 100644
  10. --- a/core/combo/linux-arm.mk
  11. +++ b/core/combo/linux-arm.mk
  12. @@ -7,6 +7,8 @@ $(combo_target)TOOLS_PREFIX := /
  13.     prebuilt/$(HOST_PREBUILT_TAG)/toolchain/arm-eabi-4.2.1/bin/arm-eabi-
  14.  endif
  15.  
  16. +TARGET_ARCH_VERSION ?= armv5te
  17. +
  18.  $(combo_target)CC := $($(combo_target)TOOLS_PREFIX)gcc$(HOST_EXECUTABLE_SUFFIX)
  19.  $(combo_target)CXX := $($(combo_target)TOOLS_PREFIX)g++$(HOST_EXECUTABLE_SUFFIX)
  20.  $(combo_target)AR := $($(combo_target)TOOLS_PREFIX)ar$(HOST_EXECUTABLE_SUFFIX)
  21. The next thing is to make the GLOBAL_CFLAGS variable dependent on the architecture version. The armv5te defines stay in place, but an armv4t architecture version is added. Most of the cflags are pretty similar, except we change the -march flag, and change the pre-processor defines. These will become important later in the patch as they provide the mechanism for distinguishing between versions in the code.
  22. @@ -46,6 +48,7 @@ ifneq ($(wildcard $($(combo_target)CC)),)
  23.  $(combo_target)LIBGCC := $(shell $($(combo_target)CC) -mthumb-interwork -print-libgcc-file-name)
  24.  endif
  25.  
  26. +ifeq ($(TARGET_ARCH_VERSION), armv5te)
  27.  $(combo_target)GLOBAL_CFLAGS += /
  28.             -march=armv5te -mtune=xscale /
  29.             -msoft-float -fpic /
  30. @@ -56,6 +59,21 @@ $(combo_target)GLOBAL_CFLAGS += /
  31.             -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ /
  32.             -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ /
  33.             -include $(call select-android-config-h,linux-arm)
  34. +else
  35. +ifeq ($(TARGET_ARCH_VERSION), armv4t)
  36. +$(combo_target)GLOBAL_CFLAGS += /
  37. +           -march=armv4t /
  38. +           -msoft-float -fpic /
  39. +           -mthumb-interwork /
  40. +           -ffunction-sections /
  41. +           -funwind-tables /
  42. +           -fstack-protector /
  43. +           -D__ARM_ARCH_4__ -D__ARM_ARCH_4T__ /
  44. +           -include $(call select-android-config-h,linux-arm)
  45. +else
  46. +$(error Unknown TARGET_ARCH_VERSION=$(TARGET_ARCH_VERSION))
  47. +endif
  48. +endif
  49.  
  50.  $(combo_target)GLOBAL_CPPFLAGS += -fvisibility-inlines-hidden
  51. The next bit we update is the prelink-linux-arm.map file. The dynamic libraries in android are laid out explicitly in virtual memory according to this map file. If I’m not mistaken those address look suspiciously 1MB aligned, which means they should fit nicely in the pagetable, and provides some opportunity to use fast-address-space-switching techniques. In the port to ARMv4 I have so far been lazy and instead of fixing up any assembler code I’ve just gone with existing C code. One outcome of this is that I need the libffi.so for my foreign function interface, so I’ve added this to the map for now. I’m not 100% sure that when compiling for ARMv5 this won’t cause a problem. Will need to see. Fixing up the code to avoid needing libffi is probably high on the list of things to do.
  52. diff --git a/core/prelink-linux-arm.map b/core/prelink-linux-arm.map
  53. index d4ebf43..6e0bc43 100644
  54. --- a/core/prelink-linux-arm.map
  55. +++ b/core/prelink-linux-arm.map
  56. @@ -113,3 +113,4 @@ libctest.so             0x9A700000
  57.  libUAPI_jni.so          0x9A500000
  58.  librpc.so               0x9A400000 
  59.  libtrace_test.so        0x9A300000 
  60. +libffi.so               0x9A200000
  61. The next module is the bionic module which is the light-weight C library that is part of Android. This has some nice optimised routines for memory copy and compare, but unfortunately they rely on ARMv5 instructions. I’ve changed the build system to only use the optimised assembler when compiling with ARMv5TE, and falling back to C routines in the other cases. (The strlen implementation isn’t pure assembly, but the optimised C implementation has inline asm, so again it needs to drop back to plain old dumb strlen.)
  62. project bionic/
  63. diff --git a/libc/Android.mk b/libc/Android.mk
  64. index faca333..3fb3455 100644
  65. --- a/libc/Android.mk
  66. +++ b/libc/Android.mk
  67. @@ -206,13 +206,9 @@ libc_common_src_files := /
  68.     arch-arm/bionic/_setjmp.S /
  69.     arch-arm/bionic/atomics_arm.S /
  70.     arch-arm/bionic/clone.S /
  71. -   arch-arm/bionic/memcmp.S /
  72. -   arch-arm/bionic/memcmp16.S /
  73. -   arch-arm/bionic/memcpy.S /
  74.     arch-arm/bionic/memset.S /
  75.     arch-arm/bionic/setjmp.S /
  76.     arch-arm/bionic/sigsetjmp.S /
  77. -   arch-arm/bionic/strlen.c.arm /
  78.     arch-arm/bionic/syscall.S /
  79.     arch-arm/bionic/kill.S /
  80.     arch-arm/bionic/tkill.S /
  81. @@ -274,6 +270,18 @@ libc_common_src_files := /
  82.     netbsd/nameser/ns_print.c /
  83.     netbsd/nameser/ns_samedomain.c
  84.  
  85. +
  86. +ifeq ($(TARGET_ARCH),arm)
  87. +ifeq ($(TARGET_ARCH_VERSION),armv5te)
  88. +libc_common_src_files += arch-arm/bionic/memcmp.S /
  89. +       arch-arm/bionic/memcmp16.S /
  90. +       arch-arm/bionic/memcpy.S /
  91. +       arch-arm/bionic/strlen.c.arm
  92. +else
  93. +libc_common_src_files += string/memcmp.c string/memcpy.c string/strlen.c string/ffs.c
  94. +endif
  95. +endif
  96. +
  97.  # These files need to be arm so that gdbserver
  98.  # can set breakpoints in them without messing
  99.  # up any thumb code.
  100. Unfortunately, it is clear that this C only code hasn’t been used in a while as there was a trivial bug as fixed by the patch below. This makes me worry about what other bugs that aren’t caught by the compiler may be lurking.
  101. diff --git a/libc/string/memcpy.c b/libc/string/memcpy.c
  102. index 4cd4a80..dea78b2 100644
  103. --- a/libc/string/memcpy.c
  104. +++ b/libc/string/memcpy.c
  105. @@ -25,5 +25,5 @@
  106.   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  107.   * SUCH DAMAGE.
  108.   */
  109. -#define MEM_COPY
  110. +#define MEMCOPY
  111.  #include "bcopy.c"
  112. Finally, frustratingly, the compiler’s ffs() implementation appears to fallback to calling the C library’s ffs() implementation if it can’t doing something optimised. This happens when compiling for ARMv4, so I’ve added an ffs() implementation (stolen from FreeBSD).
  113. #include 
  114. #include 
  115. /*
  116.  * Find First Set bit
  117.  */
  118. int
  119. ffs(int mask)
  120. {
  121.         int bit;
  122.         if (mask == 0)
  123.                 return (0);
  124.         for (bit = 1; !(mask & 1); bit++)
  125.                 mask = (unsigned int)mask >> 1;
  126.         return (bit);
  127. }
  128. The next module for attention is the dalvik virtual machine. Again this has some code that relies on ARMv5, but there is a C version that we fall back on. In this case it also means pulling in libffi. This is probably the module that needs to most attention in actually updating the code to be ARMv4 assembler in the near future.
  129. project dalvik/
  130. diff --git a/vm/Android.mk b/vm/Android.mk
  131. index dfed78d..c66a861 100644
  132. --- a/vm/Android.mk
  133. +++ b/vm/Android.mk
  134. @@ -189,6 +189,7 @@ ifeq ($(TARGET_SIMULATOR),true)
  135.  endif
  136.  
  137.  ifeq ($(TARGET_ARCH),arm)
  138. +ifeq ($(TARGET_ARCH_VERSION),armv5te)
  139.     # use custom version rather than FFI
  140.     #LOCAL_SRC_FILES += arch/arm/CallC.c
  141.     LOCAL_SRC_FILES += arch/arm/CallOldABI.S arch/arm/CallEABI.S
  142. @@ -204,6 +205,16 @@ else
  143.         mterp/out/InterpC-desktop.c /
  144.         mterp/out/InterpAsm-desktop.S
  145.     LOCAL_SHARED_LIBRARIES += libffi
  146. +   LOCAL_SHARED_LIBRARIES += libdl
  147. +endif
  148. +else
  149. +   # use FFI
  150. +   LOCAL_C_INCLUDES += external/libffi/$(TARGET_OS)-$(TARGET_ARCH)
  151. +   LOCAL_SRC_FILES += arch/generic/Call.c
  152. +   LOCAL_SRC_FILES += /
  153. +       mterp/out/InterpC-desktop.c /
  154. +       mterp/out/InterpAsm-desktop.S
  155. +   LOCAL_SHARED_LIBRARIES += libffi
  156.  endif
  157.  
  158.  LOCAL_MODULE :libdvm
  159. Next is libjpeg, which again, has assembler optimisation that we can’t easily use without real porting work, so we fall back to the C
  160. project external/jpeg/
  161. diff --git a/Android.mk b/Android.mk
  162. index 9cfe4f6..3c052cd 100644
  163. --- a/Android.mk
  164. +++ b/Android.mk
  165. @@ -19,6 +19,12 @@ ifneq ($(TARGET_ARCH),arm)
  166.  ANDROID_JPEG_NO_ASSEMBLER :true
  167.  endif
  168.  
  169. +# the assembler doesn't work for armv4t
  170. +ifeq ($(TARGET_ARCH_VERSION),armv4t)
  171. +ANDROID_JPEG_NO_ASSEMBLER :true
  172. +endif
  173. +
  174. +
  175.  # temp fix until we understand why this broke cnn.com
  176.  #ANDROID_JPEG_NO_ASSEMBLER :true
  177.  
  178. For some reason compiling with ARMv4 doesn’t allow the prefetch loop array compiler optimisation, so we turn it off for ARMv4.
  179. @@ -29,7 +35,10 @@ LOCAL_SRC_FILES += jidctint.c jidctfst.S
  180.  endif
  181.  
  182.  LOCAL_CFLAGS += -DAVOID_TABLES 
  183. -LOCAL_CFLAGS += -O3 -fstrict-aliasing -fprefetch-loop-arrays
  184. +LOCAL_CFLAGS += -O3 -fstrict-aliasing
  185. +ifeq ($(TARGET_ARCH_VERSION),armv5te)
  186. +LOCAL_FLAGS += -fprefetch-loop-arrays
  187. +endif
  188.  #LOCAL_CFLAGS += -march=armv6j
  189.  
  190.  LOCAL_MODULE:libjpeg
  191. Next up is libffi, which is just a case of turning it on since we now need it for ARMv4.
  192. project external/libffi/
  193. diff --git a/Android.mk b/Android.mk
  194. index f4452c9..07b5c2f 100644
  195. --- a/Android.mk
  196. +++ b/Android.mk
  197. @@ -6,7 +6,7 @@
  198.  # We need to generate the appropriate defines and select the right set of
  199.  # source files for the OS and architecture.
  200.  
  201. -ifneq ($(TARGET_ARCH),arm)
  202. +ifneq ($(TARGET_ARCH_VERSION),armv5te)
  203.  
  204.  LOCAL_PATH:= $(call my-dir)
  205.  include $(CLEAR_VARS)
  206. The external module opencore contains a lot of software implemented codecs. (I wonder about the licensing restrictions on these things...). Not surprisingly these too are tuned for ARMv4, but again we fall back to plain old C.
  207. project external/opencore/
  208. diff --git a/codecs_v2/audio/aac/dec/Android.mk b/codecs_v2/audio/aac/dec/Android.mk
  209. index ffe0089..6abdc2d 100644
  210. --- a/codecs_v2/audio/aac/dec/Android.mk
  211. +++ b/codecs_v2/audio/aac/dec/Android.mk
  212. @@ -150,7 +150,7 @@ LOCAL_SRC_FILES := /
  213.  LOCAL_MODULE :libpv_aac_dec
  214.  
  215.  LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO  $(PV_CFLAGS)
  216. -ifeq ($(TARGET_ARCH),arm)
  217. +ifeq ($(TARGET_ARCH_VERSION),armv5te)
  218.   LOCAL_CFLAGS += -D_ARM_GCC
  219.   else
  220.   LOCAL_CFLAGS += -DC_EQUIVALENT
  221. diff --git a/codecs_v2/audio/gsm_amr/amr_wb/dec/Android.mk b/codecs_v2/audio/gsm_amr/amr_wb/dec/Android.mk
  222. index e184178..3223841 100644
  223. --- a/codecs_v2/audio/gsm_amr/amr_wb/dec/Android.mk
  224. +++ b/codecs_v2/audio/gsm_amr/amr_wb/dec/Android.mk
  225. @@ -48,7 +48,7 @@ LOCAL_SRC_FILES := /
  226.  LOCAL_MODULE :libpvamrwbdecoder
  227.  
  228.  LOCAL_CFLAGS :=   $(PV_CFLAGS)
  229. -ifeq ($(TARGET_ARCH),arm)
  230. +ifeq ($(TARGET_ARCH_VERSION),armv5te)
  231.   LOCAL_CFLAGS += -D_ARM_GCC
  232.   else
  233.   LOCAL_CFLAGS += -DC_EQUIVALENT
  234. diff --git a/codecs_v2/audio/mp3/dec/Android.mk b/codecs_v2/audio/mp3/dec/Android.mk
  235. index 254cb6b..c2430fe 100644
  236. --- a/codecs_v2/audio/mp3/dec/Android.mk
  237. +++ b/codecs_v2/audio/mp3/dec/Android.mk
  238. @@ -28,8 +28,8 @@ LOCAL_SRC_FILES := /
  239.     src/pvmp3_seek_synch.cpp /
  240.     src/pvmp3_stereo_proc.cpp /
  241.     src/pvmp3_reorder.cpp
  242. -   
  243. -ifeq ($(TARGET_ARCH),arm)
  244. +
  245. +ifeq ($(TARGET_ARCH_VERSION),armv5te)
  246.  LOCAL_SRC_FILES += /
  247.     src/asm/pvmp3_polyphase_filter_window_gcc.s /
  248.     src/asm/pvmp3_mdct_18_gcc.s /
  249. @@ -46,7 +46,7 @@ endif
  250.  LOCAL_MODULE :libpvmp3
  251.  
  252.  LOCAL_CFLAGS :=   $(PV_CFLAGS)
  253. -ifeq ($(TARGET_ARCH),arm)
  254. +ifeq ($(TARGET_ARCH_VERSION),armv5te)
  255.   LOCAL_CFLAGS += -DPV_ARM_GCC
  256.   else
  257.   LOCAL_CFLAGS += -DC_EQUIVALENT
  258. Unfortunately it is not just the build file that needs updating in this module. I need to manually go and update the headers so that some optimised inline assembler is only used in the ARMv5 case. To be honest this messes these files up a little bit, so a nicer solution would be preferred.
  259. diff --git a/codecs_v2/video/m4v_h263/enc/src/dct_inline.h b/codecs_v2/video/m4v_h263/enc/src/dct_inline.h
  260. index 86474b2..41a3297 100644
  261. --- a/codecs_v2/video/m4v_h263/enc/src/dct_inline.h
  262. +++ b/codecs_v2/video/m4v_h263/enc/src/dct_inline.h
  263. @@ -22,7 +22,7 @@
  264.  #ifndef _DCT_INLINE_H_
  265.  #define _DCT_INLINE_H_
  266.  
  267. -#if !defined(PV_ARM_GCC)&& defined(__arm__)
  268. +#if !(defined(PV_ARM_GCC) && defined(__arm__) && defined(__ARCH_ARM_5TE__))
  269.  
  270.  #include "oscl_base_macros.h"
  271.  
  272. @@ -109,7 +109,7 @@ __inline int32 sum_abs(int32 k0, int32 k1, int32 k2, int32 k3,
  273.  #elif defined(__CC_ARM)  /* only work with arm v5 */
  274.  
  275.  #if defined(__TARGET_ARCH_5TE)
  276. -
  277. +#error
  278.  __inline int32 mla724(int32 op1, int32 op2, int32 op3)
  279.  {
  280.      int32 out;
  281. @@ -266,7 +266,7 @@ __inline int32 sum_abs(int32 k0, int32 k1, int32 k2, int32 k3,
  282.      return abs_sum;
  283.  }
  284.  
  285. -#elif defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
  286. +#elif defined(PV_ARM_GCC) && defined(__arm__) && defined(__ARCH_ARM_5TE__) /* ARM GNU COMPILER  */
  287.  
  288.  __inline int32 mla724(int32 op1, int32 op2, int32 op3)
  289.  {
  290. diff --git a/codecs_v2/video/m4v_h263/enc/src/fastquant_inline.h b/codecs_v2/video/m4v_h263/enc/src/fastquant_inline.h
  291. index 6a35d43..fbfeddf 100644
  292. --- a/codecs_v2/video/m4v_h263/enc/src/fastquant_inline.h
  293. +++ b/codecs_v2/video/m4v_h263/enc/src/fastquant_inline.h
  294. @@ -25,7 +25,7 @@
  295.  #include "mp4def.h"
  296.  #include "oscl_base_macros.h"
  297.  
  298. -#if !defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
  299. +#if !(defined(PV_ARM_GCC) && defined(__arm__) && defined(__ARCH_ARM_V5TE__)) /* ARM GNU COMPILER  */
  300.  
  301.  __inline int32 aan_scale(int32 q_value, int32 coeff, int32 round, int32 QPdiv2)
  302.  {
  303. @@ -423,7 +423,7 @@ __inline int32 coeff_dequant_mpeg_intra(int32 q_value, int32 tmp)
  304.      return q_value;
  305.  }
  306.  
  307. -#elif defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
  308. +#elif defined(PV_ARM_GCC) && defined(__arm__) && defined(__ARCH_ARM_V5TE__) /* ARM GNU COMPILER  */
  309.  
  310.  __inline int32 aan_scale(int32 q_value, int32 coeff,
  311.                           int32 round, int32 QPdiv2)
  312. diff --git a/codecs_v2/video/m4v_h263/enc/src/vlc_encode_inline.h b/codecs_v2/video/m4v_h263/enc/src/vlc_encode_inline.h
  313. index 69857f3..b0bf46d 100644
  314. --- a/codecs_v2/video/m4v_h263/enc/src/vlc_encode_inline.h
  315. +++ b/codecs_v2/video/m4v_h263/enc/src/vlc_encode_inline.h
  316. @@ -18,7 +18,7 @@
  317.  #ifndef _VLC_ENCODE_INLINE_H_
  318.  #define _VLC_ENCODE_INLINE_H_
  319.  
  320. -#if !defined(PV_ARM_GCC)&& defined(__arm__)
  321. +#if !(defined(PV_ARM_GCC) && defined(__arm__) && defined(__ARCH_ARM_V5TE__))
  322.  
  323.  __inline  Int zero_run_search(UInt *bitmapzz, Short *dataBlock, RunLevelBlock *RLB, Int nc)
  324.  {
  325. @@ -208,7 +208,7 @@ __inline  Int zero_run_search(UInt *bitmapzz, Short *dataBlock, RunLevelBlock *R
  326.      return idx;
  327.  }
  328.  
  329. -#elif defined(PV_ARM_GCC) && defined(__arm__) /* ARM GNU COMPILER  */
  330. +#elif defined(PV_ARM_GCC) && defined(__arm__) && defined(__ARCH_ARM_V5TE__) /* ARM GNU COMPILER  */
  331.  
  332.  __inline Int m4v_enc_clz(UInt temp)
  333.  {
  334. A similar approach is needed in the skia graphics library.
  335. project external/skia/
  336. diff --git a/include/corecg/SkMath.h b/include/corecg/SkMath.h
  337. index 76cf279..5f0264f 100644
  338. --- a/include/corecg/SkMath.h
  339. +++ b/include/corecg/SkMath.h
  340. @@ -162,7 +162,7 @@ static inline int SkNextLog2(uint32_t value) {
  341.      With this requirement, we can generate faster instructions on some
  342.      architectures.
  343.  */
  344. -#if defined(__arm__) && !defined(__thumb__)
  345. +#if defined(__arm__) && defined(__ARM_ARCH_5TE__) && !defined(__thumb__)
  346.      static inline int32_t SkMulS16(S16CPU x, S16CPU y) {
  347.          SkASSERT((int16_t)x == x);
  348.          SkASSERT((int16_t)y == y);
  349. The sonivox module (no idea what that is!), has the same requirement of updating the build to avoid building ARMv5 specific code.
  350. project external/sonivox/
  351. diff --git a/arm-wt-22k/Android.mk b/arm-wt-22k/Android.mk
  352. index 565c233..a59f917 100644
  353. --- a/arm-wt-22k/Android.mk
  354. +++ b/arm-wt-22k/Android.mk
  355. @@ -73,6 +73,7 @@ LOCAL_COPY_HEADERS := /
  356.     host_src/eas_reverb.h
  357.  
  358.  ifeq ($(TARGET_ARCH),arm)
  359. +ifeq (($TARGET_ARCH),armv5)
  360.  LOCAL_SRC_FILES+= /
  361.     lib_src/ARM-E_filter_gnu.s /
  362.     lib_src/ARM-E_interpolate_loop_gnu.s /
  363. The low-level audio code in audioflinger suffers from the same optimisations, and we need to dive into the code on this occasion to fix things up.
  364. project frameworks/base/
  365. diff --git a/libs/audioflinger/AudioMixer.cpp b/libs/audioflinger/AudioMixer.cpp
  366. index 9f1b17f..4c0890c 100644
  367. --- a/libs/audioflinger/AudioMixer.cpp
  368. +++ b/libs/audioflinger/AudioMixer.cpp
  369. @@ -400,7 +400,7 @@ void AudioMixer::process__validate(state_t* state, void* output)
  370.  static inline 
  371.  int32_t mulAdd(int16_t in, int16_t v, int32_t a)
  372.  {
  373. -#if defined(__arm__) && !defined(__thumb__)
  374. +#if defined(__arm__) && defined(__ARCH_ARM_5TE__) && !defined(__thumb__)
  375.      int32_t out;
  376.      asm( "smlabb %[out], %[in], %[v], %[a] /n"
  377.           : [out]"=r"(out)
  378. @@ -415,7 +415,7 @@ int32_t mulAdd(int16_t in, int16_t v, int32_t a)
  379.  static inline 
  380.  int32_t mul(int16_t in, int16_t v)
  381.  {
  382. -#if defined(__arm__) && !defined(__thumb__)
  383. +#if defined(__arm__) && defined(__ARCH_ARM_5TE__) && !defined(__thumb__)
  384.      int32_t out;
  385.      asm( "smulbb %[out], %[in], %[v] /n"
  386.           : [out]"=r"(out)
  387. @@ -430,7 +430,7 @@ int32_t mul(int16_t in, int16_t v)
  388.  static inline 
  389.  int32_t mulAddRL(int left, uint32_t inRL, uint32_t vRL, int32_t a)
  390.  {
  391. -#if defined(__arm__) && !defined(__thumb__)
  392. +#if defined(__arm__) && defined(__ARCH_ARM_5TE__) && !defined(__thumb__)
  393.      int32_t out;
  394.      if (left) {
  395.          asm( "smlabb %[out], %[inRL], %[vRL], %[a] /n"
  396. @@ -456,7 +456,7 @@ int32_t mulAddRL(int left, uint32_t inRL, uint32_t vRL, int32_t a)
  397.  static inline 
  398.  int32_t mulRL(int left, uint32_t inRL, uint32_t vRL)
  399.  {
  400. -#if defined(__arm__) && !defined(__thumb__)
  401. +#if defined(__arm__) && defined(__ARCH_ARM_5TE__) && !defined(__thumb__)
  402.      int32_t out;
  403.      if (left) {
  404.          asm( "smulbb %[out], %[inRL], %[vRL] /n"
  405. diff --git a/libs/audioflinger/AudioResamplerSinc.cpp b/libs/audioflinger/AudioResamplerSinc.cpp
  406. index e710d16..88b8c22 100644
  407. --- a/libs/audioflinger/AudioResamplerSinc.cpp
  408. +++ b/libs/audioflinger/AudioResamplerSinc.cpp
  409. @@ -62,7 +62,7 @@ const int32_t AudioResamplerSinc::mFirCoefsDown[] = {
  410.  static inline 
  411.  int32_t mulRL(int left, int32_t in, uint32_t vRL)
  412.  {
  413. -#if defined(__arm__) && !defined(__thumb__)
  414. +#if defined(__arm__) && defined(__ARCH_ARM_5TE__) && !defined(__thumb__)
  415.      int32_t out;
  416.      if (left) {
  417.          asm( "smultb %[out], %[in], %[vRL] /n"
  418. @@ -88,7 +88,7 @@ int32_t mulRL(int left, int32_t in, uint32_t vRL)
  419.  static inline 
  420.  int32_t mulAdd(int16_t in, int32_t v, int32_t a)
  421.  {
  422. -#if defined(__arm__) && !defined(__thumb__)
  423. +#if defined(__arm__) && defined(__ARCH_ARM_5TE__) && !defined(__thumb__)
  424.      int32_t out;
  425.      asm( "smlawb %[out], %[v], %[in], %[a] /n"
  426.           : [out]"=r"(out)
  427. @@ -103,7 +103,7 @@ int32_t mulAdd(int16_t in, int32_t v, int32_t a)
  428.  static inline 
  429.  int32_t mulAddRL(int left, uint32_t inRL, int32_t v, int32_t a)
  430.  {
  431. -#if defined(__arm__) && !defined(__thumb__)
  432. +#if defined(__arm__) && defined(__ARCH_ARM_5TE__) && !defined(__thumb__)
  433.      int32_t out;
  434.      if (left) {
  435.          asm( "smlawb %[out], %[v], %[inRL], %[a] /n"
  436. The AndroidConfig.h header file is included on every compile. We mess with it to convince it that we don’t have an optimised memcmp16 function.
  437. project system/core/
  438. diff --git a/include/arch/linux-arm/AndroidConfig.h b/include/arch/linux-arm/AndroidConfig.h
  439. index d7e182a..76f424e 100644
  440. --- a/include/arch/linux-arm/AndroidConfig.h
  441. +++ b/include/arch/linux-arm/AndroidConfig.h
  442. @@ -249,8 +249,9 @@
  443.  /*
  444.   * Do we have __memcmp16()?
  445.   */
  446. +#if defined(__ARCH_ARM_5TE__)
  447.  #define HAVE__MEMCMP16  1
  448. -
  449. +#endif
  450.  /*
  451.   * type for the third argument to mincore().
  452.   */
  453. Next up is the pixelflinger, where things get interesting, because all of a sudden we have armv6 code. I’ve taken the rash decision of wrapping this in conditionals that are only enabled if you actually have an ARMv6 version, not a pesky ARMv5E, but I really need to better understand the intent here. It seems a little strange.
  454. diff --git a/libpixelflinger/Android.mk b/libpixelflinger/Android.mk
  455. index a8e5ee4..077cf47 100644
  456. --- a/libpixelflinger/Android.mk
  457. +++ b/libpixelflinger/Android.mk
  458. @@ -5,7 +5,7 @@ include $(CLEAR_VARS)
  459.  # ARMv6 specific objects
  460.  #
  461.  
  462. -ifeq ($(TARGET_ARCH),arm)
  463. +ifeq ($(TARGET_ARCH_VERSION),armv6)
  464.  LOCAL_ASFLAGS :-march=armv6
  465.  LOCAL_SRC_FILES :rotate90CW_4x4_16v6.S
  466.  LOCAL_MODULE :libpixelflinger_armv6
  467. @@ -39,7 +39,7 @@ PIXELFLINGER_SRC_FILES:= /
  468.     raster.cpp /
  469.     buffer.cpp
  470.  
  471. -ifeq ($(TARGET_ARCH),arm)
  472. +ifeq ($(TARGET_ARCH_VERSION),armv5te)
  473.  PIXELFLINGER_SRC_FILES += t32cb16blend.S
  474.  endif
  475.  
  476. @@ -67,7 +67,7 @@ ifneq ($(BUILD_TINY_ANDROID),true)
  477.  LOCAL_MODULE:libpixelflinger
  478.  LOCAL_SRC_FILES := $(PIXELFLINGER_SRC_FILES)
  479.  LOCAL_CFLAGS := $(PIXELFLINGER_CFLAGS) -DWITH_LIB_HARDWARE
  480. -ifeq ($(TARGET_ARCH),arm)
  481. +ifeq ($(TARGET_ARCH_VERSION),armv6)
  482.  LOCAL_WHOLE_STATIC_LIBRARIES :libpixelflinger_armv6
  483.  endif
  484.  include $(BUILD_SHARED_LIBRARY)
  485. Finally scanline has an optimised asm version it calls in preference to doing the same thing inline with C code. Again, I take the easy way out, and use the C code.
  486. diff --git a/libpixelflinger/scanline.cpp b/libpixelflinger/scanline.cpp
  487. index d24c988..685a3b7 100644
  488. --- a/libpixelflinger/scanline.cpp
  489. +++ b/libpixelflinger/scanline.cpp
  490. @@ -1312,7 +1312,7 @@ void scanline_t32cb16blend(context_t* c)
  491.      const int32_t v = (c->state.texture[0].shade.it0>>16) + y;
  492.      uint32_t *src = reinterpret_cast(tex->data)+(u+(tex->stride*v));
  493.  
  494. -#if ((ANDROID_CODEGEN >= ANDROID_CODEGEN_ASM) && defined(__arm__))
  495. +#if ((ANDROID_CODEGEN >= ANDROID_CODEGEN_ASM) && defined(__arm__) && defined(__ARCH_ARM_5TE__))
  496.      scanline_t32cb16blend_arm(dst, src, ct);
  497.  #else
  498.      while (ct--) {
  499. And that my friends, is that! Now to see if I can actually run this code!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值