LOCAL_STATIC_LIBRARIES := cpufeatures* At the end of your Android.mk, import the 'android/cpufeatures' module, as in:
$(call import-module,android/cpufeatures)* In your source code, include the header named <cpu-features.h> Here is a simple example: <project-path>/jni/Android.mk:
LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := <your-module-name> LOCAL_SRC_FILES := <your-source-files> LOCAL_STATIC_LIBRARIES := cpufeatures include $(BUILD_SHARED_LIBRARY) $(call import-module,android/cpufeatures)
AndroidCpuFamily android_getCpuFamily();Returns the target device's CPU Family as an enum. For now, the only supported family is ANDROID_CPU_FAMILY_ARM.
uint64_t android_getCpuFeatures();Returns the set of optional features supported by the device's CPU. The result is a set of bit-flags, each corresponding to one CPU Family-specific optional feature. Currently, only the following flags are defined, for the ARM CPU Family: ANDROID_CPU_ARM_FEATURE_ARMv7 Indicates that the device's CPU supports the ARMv7-A instruction set as supported by the "armeabi-v7a" abi (see CPU-ARCH-ABIS.html). This corresponds to Thumb-2 and VFPv3-D16 instructions. ANDROID_CPU_ARM_FEATURE_VFPv3 Indicates that the device's CPU supports the VFPv3 hardware FPU instruction set extension. Due to the definition of 'armeabi-v7a', this will always be the case if ANDROID_CPU_ARM_FEATURE_ARMv7 is returned. Note that this corresponds to the minimum profile VFPv3-D16 that _only_ provides 16 hardware FP registers. ANDROID_CPU_ARM_FEATURE_NEON Indicates that the device's CPU supports the ARM Advanced SIMD (a.k.a. NEON) vector instruction set extension. Note that ARM mandates that such CPUs also implement VFPv3-D32, which provides 32 hardware FP registers (shared with the NEON unit). And the following flags for the x86 CPU Family: ANDROID_CPU_X86_FEATURE_SSSE3 Indicates that the device's CPU supports the SSSE3 instruction extension set. Note that this is unlike SSE3 which is required by the x86 NDK ABI. ANDROID_CPU_X86_FEATURE_POPCNT Indicates that the device's CPU supports the POPCNT instruction. ANDROID_CPU_X86_FEATURE_MOVBE Indicates that the device's CPU supports the MOVBE instruction. This one is specific to some Intel IA-32 CPUs, like the Atom. The following function is also defined to return the max number of CPU cores on the target device: int android_getCpuCount(void);
Important Note: The cpufeatures library will be updated to support more CPU families and optional features in the future. It is designed to work as-is on all official Android platform versions.