From ac567941a18369cd7b361d47affb1a372f29e97d Mon Sep 17 00:00:00 2001 From: Jason Zheng Date: Fri, 25 Jul 2014 10:37:36 +1000 Subject: [PATCH 1/2] fix crash when use predictor in Android Library when calling jpcnn_load_predictor jpcnn_save_predictor --- .gitignore | 1 + source/.gitignore | 3 +++ source/Android.mk | 8 +++++--- source/src/lib/svm/svm.cpp | 15 +++++++++++++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index e43b0f9..6b80ae5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_Store +eigen/ diff --git a/source/.gitignore b/source/.gitignore index 924723c..66d13d1 100644 --- a/source/.gitignore +++ b/source/.gitignore @@ -1,2 +1,5 @@ *.o +*.d +*.so +*.a data/example_networks/imagenet.ntwk diff --git a/source/Android.mk b/source/Android.mk index 2265fa2..b206304 100644 --- a/source/Android.mk +++ b/source/Android.mk @@ -1,4 +1,6 @@ -LIBSRCS:=$(shell find src/lib -name '*.cpp') +LIBSRCS:=$(shell find src/lib -path src/lib/pi -prune -o -name '*.cpp' -print) +${info ${LIBSRCS}} +NDK_PATH := /Users/zhengzhiheng/android-ndk-r9d/ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES := $(LIBSRCS) @@ -14,8 +16,8 @@ LOCAL_C_INCLUDES += ./src/lib/include \ ./src/lib \ ./src/include \ ../eigen \ -/Users/petewarden/android_ndk/sources/cxx-stl/gnu-libstdc++/4.6/include \ -/Users/petewarden/android_ndk/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include +$(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/4.6/include \ +$(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include LOCAL_CFLAGS := -DUSE_EIGEN_GEMM -DUSE_NEON LOCAL_CFLAGS += -mfloat-abi=softfp -mfpu=neon -march=armv7 diff --git a/source/src/lib/svm/svm.cpp b/source/src/lib/svm/svm.cpp index 2c2f544..f5e0988 100644 --- a/source/src/lib/svm/svm.cpp +++ b/source/src/lib/svm/svm.cpp @@ -2681,7 +2681,13 @@ int svm_save_model(const char *model_file_name, const svm_model *model) int svm_save_model_to_file_handle(FILE* fp, const svm_model* model) { - char *old_locale = strdup(setlocale(LC_ALL, NULL)); + char *locale = setlocale(LC_ALL, NULL); + char *old_locale; + if (!locale) + old_locale = NULL; + else + old_locale = strdup(locale); + setlocale(LC_ALL, "C"); const svm_parameter& param = model->param; @@ -2797,7 +2803,12 @@ svm_model *svm_load_model(const char *model_file_name) FILE *fp = fopen(model_file_name,"rb"); if(fp==NULL) return NULL; - char *old_locale = strdup(setlocale(LC_ALL, NULL)); + char *locale = setlocale(LC_ALL, NULL); + char *old_locale; + if (!locale) + old_locale = NULL; + else + old_locale = strdup(locale); setlocale(LC_ALL, "C"); // read parameters From 42a0d3eeaa026c51e19ab8c9680778bf21e438e9 Mon Sep 17 00:00:00 2001 From: Jason Zheng Date: Thu, 31 Jul 2014 11:05:01 +1000 Subject: [PATCH 2/2] Remove USE_NEON flag to avoid crash Details in https://github.com/jetpacapp/DeepBeliefSDK/issues/12 --- source/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Android.mk b/source/Android.mk index b206304..14a41ae 100644 --- a/source/Android.mk +++ b/source/Android.mk @@ -19,7 +19,7 @@ LOCAL_C_INCLUDES += ./src/lib/include \ $(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/4.6/include \ $(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include -LOCAL_CFLAGS := -DUSE_EIGEN_GEMM -DUSE_NEON +LOCAL_CFLAGS := -DUSE_EIGEN_GEMM LOCAL_CFLAGS += -mfloat-abi=softfp -mfpu=neon -march=armv7 LOCAL_CFLAGS += -fopenmp -O3