• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html><body><pre>Android NDK CPU Features detection library:
2-------------------------------------------
3
4This NDK provides a small library named "cpufeatures" that can be used at
5runtime to detect the target device's CPU family and the optional features
6it supports.
7
8Usage:
9------
10
11The library is available as an import module. To use it, you must:
12
13To use it, you must:
14
15  * List 'cpufeatures' in your list of static library dependencies, as in:
16
17        LOCAL_STATIC_LIBRARIES := cpufeatures
18
19  * At the end of your Android.mk, import the 'android/cpufeatures' module,
20    as in:
21
22        $(call import-module,android/cpufeatures)
23
24  * In your source code, include the header named &lt;cpu-features.h&gt;
25
26
27Here is a simple example:
28
29&lt;project-path&gt;/jni/Android.mk:
30    LOCAL_PATH := $(call my-dir)
31
32    include $(CLEAR_VARS)
33    LOCAL_MODULE := &lt;your-module-name&gt;
34    LOCAL_SRC_FILES := &lt;your-source-files&gt;
35    LOCAL_STATIC_LIBRARIES := cpufeatures
36    include $(BUILD_SHARED_LIBRARY)
37
38    $(call import-module,android/cpufeatures)
39
40
41Features:
42---------
43
44Two functions are provided for now:
45
46   AndroidCpuFamily   android_getCpuFamily();
47
48Returns the target device's CPU Family as an enum. For now, the only
49supported family is ANDROID_CPU_FAMILY_ARM.
50
51
52   uint64_t   android_getCpuFeatures();
53
54Returns the set of optional features supported by the device's CPU.
55The result is a set of bit-flags, each corresponding to one CPU
56Family-specific optional feature.
57
58Currently, only the following flags are defined, for the ARM CPU Family:
59
60   ANDROID_CPU_ARM_FEATURE_ARMv7
61      Indicates that the device's CPU supports the ARMv7-A instruction
62      set as supported by the "armeabi-v7a" abi (see CPU-ARCH-ABIS.html).
63      This corresponds to Thumb-2 and VFPv3-D16 instructions.
64
65   ANDROID_CPU_ARM_FEATURE_VFPv3
66      Indicates that the device's CPU supports the VFPv3 hardware FPU
67      instruction set extension. Due to the definition of 'armeabi-v7a',
68      this will always be the case if ANDROID_CPU_ARM_FEATURE_ARMv7 is
69      returned.
70
71      Note that this corresponds to the minimum profile VFPv3-D16 that
72      _only_ provides 16 hardware FP registers.
73
74   ANDROID_CPU_ARM_FEATURE_NEON
75      Indicates that the device's CPU supports the ARM Advanced SIMD
76      (a.k.a. NEON) vector instruction set extension. Note that ARM
77      mandates that such CPUs also implement VFPv3-D32, which provides
78      32 hardware FP registers (shared with the NEON unit).
79
80
81Important Note:
82---------------
83
84The cpufeatures library will be updated to support more CPU families and
85optional features in the future. It is designed to work as-is on all
86official Android platform versions.
87
88
89Change History:
90---------------
91
92Please see the comments in $NDK/sources/android/cpufeatures/cpu-features.c
93for the complete change history for this library.
94</pre></body></html>