Skip to content

Commit

Permalink
Add support for x86 to hello-neon sample
Browse files Browse the repository at this point in the history
The sample hello-neon was updated to support x86 ABI.
This change is required:
https://android-review.googlesource.com/107511

Change-Id: Icc175afd6785cf454d168973582d7d85455624b5
Signed-off-by: Anton Konovalov <[email protected]>
Signed-off-by: Pavel Chupin <[email protected]>
  • Loading branch information
Anton Konovalov authored and Pavel Chupin committed Sep 12, 2014
1 parent 779aa19 commit 031ce66
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
5 changes: 4 additions & 1 deletion hello-neon/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ LOCAL_MODULE := helloneon

LOCAL_SRC_FILES := helloneon.c

ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
ifeq ($(TARGET_ARCH_ABI),$(filter $(TARGET_ARCH_ABI), armeabi-v7a x86))
LOCAL_CFLAGS := -DHAVE_NEON=1
ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_CFLAGS += -mssse3
endif
LOCAL_SRC_FILES += helloneon-intrinsics.c.neon
endif

Expand Down
3 changes: 1 addition & 2 deletions hello-neon/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# Build both ARMv5TE and ARMv7-A machine code.
APP_ABI := armeabi armeabi-v7a arm64-v8a
APP_ABI := armeabi armeabi-v7a arm64-v8a x86
18 changes: 13 additions & 5 deletions hello-neon/jni/helloneon.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ Java_com_example_neon_HelloNeon_stringFromJNI( JNIEnv* env,
jobject thiz )
{
char* str;
AndroidCpuFamily family;
uint64_t features;
char buffer[512];
char tryNeon = 0;
Expand Down Expand Up @@ -112,20 +113,27 @@ Java_com_example_neon_HelloNeon_stringFromJNI( JNIEnv* env,

strlcat(buffer, "Neon version : ", sizeof buffer);

if (android_getCpuFamily() != ANDROID_CPU_FAMILY_ARM) {
strlcat(buffer, "Not an ARM CPU !\n", sizeof buffer);
family = android_getCpuFamily();
if ((family != ANDROID_CPU_FAMILY_ARM) &&
(family != ANDROID_CPU_FAMILY_X86))
{
strlcat(buffer, "Not an ARM and not an X86 CPU !\n", sizeof buffer);
goto EXIT;
}

features = android_getCpuFeatures();
if ((features & ANDROID_CPU_ARM_FEATURE_ARMv7) == 0) {
strlcat(buffer, "Not an ARMv7 CPU !\n", sizeof buffer);
if (((features & ANDROID_CPU_ARM_FEATURE_ARMv7) == 0) &&
((features & ANDROID_CPU_X86_FEATURE_SSSE3) == 0))
{
strlcat(buffer, "Not an ARMv7 and not an X86 SSSE3 CPU !\n", sizeof buffer);
goto EXIT;
}

/* HAVE_NEON is defined in Android.mk ! */
#ifdef HAVE_NEON
if ((features & ANDROID_CPU_ARM_FEATURE_NEON) == 0) {
if (((features & ANDROID_CPU_ARM_FEATURE_NEON) == 0) &&
((features & ANDROID_CPU_X86_FEATURE_SSSE3) == 0))
{
strlcat(buffer, "CPU doesn't support NEON !\n", sizeof buffer);
goto EXIT;
}
Expand Down

0 comments on commit 031ce66

Please sign in to comment.